From 5ee7dbbe25ca396f9b94797c417e70bfb8a9f6f0 Mon Sep 17 00:00:00 2001 From: loiclau Date: Tue, 11 Jul 2017 15:53:25 +0200 Subject: [PATCH 001/207] * fix style configObject command --- .../configObject/command/DB-Func.php | 136 ++++++++++------ .../configObject/command/formArguments.php | 34 ++-- .../configObject/command/formCommand.php | 147 +++++++++++------- .../configObject/command/formMacros.php | 32 ++-- .../configObject/command/help.php | 94 +++++++---- .../configObject/command/listCommand.php | 140 ++++++++++------- .../configObject/command/minCommand.php | 60 +++---- .../configObject/command/minHelpCommand.php | 22 ++- .../configObject/command/minPlayCommand.php | 34 ++-- 9 files changed, 434 insertions(+), 265 deletions(-) diff --git a/www/include/configuration/configObject/command/DB-Func.php b/www/include/configuration/configObject/command/DB-Func.php index 1b5aca93b86..9d52ab89920 100644 --- a/www/include/configuration/configObject/command/DB-Func.php +++ b/www/include/configuration/configObject/command/DB-Func.php @@ -46,7 +46,7 @@ function myDecodeCommand($arg) $arg = str_replace('#S#', "/", $arg); $arg = str_replace('#BS#', "\\", $arg); $arg = str_replace('#P#', "|", $arg); - return(html_entity_decode($arg)); + return (html_entity_decode($arg)); } } @@ -55,7 +55,8 @@ function getCommandName($command_id) { global $pearDB; - $DBRESULT = $pearDB->query("SELECT `command_name` FROM `command` WHERE `command_id` = " . $pearDB->escape($command_id) . ""); + $query = "SELECT `command_name` FROM `command` WHERE `command_id` = " . $pearDB->escape($command_id); + $DBRESULT = $pearDB->query($query); $command = $DBRESULT->fetchRow(); if (isset($command['command_name'])) { return $command['command_name']; @@ -73,7 +74,9 @@ function testCmdExistence($name = null) $id = $form->getSubmitValue('command_id'); } - $DBRESULT = $pearDB->query("SELECT `command_name`, `command_id` FROM `command` WHERE `command_name` = '" . $pearDB->escape($centreon->checkIllegalChar($name)) . "'"); + $query = "SELECT `command_name`, `command_id` FROM `command` WHERE `command_name` = '" . + $pearDB->escape($centreon->checkIllegalChar($name)) . "'"; + $DBRESULT = $pearDB->query($query); $command = $DBRESULT->fetchRow(); if ($DBRESULT->rowCount() >= 1 && $command["command_id"] == $id) { /* @@ -95,9 +98,10 @@ function deleteCommandInDB($commands = array()) global $pearDB, $centreon; foreach ($commands as $key => $value) { - $DBRESULT2 = $pearDB->query("SELECT command_name FROM `command` WHERE `command_id` = '" . intval($key) . "' LIMIT 1"); + $query = "SELECT command_name FROM `command` WHERE `command_id` = '" . intval($key) . "' LIMIT 1"; + $DBRESULT2 = $pearDB->query($query); $row = $DBRESULT2->fetchRow(); - $DBRESULT = $pearDB->query("DELETE FROM `command` WHERE `command_id` = '" . intval($key) . "'"); + $pearDB->query("DELETE FROM `command` WHERE `command_id` = '" . intval($key) . "'"); $centreon->CentreonLogAction->insertLog("command", $key, $row['command_name'], "d"); } } @@ -117,7 +121,8 @@ function multipleCommandInDB($commands = array(), $nbrDup = array()) foreach ($row as $key2 => $value2) { $key2 == "command_name" ? ($command_name = $value2 = $value2 . "_" . $i) : null; - $val ? $val .= ($value2 != null ? (", '" . $pearDB->escape($value2) . "'") : ", NULL") : $val .= ($value2 != null ? ("'" . $pearDB->escape($value2) . "'") : "NULL"); + $val ? $val .= ($value2 != null ? (", '" . $pearDB->escape($value2) . "'") + : ", NULL") : $val .= ($value2 != null ? ("'" . $pearDB->escape($value2) . "'") : "NULL"); if ($key2 != "command_id") { $fields[$key2] = $pearDB->escape($value2); } @@ -129,13 +134,19 @@ function multipleCommandInDB($commands = array(), $nbrDup = array()) if (isset($command_name) && testCmdExistence($command_name)) { $val ? $rq = "INSERT INTO `command` VALUES (" . $val . ")" : $rq = null; $DBRESULT = $pearDB->query($rq); - + /* * Get Max ID */ $DBRESULT = $pearDB->query("SELECT MAX(command_id) FROM `command`"); $cmd_id = $DBRESULT->fetchRow(); - $centreon->CentreonLogAction->insertLog("command", $cmd_id["MAX(command_id)"], $command_name, "a", $fields); + $centreon->CentreonLogAction->insertLog( + "command", + $cmd_id["MAX(command_id)"], + $command_name, + "a", + $fields + ); } /* @@ -175,15 +186,15 @@ function updateCommand($cmd_id = null, $params = array()) } $rq = "UPDATE `command` SET `command_name` = :command_name, " . - "`command_line` = :command_line, " . - "`enable_shell` = :enable_shell, " . - "`command_example` = :command_example, " . - "`command_type` = :command_type, " . - "`command_comment` = :command_comment, " . - "`graph_id` = :graph_id, " . - "`connector_id` = :connector_id, " . - "`command_activate` = :command_activate " . - "WHERE `command_id` = :command_id"; + "`command_line` = :command_line, " . + "`enable_shell` = :enable_shell, " . + "`command_example` = :command_example, " . + "`command_type` = :command_type, " . + "`command_comment` = :command_comment, " . + "`graph_id` = :graph_id, " . + "`connector_id` = :connector_id, " . + "`command_activate` = :command_activate " . + "WHERE `command_id` = :command_id"; $ret["connectors"] = (isset($ret["connectors"]) && !empty($ret["connectors"])) ? $ret["connectors"] : null; $ret["command_activate"]["command_activate"] = (isset($ret["command_activate"]["command_activate"])) ? @@ -242,7 +253,9 @@ function insertCommand($ret = array()) '" . $pearDB->escape($ret["command_example"]) . "', '" . $ret["command_type"]["command_type"] . "', '" . $ret["graph_id"] . "', - " . (isset($ret["connectors"]) && !empty($ret["connectors"]) ? "'" . $ret['connectors'] . "'" : "NULL") . ", + " . (isset($ret["connectors"]) && !empty($ret["connectors"]) + ? "'" . $ret['connectors'] . "'" + : "NULL") . ", '" . $pearDB->escape($ret["command_comment"]) . "', '" . $pearDB->escape($ret["command_activate"]["command_activate"]) . "'"; $rq .= ")"; @@ -256,7 +269,7 @@ function insertCommand($ret = array()) /* Prepare value for changelog */ $fields = CentreonLogAction::prepareChanges($ret); $centreon->CentreonLogAction->insertLog("command", $max_id, $pearDB->escape($ret["command_name"]), "a", $fields); - + insertArgDesc($max_id, $ret); insertMacrosDesc($max_id, $ret); @@ -277,7 +290,16 @@ function return_plugin($rep) global $centreon; $plugins = array(); - $is_not_a_plugin = array("." => 1, ".." => 1, "oreon.conf" => 1, "oreon.pm" => 1, "utils.pm" => 1, "negate" => 1, "centreon.conf" => 1, "centreon.pm" => 1); + $is_not_a_plugin = array( + "." => 1, + ".." => 1, + "oreon.conf" => 1, + "oreon.pm" => 1, + "utils.pm" => 1, + "negate" => 1, + "centreon.conf" => 1, + "centreon.pm" => 1 + ); $handle[$rep] = opendir($rep); while (false != ($filename = readdir($handle[$rep]))) { if ($filename != "." && $filename != "..") { @@ -285,7 +307,10 @@ function return_plugin($rep) $plg_tmp = return_plugin($rep . "/" . $filename, $handle[$rep]); $plugins = array_merge($plugins, $plg_tmp); unset($plg_tmp); - } elseif (!isset($is_not_a_plugin[$filename]) && substr($filename, -1) != "~" && substr($filename, -1) != "#") { + } elseif (!isset($is_not_a_plugin[$filename]) && + substr($filename, -1) != "~" && + substr($filename, -1) != "#" + ) { $key = substr($rep . "/" . $filename, strlen($centreon->optGen["nagios_path_plugins"])); $plugins[$key] = $key; } @@ -313,7 +338,8 @@ function insertArgDesc($cmd_id, $ret = null) $tab1 = preg_split("/\\n/", $ret['listOfArg']); foreach ($tab1 as $key => $value) { $tab2 = preg_split("/\ \:\ /", $value, 2); - $query .= "('" . $pearDB->escape($cmd_id) . "', '" . $pearDB->escape($tab2[0]) . "', '" . $pearDB->escape($tab2[1]) . "'),"; + $query .= "('" . $pearDB->escape($cmd_id) . "', '" . $pearDB->escape($tab2[0]) . "', '" . + $pearDB->escape($tab2[1]) . "'),"; } $query = trim($query, ","); $pearDB->query($query); @@ -345,8 +371,9 @@ function getHostNumberUse($command_id) { global $pearDB; - $DBRESULT = $pearDB->query("SELECT count(*) AS number FROM host WHERE command_command_id = '" . intval($command_id) . "' - AND host_register = '1'"); + $query = "SELECT count(*) AS number FROM host " . + "WHERE command_command_id = '" . intval($command_id) . "' AND host_register = '1'"; + $DBRESULT = $pearDB->query($query); $data = $DBRESULT->fetchRow(); return $data['number']; } @@ -360,8 +387,9 @@ function getServiceNumberUse($command_id) { global $pearDB; - $DBRESULT = $pearDB->query("SELECT count(*) AS number FROM service WHERE command_command_id = '" . intval($command_id) . "' - AND service_register = '1'"); + $query = "SELECT count(*) AS number FROM service " . + "WHERE command_command_id = '" . intval($command_id) . "' AND service_register = '1'"; + $DBRESULT = $pearDB->query($query); $data = $DBRESULT->fetchRow(); return $data['number']; } @@ -375,8 +403,9 @@ function getHostTPLNumberUse($command_id) { global $pearDB; - $DBRESULT = $pearDB->query("SELECT count(*) AS number FROM host WHERE command_command_id = '" . intval($command_id) . "' - AND host_register = '0'"); + $query = "SELECT count(*) AS number FROM host " . + "WHERE command_command_id = '" . intval($command_id) . "' AND host_register = '0'"; + $DBRESULT = $pearDB->query($query); $data = $DBRESULT->fetchRow(); return $data['number']; } @@ -390,8 +419,9 @@ function getServiceTPLNumberUse($command_id) { global $pearDB; - $DBRESULT = $pearDB->query("SELECT count(*) AS number FROM service WHERE command_command_id = '" . intval($command_id) . "' - AND service_register = '0'"); + $query = "SELECT count(*) AS number FROM service " . + "WHERE command_command_id = '" . intval($command_id) . "' AND service_register = '0'"; + $DBRESULT = $pearDB->query($query); $data = $DBRESULT->fetchRow(); return $data['number']; } @@ -436,7 +466,7 @@ function insertMacrosDesc($cmd, $ret) $tab1 = preg_split("/\\n/", $ret['listOfMacros']); $query = "DELETE FROM `on_demand_macro_command` - WHERE `command_command_id` = ".intval($cmd); + WHERE `command_command_id` = " . intval($cmd); $pearDB->query($query); foreach ($tab1 as $key => $value) { @@ -449,17 +479,17 @@ function insertMacrosDesc($cmd, $ret) $sName = trim(substr($str, $pos + 1)); } else { $sType = "1"; - $sName = trim($str); + $sName = trim($str); } - + if (!empty($sName)) { $sQueryInsert = "INSERT INTO `on_demand_macro_command` (`command_command_id`, `command_macro_name`, `command_macro_desciption`, `command_macro_type`) - VALUES (". intval($cmd).", - '".$pearDB->escape($sName)."', - '".$pearDB->escape($sDesc)."', - '".$arr[$sType]."')"; + VALUES (" . intval($cmd) . ", + '" . $pearDB->escape($sName) . "', + '" . $pearDB->escape($sDesc) . "', + '" . $arr[$sType] . "')"; $pearDB->query($sQueryInsert); } @@ -480,24 +510,28 @@ function changeCommandStatus($command_id, $commands, $status) global $pearDB, $centreon; if (isset($command_id)) { - $query = "UPDATE `command` SET command_activate = '".$pearDB->escape($status)."' - WHERE command_id = '".$pearDB->escape($command_id)."'"; + $query = "UPDATE `command` SET command_activate = '" . $pearDB->escape($status) . "' " . + "WHERE command_id = '" . $pearDB->escape($command_id) . "'"; $pearDB->query($query); - $centreon->CentreonLogAction->insertLog("command", - $command_id, - getCommandName($command_id), - $status ? "enable" : "disable"); + $centreon->CentreonLogAction->insertLog( + "command", + $command_id, + getCommandName($command_id), + $status ? "enable" : "disable" + ); } else { foreach ($commands as $command_id => $flag) { if (isset($command_id) && $command_id) { - $query = "UPDATE `command` SET command_activate = '".$pearDB->escape($status)."' - WHERE command_id = '".$pearDB->escape($command_id)."'"; - $pearDB->query($query); - - $centreon->CentreonLogAction->insertLog("command", - $command_id, - getCommandName($command_id), - $status ? "enable" : "disable"); + $query = "UPDATE `command` SET command_activate = '" . $pearDB->escape($status) . "' " . + "WHERE command_id = '" . $pearDB->escape($command_id) . "'"; + $pearDB->query($query); + + $centreon->CentreonLogAction->insertLog( + "command", + $command_id, + getCommandName($command_id), + $status ? "enable" : "disable" + ); } } } diff --git a/www/include/configuration/configObject/command/formArguments.php b/www/include/configuration/configObject/command/formArguments.php index e806354fe33..248ea1c1f10 100644 --- a/www/include/configuration/configObject/command/formArguments.php +++ b/www/include/configuration/configObject/command/formArguments.php @@ -74,12 +74,12 @@ /* FORM */ -$path = _CENTREON_PATH_."/www/include/configuration/configObject/command/"; +$path = _CENTREON_PATH_ . "/www/include/configuration/configObject/command/"; -$attrsText = array("size"=>"30"); -$attrsText2 = array("size"=>"60"); +$attrsText = array("size" => "30"); +$attrsText2 = array("size" => "60"); $attrsAdvSelect = array("style" => "width: 200px; height: 100px;"); -$attrsTextarea = array("rows"=>"5", "cols"=>"40"); +$attrsTextarea = array("rows" => "5", "cols" => "40"); /*Basic info */ $form = new HTML_QuickForm('Form', 'post'); @@ -87,23 +87,35 @@ $form->addElement('header', 'information', _("Arguments")); $subS = $form->addElement( - 'button', 'submitSaveAdd', _("Save"), array("onClick"=>"setDescriptions();", "class" => "btc bt_success") + 'button', + 'submitSaveAdd', + _("Save"), + array( + "onClick" => "setDescriptions();", + "class" => "btc bt_success" + ) ); $subS = $form->addElement( - 'button', 'close', _("Close"), array("onClick"=>"closeBox();", "class" => "btc bt_default") + 'button', + 'close', + _("Close"), + array( + "onClick" => "closeBox();", + "class" => "btc bt_default" + ) ); /* * Smarty template */ -define('SMARTY_DIR', _CENTREON_PATH_."/GPL_LIB/Smarty/libs/"); -require_once SMARTY_DIR."Smarty.class.php"; +define('SMARTY_DIR', _CENTREON_PATH_ . "/GPL_LIB/Smarty/libs/"); +require_once SMARTY_DIR . "Smarty.class.php"; $tpl = new Smarty(); $tpl->template_dir = $path; -$tpl->compile_dir = _CENTREON_PATH_."/GPL_LIB/SmartyCache/compile"; -$tpl->config_dir = _CENTREON_PATH_."/GPL_LIB/SmartyCache/config"; -$tpl->cache_dir = _CENTREON_PATH_."/GPL_LIB/SmartyCache/cache"; +$tpl->compile_dir = _CENTREON_PATH_ . "/GPL_LIB/SmartyCache/compile"; +$tpl->config_dir = _CENTREON_PATH_ . "/GPL_LIB/SmartyCache/config"; +$tpl->cache_dir = _CENTREON_PATH_ . "/GPL_LIB/SmartyCache/cache"; $tpl->caching = 0; $tpl->compile_check = true; $tpl->force_compile = true; diff --git a/www/include/configuration/configObject/command/formCommand.php b/www/include/configuration/configObject/command/formCommand.php index 1c04c2190c8..779e23e4e14 100755 --- a/www/include/configuration/configObject/command/formCommand.php +++ b/www/include/configuration/configObject/command/formCommand.php @@ -65,12 +65,12 @@ function myReplace() if (isset($lockedElements[$command_id])) { $o = "w"; } - $DBRESULT = $pearDB->query("SELECT * FROM `command` WHERE `command_id` = '".$command_id."' LIMIT 1"); + $DBRESULT = $pearDB->query("SELECT * FROM `command` WHERE `command_id` = '" . $command_id . "' LIMIT 1"); # Set base value $cmd = array_map("myDecodeCommand", $DBRESULT->fetchRow()); - $DBRESULT = $pearDB->query("SELECT * FROM `command_arg_description` WHERE `cmd_id` = '".$command_id."'"); + $DBRESULT = $pearDB->query("SELECT * FROM `command_arg_description` WHERE `cmd_id` = '" . $command_id . "'"); $strArgDesc = ""; $nbRow = 0; while ($row = $DBRESULT->fetchRow()) { @@ -86,17 +86,19 @@ function myReplace() if (count($aMacroDescription) > 0) { foreach ($aMacroDescription as $macro) { - $sStrMcro .= "MACRO (".$oCommande->aTypeMacro[$macro['type']] . ") ". $macro['name'] ." : ". $macro['description'] . "\n"; + $sStrMcro .= "MACRO (" . $oCommande->aTypeMacro[$macro['type']] . ") " . $macro['name'] . " : " . + $macro['description'] . "\n"; $nbRowMacro++; } } else { $macrosHostDesc = $oCommande->matchObject($command_id, $cmd['command_line'], '1'); $macrosServiceDesc = $oCommande->matchObject($command_id, $cmd['command_line'], '2'); - + $aMacroDescription = array_merge($macrosServiceDesc, $macrosHostDesc); foreach ($aMacroDescription as $macro) { - $sStrMcro .= "MACRO (".$oCommande->aTypeMacro[$macro['type']] . ") ". $macro['name'] ." : ". $macro['description'] . "\n"; + $sStrMcro .= "MACRO (" . $oCommande->aTypeMacro[$macro['type']] . ") " . $macro['name'] . + " : " . $macro['description'] . "\n"; $nbRowMacro++; } } @@ -105,11 +107,12 @@ function myReplace() * Resource Macro */ $resource = array(); -$DBRESULT = $pearDB->query("SELECT DISTINCT `resource_name`, `resource_comment` FROM `cfg_resource` ORDER BY `resource_line`"); +$query = "SELECT DISTINCT `resource_name`, `resource_comment` FROM `cfg_resource` ORDER BY `resource_line`"; +$DBRESULT = $pearDB->query($query); while ($row = $DBRESULT->fetchRow()) { $resource[$row["resource_name"]] = $row["resource_name"]; if (isset($row["resource_comment"]) && $row["resource_comment"] != "") { - $resource[$row["resource_name"]] .= " (".$row["resource_comment"].")"; + $resource[$row["resource_name"]] .= " (" . $row["resource_comment"] . ")"; } } unset($row); @@ -129,7 +132,7 @@ function myReplace() /* * Graphs Template comes from DB -> Store in $graphTpls Array */ -$graphTpls = array(null=>null); +$graphTpls = array(null => null); $DBRESULT = $pearDB->query("SELECT `graph_id`, `name` FROM `giv_graphs_template` ORDER BY `name`"); while ($graphTpl = $DBRESULT->fetchRow()) { $graphTpls[$graphTpl["graph_id"]] = $graphTpl["name"]; @@ -148,16 +151,16 @@ function myReplace() unset($row); $DBRESULT->closeCursor(); -$attrsText = array("size"=>"35"); -$attrsTextarea = array("rows"=>"9", "cols"=>"80", "id"=>"command_line"); -$attrsTextarea2 = array("rows"=>"$nbRow", "cols"=>"100", "id"=>"listOfArg"); -$attrsTextarea3 = array("rows"=>"5", "cols"=>"50", "id"=>"command_comment"); -$attrsTextarea4 = array("rows"=>"$nbRowMacro", "cols"=>"100", "id"=>"listOfMacros"); +$attrsText = array("size" => "35"); +$attrsTextarea = array("rows" => "9", "cols" => "80", "id" => "command_line"); +$attrsTextarea2 = array("rows" => "$nbRow", "cols" => "100", "id" => "listOfArg"); +$attrsTextarea3 = array("rows" => "5", "cols" => "50", "id" => "command_comment"); +$attrsTextarea4 = array("rows" => "$nbRowMacro", "cols" => "100", "id" => "listOfMacros"); /* * Form begin */ -$form = new HTML_QuickForm('Form', 'post', "?p=".$p.'&type='.$type); +$form = new HTML_QuickForm('Form', 'post', "?p=" . $p . '&type=' . $type); if ($o == "a") { $form->addElement('header', 'title', _("Add a Command")); } elseif ($o == "c") { @@ -178,7 +181,14 @@ function myReplace() $form->addElement('header', 'furtherInfos', _("Additional Information")); foreach ($tabCommandType as $id => $name) { - $cmdType[] = HTML_QuickForm::createElement('radio', 'command_type', null, $name, $id, 'onChange=checkType(this.value);'); + $cmdType[] = HTML_QuickForm::createElement( + 'radio', + 'command_type', + null, + $name, + $id, + 'onChange=checkType(this.value);' + ); } $form->addGroup($cmdType, 'command_type', _("Command Type"), '  '); @@ -203,10 +213,10 @@ function myReplace() $form->addElement('textarea', 'listOfArg', _("Argument Descriptions"), $attrsTextarea2)->setAttribute("readonly"); $form->addElement('select', 'graph_id', _("Graph template"), $graphTpls); -$form->addElement('button', 'desc_arg', _("Describe arguments"), array("onClick"=>"goPopup();")); -$form->addElement('button', 'clear_arg', _("Clear arguments"), array("onClick"=>"clearArgs();")); +$form->addElement('button', 'desc_arg', _("Describe arguments"), array("onClick" => "goPopup();")); +$form->addElement('button', 'clear_arg', _("Clear arguments"), array("onClick" => "clearArgs();")); $form->addElement('textarea', 'command_comment', _("Comment"), $attrsTextarea2); -$form->addElement('button', 'desc_macro', _("Describe macros"), array("onClick"=>"manageMacros();")); +$form->addElement('button', 'desc_macro', _("Describe macros"), array("onClick" => "manageMacros();")); $form->addElement('textarea', 'listOfMacros', _("Macros Descriptions"), $attrsTextarea4)->setAttribute("readonly"); $cmdActivation[] = HTML_QuickForm::createElement('radio', 'command_activate', null, _("Enabled"), '1'); @@ -241,7 +251,7 @@ function myReplace() $form->addRule('command_line', _("Compulsory Command Line"), 'required'); $form->registerRule('exist', 'callback', 'testCmdExistence'); $form->addRule('command_name', _("Name is already in use"), 'exist'); -$form->setRequiredNote("* ". _("Required fields")); +$form->setRequiredNote("* " . _("Required fields")); /* * Smarty template Init @@ -249,12 +259,17 @@ function myReplace() $tpl = new Smarty(); $tpl = initSmartyTpl($path, $tpl); -$tpl->assign("helpattr", 'TITLE, "'._("Help").'", CLOSEBTN, true, FIX, [this, 0, 5], BGCOLOR, "#ffff99", BORDERCOLOR, "orange", TITLEFONTCOLOR, "black", TITLEBGCOLOR, "orange", CLOSEBTNCOLORS, ["","black", "white", "red"], WIDTH, -300, SHADOW, true, TEXTALIGN, "justify"'); +$tpl->assign( + "helpattr", + 'TITLE, "' . _("Help") . '", CLOSEBTN, true, FIX, [this, 0, 5], BGCOLOR, "#ffff99", ' . + 'BORDERCOLOR, "orange", TITLEFONTCOLOR, "black", TITLEBGCOLOR, "orange", CLOSEBTNCOLORS, ' . + '["","black", "white", "red"], WIDTH, -300, SHADOW, true, TEXTALIGN, "justify"' +); # prepare help texts $helptext = ""; include_once("help.php"); foreach ($help as $key => $text) { - $helptext .= ''."\n"; + $helptext .= '' . "\n"; } $tpl->assign("helptext", $helptext); @@ -263,7 +278,15 @@ function myReplace() */ if ($o == "w") { if ($centreon->user->access->page($p) != 2 && !isset($lockedElements[$command_id])) { - $form->addElement("button", "change", _("Modify"), array("onClick"=>"javascript:window.location.href='?p=".$p."&o=c&command_id=".$command_id."&type=".$type."'")); + $form->addElement( + "button", + "change", + _("Modify"), + array( + "onClick" => "javascript:window.location.href='?p=" . $p . + "&o=c&command_id=" . $command_id . "&type=" . $type . "'" + ) + ); } $form->setDefaults($cmd); $form->freeze(); @@ -282,7 +305,7 @@ function myReplace() $res = $form->addElement('reset', 'reset', _("Reset"), array("class" => "btc bt_default")); } -$tpl->assign('msg', array ("comment"=>_("Commands definitions can contain Macros but they have to be valid."))); +$tpl->assign('msg', array("comment" => _("Commands definitions can contain Macros but they have to be valid."))); $tpl->assign('cmd_help', _("Plugin Help")); $tpl->assign('cmd_play', _("Test the plugin")); @@ -294,57 +317,61 @@ function myReplace() } elseif ($form->getSubmitValue("submitC")) { updateCommandInDB($cmdObj->getValue()); } - + $o = null; $cmdObj = $form->getElement('command_id'); $valid = true; } -?> +matchObject($iIdCmd, $str, '1'); $macrosServiceDesc = $oCommande->matchObject($iIdCmd, $str, '2'); - + $nb_arg = count($macrosHostDesc) + count($macrosServiceDesc); - + $macros = array_merge($macrosServiceDesc, $macrosHostDesc); } /* FORM */ -$path = _CENTREON_PATH_."/www/include/configuration/configObject/command/"; +$path = _CENTREON_PATH_ . "/www/include/configuration/configObject/command/"; $attrsText = array("size" => "30"); $attrsText2 = array("size" => "60"); @@ -95,29 +95,35 @@ $subS = $form->addElement( - 'button', 'submitSaveAdd', _("Save"), array("onClick" => "setMacrosDescriptions();", "class" => "btc bt_success") + 'button', + 'submitSaveAdd', + _("Save"), + array("onClick" => "setMacrosDescriptions();", "class" => "btc bt_success") ); $subS = $form->addElement( - 'button', 'close', _("Close"), array("onClick" => "closeBox();", "class" => "btc bt_default") + 'button', + 'close', + _("Close"), + array("onClick" => "closeBox();", "class" => "btc bt_default") ); /* * Smarty template */ -define('SMARTY_DIR', _CENTREON_PATH_."/GPL_LIB/Smarty/libs/"); +define('SMARTY_DIR', _CENTREON_PATH_ . "/GPL_LIB/Smarty/libs/"); require_once SMARTY_DIR . "Smarty.class.php"; $tpl = new Smarty(); $tpl->template_dir = $path; -$tpl->compile_dir = _CENTREON_PATH_."/GPL_LIB/SmartyCache/compile"; -$tpl->config_dir = _CENTREON_PATH_."/GPL_LIB/SmartyCache/config"; -$tpl->cache_dir = _CENTREON_PATH_."/GPL_LIB/SmartyCache/cache"; +$tpl->compile_dir = _CENTREON_PATH_ . "/GPL_LIB/SmartyCache/compile"; +$tpl->config_dir = _CENTREON_PATH_ . "/GPL_LIB/SmartyCache/config"; +$tpl->cache_dir = _CENTREON_PATH_ . "/GPL_LIB/SmartyCache/cache"; $tpl->caching = 0; $tpl->compile_check = true; $tpl->force_compile = true; $tpl->assign('nb_arg', $nb_arg); - + $tpl->assign('macros', $macros); $tpl->assign('noArgMsg', _("Sorry, your command line does not contain any \$_SERVICE\$ macro or \$_HOST\$ macro.")); diff --git a/www/include/configuration/configObject/command/help.php b/www/include/configuration/configObject/command/help.php index af483016da9..31407b1f8e8 100644 --- a/www/include/configuration/configObject/command/help.php +++ b/www/include/configuration/configObject/command/help.php @@ -3,47 +3,83 @@ * Copyright 2005-2015 Centreon * Centreon is developped by : Julien Mathis and Romain Le Merlus under * GPL Licence 2.0. - * - * This program is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software * Foundation ; either version 2 of the License. - * + * * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with + * + * You should have received a copy of the GNU General Public License along with * this program; if not, see . - * - * Linking this program statically or dynamically with other modules is making a - * combined work based on this program. Thus, the terms and conditions of the GNU + * + * Linking this program statically or dynamically with other modules is making a + * combined work based on this program. Thus, the terms and conditions of the GNU * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this program give Centreon - * permission to link this program with independent modules to produce an executable, - * regardless of the license terms of these independent modules, and to copy and - * distribute the resulting executable under terms of Centreon choice, provided that - * Centreon also meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module which is not - * derived from this program. If you modify this program, you may extend this + * + * As a special exception, the copyright holders of this program give Centreon + * permission to link this program with independent modules to produce an executable, + * regardless of the license terms of these independent modules, and to copy and + * distribute the resulting executable under terms of Centreon choice, provided that + * Centreon also meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module which is not + * derived from this program. If you modify this program, you may extend this * exception to your version of the program, but you are not obliged to do so. If you * do not wish to do so, delete this exception statement from your version. - * + * * For more information : contact@centreon.com - * + * */ $help = array(); -$help["command_name"] = dgettext("help", "The command name is used to identify and display this command in contact, host and service definitions."); +$help["command_name"] = dgettext( + "help", + "The command name is used to identify and display this command in contact, host and service definitions." +); -$help["command_line_help"] = dgettext("help", "The command line specifies the real command line which is actually executed by Monitoring engine. Before execution, all valid macros are replaced with their respective values. To use the dollar sign (\$) on the command line, you have to escape it with another dollar sign (\$\$). A semicolon (;) is used as separator for config file comments and must be worked around by setting a \$USER\$ macro to a semicolon and then referencing it here in place of the semicolon. If you want to pass arguments to commands during runtime, you can use \$ARGn\$ macros in the command line."); -$help["enable_shell"] = dgettext("help", "If your command requires shell features like pipes, redirections, globbing etc. check this box. If you are using Monitoring Engine this option cannot be disabled. Note that commands that require shell are slowing down the poller server."); +$help["command_line_help"] = dgettext( + "help", + "The command line specifies the real command line which is actually executed by Monitoring engine. " . + "Before execution, all valid macros are replaced with their respective values. To use the dollar sign (\$) " . + "on the command line, you have to escape it with another dollar sign (\$\$). A semicolon (;) " . + "is used as separator for config file comments and must be worked around by setting a \$USER\$ macro " . + "to a semicolon and then referencing it here in place of the semicolon. If you want to pass arguments " . + "to commands during runtime, you can use \$ARGn\$ macros in the command line." +); +$help["enable_shell"] = dgettext( + "help", + "If your command requires shell features like pipes, redirections, globbing etc. check this box. " . + "If you are using Monitoring Engine this option cannot be disabled. Note that commands that require shell " . + "are slowing down the poller server." +); -$help["arg_example"] = dgettext("help", "The argument example defined here will be displayed together with the command selection and help in providing a hint of how to parametrize the command for execution."); -$help["command_type"] = dgettext("help", "Define the type of the command. The type will be used to show the command only in the relevant sections."); -$help["graph_template"] = dgettext("help", "The optional definition of a graph template will be used as default graph template, when no other is specified."); -$help["arg_description"] = dgettext("help", "The argument description provided here will be displayed instead of the technical names like ARGn."); -$help["macro_description"] = dgettext("help", "The macro description provided here will be displayed instead of the technical name."); +$help["arg_example"] = dgettext( + "help", + "The argument example defined here will be displayed together with the command selection and help in " . + "providing a hint of how to parametrize the command for execution." +); +$help["command_type"] = dgettext( + "help", + "Define the type of the command. The type will be used to show the command only in the relevant sections." +); +$help["graph_template"] = dgettext( + "help", + "The optional definition of a graph template will be used as default graph template, when no other is specified." +); +$help["arg_description"] = dgettext( + "help", + "The argument description provided here will be displayed instead of the technical names like ARGn." +); +$help["macro_description"] = dgettext( + "help", + "The macro description provided here will be displayed instead of the technical name." +); $help["command_comment"] = dgettext("help", "Comments regarding the command."); -$help["connectors"] = dgettext("help", "Connectors are run in background and execute specific commands without the need to execute a binary, thus enhancing performance. This feature is available in Centreon Engine (>= 1.3)"); +$help["connectors"] = dgettext( + "help", + "Connectors are run in background and execute specific commands without the need to execute a binary, " . + "thus enhancing performance. This feature is available in Centreon Engine (>= 1.3)" +); diff --git a/www/include/configuration/configObject/command/listCommand.php b/www/include/configuration/configObject/command/listCommand.php index 0ad5789b283..d8fb649695b 100755 --- a/www/include/configuration/configObject/command/listCommand.php +++ b/www/include/configuration/configObject/command/listCommand.php @@ -3,34 +3,34 @@ * Copyright 2005-2015 Centreon * Centreon is developped by : Julien Mathis and Romain Le Merlus under * GPL Licence 2.0. - * - * This program is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software * Foundation ; either version 2 of the License. - * + * * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with + * + * You should have received a copy of the GNU General Public License along with * this program; if not, see . - * - * Linking this program statically or dynamically with other modules is making a - * combined work based on this program. Thus, the terms and conditions of the GNU + * + * Linking this program statically or dynamically with other modules is making a + * combined work based on this program. Thus, the terms and conditions of the GNU * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this program give Centreon - * permission to link this program with independent modules to produce an executable, - * regardless of the license terms of these independent modules, and to copy and - * distribute the resulting executable under terms of Centreon choice, provided that - * Centreon also meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module which is not - * derived from this program. If you modify this program, you may extend this + * + * As a special exception, the copyright holders of this program give Centreon + * permission to link this program with independent modules to produce an executable, + * regardless of the license terms of these independent modules, and to copy and + * distribute the resulting executable under terms of Centreon choice, provided that + * Centreon also meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module which is not + * derived from this program. If you modify this program, you may extend this * exception to your version of the program, but you are not obliged to do so. If you * do not wish to do so, delete this exception statement from your version. - * + * * For more information : contact@centreon.com - * + * */ if (!isset($centreon)) { @@ -54,17 +54,19 @@ if ($type_str) { $type_str = " AND " . $type_str; } - $req = "SELECT COUNT(*) FROM `command` WHERE `command_name` LIKE '%".htmlentities($search, ENT_QUOTES, "UTF-8")."%' $type_str"; + $req = "SELECT COUNT(*) FROM `command` " . + "WHERE `command_name` LIKE '%" . htmlentities($search, ENT_QUOTES, "UTF-8") . "%' $type_str"; } else { if (isset($oreon->command_search)) { $search = $oreon->command_search; } if (isset($search) && $search) { - $req = "SELECT COUNT(*) FROM `command` WHERE `command_name` LIKE '%".htmlentities($search, ENT_QUOTES, "UTF-8")."%'"; + $req = "SELECT COUNT(*) FROM `command` " . + "WHERE `command_name` LIKE '%" . htmlentities($search, ENT_QUOTES, "UTF-8") . "%'"; } elseif ($type) { $req = "SELECT COUNT(*) FROM `command` WHERE $type_str"; } else { - $req ="SELECT COUNT(*) FROM `command`"; + $req = "SELECT COUNT(*) FROM `command`"; } if ($type_str) { $type_str = " AND " . $type_str; @@ -105,18 +107,22 @@ * List of elements - Depends on different criteria */ if (isset($search) && $search) { - $rq = "SELECT `command_id`, `command_name`, `command_line`, `command_type`, `command_activate` FROM `command` WHERE `command_name` LIKE '%".htmlentities($search, ENT_QUOTES, "UTF-8")."%' $type_str ORDER BY `command_name` LIMIT ".$num * $limit.", ".$limit; + $rq = "SELECT `command_id`, `command_name`, `command_line`, `command_type`, `command_activate` FROM `command` " . + "WHERE `command_name` LIKE '%" . htmlentities($search, ENT_QUOTES, "UTF-8") . + "%' $type_str ORDER BY `command_name` LIMIT " . $num * $limit . ", " . $limit; } elseif ($type) { - $rq = "SELECT `command_id`, `command_name`, `command_line`, `command_type`, `command_activate` FROM `command` WHERE `command_type` = '".$type."' ORDER BY command_name LIMIT ".$num * $limit.", ".$limit; + $rq = "SELECT `command_id`, `command_name`, `command_line`, `command_type`, `command_activate` FROM `command` " . + "WHERE `command_type` = '" . $type . "' ORDER BY command_name LIMIT " . $num * $limit . ", " . $limit; } else { - $rq = "SELECT `command_id`, `command_name`, `command_line`, `command_type`, `command_activate` FROM `command` ORDER BY `command_name` LIMIT ".$num * $limit.", ".$limit; + $rq = "SELECT `command_id`, `command_name`, `command_line`, `command_type`, `command_activate` FROM `command` " . + "ORDER BY `command_name` LIMIT " . $num * $limit . ", " . $limit; } $search = tidySearchKey($search, $advanced_search); $DBRESULT = $pearDB->query($rq); -$form = new HTML_QuickForm('form', 'POST', "?p=".$p); +$form = new HTML_QuickForm('form', 'POST', "?p=" . $p); /* * Different style between each lines @@ -133,32 +139,42 @@ */ $elemArr = array(); for ($i = 0; $cmd = $DBRESULT->fetchRow(); $i++) { - $selectedElements = $form->addElement('checkbox', "select[".$cmd['command_id']."]"); - + $selectedElements = $form->addElement('checkbox', "select[" . $cmd['command_id'] . "]"); + if ($cmd["command_activate"]) { - $moptions = ""._("Disabled").""; + $moptions = "" . _("Disabled") . ""; } else { - $moptions = ""._("Enabled").""; + $moptions = "" . _("Enabled") . ""; } if (isset($lockedElements[$cmd['command_id']])) { $selectedElements->setAttribute('disabled', 'disabled'); } else { - $moptions .= "  31 && (event.keyCode < 45 || event.keyCode > 57)) event.returnValue = false; if(event.which > 31 && (event.which < 45 || event.which > 57)) return false;\" maxlength=\"3\" size=\"3\" value='1' style=\"margin-bottom:0px;\" name='dupNbr[".$cmd['command_id']."]'>"; + $moptions .= "  31 && (event.keyCode < 45 || event.keyCode > 57)) " . + "event.returnValue = false; if(event.which > 31 && (event.which < 45 || event.which > 57)) " . + "return false;\" maxlength=\"3\" size=\"3\" value='1' style=\"margin-bottom:0px;\" name='dupNbr[" . + $cmd['command_id'] . "]' />"; } - + $elemArr[$i] = array( - "MenuClass" => "list_".$style, + "MenuClass" => "list_" . $style, "RowMenu_select" => $selectedElements->toHtml(), "RowMenu_name" => $cmd["command_name"], - "RowMenu_link" => "?p=".$p."&o=c&command_id=".$cmd['command_id']."&type=".$cmd['command_type'], + "RowMenu_link" => "?p=" . $p . "&o=c&command_id=" . $cmd['command_id'] . "&type=" . $cmd['command_type'], "RowMenu_desc" => CentreonUtils::escapeSecure(substr(myDecodeCommand($cmd["command_line"]), 0, 50)) . "...", "RowMenu_type" => $commandType[$cmd["command_type"]], - "RowMenu_huse" => "".getHostNumberUse($cmd['command_id']) . " (".getHostTPLNumberUse($cmd['command_id']).")", - "RowMenu_suse" => "".getServiceNumberUse($cmd['command_id']) . " (".getServiceTPLNumberUse($cmd['command_id']).")", + "RowMenu_huse" => "" . + getHostNumberUse($cmd['command_id']) . " (" . getHostTPLNumberUse($cmd['command_id']) . ")", + "RowMenu_suse" => "" . + getServiceNumberUse($cmd['command_id']) . " (" . getServiceTPLNumberUse($cmd['command_id']) . ")", "RowMenu_status" => $cmd["command_activate"] ? _("Enabled") : _("Disabled"), - "RowMenu_badge" => $cmd["command_activate"] ? "service_ok" : "service_critical", - "RowMenu_options" => $moptions); + "RowMenu_badge" => $cmd["command_activate"] ? "service_ok" : "service_critical", + "RowMenu_options" => $moptions + ); $style != "two" ? $style = "two" : $style = "one"; } $tpl->assign("elemArr", $elemArr); @@ -172,42 +188,56 @@ $type = 2; } -$tpl->assign('msg', array ("addL"=>"?p=".$p."&o=a&type=".$type, "addT"=>_("Add"), "delConfirm"=>_("Do you confirm the deletion ?"))); +$tpl->assign('msg', array( + "addL" => "?p=" . $p . "&o=a&type=" . $type, + "addT" => _("Add"), + "delConfirm" => _("Do you confirm the deletion ?") +)); $redirectType = $form->addElement('hidden', 'type'); $redirectType->setValue($type); /* - * Toolbar select + * Toolbar select */ foreach (array('o1', 'o2') as $option) { $attrs1 = array( - 'onchange'=>"javascript: " . - "var bChecked = isChecked(); ". - "if (this.form.elements['$option'].selectedIndex != 0 && !bChecked) {". - " alert('"._("Please select one or more items")."'); return false;} " . - "if (this.form.elements['$option'].selectedIndex == 1 && confirm('"._("Do you confirm the duplication ?")."')) {" . + 'onchange' => "javascript: " . + "var bChecked = isChecked(); " . + "if (this.form.elements['$option'].selectedIndex != 0 && !bChecked) {" . + " alert('" . _("Please select one or more items") . "'); return false;} " . + "if (this.form.elements['$option'].selectedIndex == 1 && confirm('" . + _("Do you confirm the duplication ?") . "')) {" . " setO(this.form.elements['$option'].value); submit();} " . - "else if (this.form.elements['$option'].selectedIndex == 2 && confirm('"._("Do you confirm the deletion ?")."')) {" . + "else if (this.form.elements['$option'].selectedIndex == 2 && confirm('" . + _("Do you confirm the deletion ?") . "')) {" . " setO(this.form.elements['$option'].value); submit();} " . "else if (this.form.elements['$option'].selectedIndex == 3) {" . " setO(this.form.elements['$option'].value); submit();} " . "else if (this.form.elements['$option'].selectedIndex == 4) {" . " setO(this.form.elements['$option'].value); submit();} " . - "this.form.elements['$option'].selectedIndex = 0"); - $form->addElement('select', $option, null, array(null => _("More actions..."), "m" => _("Duplicate"), "d" => _("Delete"), "me" => _("Enable"), "md" => _("Disable")), $attrs1); + "this.form.elements['$option'].selectedIndex = 0" + ); + $form->addElement('select', $option, null, array( + null => _("More actions..."), + "m" => _("Duplicate"), + "d" => _("Delete"), + "me" => _("Enable"), + "md" => _("Disable") + ), $attrs1); $form->setDefaults(array($option => null)); $o1 = $form->getElement($option); $o1->setValue(null); $o1->setSelected(null); } -?> + +null, "command_name"=>null, "command_line"=>null); +$cmd = array("command_type" => null, "command_name" => null, "command_line" => null); if (isset($_POST["command_id1"]) && $_POST["command_id1"]) { $command_id = $_POST["command_id1"]; } elseif (isset($_POST["command_id2"]) && $_POST["command_id2"]) { @@ -53,42 +53,44 @@ function myDecodeCommand($arg) $arg = str_replace('#R#', "\\r", $arg); $arg = str_replace('#S#', "/", $arg); $arg = str_replace('#BS#', "\\", $arg); - return($arg); + return ($arg); } } - $DBRESULT = $pearDB->query("SELECT * FROM `command` WHERE `command_id` = '".$command_id."' LIMIT 1"); + $DBRESULT = $pearDB->query("SELECT * FROM `command` WHERE `command_id` = '" . $command_id . "' LIMIT 1"); if ($DBRESULT->rowCount()) { $cmd = array_map("myDecodeCommand", $DBRESULT->fetchRow()); } } - /* - * Notification commands comes from DB -> Store in $notifCmds Array - */ - $notifCmds = array(null=>null); - $DBRESULT = $pearDB->query("SELECT `command_id`, `command_name` FROM `command` WHERE `command_type` = '1' ORDER BY `command_name`"); +/* + * Notification commands comes from DB -> Store in $notifCmds Array + */ +$notifCmds = array(null => null); +$query = "SELECT `command_id`, `command_name` FROM `command` WHERE `command_type` = '1' ORDER BY `command_name`"; +$DBRESULT = $pearDB->query($query); while ($notifCmd = $DBRESULT->fetchRow()) { $notifCmds[$notifCmd["command_id"]] = $notifCmd["command_name"]; } - $DBRESULT->closeCursor(); - - /* - * Check commands comes from DB -> Store in $checkCmds Array - */ - - $checkCmds = array(null=>null); - $DBRESULT = $pearDB->query("SELECT `command_id`, `command_name` FROM `command` WHERE `command_type` = '2' ORDER BY `command_name`"); +$DBRESULT->closeCursor(); + +/* + * Check commands comes from DB -> Store in $checkCmds Array + */ + +$checkCmds = array(null => null); +$query = "SELECT `command_id`, `command_name` FROM `command` WHERE `command_type` = '2' ORDER BY `command_name`"; +$DBRESULT = $pearDB->query($query); while ($checkCmd = $DBRESULT->fetchRow()) { $checkCmds[$checkCmd["command_id"]] = $checkCmd["command_name"]; } $DBRESULT->closeCursor(); -$attrsText = array("size"=>"35"); -$attrsTextarea = array("rows"=>"9", "cols"=>"80"); +$attrsText = array("size" => "35"); +$attrsTextarea = array("rows" => "9", "cols" => "80"); -$form = new HTML_QuickForm('Form', 'post', "?p=".$p); +$form = new HTML_QuickForm('Form', 'post', "?p=" . $p); $form->addElement('header', 'title', _("View command definition")); /* @@ -105,8 +107,8 @@ function myDecodeCommand($arg) } else { $form->addElement('header', 'information', _("No command selected")); } - - + + $cmdType[] = HTML_QuickForm::createElement('radio', 'command_type', null, _("Notification"), '1'); $cmdType[] = HTML_QuickForm::createElement('radio', 'command_type', null, _("Check"), '2'); @@ -122,11 +124,15 @@ function myDecodeCommand($arg) /* * Command Select */ -$form->addElement('select', 'command_id1', _("Check"), $checkCmds, array("onChange"=>"this.form.submit()")); -$form->addElement('select', 'command_id2', _("Notif"), $notifCmds, array("onChange"=>"this.form.submit()")); -$form->setConstants(array("command_name"=>$cmd["command_name"], "command_line"=>$cmd["command_line"], "command_type"=>$cmd["command_type"]["command_type"])); - -$form->setDefaults(array("command_id1"=>$cmd["command_id"])); +$form->addElement('select', 'command_id1', _("Check"), $checkCmds, array("onChange" => "this.form.submit()")); +$form->addElement('select', 'command_id2', _("Notif"), $notifCmds, array("onChange" => "this.form.submit()")); +$form->setConstants(array( + "command_name" => $cmd["command_name"], + "command_line" => $cmd["command_line"], + "command_type" => $cmd["command_type"]["command_type"] +)); + +$form->setDefaults(array("command_id1" => $cmd["command_id"])); /* * Further informations diff --git a/www/include/configuration/configObject/command/minHelpCommand.php b/www/include/configuration/configObject/command/minHelpCommand.php index f570d6ce516..f75f6dc2310 100644 --- a/www/include/configuration/configObject/command/minHelpCommand.php +++ b/www/include/configuration/configObject/command/minHelpCommand.php @@ -57,7 +57,7 @@ /* * Get command informations */ - $DBRESULT = $pearDB->query("SELECT * FROM `command` WHERE `command_id` = '".$command_id."' LIMIT 1"); + $DBRESULT = $pearDB->query("SELECT * FROM `command` WHERE `command_id` = '" . $command_id . "' LIMIT 1"); $cmd = $DBRESULT->fetchRow(); $cmd_array = explode(" ", $cmd["command_line"]); @@ -73,14 +73,16 @@ /* * Select Resource line */ - $DBRESULT = $pearDB->query("SELECT `resource_line` FROM `cfg_resource` WHERE `resource_name` = '\$USER".$matches[1]."\$' LIMIT 1"); + $query = "SELECT `resource_line` FROM `cfg_resource` " . + "WHERE `resource_name` = '\$USER" . $matches[1] . "\$' LIMIT 1"; + $DBRESULT = $pearDB->query($query); $resource = $DBRESULT->fetchRow(); unset($DBRESULT); $resource_path = $resource["resource_line"]; unset($cmd_array[0]); - $command = rtrim($resource_path, "/")."#S#".implode("#S#", $cmd_array); + $command = rtrim($resource_path, "/") . "#S#" . implode("#S#", $cmd_array); } else { $command = $full_line; } @@ -94,7 +96,11 @@ if (strncmp($command, "/usr/lib/nagios/", strlen("/usr/lib/nagios/"))) { if (is_dir("/usr/lib64/nagios/")) { $command = str_replace("/usr/lib/nagios/plugins/", "/usr/lib64/nagios/plugins/", $command); - $oreon->optGen["nagios_path_plugins"] = str_replace("/usr/lib/nagios/plugins/", "/usr/lib64/nagios/plugins/", $oreon->optGen["nagios_path_plugins"]); + $oreon->optGen["nagios_path_plugins"] = str_replace( + "/usr/lib/nagios/plugins/", + "/usr/lib64/nagios/plugins/", + $oreon->optGen["nagios_path_plugins"] + ); } } @@ -104,12 +110,12 @@ $command = realpath($tab[0]); } else { $command = realpath($tab[0]); - $stdout = shell_exec(realpath($tab[0])." --help"); + $stdout = shell_exec(realpath($tab[0]) . " --help"); $msg = str_replace("\n", "
", $stdout); } -$attrsText = array("size" => "25"); -$form = new HTML_QuickForm('Form', 'post', "?p=".$p); +$attrsText = array("size" => "25"); +$form = new HTML_QuickForm('Form', 'post', "?p=" . $p); $form->addElement('header', 'title', _("Plugin Help")); /* @@ -132,7 +138,7 @@ $form->accept($renderer); $tpl->assign('form', $renderer->toArray()); $tpl->assign('o', $o); -$tpl->assign('command_line', $command." --help"); +$tpl->assign('command_line', $command . " --help"); if (isset($msg) && $msg) { $tpl->assign('msg', $msg); } diff --git a/www/include/configuration/configObject/command/minPlayCommand.php b/www/include/configuration/configObject/command/minPlayCommand.php index 41ac3c78a21..8a6a373c61f 100644 --- a/www/include/configuration/configObject/command/minPlayCommand.php +++ b/www/include/configuration/configObject/command/minPlayCommand.php @@ -54,12 +54,17 @@ /* Get resources in DB and replace by the value */ while (preg_match("/@DOLLAR@USER([0-9]+)@DOLLAR@/", $resource_def, $matches) and $error_msg == "") { - $DBRESULT = $pearDB->query("SELECT resource_line FROM cfg_resource WHERE resource_name = '\$USER".$matches[1]."\$' LIMIT 1"); + $query = "SELECT resource_line FROM cfg_resource WHERE resource_name = '\$USER" . $matches[1] . "\$' LIMIT 1"; + $DBRESULT = $pearDB->query($query); $resource = $DBRESULT->fetchRow(); if (!isset($resource["resource_line"])) { - $error_msg .= "\$USER".$matches[1]."\$"; + $error_msg .= "\$USER" . $matches[1] . "\$"; } else { - $resource_def = str_replace("@DOLLAR@USER". $matches[1] ."@DOLLAR@", $resource["resource_line"], $resource_def); + $resource_def = str_replace( + "@DOLLAR@USER" . $matches[1] . "@DOLLAR@", + $resource["resource_line"], + $resource_def + ); } } @@ -76,15 +81,21 @@ while (preg_match("/@DOLLAR@ARG([0-9]+)@DOLLAR@/", $resource_def, $matches) and $error_msg == "") { $match_id = $matches[1]; if (isset($args[$match_id])) { - $resource_def = str_replace("@DOLLAR@ARG". $match_id ."@DOLLAR@", $args[$match_id], $resource_def); + $resource_def = str_replace("@DOLLAR@ARG" . $match_id . "@DOLLAR@", $args[$match_id], $resource_def); $resource_def = str_replace('$', '@DOLLAR@', $resource_def); if (preg_match("/@DOLLAR@USER([0-9]+)@DOLLAR@/", $resource_def, $matches)) { - $DBRESULT = $pearDB->query("SELECT resource_line FROM cfg_resource WHERE resource_name = '\$USER".$matches[1]."\$' LIMIT 1"); + $query = "SELECT resource_line FROM cfg_resource " . + "WHERE resource_name = '\$USER" . $matches[1] . "\$' LIMIT 1"; + $DBRESULT = $pearDB->query($query); $resource = $DBRESULT->fetchRow(); if (!isset($resource["resource_line"])) { - $error_msg .= "\$USER".$match_id."\$"; + $error_msg .= "\$USER" . $match_id . "\$"; } else { - $resource_def = str_replace("@DOLLAR@USER". $matches[1] ."@DOLLAR@", $resource["resource_line"], $resource_def); + $resource_def = str_replace( + "@DOLLAR@USER" . $matches[1] . "@DOLLAR@", + $resource["resource_line"], + $resource_def + ); } } if (preg_match("/@DOLLAR@HOSTADDRESS@DOLLAR@/", $resource_def, $matches)) { @@ -116,7 +127,8 @@ /* * for security reasons, we do not allow the execution of any command unless it is located in path $USER1$ */ - $DBRESULT = $pearDB->query("SELECT `resource_line` FROM `cfg_resource` WHERE `resource_name` = '\$USER1\$' LIMIT 1"); + $query = "SELECT `resource_line` FROM `cfg_resource` WHERE `resource_name` = '\$USER1\$' LIMIT 1"; + $DBRESULT = $pearDB->query($query); $resource = $DBRESULT->fetchRow(); $user1Path = $resource["resource_line"]; $pathMatch = str_replace('/', '\/', $user1Path); @@ -132,7 +144,7 @@ } elseif ($status == 2) { $status = _("CRITICAL"); } elseif ($status == 0) { - $status = _("OK"); + $status = _("OK"); } else { $status = _("UNKNOWN"); } @@ -142,8 +154,8 @@ } } -$attrsText = array("size" => "25"); -$form = new HTML_QuickForm('Form', 'post', "?p=".$p); +$attrsText = array("size" => "25"); +$form = new HTML_QuickForm('Form', 'post', "?p=" . $p); $form->addElement('header', 'title', _("Plugin Test")); /* From f58e96c568034fd719508c69ea3a677569418ec6 Mon Sep 17 00:00:00 2001 From: loiclau Date: Tue, 11 Jul 2017 16:17:46 +0200 Subject: [PATCH 002/207] * fix style configNagios --- .../configuration/configNagios/formNagios.php | 138 +++-- .../configuration/configNagios/help.php | 582 +++++++++++++++--- .../configuration/configNagios/listNagios.php | 85 ++- 3 files changed, 631 insertions(+), 174 deletions(-) diff --git a/www/include/configuration/configNagios/formNagios.php b/www/include/configuration/configNagios/formNagios.php index bf05fb0c40f..bbf0cfef0c5 100644 --- a/www/include/configuration/configNagios/formNagios.php +++ b/www/include/configuration/configNagios/formNagios.php @@ -34,7 +34,8 @@ */ if (!$centreon->user->admin && isset($nagios_id) - && count($allowedMainConf) && !isset($allowedMainConf[$nagios_id])) { + && count($allowedMainConf) && !isset($allowedMainConf[$nagios_id]) +) { $msg = new CentreonMsg(); $msg->setImage("./img/icons/warning.png"); $msg->setTextStyle("bold"); @@ -51,7 +52,7 @@ $nagios = array(); $nagios_d = array(); if (($o == "c" || $o == "w") && $nagios_id) { - $DBRESULT = $pearDB->query("SELECT * FROM cfg_nagios WHERE nagios_id = '".$nagios_id."' LIMIT 1"); + $DBRESULT = $pearDB->query("SELECT * FROM cfg_nagios WHERE nagios_id = '" . $nagios_id . "' LIMIT 1"); # Set base value $nagios = array_map("myDecode", $DBRESULT->fetchRow()); $DBRESULT->closeCursor(); @@ -104,8 +105,10 @@ * Get all nagios servers */ $nagios_server = array(null => ""); -$result = $oreon->user->access->getPollerAclConf(array('fields' => array('name', 'id'), - 'keys' => array('id'))); +$result = $oreon->user->access->getPollerAclConf(array( + 'fields' => array('name', 'id'), + 'keys' => array('id') +)); foreach ($result as $ns) { $nagios_server[$ns["id"]] = $ns["name"]; } @@ -115,7 +118,7 @@ */ $nBk = 0; $aBk = array(); -$DBRESULT= $pearDB->query( +$DBRESULT = $pearDB->query( "SELECT bk_mod_id, broker_module FROM cfg_nagios_broker_module WHERE cfg_nagios_id = '" . $nagios_id . "'" ); @@ -126,15 +129,15 @@ $DBRESULT->closeCursor(); unset($lineBk); -$attrsText = array("size"=>"30"); -$attrsText2 = array("size"=>"50"); -$attrsText3 = array("size"=>"10"); -$attrsTextarea = array("rows"=>"5", "cols"=>"40"); +$attrsText = array("size" => "30"); +$attrsText2 = array("size" => "50"); +$attrsText3 = array("size" => "10"); +$attrsTextarea = array("rows" => "5", "cols" => "40"); /* * Form begin */ -$form = new HTML_QuickForm('Form', 'post', "?p=".$p); +$form = new HTML_QuickForm('Form', 'post', "?p=" . $p); if ($o == "a") { $form->addElement('header', 'title', _("Add a Monitoring Engine Configuration File")); } elseif ($o == "c") { @@ -579,10 +582,12 @@ /* ***************************************************** * General Informations */ -$dateFormats = array("euro"=>"euro (30/06/2002 03:15:00)", -"us"=>"us (06/30/2002 03:15:00)", -"iso8601"=>"iso8601 (2002-06-30 03:15:00)", -"strict-iso8601"=>"strict-iso8601 (2002-06-30 03:15:00)"); +$dateFormats = array( + "euro" => "euro (30/06/2002 03:15:00)", + "us" => "us (06/30/2002 03:15:00)", + "iso8601" => "iso8601 (2002-06-30 03:15:00)", + "strict-iso8601" => "strict-iso8601 (2002-06-30 03:15:00)" +); $form->addElement('select', 'date_format', _("Date Format"), $dateFormats); $form->addElement('text', 'admin_email', _("Administrator Email Address"), $attrsText); $form->addElement('text', 'admin_pager', _("Administrator Pager"), $attrsText); @@ -692,26 +697,28 @@ $nagTab[] = HTML_QuickForm::createElement('radio', 'daemon_dumps_core', null, _("No"), '0'); $form->addGroup($nagTab, 'daemon_dumps_core', _('Daemon core dumps'), ' '); -$verboseOptions = array('0'=>_("Basic information"), - '1'=>_("More detailed information"), - '2'=>_("Highly detailed information") ); +$verboseOptions = array( + '0' => _("Basic information"), + '1' => _("More detailed information"), + '2' => _("Highly detailed information") +); $form->addElement('select', 'debug_verbosity', _("Debug Verbosity"), $verboseOptions); $debugLevel = array(); -$debugLevel["-1"]= _("Log everything"); -$debugLevel["0"]= _("Log nothing (default)"); -$debugLevel["1"]= _("Function enter/exit information"); -$debugLevel["2"]= _("Config information"); -$debugLevel["4"]= _("Process information"); -$debugLevel["8"]= _("Scheduled event information"); -$debugLevel["16"]= _("Host/service check information"); -$debugLevel["32"]= _("Notification information"); -$debugLevel["64"]= _("Event broker information"); -$debugLevel["128"]= _("External Commands"); -$debugLevel["256"]= _("Commands"); -$debugLevel["512"]= _("Downtimes"); -$debugLevel["1024"]= _("Comments"); -$debugLevel["2048"]= _("Macros"); +$debugLevel["-1"] = _("Log everything"); +$debugLevel["0"] = _("Log nothing (default)"); +$debugLevel["1"] = _("Function enter/exit information"); +$debugLevel["2"] = _("Config information"); +$debugLevel["4"] = _("Process information"); +$debugLevel["8"] = _("Scheduled event information"); +$debugLevel["16"] = _("Host/service check information"); +$debugLevel["32"] = _("Notification information"); +$debugLevel["64"] = _("Event broker information"); +$debugLevel["128"] = _("External Commands"); +$debugLevel["256"] = _("Commands"); +$debugLevel["512"] = _("Downtimes"); +$debugLevel["1024"] = _("Comments"); +$debugLevel["2048"] = _("Macros"); foreach ($debugLevel as $key => $val) { if ($key == "-1" || $key == "0") { $debugCheck[] = HTML_QuickForm::createElement( @@ -719,7 +726,7 @@ $key, ' ', $val, - array("id"=>"debug".$key, "onClick"=>"unCheckOthers(this.id);") + array("id" => "debug" . $key, "onClick" => "unCheckOthers(this.id);") ); } else { $debugCheck[] = HTML_QuickForm::createElement( @@ -727,7 +734,7 @@ $key, ' ', $val, - array("id"=>"debug".$key, "onClick"=>"unCheckAllAndNaught();") + array("id" => "debug" . $key, "onClick" => "unCheckAllAndNaught();") ); } } @@ -775,7 +782,7 @@ function isNum($value) } $form->addRule('event_broker_options', _("This value must be a numerical value."), 'isNum'); -$form->setRequiredNote("* "._("Required fields")); +$form->setRequiredNote("* " . _("Required fields")); /* * Smarty template Init @@ -790,7 +797,7 @@ function isNum($value) "button", "change", _("Modify"), - array("onClick"=>"javascript:window.location.href='?p=".$p."&o=c&nagios_id=".$nagios_id."'") + array("onClick" => "javascript:window.location.href='?p=" . $p . "&o=c&nagios_id=" . $nagios_id . "'") ); } $form->setDefaults($nagios); @@ -802,7 +809,7 @@ function isNum($value) 'reset', 'reset', _("Reset"), - array("onClick"=>"javascript:resetBroker('".$o."')", "class" => "btc bt_default") + array("onClick" => "javascript:resetBroker('" . $o . "')", "class" => "btc bt_default") ); $form->setDefaults($nagios); @@ -813,10 +820,10 @@ function isNum($value) 'reset', 'reset', _("Reset"), - array("onClick"=>"javascript:resetBroker('".$o."')", "class" => "btc bt_default") + array("onClick" => "javascript:resetBroker('" . $o . "')", "class" => "btc bt_default") ); } -$tpl->assign('msg', array("nagios"=>$oreon->user->get_version())); +$tpl->assign('msg', array("nagios" => $oreon->user->get_version())); $tpl->assign( "helpattr", @@ -830,7 +837,7 @@ function isNum($value) $helptext = ""; include_once("help.php"); foreach ($help as $key => $text) { - $helptext .= ''."\n"; + $helptext .= '' . "\n"; } $tpl->assign("helptext", $helptext); @@ -849,14 +856,17 @@ function isNum($value) "button", "change", _("Modify"), - array("onClick"=>"javascript:window.location.href='?p=".$p."&o=c&nagios_id=".$nagiosObj->getValue()."'") + array( + "onClick" => "javascript:window.location.href='?p=" . $p . + "&o=c&nagios_id=" . $nagiosObj->getValue() . "'" + ) ); } $valid = true; } if ($valid) { - require_once($path."listNagios.php"); + require_once($path . "listNagios.php"); } else { /* * Apply a template definition @@ -920,30 +930,30 @@ function isNum($value) diff --git a/www/include/configuration/configNagios/help.php b/www/include/configuration/configNagios/help.php index 09256bab3d8..0d7271c361f 100644 --- a/www/include/configuration/configNagios/help.php +++ b/www/include/configuration/configNagios/help.php @@ -267,7 +267,6 @@ ); - $help["retained_service_attribute_mask"] = dgettext( "help", "This is an advanced feature. You'll need to read the Centreon Engine source code " @@ -405,92 +404,519 @@ . "on host check scheduling if scheduling information is being retained using " . "the use_retained_scheduling_info option. Default value is 30 (minutes)." ); -$help["max_service_check_spread"] = dgettext("help", "This option determines the maximum number of minutes from when Monitoring Engine starts that all services (that are scheduled to be regularly checked) are checked. This option will automatically adjust the service inter-check delay method (if necessary) to ensure that the initial checks of all services occur within the timeframe you specify. In general, this option will not have an effect on service check scheduling if scheduling information is being retained using the use_retained_scheduling_info option. Default value is 30 (minutes)."); -$help["service_interleave_factor"] = dgettext("help", "This option determines how service checks are interleaved. Interleaving allows for a more even distribution of service checks, reduced load on remote hosts, and faster overall detection of host problems. By default this value is set to s (smart) for automatic calculation of the interleave factor. Don't change unless you have a specific reason to change it. Setting this value to a number greater than or equal to 1 specifies the interleave factor to use. A value of 1 is equivalent to not interleaving the service checks."); -$help["service_inter_check_delay_method"] = dgettext("help", "This option allows you to control how service checks are initially \"spread out\" in the event queue. Enter \"s\" for using a \"smart\" delay calculation (the default), which will cause Monitoring Engine to calculate an average check interval and spread initial checks of all services out over that interval, thereby helping to eliminate CPU load spikes. Using no delay (\"n\") is generally not recommended, as it will cause all service checks to be scheduled for execution at the same time. This means that you will generally have large CPU spikes when the services are all executed in parallel. Use a \"d\" for a \"dumb\" delay of 1 second between service checks or supply a fixed value of x.xx seconds for the inter-check delay."); -$help["host_inter_check_delay_method"] = dgettext("help", "This option allows you to control how host checks are initially \"spread out\" in the event queue. Enter \"s\" for using a \"smart\" delay calculation (the default), which will cause Monitoring Engine to calculate an average check interval and spread initial checks of all hosts out over that interval, thereby helping to eliminate CPU load spikes. Using no delay (\"n\") is generally not recommended, as it will cause all host checks to be scheduled for execution at the same time. This means that you will generally have large CPU spikes when the hosts are all executed in parallel. Use a \"d\" for a \"dumb\" delay of 1 second between host checks or supply a fixed value of x.xx seconds for the inter-check delay."); -$help["check_result_reaper_frequency"] = dgettext("help", "This option allows you to control the frequency in seconds of check result \"reaper\" events. \"Reaper\" events process the results from host and service checks that have finished executing. These events constitute the core of the monitoring logic in Monitoring Engine."); -$help["translate_passive_host_checks"] = dgettext("help", "This option determines whether or not Monitoring Engine will translate DOWN/UNREACHABLE passive host check results to their \"correct\" state from the viewpoint of the local Monitoring Engine instance. This can be very useful in distributed and failover monitoring installations. Option is disabled by default."); -$help["passive_host_checks_are_soft"] = dgettext("help", "This option determines whether or not Monitoring Engine will treat passive host checks as HARD states or SOFT states. By default, a passive host check result will put a host into a HARD state type. This option is disabled by default."); -$help["auto_reschedule_checks"] = dgettext("help", "This option determines whether or not Monitoring Engine will attempt to automatically reschedule active host and service checks to \"smooth\" them out over time. This can help to balance the load on the monitoring server, as it will attempt to keep the time between consecutive checks consistent, at the expense of executing checks on a more rigid schedule.
Warning: this is an experimental feature and may be removed in future versions. Enabling this option can degrade performance - rather than increase it - if used improperly!"); -$help["auto_rescheduling_interval"] = dgettext("help", "This option determines how often Monitoring Engine will attempt to automatically reschedule checks. This option only has an effect if the auto_reschedule_checks option is enabled. Default is 30 seconds."); -$help["auto_rescheduling_window"] = dgettext("help", "This option determines the \"window\" of time that Monitoring Engine will look at when automatically rescheduling checks. Only host and service checks that occur in the next X seconds (determined by this variable) will be rescheduled. This option only has an effect if the auto_reschedule_checks option is enabled. Default is 180 seconds (3 minutes)."); -$help["use_aggressive_host_checking"] = dgettext("help", "Monitoring Engine tries to be smart about how and when it checks the status of hosts. By default this option is disabled and will allow Monitoring Engine to make some smarter decisions and check hosts a bit faster. Enabling this option will increase the amount of time required to check hosts, but may improve reliability a bit. Unless you have problems with Monitoring Engine not recognizing that a host recovered, I would suggest not enabling this option."); -$help["enable_flap_detection"] = dgettext("help", "This option determines whether or not Monitoring Engine will try and detect hosts and services that are \"flapping\". Flapping occurs when a host or service changes between states too frequently, resulting in a barrage of notifications being sent out. When Monitoring Engine detects that a host or service is flapping, it will temporarily suppress notifications for that host/service until it stops flapping. Flap detection is very experimental at this point, so use this feature with caution! More information on how flap detection and handling works can be found here. Note: If you have state retention enabled, Monitoring Engine will ignore this setting when it (re)starts and use the last known setting for this option (as stored in the state retention file), unless you disable the use_retained_program_state option. This option is disabled by default."); -$help["low_service_flap_threshold"] = dgettext("help", "This option is used to set the low threshold for detection of service flapping. For more information read the Monitoring Engine section about flapping."); -$help["high_service_flap_threshold"] = dgettext("help", "This option is used to set the high threshold for detection of service flapping. For more information read the Monitoring Engine section about flapping."); -$help["low_host_flap_threshold"] = dgettext("help", "This option is used to set the low threshold for detection of host flapping. For more information read the Monitoring Engine section about flapping."); -$help["high_host_flap_threshold"] = dgettext("help", "This option is used to set the high threshold for detection of host flapping. For more information read the Monitoring Engine section about flapping."); -$help["soft_state_dependencies"] = dgettext("help", "This option determines whether or not Monitoring Engine will use soft state information when checking host and service dependencies. Normally Monitoring Engine will only use the latest hard host or service state when checking dependencies. If you want it to use the latest state (regardless of whether its a soft or hard state type), enable this option."); -$help["service_check_timeout"] = dgettext("help", "This is the maximum number of seconds that Monitoring Engine will allow service checks to run. If checks exceed this limit, they are killed and a CRITICAL state is returned. A timeout error will also be logged. This option is meant to be used as a last ditch mechanism to kill off plugins which are misbehaving and not exiting in a timely manner. It should be set to something high (like 60 seconds or more), so that each service check normally finishes executing within this time limit. If a service check runs longer than this limit, Monitoring Engine will kill it off thinking it is a runaway processes."); -$help["host_check_timeout"] = dgettext("help", "This is the maximum number of seconds that Monitoring Engine will allow host checks to run. If checks exceed this limit, they are killed and a CRITICAL state is returned and the host will be assumed to be DOWN. A timeout error will also be logged. This option is meant to be used as a last ditch mechanism to kill off plugins which are misbehaving and not exiting in a timely manner. It should be set to something high (like 60 seconds or more), so that each host check normally finishes executing within this time limit. If a host check runs longer than this limit, Monitoring Engine will kill it off thinking it is a runaway processes."); -$help["event_handler_timeout"] = dgettext("help", "This is the maximum number of seconds that Monitoring Engine will allow event handlers to be run. If an event handler exceeds this time limit it will be killed and a warning will be logged. This option is meant to be used as a last ditch mechanism to kill off commands which are misbehaving and not exiting in a timely manner. It should be set to something high (like 60 seconds or more), so that each event handler command normally finishes executing within this time limit. If an event handler runs longer than this limit, Monitoring Engine will kill it off thinking it is a runaway processes."); -$help["notification_timeout"] = dgettext("help", "This is the maximum number of seconds that Monitoring Engine will allow notification commands to be run. If a notification command exceeds this time limit it will be killed and a warning will be logged. This option is meant to be used as a last ditch mechanism to kill off commands which are misbehaving and not exiting in a timely manner. It should be set to something high (like 60 seconds or more), so that each notification command finishes executing within this time limit. If a notification command runs longer than this limit, Monitoring Engine will kill it off thinking it is a runaway processes."); -$help["ocsp_timeout"] = dgettext("help", "This is the maximum number of seconds that Monitoring Engine will allow an obsessive compulsive service processor command to be run. If a command exceeds this time limit it will be killed and a warning will be logged."); -$help["ochp_timeout"] = dgettext("help", "This is the maximum number of seconds that Monitoring Engine will allow an obsessive compulsive host processor command to be run. If a command exceeds this time limit it will be killed and a warning will be logged."); -$help["perfdata_timeout"] = dgettext("help", "This is the maximum number of seconds that Monitoring Engine will allow a host performance data processor command or service performance data processor command to be run. If a command exceeds this time limit it will be killed and a warning will be logged."); -$help["obsess_over_services"] = dgettext("help", "This value determines whether or not Monitoring Engine will \"obsess\" over service checks results and run the obsessive compulsive service processor command you define. This option is useful for performing distributed monitoring. This option is disabled by default. If you're not doing distributed monitoring, don't enable this option."); -$help["ocsp_command"] = dgettext("help", "This option allows you to specify a command to be run after every service check, which can be useful in distributed monitoring. This command is executed after any event handler or notification commands. The maximum amount of time that this command can run is controlled by the ocsp_timeout option. This command is only executed if the obsess_over_services option is enabled globally and if the obsess_over_service directive in the service definition is enabled."); -$help["obsess_over_hosts"] = dgettext("help", "This value determines whether or not Monitoring Engine will \"obsess\" over host checks results and run the obsessive compulsive host processor command you define. This option is useful for performing distributed monitoring. This option is disabled by default. If you're not doing distributed monitoring, don't enable this option."); -$help["ochp_command"] = dgettext("help", "This option allows you to specify a command to be run after every host check, which can be useful in distributed monitoring. This command is executed after any event handler or notification commands. The maximum amount of time that this command can run is controlled by the ochp_timeout option. This command is only executed if the obsess_over_hosts option is enabled globally and if the obsess_over_host directive in the host definition is enabled."); -$help["process_performance_data"] = dgettext("help", "This value determines whether or not Monitoring Engine will process host and service check performance data. This option is disabled by default."); -$help["host_perfdata_command"] = dgettext("help", "This option allows you to specify a command to be run after every host check to process host performance data that may be returned from the check. This command is only executed if the process_performance_data option is enabled globally and if the process_perf_data directive in the host definition is enabled."); -$help["service_perfdata_command"] = dgettext("help", "This option allows you to specify a command to be run after every service check to process service performance data that may be returned from the check. This command is only executed if the process_performance_data option is enabled globally and if the process_perf_data directive in the service definition is enabled."); -$help["host_perfdata_file"] = dgettext("help", "This option allows you to specify a file to which host performance data will be written after every host check. Data will be written to the performance file as specified by the host_perfdata_file_template option. Performance data is only written to this file if the process_performance_data option is enabled globally and if the process_perf_data directive in the host definition is enabled."); -$help["service_perfdata_file"] = dgettext("help", "This option allows you to specify a file to which service performance data will be written after every service check. Data will be written to the performance file as specified by the service_perfdata_file_template option. Performance data is only written to this file if the process_performance_data option is enabled globally and if the process_perf_data directive in the service definition is enabled."); -$help["host_perfdata_file_template"] = dgettext("help", "This option determines what (and how) data is written to the host performance data file. The template may contain macros, special characters (\\t for tab, \\r for carriage return, \\n for newline) and plain text. A newline is automatically added after each write to the performance data file."); -$help["service_perfdata_file_template"] = dgettext("help", "This option determines what (and how) data is written to the service performance data file. The template may contain macros, special characters (\\t for tab, \\r for carriage return, \\n for newline) and plain text. A newline is automatically added after each write to the performance data file."); -$help["host_perfdata_file_mode"] = dgettext("help", "This option determines how the host performance data file is opened. Unless the file is a named pipe you'll probably want to use the default mode of append."); -$help["service_perfdata_file_mode"] = dgettext("help", "This option determines how the service performance data file is opened. Unless the file is a named pipe you'll probably want to use the default mode of append."); -$help["host_perfdata_file_processing_interval"] = dgettext("help", "This option allows you to specify the interval (in seconds) at which the host performance data file is processed using the host performance data file processing command. A value of 0 indicates that the performance data file should not be processed at regular intervals."); -$help["service_perfdata_file_processing_interval"] = dgettext("help", "This option allows you to specify the interval (in seconds) at which the service performance data file is processed using the service performance data file processing command. A value of 0 indicates that the performance data file should not be processed at regular intervals."); -$help["host_perfdata_file_processing_command"] = dgettext("help", "This option allows you to specify the command that should be executed to process the host performance data file."); -$help["service_perfdata_file_processing_command"] = dgettext("help", "This option allows you to specify the command that should be executed to process the service performance data file."); -$help["check_for_orphaned_services"] = dgettext("help", "This option allows you to enable or disable checks for orphaned service checks. Orphaned service checks are checks which have been executed and have been removed from the event queue, but have not had any results reported in a long time. Since no results have come back in for the service, it is not rescheduled in the event queue. This can cause service checks to stop being executed. Normally it is very rare for this to happen - it might happen if an external user or process killed off the process that was being used to execute a service check. If this option is enabled and Monitoring Engine finds that results for a particular service check have not come back, it will log an error message and reschedule the service check. This option is enabled by default."); -$help["check_for_orphaned_hosts"] = dgettext("help", "This option allows you to enable or disable checks for orphaned hoste checks. Orphaned host checks are checks which have been executed and have been removed from the event queue, but have not had any results reported in a long time. Since no results have come back in for the host, it is not rescheduled in the event queue. This can cause host checks to stop being executed. Normally it is very rare for this to happen - it might happen if an external user or process killed off the process that was being used to execute a host check. If this option is enabled and Monitoring Engine finds that results for a particular host check have not come back, it will log an error message and reschedule the host check. This option is enabled by default."); -$help["check_service_freshness"] = dgettext("help", "This option determines whether or not Monitoring Engine will periodically check the \"freshness\" of service checks. Enabling this option is useful for helping to ensure that passive service checks are received in a timely manner. If the check results is found to be not fresh, Monitoring Engine will force an active check of the host or service by executing the command specified by in the host or service definition. This option is enabled by default."); -$help["service_freshness_check_interval"] = dgettext("help", "This setting determines how often (in seconds) Monitoring Engine will periodically check the \"freshness\" of service check results. If you have disabled service freshness checking (with the check_service_freshness option), this option has no effect."); -$help["check_host_freshness"] = dgettext("help", "This option determines whether or not Monitoring Engine will periodically check the \"freshness\" of host checks. Enabling this option is useful for helping to ensure that passive host checks are received in a timely manner. If the check results is found to be not fresh, Monitoring Engine will force an active check of the host or service by executing the command specified by in the host or service definition. This option is enabled by default."); -$help["host_freshness_check_interval"] = dgettext("help", "This setting determines how often (in seconds) Monitoring Engine will periodically check the \"freshness\" of host check results. If you have disabled host freshness checking (with the check_host_freshness option), this option has no effect."); -$help["additional_freshness_latency"] = dgettext("help", "This option determines the number of seconds Monitoring Engine will add to any host or services freshness threshold it automatically calculates (e.g. those not specified explicitly by the user)."); -$help["date_format"] = dgettext("help", "This option allows you to specify what kind of date/time format Monitoring Engine should use in the web interface and date/time macros."); -$help["admin_email"] = dgettext("help", "This is the email address for the administrator of the local machine (i.e. the one that Monitoring Engine is running on). This value can be used in notification commands by using the \$ADMINEMAIL\$ macro."); -$help["admin_pager"] = dgettext("help", "This is the pager number (or pager email gateway) for the administrator of the local machine (i.e. the one that Monitoring Engine is running on). The pager number/address can be used in notification commands by using the \$ADMINPAGER\$ macro."); -$help["illegal_object_name_chars"] = dgettext("help", "This option allows you to specify illegal characters that cannot be used in host names, service descriptions, or names of other object types. Monitoring Engine will allow you to use most characters in object definitions, but I recommend not using the characters set by default. Doing may give you problems in the web interface, notification commands, etc."); -$help["illegal_macro_output_chars"] = dgettext("help", "This option allows you to specify illegal characters that should be stripped from macros before being used in notifications, event handlers, and other commands. This DOES NOT affect macros used in service or host check commands. Some of these characters are interpreted by the shell (i.e. the backtick) and can lead to security problems."); -$help["use_regexp_matching"] = dgettext("help", "This option determines whether or not various directives in your object definitions will be processed as regular expressions. More information on how this works can be found in Monitoring Engine section on object tricks. This option is disabled by default."); -$help["use_true_regexp_matching"] = dgettext("help", "If you've enabled regular expression matching of various object directives using the use_regexp_matching option, this option will determine when object directives are treated as regular expressions. If this option is disabled (the default), directives will only be treated as regular expressions if they contain *, ?, +, or \\.. If this option is enabled, all appropriate directives will be treated as regular expression."); -$help["event_broker_options"] = dgettext("help", "This option controls what (if any) data gets sent to the event broker and, in turn, to any loaded event broker module. Centreon relies heavily on the broker and needs this value to be set as -1."); -$help["broker_module"] = dgettext("help", "This directive is used to specify an event broker module that should by loaded by Monitoring Engine at startup. Use multiple directives if you want to load more than one module. Arguments that should be passed to the module at startup are separated from the module path by a space."); -$help["enable_predictive_host_dependency_checks"] = dgettext("help", "This option determines whether or not Monitoring Engine will execute predictive checks of hosts that are being depended upon (as defined in host dependencies) for a particular host when it changes state. Predictive checks help ensure that the dependency logic is as accurate as possible. This option is enabled by default."); -$help["enable_predictive_service_dependency_checks"] = dgettext("help", "This option determines whether or not Monitoring Engine will execute predictive checks of services that are being depended upon (as defined in service dependencies) for a particular service when it changes state. Predictive checks help ensure that the dependency logic is as accurate as possible. More information on how predictive checks work can be found here. This option is enabled by default."); -$help["cached_host_check_horizon"] = dgettext("help", "This option determines the maximum amount of time (in seconds) that the state of a previous host check is considered current. Cached host states (from host checks that were performed more recently than the time specified by this value) can improve host check performance immensely. Too high of a value for this option may result in (temporarily) inaccurate host states, while a low value may result in a performance hit for host checks. Use a value of 0 if you want to disable host check caching."); -$help["cached_service_check_horizon"] = dgettext("help", "This option determines the maximum amount of time (in seconds) that the state of a previous service check is considered current. Cached service states (from service checks that were performed more recently than the time specified by this value) can improve service check performance when a lot of service dependencies are used. Too high of a value for this option may result in inaccuracies in the service dependency logic. Use a value of 0 if you want to disable service check caching."); -$help["use_large_installation_tweaks"] = dgettext("help", "This option determines whether or not the Monitoring Engine daemon will take several shortcuts to improve performance. These shortcuts result in the loss of a few features, but larger installations will likely see a lot of benefit from doing so. This option is disabled by default."); -$help["free_child_process_memory"] = dgettext("help", "This option determines whether or not Monitoring Engine will free memory in child processes when they are fork()ed off from the main process. By default, Monitoring Engine frees memory. However, if the use_large_installation_tweaks option is enabled, it will not. By defining this option in your configuration file, you are able to override things to get the behavior you want."); -$help["child_processes_fork_twice"] = dgettext("help", "This option determines whether or not Monitoring Engine will fork() child processes twice when it executes host and service checks. By default, Monitoring Engine fork()s twice. However, if the use_large_installation_tweaks option is enabled, it will only fork() once. By defining this option in your configuration file, you are able to override things to get the behavior you want."); -$help["enable_environment_macros"] = dgettext("help", "This option determines whether or not the Monitoring Engine daemon will make all standard macros available as environment variables to your check, notification, event hander, etc. commands. In large Monitoring Engine installations this can be problematic because it takes additional memory and (more importantly) CPU to compute the values of all macros and make them available to the environment. This option is enabled by default."); -$help["use_setpgid"] = dgettext("help", "Only works with Centreon Engine (>= 1.3). For better performance, set this to 'No'. But it is safer to leave it to 'Default' ('Yes'), for a few native plugins could trigger a monitoring crash."); -$help["debug_file"] = dgettext("help", "This option determines where Monitoring Engine should write debugging information. What (if any) information is written is determined by the debug_level and debug_verbosity options. You can have Monitoring Engine automaticaly rotate the debug file when it reaches a certain size by using the max_debug_file_size option."); -$help["max_debug_file_size"] = dgettext("help", "This option determines the maximum size (in bytes) of the debug file. If the file grows larger than this size, it will be renamed with a .old extension. If a file already exists with a .old extension it will automatically be deleted. This helps ensure your disk space usage doesn't get out of control when debugging Monitoring Engine."); -$help["daemon_dumps_core"] = dgettext("help", "This option allows dumping core in case a segmentation fault occurs. Warning: Make sure that server has sufficient disk space for these dumps (ulimit). This option is discarded when using Centreon Engine."); -$help["debug_verbosity"] = dgettext("help", "This option determines how much debugging information Monitoring Engine should write to the debug_file. By default the verbosity is set to level 1."); -$help["Monitoring Engine_debug_level"] = dgettext("help", "This option determines what type of information Monitoring Engine should write to the debug_file."); +$help["max_service_check_spread"] = dgettext( + "help", + "This option determines the maximum number of minutes from when Monitoring Engine starts that all " . + "services (that are scheduled to be regularly checked) are checked. This option will automatically " . + "adjust the service inter-check delay method (if necessary) to ensure that the initial checks of all " . + "services occur within the timeframe you specify. In general, this option will not have an effect on service " . + "check scheduling if scheduling information is being retained using the use_retained_scheduling_info option. " . + "Default value is 30 (minutes)." +); +$help["service_interleave_factor"] = dgettext( + "help", + "This option determines how service checks are interleaved. Interleaving allows for a more even " . + "distribution of service checks, reduced load on remote hosts, and faster overall detection of " . + "host problems. By default this value is set to s (smart) for automatic calculation of the interleave factor. " . + "Don't change unless you have a specific reason to change it. Setting this value to a number greater " . + "than or equal to 1 specifies the interleave factor to use. A value of 1 is equivalent to not interleaving " . + "the service checks." +); +$help["service_inter_check_delay_method"] = dgettext( + "help", + "This option allows you to control how service checks are initially \"spread out\" in the event queue. " . + "Enter \"s\" for using a \"smart\" delay calculation (the default), which will cause " . + "Monitoring Engine to calculate an average check interval and spread initial checks of all " . + "services out over that interval, thereby helping to eliminate CPU load spikes. Using no " . + "delay (\"n\") is generally not recommended, as it will cause all service checks to be scheduled " . + "for execution at the same time. This means that you will generally have large CPU spikes when the " . + "services are all executed in parallel. Use a \"d\" for a \"dumb\" delay of 1 second between service " . + "checks or supply a fixed value of x.xx seconds for the inter-check delay." +); +$help["host_inter_check_delay_method"] = dgettext( + "help", + "This option allows you to control how host checks are initially \"spread out\" in the event queue. " . + "Enter \"s\" for using a \"smart\" delay calculation (the default), which will cause Monitoring Engine " . + "to calculate an average check interval and spread initial checks of all hosts out over that interval, " . + "thereby helping to eliminate CPU load spikes. Using no delay (\"n\") is generally not recommended, " . + "as it will cause all host checks to be scheduled for execution at the same time. This means that you will " . + "generally have large CPU spikes when the hosts are all executed in parallel. " . + "Use a \"d\" for a \"dumb\" delay of 1 second between host checks or supply a fixed value of x.xx seconds " . + "for the inter-check delay." +); +$help["check_result_reaper_frequency"] = dgettext( + "help", + "This option allows you to control the frequency in seconds of check result \"reaper\" events. " . + "\"Reaper\" events process the results from host and service checks that have finished executing. These events " . + "constitute the core of the monitoring logic in Monitoring Engine." +); +$help["translate_passive_host_checks"] = dgettext( + "help", + "This option determines whether or not Monitoring Engine will translate DOWN/UNREACHABLE passive host " . + "check results to their \"correct\" state from the viewpoint of the local Monitoring Engine instance. " . + "This can be very useful in distributed and failover monitoring installations. Option is disabled by default." +); +$help["passive_host_checks_are_soft"] = dgettext( + "help", + "This option determines whether or not Monitoring Engine will treat passive host checks as HARD states or " . + "SOFT states. By default, a passive host check result will put a host into a HARD state type. This option is " . + "disabled by default." +); +$help["auto_reschedule_checks"] = dgettext( + "help", + "This option determines whether or not Monitoring Engine will attempt to automatically reschedule active " . + "host and service checks to \"smooth\" them out over time. This can help to balance the load on " . + "the monitoring server, as it will attempt to keep the time between consecutive checks consistent, " . + "at the expense of executing checks on a more rigid schedule.
Warning: this is an experimental " . + "feature and may be removed in future versions. Enabling this option can degrade performance - rather than " . + "increase it - if used improperly!" +); +$help["auto_rescheduling_interval"] = dgettext( + "help", + "This option determines how often Monitoring Engine will attempt to automatically reschedule checks. " . + "This option only has an effect if the auto_reschedule_checks option is enabled. Default is 30 seconds." +); +$help["auto_rescheduling_window"] = dgettext( + "help", + "This option determines the \"window\" of time that Monitoring Engine will look at when automatically " . + "rescheduling checks. Only host and service checks that occur in the next X seconds " . + "(determined by this variable) will be rescheduled. This option only has an effect if the " . + "auto_reschedule_checks option is enabled. Default is 180 seconds (3 minutes)." +); +$help["use_aggressive_host_checking"] = dgettext( + "help", + "Monitoring Engine tries to be smart about how and when it checks the status of hosts. By default this " . + "option is disabled and will allow Monitoring Engine to make some smarter decisions and check hosts a " . + "bit faster. Enabling this option will increase the amount of time required to check hosts, but may " . + "improve reliability a bit. Unless you have problems with Monitoring Engine not recognizing that a " . + "host recovered, I would suggest not enabling this option." +); +$help["enable_flap_detection"] = dgettext( + "help", + "This option determines whether or not Monitoring Engine will try and detect hosts and services " . + "that are \"flapping\". Flapping occurs when a host or service changes between states too frequently, " . + "resulting in a barrage of notifications being sent out. When Monitoring Engine detects that a host " . + "or service is flapping, it will temporarily suppress notifications for that host/service until it stops " . + "flapping. Flap detection is very experimental at this point, so use this feature with caution! " . + "More information on how flap detection and handling works can be found here. Note: If you have " . + "state retention enabled, Monitoring Engine will ignore this setting when it (re)starts and use the " . + "last known setting for this option (as stored in the state retention file), unless you disable the " . + "use_retained_program_state option. This option is disabled by default." +); +$help["low_service_flap_threshold"] = dgettext( + "help", + "This option is used to set the low threshold for detection of service flapping. For more information " . + "read the Monitoring Engine section about flapping." +); +$help["high_service_flap_threshold"] = dgettext( + "help", + "This option is used to set the high threshold for detection of service flapping. For more " . + "information read the Monitoring Engine section about flapping." +); +$help["low_host_flap_threshold"] = dgettext( + "help", + "This option is used to set the low threshold for detection of host flapping. For more information " . + "read the Monitoring Engine section about flapping." +); +$help["high_host_flap_threshold"] = dgettext( + "help", + "This option is used to set the high threshold for detection of host flapping. For more information " . + "read the Monitoring Engine section about flapping." +); +$help["soft_state_dependencies"] = dgettext( + "help", + "This option determines whether or not Monitoring Engine will use soft state information when checking " . + "host and service dependencies. Normally Monitoring Engine will only use the latest hard host or " . + "service state when checking dependencies. If you want it to use the latest state (regardless of " . + "whether its a soft or hard state type), enable this option." +); +$help["service_check_timeout"] = dgettext( + "help", + "This is the maximum number of seconds that Monitoring Engine will allow service checks to run. " . + "If checks exceed this limit, they are killed and a CRITICAL state is returned. A timeout error will " . + "also be logged. This option is meant to be used as a last ditch mechanism to kill off plugins " . + "which are misbehaving and not exiting in a timely manner. It should be set to something high " . + "(like 60 seconds or more), so that each service check normally finishes executing within this " . + "time limit. If a service check runs longer than this limit, Monitoring Engine will kill it off " . + "thinking it is a runaway processes." +); +$help["host_check_timeout"] = dgettext( + "help", + "This is the maximum number of seconds that Monitoring Engine will allow host checks to run. " . + "If checks exceed this limit, they are killed and a CRITICAL state is returned and the host will be assumed " . + "to be DOWN. A timeout error will also be logged. This option is meant to be used as a last ditch mechanism " . + "to kill off plugins which are misbehaving and not exiting in a timely manner. It should be set to " . + "something high (like 60 seconds or more), so that each host check normally finishes executing within " . + "this time limit. If a host check runs longer than this limit, Monitoring Engine will kill it off thinking " . + "it is a runaway processes." +); +$help["event_handler_timeout"] = dgettext( + "help", + "This is the maximum number of seconds that Monitoring Engine will allow event handlers to be run. " . + "If an event handler exceeds this time limit it will be killed and a warning will be logged. This option " . + "is meant to be used as a last ditch mechanism to kill off commands which are misbehaving and not exiting " . + "in a timely manner. It should be set to something high (like 60 seconds or more), so that each event handler " . + "command normally finishes executing within this time limit. If an event handler runs longer than this limit, " . + "Monitoring Engine will kill it off thinking it is a runaway processes." +); +$help["notification_timeout"] = dgettext( + "help", + "This is the maximum number of seconds that Monitoring Engine will allow notification commands to be run. " . + "If a notification command exceeds this time limit it will be killed and a warning will be logged. " . + "This option is meant to be used as a last ditch mechanism to kill off commands which are misbehaving " . + "and not exiting in a timely manner. It should be set to something high (like 60 seconds or more), so that " . + "each notification command finishes executing within this time limit. If a notification command runs " . + "longer than this limit, Monitoring Engine will kill it off thinking it is a runaway processes." +); +$help["ocsp_timeout"] = dgettext( + "help", + "This is the maximum number of seconds that Monitoring Engine will allow an obsessive compulsive " . + "service processor command to be run. If a command exceeds this time limit it will be killed and a " . + "warning will be logged." +); +$help["ochp_timeout"] = dgettext( + "help", + "This is the maximum number of seconds that Monitoring Engine will allow an obsessive compulsive " . + "host processor command to be run. If a command exceeds this time limit it will be killed and a " . + "warning will be logged." +); +$help["perfdata_timeout"] = dgettext( + "help", + "This is the maximum number of seconds that Monitoring Engine will allow a host performance data " . + "processor command or service performance data processor command to be run. If a command exceeds " . + "this time limit it will be killed and a warning will be logged." +); +$help["obsess_over_services"] = dgettext( + "help", + "This value determines whether or not Monitoring Engine will \"obsess\" over service checks results " . + "and run the obsessive compulsive service processor command you define. This option is useful for " . + "performing distributed monitoring. This option is disabled by default. If you're not doing distributed " . + "monitoring, don't enable this option." +); +$help["ocsp_command"] = dgettext( + "help", + "This option allows you to specify a command to be run after every service check, which can be useful " . + "in distributed monitoring. This command is executed after any event handler or notification commands. " . + "The maximum amount of time that this command can run is controlled by the ocsp_timeout option. " . + "This command is only executed if the obsess_over_services option is enabled globally and if the " . + "obsess_over_service directive in the service definition is enabled." +); +$help["obsess_over_hosts"] = dgettext( + "help", + "This value determines whether or not Monitoring Engine will \"obsess\" over host checks results and " . + "run the obsessive compulsive host processor command you define. This option is useful for performing " . + "distributed monitoring. This option is disabled by default. If you're not doing distributed monitoring, " . + "don't enable this option." +); +$help["ochp_command"] = dgettext( + "help", + "This option allows you to specify a command to be run after every host check, which can be " . + "useful in distributed monitoring. This command is executed after any event handler or notification " . + "commands. The maximum amount of time that this command can run is controlled by the ochp_timeout option. " . + "This command is only executed if the obsess_over_hosts option is enabled globally and if the " . + "obsess_over_host directive in the host definition is enabled." +); +$help["process_performance_data"] = dgettext( + "help", + "This value determines whether or not Monitoring Engine will process host and service check " . + "performance data. This option is disabled by default." +); +$help["host_perfdata_command"] = dgettext( + "help", + "This option allows you to specify a command to be run after every host check to process host " . + "performance data that may be returned from the check. This command is only executed if the " . + "process_performance_data option is enabled globally and if the process_perf_data directive in " . + "the host definition is enabled." +); +$help["service_perfdata_command"] = dgettext( + "help", + "This option allows you to specify a command to be run after every service check to process " . + "service performance data that may be returned from the check. This command is only executed if the " . + "process_performance_data option is enabled globally and if the process_perf_data directive in the " . + "service definition is enabled." +); +$help["host_perfdata_file"] = dgettext( + "help", + "This option allows you to specify a file to which host performance data will be written after every " . + "host check. Data will be written to the performance file as specified by the " . + "host_perfdata_file_template option. Performance data is only written to this file if the " . + "process_performance_data option is enabled globally and if the process_perf_data directive in the " . + "host definition is enabled." +); +$help["service_perfdata_file"] = dgettext( + "help", + "This option allows you to specify a file to which service performance data will be written after " . + "every service check. Data will be written to the performance file as specified by the " . + "service_perfdata_file_template option. Performance data is only written to this file if the " . + "process_performance_data option is enabled globally and if the process_perf_data directive in the " . + "service definition is enabled." +); +$help["host_perfdata_file_template"] = dgettext( + "help", + "This option determines what (and how) data is written to the host performance data file. " . + "The template may contain macros, special characters (\\t for tab, \\r for carriage return, \\n for newline) " . + "and plain text. A newline is automatically added after each write to the performance data file." +); +$help["service_perfdata_file_template"] = dgettext( + "help", + "This option determines what (and how) data is written to the service performance data file. " . + "The template may contain macros, special characters (\\t for tab, \\r for carriage return, \\n for newline) " . + "and plain text. A newline is automatically added after each write to the performance data file." +); +$help["host_perfdata_file_mode"] = dgettext( + "help", + "This option determines how the host performance data file is opened. Unless the file is a " . + "named pipe you'll probably want to use the default mode of append." +); +$help["service_perfdata_file_mode"] = dgettext( + "help", + "This option determines how the service performance data file is opened. Unless the file is " . + "a named pipe you'll probably want to use the default mode of append." +); +$help["host_perfdata_file_processing_interval"] = dgettext( + "help", + "This option allows you to specify the interval (in seconds) at which the host performance data file " . + "is processed using the host performance data file processing command. A value of 0 indicates that " . + "the performance data file should not be processed at regular intervals." +); +$help["service_perfdata_file_processing_interval"] = dgettext( + "help", + "This option allows you to specify the interval (in seconds) at which the service performance " . + "data file is processed using the service performance data file processing command. A value of 0 " . + "indicates that the performance data file should not be processed at regular intervals." +); +$help["host_perfdata_file_processing_command"] = dgettext( + "help", + "This option allows you to specify the command that should be executed to process the host performance data file." +); +$help["service_perfdata_file_processing_command"] = dgettext( + "help", + "This option allows you to specify the command that should be executed to process " . + "the service performance data file." +); +$help["check_for_orphaned_services"] = dgettext( + "help", + "This option allows you to enable or disable checks for orphaned service checks. Orphaned service checks " . + "are checks which have been executed and have been removed from the event queue, but have not had any results " . + "reported in a long time. Since no results have come back in for the service, it is not rescheduled in " . + "the event queue. This can cause service checks to stop being executed. Normally it is very rare for " . + "this to happen - it might happen if an external user or process killed off the process that was " . + "being used to execute a service check. If this option is enabled and Monitoring Engine finds that results " . + "for a particular service check have not come back, it will log an error message and reschedule the " . + "service check. This option is enabled by default." +); +$help["check_for_orphaned_hosts"] = dgettext( + "help", + "This option allows you to enable or disable checks for orphaned hoste checks. Orphaned host checks are " . + "checks which have been executed and have been removed from the event queue, but have not had any results " . + "reported in a long time. Since no results have come back in for the host, it is not rescheduled in " . + "the event queue. This can cause host checks to stop being executed. Normally it is very rare for " . + "this to happen - it might happen if an external user or process killed off the process that was being " . + "used to execute a host check. If this option is enabled and Monitoring Engine finds that results for a " . + "particular host check have not come back, it will log an error message and reschedule the host check. " . + "This option is enabled by default." +); +$help["check_service_freshness"] = dgettext( + "help", + "This option determines whether or not Monitoring Engine will periodically check the \"freshness\" of " . + "service checks. Enabling this option is useful for helping to ensure that passive service checks are " . + "received in a timely manner. If the check results is found to be not fresh, Monitoring Engine will " . + "force an active check of the host or service by executing the command specified by in the host or " . + "service definition. This option is enabled by default." +); +$help["service_freshness_check_interval"] = dgettext( + "help", + "This setting determines how often (in seconds) Monitoring Engine will periodically check the \"freshness\" of " . + "service check results. If you have disabled service freshness checking (with the " . + "check_service_freshness option), this option has no effect." +); +$help["check_host_freshness"] = dgettext( + "help", + "This option determines whether or not Monitoring Engine will periodically check the \"freshness\" of " . + "host checks. Enabling this option is useful for helping to ensure that passive host checks are " . + "received in a timely manner. If the check results is found to be not fresh, Monitoring Engine will " . + "force an active check of the host or service by executing the command specified by in the host or " . + "service definition. This option is enabled by default." +); +$help["host_freshness_check_interval"] = dgettext( + "help", + "This setting determines how often (in seconds) Monitoring Engine will periodically check the \"freshness\" of " . + "host check results. If you have disabled host freshness checking (with the check_host_freshness option), " . + "this option has no effect." +); +$help["additional_freshness_latency"] = dgettext( + "help", + "This option determines the number of seconds Monitoring Engine will add to any host or services " . + "freshness threshold it automatically calculates (e.g. those not specified explicitly by the user)." +); +$help["date_format"] = dgettext( + "help", + "This option allows you to specify what kind of date/time format Monitoring Engine should use in the web " . + "interface and date/time macros." +); +$help["admin_email"] = dgettext( + "help", + "This is the email address for the administrator of the local machine (i.e. the one that Monitoring " . + "Engine is running on). This value can be used in notification commands by using the \$ADMINEMAIL\$ macro." +); +$help["admin_pager"] = dgettext( + "help", + "This is the pager number (or pager email gateway) for the administrator of the local machine (i.e. " . + "the one that Monitoring Engine is running on). The pager number/address can be used in notification " . + "commands by using the \$ADMINPAGER\$ macro." +); +$help["illegal_object_name_chars"] = dgettext( + "help", + "This option allows you to specify illegal characters that cannot be used in host names, service " . + "descriptions, or names of other object types. Monitoring Engine will allow you to use most characters " . + "in object definitions, but I recommend not using the characters set by default. Doing may give you problems " . + "in the web interface, notification commands, etc." +); +$help["illegal_macro_output_chars"] = dgettext( + "help", + "This option allows you to specify illegal characters that should be stripped from macros before " . + "being used in notifications, event handlers, and other commands. This DOES NOT affect macros used " . + "in service or host check commands. Some of these characters are interpreted by the shell (i.e. the backtick) " . + "and can lead to security problems." +); +$help["use_regexp_matching"] = dgettext( + "help", + "This option determines whether or not various directives in your object definitions will be processed " . + "as regular expressions. More information on how this works can be found in Monitoring Engine section " . + "on object tricks. This option is disabled by default." +); +$help["use_true_regexp_matching"] = dgettext( + "help", + "If you've enabled regular expression matching of various object directives using the use_regexp_matching " . + "option, this option will determine when object directives are treated as regular expressions. " . + "If this option is disabled (the default), directives will only be treated as regular expressions if " . + "they contain *, ?, +, or \\.. If this option is enabled, all appropriate directives will be treated " . + "as regular expression." +); +$help["event_broker_options"] = dgettext( + "help", + "This option controls what (if any) data gets sent to the event broker and, in turn, to any loaded event " . + "broker module. Centreon relies heavily on the broker and needs this value to be set as -1." +); +$help["broker_module"] = dgettext( + "help", + "This directive is used to specify an event broker module that should by loaded by Monitoring Engine " . + "at startup. Use multiple directives if you want to load more than one module. Arguments that should be " . + "passed to the module at startup are separated from the module path by a space." +); +$help["enable_predictive_host_dependency_checks"] = dgettext( + "help", + "This option determines whether or not Monitoring Engine will execute predictive checks of hosts that are " . + "being depended upon (as defined in host dependencies) for a particular host when it changes state. " . + "Predictive checks help ensure that the dependency logic is as accurate as possible. This option is " . + "enabled by default." +); +$help["enable_predictive_service_dependency_checks"] = dgettext( + "help", + "This option determines whether or not Monitoring Engine will execute predictive checks of services that are " . + "being depended upon (as defined in service dependencies) for a particular service when it changes state. " . + "Predictive checks help ensure that the dependency logic is as accurate as possible. More information on " . + "how predictive checks work can be found here. This option is enabled by default." +); +$help["cached_host_check_horizon"] = dgettext( + "help", + "This option determines the maximum amount of time (in seconds) that the state of a previous host check is " . + "considered current. Cached host states (from host checks that were performed more recently than the time " . + "specified by this value) can improve host check performance immensely. Too high of a value for this " . + "option may result in (temporarily) inaccurate host states, while a low value may result in a performance " . + "hit for host checks. Use a value of 0 if you want to disable host check caching." +); +$help["cached_service_check_horizon"] = dgettext( + "help", + "This option determines the maximum amount of time (in seconds) that the state of a previous service " . + "check is considered current. Cached service states (from service checks that were performed more " . + "recently than the time specified by this value) can improve service check performance when a lot of " . + "service dependencies are used. Too high of a value for this option may result in inaccuracies in the " . + "service dependency logic. Use a value of 0 if you want to disable service check caching." +); +$help["use_large_installation_tweaks"] = dgettext( + "help", + "This option determines whether or not the Monitoring Engine daemon will take several shortcuts to " . + "improve performance. These shortcuts result in the loss of a few features, but larger installations will " . + "likely see a lot of benefit from doing so. This option is disabled by default." +); +$help["free_child_process_memory"] = dgettext( + "help", + "This option determines whether or not Monitoring Engine will free memory in child processes when they " . + "are fork()ed off from the main process. By default, Monitoring Engine frees memory. However, " . + "if the use_large_installation_tweaks option is enabled, it will not. By defining this option in your " . + "configuration file, you are able to override things to get the behavior you want." +); +$help["child_processes_fork_twice"] = dgettext( + "help", + "This option determines whether or not Monitoring Engine will fork() child processes twice when it executes " . + "host and service checks. By default, Monitoring Engine fork()s twice. However, if the " . + "use_large_installation_tweaks option is enabled, it will only fork() once. By defining this option in " . + "your configuration file, you are able to override things to get the behavior you want." +); +$help["enable_environment_macros"] = dgettext( + "help", + "This option determines whether or not the Monitoring Engine daemon will make all standard macros available " . + "as environment variables to your check, notification, event hander, etc. commands. In large Monitoring " . + "Engine installations this can be problematic because it takes additional memory and (more importantly) " . + "CPU to compute the values of all macros and make them available to the environment. " . + "This option is enabled by default." +); +$help["use_setpgid"] = dgettext( + "help", + "Only works with Centreon Engine (>= 1.3). For better performance, set this to 'No'. But it is safer to leave " . + "it to 'Default' ('Yes'), for a few native plugins could trigger a monitoring crash." +); +$help["debug_file"] = dgettext( + "help", + "This option determines where Monitoring Engine should write debugging information. What (if any) " . + "information is written is determined by the debug_level and debug_verbosity options. You can have " . + "Monitoring Engine automaticaly rotate the debug file when it reaches a certain size by using the " . + "max_debug_file_size option." +); +$help["max_debug_file_size"] = dgettext( + "help", + "This option determines the maximum size (in bytes) of the debug file. If the file grows larger than this " . + "size, it will be renamed with a .old extension. If a file already exists with a .old extension it will " . + "automatically be deleted. This helps ensure your disk space usage doesn't get out of control when debugging " . + "Monitoring Engine." +); +$help["daemon_dumps_core"] = dgettext( + "help", + "This option allows dumping core in case a segmentation fault occurs. Warning: Make sure that server has " . + "sufficient disk space for these dumps (ulimit). This option is discarded when using Centreon Engine." +); +$help["debug_verbosity"] = dgettext( + "help", + "This option determines how much debugging information Monitoring Engine should write to the debug_file. " . + "By default the verbosity is set to level 1." +); +$help["Monitoring Engine_debug_level"] = dgettext( + "help", + "This option determines what type of information Monitoring Engine should write to the debug_file." +); $help["Monitoring Engine_name"] = dgettext("help", "Description or name used to identify this configuration set."); $help["Monitoring Engine_activate"] = dgettext( "help", "Specify whether this configuration is currently active or not. " . "This way you can test different configuration sets for one monitoring node." ); -$help["Monitoring Engine_server_id"] = dgettext("help", "Choose the Monitoring Engine server instance this configuration is defined for."); -$help["log_pid"] = dgettext("help", "Enable the possibility to log pid information in engine log file (option only for Centreon Engine)"); -$help["use_check_result_path"] = dgettext("help", "This option enable or disable compatibility mode to use check result path."); +$help["Monitoring Engine_server_id"] = dgettext( + "help", + "Choose the Monitoring Engine server instance this configuration is defined for." +); +$help["log_pid"] = dgettext( + "help", + "Enable the possibility to log pid information in engine log file (option only for Centreon Engine)" +); +$help["use_check_result_path"] = dgettext( + "help", + "This option enable or disable compatibility mode to use check result path." +); /* * unsupported in centreon - */ - -/* + *//* status_file status_update_interval diff --git a/www/include/configuration/configNagios/listNagios.php b/www/include/configuration/configNagios/listNagios.php index f03d8cba815..0f44b850894 100644 --- a/www/include/configuration/configNagios/listNagios.php +++ b/www/include/configuration/configNagios/listNagios.php @@ -43,7 +43,7 @@ $search = ''; if (isset($_POST['searchN']) && $_POST['searchN']) { $search = $_POST['searchN']; - $SearchTool = " WHERE nagios_name LIKE '%".htmlentities($search, ENT_QUOTES, "UTF-8")."%' "; + $SearchTool = " WHERE nagios_name LIKE '%" . htmlentities($search, ENT_QUOTES, "UTF-8") . "%' "; } $aclCond = ""; @@ -53,7 +53,7 @@ } else { $aclCond = " WHERE "; } - $aclCond .= "nagios_id IN (".implode(',', array_keys($allowedMainConf)).") "; + $aclCond .= "nagios_id IN (" . implode(',', array_keys($allowedMainConf)) . ") "; } $DBRESULT = $pearDB->query("SELECT COUNT(*) FROM cfg_nagios $SearchTool $aclCond"); @@ -99,9 +99,9 @@ $DBRESULT = $pearDB->query("SELECT nagios_id, nagios_name, nagios_comment, nagios_activate, nagios_server_id FROM cfg_nagios $SearchTool $aclCond ORDER BY nagios_name - LIMIT ".$num * $limit.", ".$limit); + LIMIT " . $num * $limit . ", " . $limit); -$form = new HTML_QuickForm('select_form', 'POST', "?p=".$p); +$form = new HTML_QuickForm('select_form', 'POST', "?p=" . $p); /* * Different style between each lines @@ -114,22 +114,31 @@ $elemArr = array(); for ($i = 0; $nagios = $DBRESULT->fetchRow(); $i++) { $moptions = ""; - $selectedElements = $form->addElement('checkbox', "select[".$nagios['nagios_id']."]"); + $selectedElements = $form->addElement('checkbox', "select[" . $nagios['nagios_id'] . "]"); if ($nagios["nagios_activate"]) { - $moptions .= ""._("Disabled")."  "; + $moptions .= "  "; } else { - $moptions .= ""._("Enabled")."  "; + $moptions .= "" . _("Enabled") . "  "; } - $moptions .= "  31 && (event.keyCode < 45 || event.keyCode > 57)) event.returnValue = false; if(event.which > 31 && (event.which < 45 || event.which > 57)) return false;\" maxlength=\"3\" size=\"3\" value='1' style=\"margin-bottom:0px;\" name='dupNbr[".$nagios['nagios_id']."]'>"; - $elemArr[$i] = array("MenuClass"=>"list_".$style, - "RowMenu_select"=>$selectedElements->toHtml(), - "RowMenu_name"=>$nagios["nagios_name"], - "RowMenu_instance"=>$nagios_servers[$nagios["nagios_server_id"]], - "RowMenu_link"=>"?p=".$p."&o=c&nagios_id=".$nagios['nagios_id'], - "RowMenu_desc"=>substr($nagios["nagios_comment"], 0, 40), - "RowMenu_status"=>$nagios["nagios_activate"] ? _("Enabled") : _("Disabled"), - "RowMenu_badge" => $nagios["nagios_activate"] ? "service_ok" : "service_critical", - "RowMenu_options"=>$moptions); + $moptions .= "  31 && (event.keyCode < 45 || event.keyCode > 57)) " . + "event.returnValue = false; if(event.which > 31 && (event.which < 45 || event.which > 57)) " . + "return false;\" maxlength=\"3\" size=\"3\" value='1' style=\"margin-bottom:0px;\" name='dupNbr[" . + $nagios['nagios_id'] . "]' />"; + $elemArr[$i] = array( + "MenuClass" => "list_" . $style, + "RowMenu_select" => $selectedElements->toHtml(), + "RowMenu_name" => $nagios["nagios_name"], + "RowMenu_instance" => $nagios_servers[$nagios["nagios_server_id"]], + "RowMenu_link" => "?p=" . $p . "&o=c&nagios_id=" . $nagios['nagios_id'], + "RowMenu_desc" => substr($nagios["nagios_comment"], 0, 40), + "RowMenu_status" => $nagios["nagios_activate"] ? _("Enabled") : _("Disabled"), + "RowMenu_badge" => $nagios["nagios_activate"] ? "service_ok" : "service_critical", + "RowMenu_options" => $moptions + ); $style != "two" ? $style = "two" : $style = "one"; } @@ -138,27 +147,39 @@ /* * Different messages we put in the template */ -$tpl->assign('msg', array ("addL"=>"?p=".$p."&o=a", "addT"=>_("Add"), "delConfirm"=>_("Do you confirm the deletion ?"))); +$tpl->assign( + 'msg', + array("addL" => "?p=" . $p . "&o=a", "addT" => _("Add"), "delConfirm" => _("Do you confirm the deletion ?")) +); ?> - + "javascript: " . - "if (this.form.elements['".$option."'].selectedIndex == 1 && confirm('"._("Do you confirm the duplication ?")."')) {" . - " setO(this.form.elements['".$option."'].value); submit();} " . - "else if (this.form.elements['".$option."'].selectedIndex == 2 && confirm('"._("Do you confirm the deletion ?")."')) {" . - " setO(this.form.elements['".$option."'].value); submit();} " . - "else if (this.form.elements['".$option."'].selectedIndex == 3) {" . - " setO(this.form.elements['".$option."'].value); submit();} " . - ""); - $form->addElement('select', $option, null, array(null=>_("More actions..."), "m"=>_("Duplicate"), "d"=>_("Delete")), $attrs); + 'onchange' => "javascript: " . + "if (this.form.elements['" . $option . "'].selectedIndex == 1 && confirm('" . + _("Do you confirm the duplication ?") . "')) {" . + " setO(this.form.elements['" . $option . "'].value); submit();} " . + "else if (this.form.elements['" . $option . "'].selectedIndex == 2 && confirm('" . + _("Do you confirm the deletion ?") . "')) {" . + " setO(this.form.elements['" . $option . "'].value); submit();} " . + "else if (this.form.elements['" . $option . "'].selectedIndex == 3) {" . + " setO(this.form.elements['" . $option . "'].value); submit();} " . + "" + ); + $form->addElement( + 'select', + $option, + null, + array(null => _("More actions..."), "m" => _("Duplicate"), "d" => _("Delete")), + $attrs + ); $form->setDefaults(array($option => null)); $o1 = $form->getElement($option); $o1->setValue(null); From 8350368fff3216f84a05e693c96dab2c60e7dce1 Mon Sep 17 00:00:00 2001 From: mariegallardo Date: Tue, 11 Jul 2017 16:53:55 +0200 Subject: [PATCH 003/207] Improve CLAPI documentation (#5329) * First_notification_option: one deleted. * Flap_detection_options deleted It didn't work anymore * First_notification_delay deleted One of the two. * flap_detection_options deleted * flap_detection_options deleted One of the two. * flap_detection_options One of the two. * Check_freshness modified The description was not correct. * Check_freshness modified The description was not correct. * Timezone shifted * Timezone shifted * Update dependencies.rst * Delparent and Delchild Their descriptions were not correct. * Add setparam comment It was missing * Add setparam comment It was missing. * Changing grant/revoke example Home/Nagios statistics do not exist anymore. * Changing a grant/revoke example. Home/Nagios statistics do not exist anymore. * Add delhostexclusion It exists but was not written on the documentation * Add delhostexclusion The function exists but it was not written on the documentation. * Delete *stats delstats, addstats, getstats... Every *stats do not exist anymore. * Update broker_cfg.rst * Delete addstats, delstats... Every *stats was deleted * Delete Liststats I missed it. * Delete deltemporary It is not implemented. * Delete deltemporary It is not implemented * Delete every *correlation They do not exist anymore. * Delete the last correlation I missed one exemple. * Update broker_cfg.rst * Delete every *correlation They do not exist anymore. * Delete local-server and local-client They are not implemented. * Delete local-client I missed it the first time. * Delete local-server and local-client They are not implemented. * Add category for output file It is implemented but not written in th documentation. * Update broker_cfg.rst * Update broker_cfg.rst * Add category for output file It is implemented but not written in the documentation. * Add category for output rrd It is implemented but not written on the documentation. * Add category for output rrd It is implemented but not written on the documentation. * Add write_metrics for output rrd It is implemented but not written on the documentation. * Add write_metrics for output rrd It is implemented but not written on the documentation. * Add write_status for output rrd It is implemented but not written on the documentation. * Update broker_cfg.rst * Try to fix a bug * Again * Update broker_cfg.rst * Update broker_cfg.rst * Update broker_cfg.rst * Update broker_cfg.rst * Update broker_cfg.rst * Update broker_cfg.rst * Update broker_cfg.rst * Update broker_cfg.rst * Update broker_cfg.rst * Update broker_cfg.rst * Update broker_cfg.rst * Add write_status for output rrd It is implemented but not written on the documentation. * Add store_in_date_bin for output rrd It is implemented but not written on the documentation. * Add store_in_data_bin for output rrd It is implemented but not written on the documentation. * Spelling mistake * Spelling mistake * Add store_in_data_bin for output storage It is implemented but not written on the documentation. * Add category for output storage It is implemented but not written on the documentation. * Add store_in_data_bin for output storage It is implemented but not written on the documentation. * Add category for output storage It is implemented but not written on the documentation. * Delete stats_activate It is not used anymore. * Delete setparam stats_activate It is not used anymore. * Add category for output sql It is implemented but not written on the documentation * Add category for output sql It is implemented but not written on the documentation. * Update broker_cfg.rst * Update broker_cfg.rst * Specify options for flap_detection_options * Specify options for flap_detection_options * Add host_high_flap_threshold The function was missing * Add host_high_flap_threshold The function was missing * Add host_high_flap_threshold The function was missing. * Add host_low_flap_threshold The function was missing. * Change gettypelist example It needed an update. * Change example getypelist This example needed an update. --- doc/en/api/clapi/objects/acl_menu.rst | 6 +- doc/en/api/clapi/objects/acl_resource.rst | 1 + doc/en/api/clapi/objects/broker_cfg.rst | 185 +++--------------- doc/en/api/clapi/objects/dependencies.rst | 2 +- doc/en/api/clapi/objects/hosts.rst | 10 +- .../api/clapi/objects/service_templates.rst | 4 - doc/en/api/clapi/objects/services.rst | 2 - doc/fr/api/clapi/objects/acl_menu.rst | 6 +- doc/fr/api/clapi/objects/acl_resource.rst | 1 + doc/fr/api/clapi/objects/broker_cfg.rst | 184 +++-------------- doc/fr/api/clapi/objects/dependencies.rst | 2 +- doc/fr/api/clapi/objects/hosts.rst | 12 +- .../api/clapi/objects/service_templates.rst | 4 - doc/fr/api/clapi/objects/services.rst | 2 - 14 files changed, 83 insertions(+), 338 deletions(-) diff --git a/doc/en/api/clapi/objects/acl_menu.rst b/doc/en/api/clapi/objects/acl_menu.rst index 71d1a2e5172..1adbe76d76a 100644 --- a/doc/en/api/clapi/objects/acl_menu.rst +++ b/doc/en/api/clapi/objects/acl_menu.rst @@ -94,6 +94,8 @@ name Name alias Alias activate 1 when ACL Menu is enabled, 0 otherwise + +comment Comment ========= ======================================= @@ -124,9 +126,9 @@ Let's assume that you would like to grant full access to the [Monitoring] menu i [root@centreon ~]# ./centreon -u admin -p centreon -o ACLMENU -a grant -v "ACL Menu test;Monitoring" -Then, you would like to grant access to the [Home] > [Nagios statistics] menu::: +Then, you would like to grant access to the [Home] > [Poller statistics] menu::: - [root@centreon ~]# ./centreon -u admin -p centreon -o ACLMENU -a grant -v "ACL Menu test;Home;Nagios statistics" + [root@centreon ~]# ./centreon -u admin -p centreon -o ACLMENU -a grant -v "ACL Menu test;Home;Poller statistics" Then, you decide to revoke access from [Monitoring] > [Event Logs]::: diff --git a/doc/en/api/clapi/objects/acl_resource.rst b/doc/en/api/clapi/objects/acl_resource.rst index 439b15cd196..a021e0ac278 100644 --- a/doc/en/api/clapi/objects/acl_resource.rst +++ b/doc/en/api/clapi/objects/acl_resource.rst @@ -140,6 +140,7 @@ revoke_host Put host name(s) [...] -a revoke_host -v "ACL revoke_hostgroup Put hostgroup name(s) [...] -a revoke_hostgroup -v "ACL Resource Test;Linux servers" Yes revoke_servicegroup Put servicegroup name(s) [...] -a revoke_servicegroup -v "ACL Resource Test;Ping" Yes revoke_metaservice Put metaservice name(s) [...] -a revoke_metaservice -v "ACL Resource Test;Traffic Average" Yes +delhostexclusion Put host name(s) [...] -a delhostexclusion -v "ACL Resource Test;srv-test|srv-test2" Yes addfilter_instance Put instance name(s) [...] -a addfilter_instance -v "ACL Resource Test;Monitoring-2" No addfilter_hostcategory Put host category name(s) [...] -a addfilter_hostcategory -v "ACL Resource Test;Customer-1" No addfilter_servicecategory Put service category name(s) [...] -a addfilter_servicecategory -v "ACL Resource Test;System" No diff --git a/doc/en/api/clapi/objects/broker_cfg.rst b/doc/en/api/clapi/objects/broker_cfg.rst index 6cebd581230..5863cc3a7a6 100644 --- a/doc/en/api/clapi/objects/broker_cfg.rst +++ b/doc/en/api/clapi/objects/broker_cfg.rst @@ -96,21 +96,17 @@ cache_directory Path for cache files daemon Link this configuration to cbd service (0 or 1) -stats_activate Enable statistics (0 or 1) - correlation_activate Enable correlation (0 or 1) ======================== ================================================== -Listinput, Listoutput, Listlogger, Listcorrelation and Liststats +Listinput, Listoutput and Listlogger ---------------------------------------------------------------------------------- If you want to list specific input output types of Centreon Broker, use one of the following commands: listinput listoutput listlogger -listcorrelation -liststats Example:: @@ -129,14 +125,13 @@ ID I/O ID Name I/O Name ======= ============ -Getinput, Getoutput, Getlogger, Getcorrelation and Getstats +Getinput, Getoutput and Getlogger ----------------------------------------------------------- In order to get parameters of a specific I/O object, use one of the following commands: - getinput - getoutput - getlogger - - getcorrelation Example:: @@ -166,15 +161,13 @@ Order Description ======== =========================== -Addinput, Addoutput, Addlogger, Addcorrelation and Addstats +Addinput, Addoutput and Addlogger ----------------------------------------------------------- In order to add a new I/O object, use one of the following commands: - **ADDINPUT** - **ADDOUTPUT** - **ADDLOGGER** - - **ADDCORRELATION** - - **ADDSTATS** Example:: @@ -197,16 +190,13 @@ Order Column description ======== ============================ -Delinput, Deloutput, Dellogger, Delcorrelation and Delstats +Delinput, Deloutput and Dellogger ----------------------------------------------------------- In order to remove an I/O object from the Centreon Broker configuration, use one of the following commands: - **DELINPUT** - **DELOUTPUT** - **DELLOGGER** - - **DELCORRELATION** - - **DELTEMPORARY** - - **DELSTATS** Example:: @@ -215,19 +205,17 @@ Example:: The I/O ID is used for identifying the object to delete. -Setintput, Setoutput, Setlogger, Setcorrelation and Setstats +Setintput, Setoutput and Setlogger ------------------------------------------------------------ In order to set parameters of an I/O object, use one of the following commands: - **SETINPUT** - **SETOUTPUT** - **SETLOGGER** - - **SETCORRELATION** - - **SETSTATS** Example:: - [root@centreon ~]# ./centreon -u admin -p centreon -o CENTBROKERCFG -a setcorrelation -v "broker cfg for poller test;1;file;/etc/centreon-broker/correlation.xml" + [root@centreon ~]# ./centreon -u admin -p centreon -o CENTBROKERCFG -a setlogger -v "broker cfg for poller test;1;debug;no" Arguments are composed of the following columns: @@ -252,14 +240,19 @@ Example:: [root@localhost core]# ./centreon -u admin -p centreon -o CENTBROKERCFG -a gettypelist -v "output" type id;short name;name + 27;bam_bi;BI engine (BAM) 16;sql;Broker SQL Database + 32;correlation;Correlation + 28;db_cfg_reader;Database configuration reader + 29;db_cfg_writer;Database configuration writer 11;file;File 3;ipv4;IPv4 10;ipv6;IPv6 - 15;local_client;Local Client Socket - 12;local_server;Local Server Socket + 26;bam;Monitoring engine (BAM) 14;storage;Perfdata Generator (Centreon Storage) 13;rrd;RRD File Generator + 30;graphite;Storage - Graphite + 31;influxdb;Storage - InfluxDB [root@localhost core]# ./centreon -u admin -p centreon -o CENTBROKERCFG -a getfieldlist -v "ipv4" field id;short name;name @@ -286,24 +279,6 @@ This is how you get the list of possible values of a given field:: The following chapters describes the parameters of each Object type -correlation -~~~~~~~~~~~ - -correlation: - -============================== ============================================================ ============================================================ =========================================================== -ID Label Description Possible values -============================== ============================================================ ============================================================ =========================================================== -file Correlation file Path to the correlation file which holds host, services, - dependencies and parenting definitions. - - -retention Retention file File where correlation state will be stored during - correlation engine restart - - -============================== ============================================================ ============================================================ =========================================================== - - - input ~~~~~ @@ -418,57 +393,6 @@ protocol Serialization protocol ============================== ============================================================ ============================================================ =========================================================== -local_server: - -============================== ============================================================ ============================================================ =========================================================== -ID Label Description Possible values -============================== ============================================================ ============================================================ =========================================================== -buffering_timeout Buffering timeout Time in seconds to wait before launching failover. - - -compression Compression (zlib) Enable or not data stream compression. - - -compression_buffer Compression buffer size The higher the buffer size is, the best compression. - This however increase data streaming latency. - Use with caution. - - -compression_level Compression level Ranges from 0 (no compression) to 9 (best compression). - Default is -1 (zlib compression) - - -retry_interval Retry interval Time in seconds to wait between each connection attempt. - - -path File path Path to the file. - - -protocol Serialization protocol Serialization protocol. ndo - -============================== ============================================================ ============================================================ =========================================================== - - -local_client: - -============================== ============================================================ ============================================================ =========================================================== -ID Label Description Possible values -============================== ============================================================ ============================================================ =========================================================== -buffering_timeout Buffering timeout Time in seconds to wait before launching failover. - - -compression Compression (zlib) Enable or not data stream compression. - - -compression_buffer Compression buffer size The higher the buffer size is, the best compression. - This however increase data streaming latency. - Use with caution. - - -compression_level Compression level Ranges from 0 (no compression) to 9 (best compression). - Default is -1 (zlib compression) - - -retry_interval Retry interval Time in seconds to wait between each connection attempt. - - -path File path Path to the file. - - -protocol Serialization protocol Serialization protocol. ndo - -============================== ============================================================ ============================================================ =========================================================== - - - logger ~~~~~~ @@ -667,34 +591,9 @@ failover Failover name retry_interval Retry interval Time in seconds to wait between each connection attempt. - -max_size Maximum size of file Maximum size in bytes. - - -path File path Path to the file. - - -protocol Serialization protocol Serialization protocol. ndo +category Filter category Category filter for flux in output. - -============================== ============================================================ ============================================================ =========================================================== - - -local_server: - -============================== ============================================================ ============================================================ =========================================================== -ID Label Description Possible values -============================== ============================================================ ============================================================ =========================================================== -buffering_timeout Buffering timeout Time in seconds to wait before launching failover. - - -compression Compression (zlib) Enable or not data stream compression. - - -compression_buffer Compression buffer size The higher the buffer size is, the best compression. - This however increase data streaming latency. - Use with caution. - - -compression_level Compression level Ranges from 0 (no compression) to 9 (best compression). - Default is -1 (zlib compression) - - -failover Failover name Name of the output which will act as failover - - -retry_interval Retry interval Time in seconds to wait between each connection attempt. - +max_size Maximum size of file Maximum size in bytes. - path File path Path to the file. - @@ -714,6 +613,8 @@ failover Failover name retry_interval Retry interval Time in seconds to wait between each connection attempt. - +category Filter category Category filter for flux in output. - + metrics_path RRD file directory for metrics RRD file directory, for example /var/lib/centreon/metrics - path Unix socket The Unix socket used to communicate with rrdcached. @@ -726,6 +627,12 @@ port TCP port status_path RRD file directory for statuses RRD file directory, for example /var/lib/centreon/status - +write_metrics Enable write_metrics Enable or not write_metrics. - + +write_status Enable write_status Enable or not write_status. - + +store_in_data_bin Enable store_in_data_bin Enable or not store in performance data in data_bin. - + ============================== ============================================================ ============================================================ =========================================================== @@ -740,6 +647,8 @@ failover Failover name retry_interval Retry interval Time in seconds to wait between each connection attempt. - +category Filter category Category filter for flux in output. - + check_replication Replication enabled When enabled, the broker engine will check whether or not the replication is up to date before attempting to update data. - @@ -767,32 +676,7 @@ read_timeout Transaction commit timeout rebuild_check_interval Rebuild check interval in seconds The interval between check if some metrics must be rebuild. The default value is 300s - -============================== ============================================================ ============================================================ =========================================================== - - -local_client: - -============================== ============================================================ ============================================================ =========================================================== -ID Label Description Possible values -============================== ============================================================ ============================================================ =========================================================== -buffering_timeout Buffering timeout Time in seconds to wait before launching failover. - - -compression Compression (zlib) Enable or not data stream compression. - - -compression_buffer Compression buffer size The higher the buffer size is, the best compression. - This however increase data streaming latency. - Use with caution. - - -compression_level Compression level Ranges from 0 (no compression) to 9 (best compression). - Default is -1 (zlib compression) - - -failover Failover name Name of the output which will act as failover - - -retry_interval Retry interval Time in seconds to wait between each connection attempt. - - -path File path Path to the file. - - -protocol Serialization protocol Serialization protocol. ndo +store_in_data_bin Enable store_in_data_bin Enable or not store in performance data in data_bin. - ============================== ============================================================ ============================================================ =========================================================== @@ -808,6 +692,8 @@ failover Failover name retry_interval Retry interval Time in seconds to wait between each connection attempt. - +category Filter category Category filter for flux in output. - + check_replication Replication enabled When enabled, the broker engine will check whether or not the replication is up to date before attempting to update data. - @@ -829,18 +715,3 @@ queries_per_transaction Maximum queries per transaction read_timeout Transaction commit timeout The transaction timeout before running commit. - ============================== ============================================================ ============================================================ =========================================================== - - - -stats -~~~~~ - -stats: - -============================== ============================================================ ============================================================ =========================================================== -ID Label Description Possible values -============================== ============================================================ ============================================================ =========================================================== -fifo File for Centreon Broker statistics File where Centreon Broker statistics will be stored - - -============================== ============================================================ ============================================================ =========================================================== - diff --git a/doc/en/api/clapi/objects/dependencies.rst b/doc/en/api/clapi/objects/dependencies.rst index da79fb4335e..bc27b30aa3c 100644 --- a/doc/en/api/clapi/objects/dependencies.rst +++ b/doc/en/api/clapi/objects/dependencies.rst @@ -131,7 +131,7 @@ If you want to add a new parent or a new child in a dependency definition, use t Delparent and Delchild ---------------------- -If you want to add a new parent or a new child in a dependency definition, use the **DELPARENT** or **DELCHILD** action:: +In order to delete a parent or a child in a dependency definition, use the **DELPARENT** or **DELCHILD** action:: [root@centreon ~]# ./centreon -u admin -p centreon -o DEP -a DELPARENT \ -v "my dependency;my_parent_host" diff --git a/doc/en/api/clapi/objects/hosts.rst b/doc/en/api/clapi/objects/hosts.rst index f3426b49cc5..86470e8c373 100644 --- a/doc/en/api/clapi/objects/hosts.rst +++ b/doc/en/api/clapi/objects/hosts.rst @@ -121,7 +121,7 @@ check_command_arguments Check command arguments check_interval Normal check interval -check_freshness Check freshness (in seconds) +check_freshness Enables check freshness check_period Check period @@ -141,7 +141,11 @@ first_notification_delay First notification delay (in seconds) flap_detection_enabled Whether or not flap detection is enabled -flap_detection_options Flap detection options +flap_detection_options Flap detection options 'o' for Up, 'd' for Down, 'u' for Unreachable + +host_high_flap_threshold High flap threshold + +host_low_flap_threshold Low flap threshold icon_image Icon image @@ -187,7 +191,7 @@ statusmap_image Status map image (used by statusmap host_notification_options Notification options (d,u,r,f,s) -timezone Timezone +timezone Timezone ==================================== ================================================================================= diff --git a/doc/en/api/clapi/objects/service_templates.rst b/doc/en/api/clapi/objects/service_templates.rst index 6e1325463fe..a79dcd65654 100644 --- a/doc/en/api/clapi/objects/service_templates.rst +++ b/doc/en/api/clapi/objects/service_templates.rst @@ -174,10 +174,6 @@ event_handler Name of the event handler command event_handler_arguments Arguments that go along with the event handler, prepend each argument with the "!" character -first_notification_delay First notification delay in seconds - -flap_detection_options Flap detection options - notes Notes notes_url Notes URL diff --git a/doc/en/api/clapi/objects/services.rst b/doc/en/api/clapi/objects/services.rst index 14570c94b43..1508a808e76 100644 --- a/doc/en/api/clapi/objects/services.rst +++ b/doc/en/api/clapi/objects/services.rst @@ -194,8 +194,6 @@ event_handler Name of the event handler command event_handler_arguments Arguments that go along with the event handler, prepend each argument with the '!' character -flap_detection_options Flap detection options - notes Notes notes_url Notes URL diff --git a/doc/fr/api/clapi/objects/acl_menu.rst b/doc/fr/api/clapi/objects/acl_menu.rst index 71d1a2e5172..1adbe76d76a 100644 --- a/doc/fr/api/clapi/objects/acl_menu.rst +++ b/doc/fr/api/clapi/objects/acl_menu.rst @@ -94,6 +94,8 @@ name Name alias Alias activate 1 when ACL Menu is enabled, 0 otherwise + +comment Comment ========= ======================================= @@ -124,9 +126,9 @@ Let's assume that you would like to grant full access to the [Monitoring] menu i [root@centreon ~]# ./centreon -u admin -p centreon -o ACLMENU -a grant -v "ACL Menu test;Monitoring" -Then, you would like to grant access to the [Home] > [Nagios statistics] menu::: +Then, you would like to grant access to the [Home] > [Poller statistics] menu::: - [root@centreon ~]# ./centreon -u admin -p centreon -o ACLMENU -a grant -v "ACL Menu test;Home;Nagios statistics" + [root@centreon ~]# ./centreon -u admin -p centreon -o ACLMENU -a grant -v "ACL Menu test;Home;Poller statistics" Then, you decide to revoke access from [Monitoring] > [Event Logs]::: diff --git a/doc/fr/api/clapi/objects/acl_resource.rst b/doc/fr/api/clapi/objects/acl_resource.rst index 439b15cd196..c80ac75d4f2 100644 --- a/doc/fr/api/clapi/objects/acl_resource.rst +++ b/doc/fr/api/clapi/objects/acl_resource.rst @@ -140,6 +140,7 @@ revoke_host Put host name(s) [...] -a revoke_host -v "ACL revoke_hostgroup Put hostgroup name(s) [...] -a revoke_hostgroup -v "ACL Resource Test;Linux servers" Yes revoke_servicegroup Put servicegroup name(s) [...] -a revoke_servicegroup -v "ACL Resource Test;Ping" Yes revoke_metaservice Put metaservice name(s) [...] -a revoke_metaservice -v "ACL Resource Test;Traffic Average" Yes +delhostexclusion Put hostgroup name(s) [...] -a delhostexclusion -v "ACL Resource Test;srv-test|srv-test2" Yes addfilter_instance Put instance name(s) [...] -a addfilter_instance -v "ACL Resource Test;Monitoring-2" No addfilter_hostcategory Put host category name(s) [...] -a addfilter_hostcategory -v "ACL Resource Test;Customer-1" No addfilter_servicecategory Put service category name(s) [...] -a addfilter_servicecategory -v "ACL Resource Test;System" No diff --git a/doc/fr/api/clapi/objects/broker_cfg.rst b/doc/fr/api/clapi/objects/broker_cfg.rst index 6cebd581230..a18167d7a5f 100644 --- a/doc/fr/api/clapi/objects/broker_cfg.rst +++ b/doc/fr/api/clapi/objects/broker_cfg.rst @@ -96,21 +96,17 @@ cache_directory Path for cache files daemon Link this configuration to cbd service (0 or 1) -stats_activate Enable statistics (0 or 1) - correlation_activate Enable correlation (0 or 1) ======================== ================================================== -Listinput, Listoutput, Listlogger, Listcorrelation and Liststats +Listinput, Listoutput and Listlogger ---------------------------------------------------------------------------------- If you want to list specific input output types of Centreon Broker, use one of the following commands: listinput listoutput listlogger -listcorrelation -liststats Example:: @@ -129,14 +125,13 @@ ID I/O ID Name I/O Name ======= ============ -Getinput, Getoutput, Getlogger, Getcorrelation and Getstats +Getinput, Getoutput and Getlogger ----------------------------------------------------------- In order to get parameters of a specific I/O object, use one of the following commands: - getinput - getoutput - getlogger - - getcorrelation Example:: @@ -166,15 +161,13 @@ Order Description ======== =========================== -Addinput, Addoutput, Addlogger, Addcorrelation and Addstats +Addinput, Addoutput and Addlogger ----------------------------------------------------------- In order to add a new I/O object, use one of the following commands: - **ADDINPUT** - **ADDOUTPUT** - **ADDLOGGER** - - **ADDCORRELATION** - - **ADDSTATS** Example:: @@ -197,16 +190,13 @@ Order Column description ======== ============================ -Delinput, Deloutput, Dellogger, Delcorrelation and Delstats +Delinput, Deloutput and Dellogger ----------------------------------------------------------- In order to remove an I/O object from the Centreon Broker configuration, use one of the following commands: - **DELINPUT** - **DELOUTPUT** - **DELLOGGER** - - **DELCORRELATION** - - **DELTEMPORARY** - - **DELSTATS** Example:: @@ -215,19 +205,17 @@ Example:: The I/O ID is used for identifying the object to delete. -Setintput, Setoutput, Setlogger, Setcorrelation and Setstats +Setintput, Setoutput and Setlogger ------------------------------------------------------------ In order to set parameters of an I/O object, use one of the following commands: - **SETINPUT** - **SETOUTPUT** - **SETLOGGER** - - **SETCORRELATION** - - **SETSTATS** Example:: - [root@centreon ~]# ./centreon -u admin -p centreon -o CENTBROKERCFG -a setcorrelation -v "broker cfg for poller test;1;file;/etc/centreon-broker/correlation.xml" + [root@centreon ~]# ./centreon -u admin -p centreon -o CENTBROKERCFG -a setlogger -v "broker cfg for poller test;1;debug;no" Arguments are composed of the following columns: @@ -252,14 +240,19 @@ Example:: [root@localhost core]# ./centreon -u admin -p centreon -o CENTBROKERCFG -a gettypelist -v "output" type id;short name;name + 27;bam_bi;BI engine (BAM) 16;sql;Broker SQL Database + 32;correlation;correlation + 28;db_cfg_reader;Database configuration reader + 29;db_cfg_writer;Database configuration writer 11;file;File 3;ipv4;IPv4 10;ipv6;IPv6 - 15;local_client;Local Client Socket - 12;local_server;Local Server Socket + 26;bam;Monitoring engine (BAM) 14;storage;Perfdata Generator (Centreon Storage) 13;rrd;RRD File Generator + 30;graphite;Storage - Graphite + 31;influxdb;Storage - InfluxDB [root@localhost core]# ./centreon -u admin -p centreon -o CENTBROKERCFG -a getfieldlist -v "ipv4" field id;short name;name @@ -286,24 +279,6 @@ This is how you get the list of possible values of a given field:: The following chapters describes the parameters of each Object type -correlation -~~~~~~~~~~~ - -correlation: - -============================== ============================================================ ============================================================ =========================================================== -ID Label Description Possible values -============================== ============================================================ ============================================================ =========================================================== -file Correlation file Path to the correlation file which holds host, services, - dependencies and parenting definitions. - - -retention Retention file File where correlation state will be stored during - correlation engine restart - - -============================== ============================================================ ============================================================ =========================================================== - - - input ~~~~~ @@ -418,57 +393,6 @@ protocol Serialization protocol ============================== ============================================================ ============================================================ =========================================================== -local_server: - -============================== ============================================================ ============================================================ =========================================================== -ID Label Description Possible values -============================== ============================================================ ============================================================ =========================================================== -buffering_timeout Buffering timeout Time in seconds to wait before launching failover. - - -compression Compression (zlib) Enable or not data stream compression. - - -compression_buffer Compression buffer size The higher the buffer size is, the best compression. - This however increase data streaming latency. - Use with caution. - - -compression_level Compression level Ranges from 0 (no compression) to 9 (best compression). - Default is -1 (zlib compression) - - -retry_interval Retry interval Time in seconds to wait between each connection attempt. - - -path File path Path to the file. - - -protocol Serialization protocol Serialization protocol. ndo - -============================== ============================================================ ============================================================ =========================================================== - - -local_client: - -============================== ============================================================ ============================================================ =========================================================== -ID Label Description Possible values -============================== ============================================================ ============================================================ =========================================================== -buffering_timeout Buffering timeout Time in seconds to wait before launching failover. - - -compression Compression (zlib) Enable or not data stream compression. - - -compression_buffer Compression buffer size The higher the buffer size is, the best compression. - This however increase data streaming latency. - Use with caution. - - -compression_level Compression level Ranges from 0 (no compression) to 9 (best compression). - Default is -1 (zlib compression) - - -retry_interval Retry interval Time in seconds to wait between each connection attempt. - - -path File path Path to the file. - - -protocol Serialization protocol Serialization protocol. ndo - -============================== ============================================================ ============================================================ =========================================================== - - - logger ~~~~~~ @@ -667,34 +591,9 @@ failover Failover name retry_interval Retry interval Time in seconds to wait between each connection attempt. - -max_size Maximum size of file Maximum size in bytes. - - -path File path Path to the file. - - -protocol Serialization protocol Serialization protocol. ndo - -============================== ============================================================ ============================================================ =========================================================== - - -local_server: +category Filter category Category filter for flux in output. - -============================== ============================================================ ============================================================ =========================================================== -ID Label Description Possible values -============================== ============================================================ ============================================================ =========================================================== -buffering_timeout Buffering timeout Time in seconds to wait before launching failover. - - -compression Compression (zlib) Enable or not data stream compression. - - -compression_buffer Compression buffer size The higher the buffer size is, the best compression. - This however increase data streaming latency. - Use with caution. - - -compression_level Compression level Ranges from 0 (no compression) to 9 (best compression). - Default is -1 (zlib compression) - - -failover Failover name Name of the output which will act as failover - - -retry_interval Retry interval Time in seconds to wait between each connection attempt. - +max_size Maximum size of file Maximum size in bytes. - path File path Path to the file. - @@ -714,6 +613,8 @@ failover Failover name retry_interval Retry interval Time in seconds to wait between each connection attempt. - +category Filter category Category filter for flux in output. - + metrics_path RRD file directory for metrics RRD file directory, for example /var/lib/centreon/metrics - path Unix socket The Unix socket used to communicate with rrdcached. @@ -726,6 +627,12 @@ port TCP port status_path RRD file directory for statuses RRD file directory, for example /var/lib/centreon/status - +write_metrics Enable write_metrics Enable or not write_metrics. - + +write_status Enable write_status Enable or not write_status. - + +store_in_data_bin Enable store_in_data_bin Enable or not store in performance data in data_bin. - + ============================== ============================================================ ============================================================ =========================================================== @@ -740,6 +647,8 @@ failover Failover name retry_interval Retry interval Time in seconds to wait between each connection attempt. - +category Filter category Category filter for flux in output. - + check_replication Replication enabled When enabled, the broker engine will check whether or not the replication is up to date before attempting to update data. - @@ -767,32 +676,7 @@ read_timeout Transaction commit timeout rebuild_check_interval Rebuild check interval in seconds The interval between check if some metrics must be rebuild. The default value is 300s - -============================== ============================================================ ============================================================ =========================================================== - - -local_client: - -============================== ============================================================ ============================================================ =========================================================== -ID Label Description Possible values -============================== ============================================================ ============================================================ =========================================================== -buffering_timeout Buffering timeout Time in seconds to wait before launching failover. - - -compression Compression (zlib) Enable or not data stream compression. - - -compression_buffer Compression buffer size The higher the buffer size is, the best compression. - This however increase data streaming latency. - Use with caution. - - -compression_level Compression level Ranges from 0 (no compression) to 9 (best compression). - Default is -1 (zlib compression) - - -failover Failover name Name of the output which will act as failover - - -retry_interval Retry interval Time in seconds to wait between each connection attempt. - - -path File path Path to the file. - - -protocol Serialization protocol Serialization protocol. ndo +store_in_data_bin Enable store_in_data_bin Enable or not store in performance data in data_bin. - ============================== ============================================================ ============================================================ =========================================================== @@ -808,6 +692,8 @@ failover Failover name retry_interval Retry interval Time in seconds to wait between each connection attempt. - +category Filter category Category filter for flux in output. - + check_replication Replication enabled When enabled, the broker engine will check whether or not the replication is up to date before attempting to update data. - @@ -830,17 +716,3 @@ read_timeout Transaction commit timeout ============================== ============================================================ ============================================================ =========================================================== - - -stats -~~~~~ - -stats: - -============================== ============================================================ ============================================================ =========================================================== -ID Label Description Possible values -============================== ============================================================ ============================================================ =========================================================== -fifo File for Centreon Broker statistics File where Centreon Broker statistics will be stored - - -============================== ============================================================ ============================================================ =========================================================== - diff --git a/doc/fr/api/clapi/objects/dependencies.rst b/doc/fr/api/clapi/objects/dependencies.rst index da79fb4335e..bc27b30aa3c 100644 --- a/doc/fr/api/clapi/objects/dependencies.rst +++ b/doc/fr/api/clapi/objects/dependencies.rst @@ -131,7 +131,7 @@ If you want to add a new parent or a new child in a dependency definition, use t Delparent and Delchild ---------------------- -If you want to add a new parent or a new child in a dependency definition, use the **DELPARENT** or **DELCHILD** action:: +In order to delete a parent or a child in a dependency definition, use the **DELPARENT** or **DELCHILD** action:: [root@centreon ~]# ./centreon -u admin -p centreon -o DEP -a DELPARENT \ -v "my dependency;my_parent_host" diff --git a/doc/fr/api/clapi/objects/hosts.rst b/doc/fr/api/clapi/objects/hosts.rst index f3426b49cc5..98fbfc91388 100644 --- a/doc/fr/api/clapi/objects/hosts.rst +++ b/doc/fr/api/clapi/objects/hosts.rst @@ -121,7 +121,7 @@ check_command_arguments Check command arguments check_interval Normal check interval -check_freshness Check freshness (in seconds) +check_freshness Enables check freshness check_period Check period @@ -141,7 +141,11 @@ first_notification_delay First notification delay (in seconds) flap_detection_enabled Whether or not flap detection is enabled -flap_detection_options Flap detection options +flap_detection_options Flap detection options: 'o' for Up, 'd' for Down, 'u' for Unreachable + +host_high_flap_threshold High flap threshold + +host_low_flap_threshold Low flap threshold icon_image Icon image @@ -183,11 +187,11 @@ snmp_version Snmp version stalking_options Comma separated options: 'o' for OK, 'd' for Down, 'u' for Unreachable -statusmap_image Status map image (used by statusmap +statusmap_image Status map image (used by statusmap) host_notification_options Notification options (d,u,r,f,s) -timezone Timezone +timezone Timezone ==================================== ================================================================================= diff --git a/doc/fr/api/clapi/objects/service_templates.rst b/doc/fr/api/clapi/objects/service_templates.rst index 6e1325463fe..a79dcd65654 100644 --- a/doc/fr/api/clapi/objects/service_templates.rst +++ b/doc/fr/api/clapi/objects/service_templates.rst @@ -174,10 +174,6 @@ event_handler Name of the event handler command event_handler_arguments Arguments that go along with the event handler, prepend each argument with the "!" character -first_notification_delay First notification delay in seconds - -flap_detection_options Flap detection options - notes Notes notes_url Notes URL diff --git a/doc/fr/api/clapi/objects/services.rst b/doc/fr/api/clapi/objects/services.rst index 9e23218dc46..37284bcbe4f 100644 --- a/doc/fr/api/clapi/objects/services.rst +++ b/doc/fr/api/clapi/objects/services.rst @@ -192,8 +192,6 @@ event_handler Name of the event handler command event_handler_arguments Arguments that go along with the event handler, prepend each argument with the '!' character -flap_detection_options Flap detection options - notes Notes notes_url Notes URL From da6d0528e80638d03f7c58047c3f5a6132fc5cc9 Mon Sep 17 00:00:00 2001 From: loiclau Date: Tue, 11 Jul 2017 18:20:09 +0200 Subject: [PATCH 004/207] * fix style escalation --- .../configObject/escalation/DB-Func.php | 58 ++-- .../configObject/escalation/help.php | 80 ++++- .../configObject/escalation/img_gantt.php | 288 +++++++++--------- 3 files changed, 241 insertions(+), 185 deletions(-) diff --git a/www/include/configuration/configObject/escalation/DB-Func.php b/www/include/configuration/configObject/escalation/DB-Func.php index bd6554e9fd6..9e7de3d485a 100644 --- a/www/include/configuration/configObject/escalation/DB-Func.php +++ b/www/include/configuration/configObject/escalation/DB-Func.php @@ -48,12 +48,12 @@ function testExistence($name = null) if (isset($form)) { $id = $form->getSubmitValue('esc_id'); } - $DBRESULT = $pearDB->query("SELECT esc_name, esc_id FROM escalation WHERE esc_name = '".$name."'"); + $DBRESULT = $pearDB->query("SELECT esc_name, esc_id FROM escalation WHERE esc_name = '" . $name . "'"); $esc = $DBRESULT->fetchRow(); #Modif case if ($DBRESULT->rowCount() >= 1 && $esc["esc_id"] == $id) { return true; - #Duplicate entry + #Duplicate entry } elseif ($DBRESULT->rowCount() >= 1 && $esc["esc_id"] != $id) { return false; } else { @@ -66,10 +66,10 @@ function deleteEscalationInDB($escalations = array()) global $pearDB, $centreon; foreach ($escalations as $key => $value) { - $DBRESULT2 = $pearDB->query("SELECT esc_name FROM `escalation` WHERE `esc_id` = '".$key."' LIMIT 1"); + $DBRESULT2 = $pearDB->query("SELECT esc_name FROM `escalation` WHERE `esc_id` = '" . $key . "' LIMIT 1"); $row = $DBRESULT2->fetchRow(); - $DBRESULT = $pearDB->query("DELETE FROM escalation WHERE esc_id = '".$key."'"); + $DBRESULT = $pearDB->query("DELETE FROM escalation WHERE esc_id = '" . $key . "'"); $centreon->CentreonLogAction->insertLog("escalation", $key, $row['esc_name'], "d"); } } @@ -78,7 +78,7 @@ function multipleEscalationInDB($escalations = array(), $nbrDup = array()) { foreach ($escalations as $key => $value) { global $pearDB, $centreon; - $DBRESULT = $pearDB->query("SELECT * FROM escalation WHERE esc_id = '".$key."' LIMIT 1"); + $DBRESULT = $pearDB->query("SELECT * FROM escalation WHERE esc_id = '" . $key . "' LIMIT 1"); $row = $DBRESULT->fetchRow(); $row["esc_id"] = ''; for ($i = 1; $i <= $nbrDup[$key]; $i++) { @@ -95,7 +95,7 @@ function multipleEscalationInDB($escalations = array(), $nbrDup = array()) } } if (isset($esc_name) && testExistence($esc_name)) { - $val ? $rq = "INSERT INTO escalation VALUES (".$val.")" : $rq = null; + $val ? $rq = "INSERT INTO escalation VALUES (" . $val . ")" : $rq = null; $DBRESULT = $pearDB->query($rq); $DBRESULT = $pearDB->query("SELECT MAX(esc_id) FROM escalation"); $maxId = $DBRESULT->fetchRow(); @@ -109,8 +109,8 @@ function multipleEscalationInDB($escalations = array(), $nbrDup = array()) while ($cg = $DBRESULT->fetchRow()) { $DBRESULT2 = $pearDB->query( "INSERT INTO escalation_contactgroup_relation " - . "VALUES ('', '" . $maxId["MAX(esc_id)"]."', '" - . $cg["contactgroup_cg_id"]."')" + . "VALUES ('', '" . $maxId["MAX(esc_id)"] . "', '" + . $cg["contactgroup_cg_id"] . "')" ); $fields["esc_cgs"] .= $cg["contactgroup_cg_id"] . ","; } @@ -118,14 +118,14 @@ function multipleEscalationInDB($escalations = array(), $nbrDup = array()) $DBRESULT = $pearDB->query( "SELECT DISTINCT host_host_id " . "FROM escalation_host_relation " - . "WHERE escalation_esc_id = '".$key."'" + . "WHERE escalation_esc_id = '" . $key . "'" ); $fields["esc_hosts"] = ""; while ($host = $DBRESULT->fetchRow()) { $DBRESULT2 = $pearDB->query( "INSERT INTO escalation_host_relation " - . "VALUES ('', '" . $maxId["MAX(esc_id)"]."', '" - . $host["host_host_id"]."')" + . "VALUES ('', '" . $maxId["MAX(esc_id)"] . "', '" + . $host["host_host_id"] . "')" ); $fields["esc_hosts"] .= $host["host_host_id"] . ","; } @@ -133,14 +133,14 @@ function multipleEscalationInDB($escalations = array(), $nbrDup = array()) $DBRESULT = $pearDB->query( "SELECT DISTINCT hostgroup_hg_id " . "FROM escalation_hostgroup_relation " - . "WHERE escalation_esc_id = '".$key."'" + . "WHERE escalation_esc_id = '" . $key . "'" ); $fields["esc_hgs"] = ""; while ($hg = $DBRESULT->fetchRow()) { $DBRESULT2 = $pearDB->query( "INSERT INTO escalation_hostgroup_relation " - . "VALUES ('', '" . $maxId["MAX(esc_id)"]."', '" - . $hg["hostgroup_hg_id"]."')" + . "VALUES ('', '" . $maxId["MAX(esc_id)"] . "', '" + . $hg["hostgroup_hg_id"] . "')" ); $fields["esc_hgs"] .= $hg["hostgroup_hg_id"] . ","; } @@ -170,7 +170,7 @@ function multipleEscalationInDB($escalations = array(), $nbrDup = array()) "INSERT INTO escalation_service_relation " . "VALUES ('', '" . $maxId["MAX(esc_id)"] . "', '" . $sv["service_service_id"] . "', '" - . $sv["host_host_id"]."')" + . $sv["host_host_id"] . "')" ); $fields["esc_hServices"] .= $sv["service_service_id"] . ","; } @@ -187,7 +187,7 @@ function multipleEscalationInDB($escalations = array(), $nbrDup = array()) . "VALUES ('', '" . $maxId["MAX(esc_id)"] . "', '" . $sv["meta_service_meta_id"] . "')" ); - $fields["esc_metas"] .= $sv["meta_service_meta_id"] . ","; + $fields["esc_metas"] .= $sv["meta_service_meta_id"] . ","; } $fields["esc_metas"] = trim($fields["esc_metas"], ","); $centreon->CentreonLogAction->insertLog( @@ -377,7 +377,7 @@ function updateEscalation($esc_id = null) isset($ret["esc_comment"]) && $ret["esc_comment"] != null ? $rq .= "'" . htmlentities($ret["esc_comment"], ENT_QUOTES, "UTF-8") . "' " : $rq .= "NULL "; - $rq .= "WHERE esc_id = '".$esc_id."'"; + $rq .= "WHERE esc_id = '" . $esc_id . "'"; $DBRESULT = $pearDB->query($rq); $fields["esc_name"] = htmlentities($ret["esc_name"], ENT_QUOTES, "UTF-8"); $fields["esc_alias"] = htmlentities($ret["esc_alias"], ENT_QUOTES, "UTF-8"); @@ -433,7 +433,7 @@ function updateEscalationContactGroups($esc_id = null) global $form; global $pearDB; $rq = "DELETE FROM escalation_contactgroup_relation "; - $rq .= "WHERE escalation_esc_id = '".$esc_id."'"; + $rq .= "WHERE escalation_esc_id = '" . $esc_id . "'"; $DBRESULT = $pearDB->query($rq); $ret = array(); $ret = CentreonUtils::mergeWithInitialValues($form, 'esc_cgs'); @@ -450,7 +450,7 @@ function updateEscalationContactGroups($esc_id = null) $rq = "INSERT INTO escalation_contactgroup_relation "; $rq .= "(escalation_esc_id, contactgroup_cg_id) "; $rq .= "VALUES "; - $rq .= "('".$esc_id."', '".$ret[$i]."')"; + $rq .= "('" . $esc_id . "', '" . $ret[$i] . "')"; $DBRESULT = $pearDB->query($rq); } } @@ -463,7 +463,7 @@ function updateEscalationHosts($esc_id = null) global $form; global $pearDB; $rq = "DELETE FROM escalation_host_relation "; - $rq .= "WHERE escalation_esc_id = '".$esc_id."'"; + $rq .= "WHERE escalation_esc_id = '" . $esc_id . "'"; $DBRESULT = $pearDB->query($rq); $ret = array(); $ret = CentreonUtils::mergeWithInitialValues($form, 'esc_hosts'); @@ -471,7 +471,7 @@ function updateEscalationHosts($esc_id = null) $rq = "INSERT INTO escalation_host_relation "; $rq .= "(escalation_esc_id, host_host_id) "; $rq .= "VALUES "; - $rq .= "('".$esc_id."', '".$ret[$i]."')"; + $rq .= "('" . $esc_id . "', '" . $ret[$i] . "')"; $DBRESULT = $pearDB->query($rq); } } @@ -484,7 +484,7 @@ function updateEscalationHostGroups($esc_id = null) global $form; global $pearDB; $rq = "DELETE FROM escalation_hostgroup_relation "; - $rq .= "WHERE escalation_esc_id = '".$esc_id."'"; + $rq .= "WHERE escalation_esc_id = '" . $esc_id . "'"; $DBRESULT = $pearDB->query($rq); $ret = array(); $ret = CentreonUtils::mergeWithInitialValues($form, 'esc_hgs'); @@ -492,7 +492,7 @@ function updateEscalationHostGroups($esc_id = null) $rq = "INSERT INTO escalation_hostgroup_relation "; $rq .= "(escalation_esc_id, hostgroup_hg_id) "; $rq .= "VALUES "; - $rq .= "('".$esc_id."', '".$ret[$i]."')"; + $rq .= "('" . $esc_id . "', '" . $ret[$i] . "')"; $DBRESULT = $pearDB->query($rq); } } @@ -505,7 +505,7 @@ function updateEscalationServiceGroups($esc_id = null) global $form; global $pearDB; $rq = "DELETE FROM escalation_servicegroup_relation "; - $rq .= "WHERE escalation_esc_id = '".$esc_id."'"; + $rq .= "WHERE escalation_esc_id = '" . $esc_id . "'"; $DBRESULT = $pearDB->query($rq); $ret = array(); $ret = CentreonUtils::mergeWithInitialValues($form, 'esc_sgs'); @@ -513,7 +513,7 @@ function updateEscalationServiceGroups($esc_id = null) $rq = "INSERT INTO escalation_servicegroup_relation "; $rq .= "(escalation_esc_id, servicegroup_sg_id) "; $rq .= "VALUES "; - $rq .= "('".$esc_id."', '".$ret[$i]."')"; + $rq .= "('" . $esc_id . "', '" . $ret[$i] . "')"; $DBRESULT = $pearDB->query($rq); } } @@ -526,7 +526,7 @@ function updateEscalationServices($esc_id = null) global $form; global $pearDB; $rq = "DELETE FROM escalation_service_relation "; - $rq .= "WHERE escalation_esc_id = '".$esc_id."'"; + $rq .= "WHERE escalation_esc_id = '" . $esc_id . "'"; $DBRESULT = $pearDB->query($rq); $ret = array(); $ret = CentreonUtils::mergeWithInitialValues($form, 'esc_hServices'); @@ -536,7 +536,7 @@ function updateEscalationServices($esc_id = null) $rq = "INSERT INTO escalation_service_relation "; $rq .= "(escalation_esc_id, service_service_id, host_host_id) "; $rq .= "VALUES "; - $rq .= "('".$esc_id."', '".$exp[1]."', '".$exp[0]."')"; + $rq .= "('" . $esc_id . "', '" . $exp[1] . "', '" . $exp[0] . "')"; $DBRESULT = $pearDB->query($rq); } } @@ -550,7 +550,7 @@ function updateEscalationMetaServices($esc_id = null) global $form; global $pearDB; $rq = "DELETE FROM escalation_meta_service_relation "; - $rq .= "WHERE escalation_esc_id = '".$esc_id."'"; + $rq .= "WHERE escalation_esc_id = '" . $esc_id . "'"; $DBRESULT = $pearDB->query($rq); $ret = array(); $ret = CentreonUtils::mergeWithInitialValues($form, 'esc_metas'); @@ -558,7 +558,7 @@ function updateEscalationMetaServices($esc_id = null) $rq = "INSERT INTO escalation_meta_service_relation "; $rq .= "(escalation_esc_id, meta_service_meta_id) "; $rq .= "VALUES "; - $rq .= "('".$esc_id."', '".$ret[$i]."')"; + $rq .= "('" . $esc_id . "', '" . $ret[$i] . "')"; $DBRESULT = $pearDB->query($rq); } } diff --git a/www/include/configuration/configObject/escalation/help.php b/www/include/configuration/configObject/escalation/help.php index 08085517b23..aae4cab0952 100644 --- a/www/include/configuration/configObject/escalation/help.php +++ b/www/include/configuration/configObject/escalation/help.php @@ -3,21 +3,77 @@ $help["name"] = dgettext("help", "Enter a short name for the escalation to identify it."); $help["alias"] = dgettext("help", "The alias is used to define a longer name or description for the escalation."); -$help["first_notification"] = dgettext("help", "Enter a number that identifies the first notification for which this escalation is effective. For instance, if you set this value to 3, this escalation will only be used if the host is down or unreachable long enough for a third notification to go out."); -$help["last_notification"] = dgettext("help", "Enter a number that identifies the last notification for which this escalation is effective. For instance, if you set this value to 5, this escalation will not be used if more than five notifications are sent out for the host. Setting this value to 0 means to keep using this escalation entry forever (no matter how many notifications go out)."); -$help["notification_interval"] = dgettext("help", "Select the interval at which notifications should be made while this escalation is valid. If you specify a value of 0 for the interval, Monitoring Engine will send the first notification when this escalation definition is valid, but will then prevent any more problem notifications from being sent out. Notifications are sent out again until the host or service recovers. This is useful if you want to stop having notifications sent out after a certain amount of time. Note: If multiple escalation entries overlap for one or more notification ranges, the smallest notification interval from all escalation entries is used."); -$help["escalation_period"] = dgettext("help", "Select the time period during which this escalation is valid. If no time period is specified, the escalation is considered to be valid during all times."); -$help["host_escalation_options"] = dgettext("help", "Define the criteria that determine when the host escalation is used. The escalation is used only if the host is in one of the states specified in these options. If no options are specified in a host escalation, the escalation is considered to be valid during all host states."); -$help["service_escalation_options"] = dgettext("help", "Define the criteria that determine when the service escalation is used. The escalation is used only if the service is in one of the states specified in these options. If no options are specified in a service escalation, the escalation is considered to be valid during all service states."); -$help["contact_groups"] = dgettext("help", "Select the contact group(s) that should be notified when the notification is escalated. You must specify at least one contact group in each escalation definition."); +$help["first_notification"] = dgettext( + "help", + "Enter a number that identifies the first notification for which this escalation is effective. " . + "For instance, if you set this value to 3, this escalation will only be used if the host is down or " . + "unreachable long enough for a third notification to go out." +); +$help["last_notification"] = dgettext( + "help", + "Enter a number that identifies the last notification for which this escalation is effective. " . + "For instance, if you set this value to 5, this escalation will not be used if more than five notifications are " . + "sent out for the host. Setting this value to 0 means to keep using this escalation entry forever " . + "(no matter how many notifications go out)." +); +$help["notification_interval"] = dgettext( + "help", + "Select the interval at which notifications should be made while this escalation is valid. If you specify " . + "a value of 0 for the interval, Monitoring Engine will send the first notification when this escalation " . + "definition is valid, but will then prevent any more problem notifications from being sent out. " . + "Notifications are sent out again until the host or service recovers. This is useful if you want to stop " . + "having notifications sent out after a certain amount of time. Note: If multiple escalation entries overlap " . + "for one or more notification ranges, the smallest notification interval from all escalation entries is used." +); +$help["escalation_period"] = dgettext( + "help", + "Select the time period during which this escalation is valid. If no time period is specified, " . + "the escalation is considered to be valid during all times." +); +$help["host_escalation_options"] = dgettext( + "help", + "Define the criteria that determine when the host escalation is used. The escalation is used only if the " . + "host is in one of the states specified in these options. If no options are specified in a host escalation, " . + "the escalation is considered to be valid during all host states." +); +$help["service_escalation_options"] = dgettext( + "help", + "Define the criteria that determine when the service escalation is used. The escalation is used only if " . + "the service is in one of the states specified in these options. If no options are specified in a service " . + "escalation, the escalation is considered to be valid during all service states." +); +$help["contact_groups"] = dgettext( + "help", + "Select the contact group(s) that should be notified when the notification is escalated. " . + "You must specify at least one contact group in each escalation definition." +); $help["host_name"] = dgettext("help", "Select the host(s) that the escalation should apply to or is associated with."); -$help["service_description"] = dgettext("help", "Select the service(s) the escalation should apply to or is associated with."); -$help["hostgroup_name"] = dgettext("help", "Select the hostgroup(s) that the escalation should apply to. The escalation will apply to all hosts that are members of the specified hostgroup(s)."); -$help["servicegroup_name"] = dgettext("help", "Select the service group(s) the escalation should apply to or is associated with. The escalation will apply to all services that are members of the specified service group(s)."); -$help["metaservice_name"] = dgettext("help", "Select the meta service(s) the escalation should apply to or is associated with."); +$help["service_description"] = dgettext( + "help", + "Select the service(s) the escalation should apply to or is associated with." +); +$help["hostgroup_name"] = dgettext( + "help", + "Select the hostgroup(s) that the escalation should apply to. The escalation will apply to all hosts that " . + "are members of the specified hostgroup(s)." +); +$help["servicegroup_name"] = dgettext( + "help", + "Select the service group(s) the escalation should apply to or is associated with. The escalation will apply " . + "to all services that are members of the specified service group(s)." +); +$help["metaservice_name"] = dgettext( + "help", + "Select the meta service(s) the escalation should apply to or is associated with." +); /* * unsupported in centreon */ -$help["contacts"] = dgettext("help", "Select contacts that should be notified whenever there are problems (or recoveries) with this host. Useful if you want notifications to go to just a few people and don't want to configure contact groups. You must specify at least one contact or contact group in each host escalation definition."); +$help["contacts"] = dgettext( + "help", + "Select contacts that should be notified whenever there are problems (or recoveries) with this host. " . + "Useful if you want notifications to go to just a few people and don't want to configure contact groups. " . + "You must specify at least one contact or contact group in each host escalation definition." +); diff --git a/www/include/configuration/configObject/escalation/img_gantt.php b/www/include/configuration/configObject/escalation/img_gantt.php index f525e30b2d9..f866b3b96a0 100644 --- a/www/include/configuration/configObject/escalation/img_gantt.php +++ b/www/include/configuration/configObject/escalation/img_gantt.php @@ -38,23 +38,23 @@ # connect DB oreon - require_once("../../../../class/centreonSession.class.php"); - require_once("../../../../class/centreon.class.php"); - require_once("../../../../class/centreonDB.class.php"); +require_once("../../../../class/centreonSession.class.php"); +require_once("../../../../class/centreon.class.php"); +require_once("../../../../class/centreonDB.class.php"); - CentreonSession::start(); - $oreon = $_SESSION["oreon"]; +CentreonSession::start(); +$oreon = $_SESSION["oreon"]; - /* Connect to Centreon DB */ +/* Connect to Centreon DB */ - include("../../../../centreon.conf.php"); - is_file("../../../../lang/".$oreon->user->get_lang().".php") - ? include_once("../../../../lang/".$oreon->user->get_lang().".php") - : include_once("../../../../lang/en.php"); +include("../../../../centreon.conf.php"); +is_file("../../../../lang/" . $oreon->user->get_lang() . ".php") + ? include_once("../../../../lang/" . $oreon->user->get_lang() . ".php") + : include_once("../../../../lang/en.php"); - require_once "../../../common/common-Func.php"; +require_once "../../../common/common-Func.php"; - $pearDB = new CentreonDB(); +$pearDB = new CentreonDB(); # get info from database @@ -66,7 +66,7 @@ . "min(esc.first_notification) nb_firstmin_service, " . "max(esc.first_notification) nb_firstmax_service " . "FROM escalation_service_relation ehr, escalation esc " - . "WHERE ehr.service_service_id = ".$_GET["service_id"]." " + . "WHERE ehr.service_service_id = " . $_GET["service_id"] . " " . "AND ehr.escalation_esc_id = esc.esc_id " . "ORDER BY esc.first_notification"; $res_max = $pearDB->query($max_notif); @@ -87,11 +87,11 @@ $res_max->closeCursor(); # retrieve all escalation correspond to service - $cmd = "SELECT esc.esc_id, esc.esc_name, esc.first_notification, ". - "esc.last_notification, esc.notification_interval, esc.esc_comment ". - "FROM escalation_service_relation ehr, escalation esc ". - "WHERE ehr.service_service_id = ".$_GET["service_id"]." ". - "AND ehr.escalation_esc_id = esc.esc_id ". + $cmd = "SELECT esc.esc_id, esc.esc_name, esc.first_notification, " . + "esc.last_notification, esc.notification_interval, esc.esc_comment " . + "FROM escalation_service_relation ehr, escalation esc " . + "WHERE ehr.service_service_id = " . $_GET["service_id"] . " " . + "AND ehr.escalation_esc_id = esc.esc_id " . "ORDER BY esc.first_notification desc "; $res_esc_svc = $pearDB->query($cmd); $nb_esc = $res_esc_svc->rowCount(); @@ -99,45 +99,45 @@ $nb_esc != null ? $nb_esc = $nb_esc : $nb_esc = 1; # calc all row for service escalation (service escalation + contactgroup escalation) - $cmd = "SELECT cg.cg_name, esc.esc_id, esc.esc_name, ". - "esc.first_notification, esc.last_notification, ". - "esc.notification_interval, esc.esc_comment ". - "FROM escalation_service_relation ehr, escalation esc, ". - "contactgroup cg, escalation_contactgroup_relation ecr ". - "WHERE ehr.service_service_id = ".$_GET["service_id"]." ". - "AND ehr.escalation_esc_id = esc.esc_id ". - "AND ecr.escalation_esc_id = esc.esc_id ". - "AND ecr.contactgroup_cg_id = cg.cg_id ". + $cmd = "SELECT cg.cg_name, esc.esc_id, esc.esc_name, " . + "esc.first_notification, esc.last_notification, " . + "esc.notification_interval, esc.esc_comment " . + "FROM escalation_service_relation ehr, escalation esc, " . + "contactgroup cg, escalation_contactgroup_relation ecr " . + "WHERE ehr.service_service_id = " . $_GET["service_id"] . " " . + "AND ehr.escalation_esc_id = esc.esc_id " . + "AND ecr.escalation_esc_id = esc.esc_id " . + "AND ecr.contactgroup_cg_id = cg.cg_id " . "ORDER BY esc.first_notification desc "; $nb_svc = $pearDB->query($cmd); $nb_esc_tot = $nb_svc->rowCount(); $nb_esc_tot != null ? $nb_esc_tot = $nb_esc_tot : $nb_esc_tot = 1; # retrieve all contactgroup correspond to service - $cg_host = "SELECT cg.cg_name ". - "FROM contactgroup cg, contactgroup_service_relation csr ". - "WHERE csr.service_service_id = ".$_GET["service_id"]." ". - "AND csr.contactgroup_cg_id = cg.cg_id"; + $cg_host = "SELECT cg.cg_name " . + "FROM contactgroup cg, contactgroup_service_relation csr " . + "WHERE csr.service_service_id = " . $_GET["service_id"] . " " . + "AND csr.contactgroup_cg_id = cg.cg_id"; $res_cg_service = $pearDB->query($cg_host); $max_contact_service = $res_cg_service->rowCount(); # retrieve max length contactgroup of service - $cg_svc_length = "SELECT max(length(cg.cg_name)) max_length ". - "FROM contactgroup cg, contactgroup_service_relation csr ". - "WHERE csr.service_service_id = ".$_GET["service_id"]." ". - "AND csr.contactgroup_cg_id = cg.cg_id"; + $cg_svc_length = "SELECT max(length(cg.cg_name)) max_length " . + "FROM contactgroup cg, contactgroup_service_relation csr " . + "WHERE csr.service_service_id = " . $_GET["service_id"] . " " . + "AND csr.contactgroup_cg_id = cg.cg_id"; $res_svc_max = $pearDB->query($cg_svc_length); $cg_contactgroup_svc_max = $res_svc_max->fetchRow(); $max_contact_length = $cg_contactgroup_svc_max["max_length"]; } elseif (isset($_GET["host_id"]) && $_GET["host_id"] != null) { # get number of max last_notification host - $max_notif = "SELECT max(esc.last_notification) nb_max_host, ". - "min(esc.last_notification) nb_min_lasthost, ". - "min(esc.first_notification) nb_firstmin_host ,". - "max(esc.first_notification) nb_firstmax_host ". - "FROM escalation_host_relation ehr, escalation esc ". - "WHERE ehr.host_host_id = ".$_GET["host_id"]." ". - "AND ehr.escalation_esc_id = esc.esc_id ". + $max_notif = "SELECT max(esc.last_notification) nb_max_host, " . + "min(esc.last_notification) nb_min_lasthost, " . + "min(esc.first_notification) nb_firstmin_host ," . + "max(esc.first_notification) nb_firstmax_host " . + "FROM escalation_host_relation ehr, escalation esc " . + "WHERE ehr.host_host_id = " . $_GET["host_id"] . " " . + "AND ehr.escalation_esc_id = esc.esc_id " . "ORDER BY esc.first_notification"; $res_max = $pearDB->query($max_notif); $nb_max = $res_max->fetchRow(); @@ -157,11 +157,11 @@ $res_max->closeCursor(); # retrieve all escalation correspond to host - $cmd = "SELECT esc.esc_id, esc.esc_name, esc.first_notification, ". - "esc.last_notification, esc.notification_interval, esc.esc_comment ". - "FROM escalation_host_relation ehr, escalation esc ". - "WHERE ehr.host_host_id = ".$_GET["host_id"]." ". - "AND ehr.escalation_esc_id = esc.esc_id ". + $cmd = "SELECT esc.esc_id, esc.esc_name, esc.first_notification, " . + "esc.last_notification, esc.notification_interval, esc.esc_comment " . + "FROM escalation_host_relation ehr, escalation esc " . + "WHERE ehr.host_host_id = " . $_GET["host_id"] . " " . + "AND ehr.escalation_esc_id = esc.esc_id " . "ORDER BY esc.first_notification desc "; $res_esc_host = $pearDB->query($cmd); $nb_esc = $res_esc_host->rowCount(); @@ -169,45 +169,45 @@ $nb_esc != null ? $nb_esc = $nb_esc : $nb_esc = 1; # calc all row for host escalation (host escalation + contactgroup escalation) - $cmd = "SELECT cg.cg_name, esc.esc_id, esc.esc_name, ". - "esc.first_notification, esc.last_notification, ". - "esc.notification_interval, esc.esc_comment ". - "FROM escalation_host_relation ehr, escalation esc, ". - "contactgroup cg, escalation_contactgroup_relation ecr ". - "WHERE ehr.host_host_id = ".$_GET["host_id"]." ". - "AND ehr.escalation_esc_id = esc.esc_id ". - "AND ecr.escalation_esc_id = esc.esc_id ". - "AND ecr.contactgroup_cg_id = cg.cg_id ". + $cmd = "SELECT cg.cg_name, esc.esc_id, esc.esc_name, " . + "esc.first_notification, esc.last_notification, " . + "esc.notification_interval, esc.esc_comment " . + "FROM escalation_host_relation ehr, escalation esc, " . + "contactgroup cg, escalation_contactgroup_relation ecr " . + "WHERE ehr.host_host_id = " . $_GET["host_id"] . " " . + "AND ehr.escalation_esc_id = esc.esc_id " . + "AND ecr.escalation_esc_id = esc.esc_id " . + "AND ecr.contactgroup_cg_id = cg.cg_id " . "ORDER BY esc.first_notification desc "; $nb_host = $pearDB->query($cmd); $nb_esc_tot = $nb_host->rowCount(); $nb_esc_tot != null ? $nb_esc_tot = $nb_esc_tot : $nb_esc_tot = 1; # retrieve all contactgroup correspond to host - $cg_host = "SELECT cg.cg_name ". - "FROM contactgroup cg, contactgroup_host_relation chr ". - "WHERE chr.host_host_id = ".$_GET["host_id"]." ". - "AND chr.contactgroup_cg_id = cg.cg_id"; + $cg_host = "SELECT cg.cg_name " . + "FROM contactgroup cg, contactgroup_host_relation chr " . + "WHERE chr.host_host_id = " . $_GET["host_id"] . " " . + "AND chr.contactgroup_cg_id = cg.cg_id"; $res_cg_host = $pearDB->query($cg_host); $max_contact_service = $res_cg_host->rowCount(); # retrieve the max length contactgroup - $cg_max_length = "SELECT max(length(cg.cg_name)) max_length ". - "FROM contactgroup cg, contactgroup_host_relation chr ". - "WHERE chr.host_host_id = ".$_GET["host_id"]." ". - "AND chr.contactgroup_cg_id = cg.cg_id"; + $cg_max_length = "SELECT max(length(cg.cg_name)) max_length " . + "FROM contactgroup cg, contactgroup_host_relation chr " . + "WHERE chr.host_host_id = " . $_GET["host_id"] . " " . + "AND chr.contactgroup_cg_id = cg.cg_id"; $res_length_contact = $pearDB->query($cg_max_length); $cg_contactgroup_host_max = $res_length_contact->fetchRow(); $max_contact_length = $cg_contactgroup_host_max["max_length"]; } elseif (isset($_GET["hostgroup_id"]) && $_GET["hostgroup_id"] != null) { # get number of max last_notification hostgroup - $max_notif = "SELECT max(esc.last_notification) nb_max_hostgroup, ". - "min(esc.last_notification) nb_min_lasthostgroup, ". - "min(esc.first_notification) nb_firstmin_hostgroup, ". - "max(esc.first_notification) nb_firstmax_hostgroup ". - "FROM escalation_hostgroup_relation ehr, escalation esc ". - "WHERE ehr.hostgroup_hg_id = ".$_GET["hostgroup_id"]." ". - "AND ehr.escalation_esc_id = esc.esc_id ". + $max_notif = "SELECT max(esc.last_notification) nb_max_hostgroup, " . + "min(esc.last_notification) nb_min_lasthostgroup, " . + "min(esc.first_notification) nb_firstmin_hostgroup, " . + "max(esc.first_notification) nb_firstmax_hostgroup " . + "FROM escalation_hostgroup_relation ehr, escalation esc " . + "WHERE ehr.hostgroup_hg_id = " . $_GET["hostgroup_id"] . " " . + "AND ehr.escalation_esc_id = esc.esc_id " . "ORDER BY esc.first_notification"; $res_max = $pearDB->query($max_notif); $nb_max = $res_max->fetchRow(); @@ -227,11 +227,11 @@ $res_max->closeCursor(); # retrieve all escalation correspond to hostgroup - $cmd = "SELECT esc.esc_id, esc.esc_name, esc.first_notification, ". - "esc.last_notification, esc.notification_interval, esc.esc_comment ". - "FROM escalation_hostgroup_relation ehr, escalation esc ". - "WHERE ehr.hostgroup_hg_id = ".$_GET["hostgroup_id"]." ". - "AND ehr.escalation_esc_id = esc.esc_id ". + $cmd = "SELECT esc.esc_id, esc.esc_name, esc.first_notification, " . + "esc.last_notification, esc.notification_interval, esc.esc_comment " . + "FROM escalation_hostgroup_relation ehr, escalation esc " . + "WHERE ehr.hostgroup_hg_id = " . $_GET["hostgroup_id"] . " " . + "AND ehr.escalation_esc_id = esc.esc_id " . "ORDER BY esc.first_notification desc "; $res_esc_hostgroup = $pearDB->query($cmd); $nb_esc = $res_esc_hostgroup->rowCount(); @@ -239,33 +239,33 @@ $nb_esc != null ? $nb_esc = $nb_esc : $nb_esc = 1; # calc all row for hostgroup escalation (hostgroup escalation + contactgroup escalation) - $cmd = "SELECT cg.cg_name, esc.esc_id, esc.esc_name, ". - "esc.first_notification, esc.last_notification, ". - "esc.notification_interval, esc.esc_comment ". - "FROM escalation_hostgroup_relation ehr, escalation esc, ". - "contactgroup cg, escalation_contactgroup_relation ecr ". - "WHERE ehr.hostgroup_hg_id = ".$_GET["hostgroup_id"]." ". - "AND ehr.escalation_esc_id = esc.esc_id ". - "AND ecr.escalation_esc_id = esc.esc_id ". - "AND ecr.contactgroup_cg_id = cg.cg_id ". + $cmd = "SELECT cg.cg_name, esc.esc_id, esc.esc_name, " . + "esc.first_notification, esc.last_notification, " . + "esc.notification_interval, esc.esc_comment " . + "FROM escalation_hostgroup_relation ehr, escalation esc, " . + "contactgroup cg, escalation_contactgroup_relation ecr " . + "WHERE ehr.hostgroup_hg_id = " . $_GET["hostgroup_id"] . " " . + "AND ehr.escalation_esc_id = esc.esc_id " . + "AND ecr.escalation_esc_id = esc.esc_id " . + "AND ecr.contactgroup_cg_id = cg.cg_id " . "ORDER BY esc.first_notification desc "; $nb_hostgroup = $pearDB->query($cmd); $nb_esc_tot = $nb_hostgroup->rowCount(); $nb_esc_tot != null ? $nb_esc_tot = $nb_esc_tot : $nb_esc_tot = 1; # retrieve all contactgroup correspond to hostgroup - $cg_host = "SELECT cg.cg_name ". - "FROM contactgroup cg, contactgroup_hostgroup_relation chr ". - "WHERE chr.hostgroup_hg_id = ".$_GET["hostgroup_id"]." ". - "AND chr.contactgroup_cg_id = cg.cg_id"; + $cg_host = "SELECT cg.cg_name " . + "FROM contactgroup cg, contactgroup_hostgroup_relation chr " . + "WHERE chr.hostgroup_hg_id = " . $_GET["hostgroup_id"] . " " . + "AND chr.contactgroup_cg_id = cg.cg_id"; $res_cg_hostgroup = $pearDB->query($cg_host); $max_contact_service = $res_cg_hostgroup->rowCount(); # retrieve max length contactgroup of hostgroup - $cg_svc_length = "SELECT max(length(cg.cg_name)) max_length ". - "FROM contactgroup cg, contactgroup_hostgroup_relation chr ". - "WHERE chr.hostgroup_hg_id = ".$_GET["hostgroup_id"]." ". - "AND chr.contactgroup_cg_id = cg.cg_id"; + $cg_svc_length = "SELECT max(length(cg.cg_name)) max_length " . + "FROM contactgroup cg, contactgroup_hostgroup_relation chr " . + "WHERE chr.hostgroup_hg_id = " . $_GET["hostgroup_id"] . " " . + "AND chr.contactgroup_cg_id = cg.cg_id"; $res_svc_max = $pearDB->query($cg_svc_length); $cg_contactgroup_svc_max = $res_svc_max->fetchRow(); $max_contact_length = $cg_contactgroup_svc_max["max_length"]; @@ -275,8 +275,8 @@ //$hauteur = ($nb_esc > 5) ? 768 : 400; $hauteur = ($nb_esc_tot * 35) + (($max_contact_service == 0 - ? $nb_esc - : $max_contact_service) * 35) + 70; + ? $nb_esc + : $max_contact_service) * 35) + 70; $marge_left = ($max_contact_length) ? $max_contact_length * 13 : 10 * 13; $marge_legende = 20; $marge_bottom = 50 + $marge_legende; @@ -363,8 +363,8 @@ function trace_bat($x1, $y1, $x2, $y2, $esc_name) #show contactgroup link with the service $pas_tmp_svc = ($max_contact_service * 20 > $pas_graduation_y - ? $pas_graduation_y / ($max_contact_service > 0 - ? $max_contact_service : 1) : 20); + ? $pas_graduation_y / ($max_contact_service > 0 + ? $max_contact_service : 1) : 20); for ($cnt = 0, $i = 0; $contactgroup_service = $res_cg_service->fetchRow(); $cnt++) { ($cnt == 0) ? $i += 15 : $i += $pas_tmp_svc; imagestring( @@ -412,23 +412,23 @@ function trace_bat($x1, $y1, $x2, $y2, $esc_name) $image, $largeur - 10, $hauteur - $marge_bottom - 5, - $largeur- 10, + $largeur - 10, $hauteur - $marge_bottom + 5, $noir ); imagestring($image, 2, $largeur - 10, $hauteur - $marge_bottom + 10, 'x', $noir); for ($i = 0, $tmp_x = 0, $flag = 0; $esc_svc_data = $res_esc_svc->fetchRow();) { # retrieve contactgroup associated with the escalation service - $cmd_contactgroup = "SELECT cg.cg_name ". - "FROM contactgroup cg, escalation_contactgroup_relation ecr ". - "WHERE ecr.escalation_esc_id = ".$esc_svc_data["esc_id"]." ". + $cmd_contactgroup = "SELECT cg.cg_name " . + "FROM contactgroup cg, escalation_contactgroup_relation ecr " . + "WHERE ecr.escalation_esc_id = " . $esc_svc_data["esc_id"] . " " . "AND ecr.contactgroup_cg_id = cg.cg_id"; $res_cg = $pearDB->query($cmd_contactgroup); $max_contact = $res_cg->rowCount(); $pas_tmp = ($max_contact * 20 > $pas_graduation_y - ? $pas_graduation_y / ($max_contact > 0 ? $max_contact : 1) - : 20); + ? $pas_graduation_y / ($max_contact > 0 ? $max_contact : 1) + : 20); for ($cnt = 0; $contactgroup = $res_cg->fetchRow(); $cnt++) { #show contactgroup link with the escalation of the service ($cnt == 0) ? $i += $pas_graduation_y / 2 : $i += $pas_tmp; @@ -443,7 +443,7 @@ function trace_bat($x1, $y1, $x2, $y2, $esc_name) imagestring($image, 3, 10, $hauteur - $marge_bottom - $i, $contactgroup["cg_name"], $noir); if ($esc_svc_data["last_notification"] == 0) { trace_bat( - $marge_left+(($esc_svc_data["first_notification"] - $min_notif + 1)*$pas_graduation_x), + $marge_left + (($esc_svc_data["first_notification"] - $min_notif + 1) * $pas_graduation_x), $hauteur - $marge_bottom - $i, $largeur - 10, $hauteur - $marge_bottom - $i + 10, @@ -451,9 +451,9 @@ function trace_bat($x1, $y1, $x2, $y2, $esc_name) ); } else { trace_bat( - $marge_left+(($esc_svc_data["first_notification"] - $min_notif + 1)*$pas_graduation_x), + $marge_left + (($esc_svc_data["first_notification"] - $min_notif + 1) * $pas_graduation_x), $hauteur - $marge_bottom - $i, - $marge_left + (($esc_svc_data["last_notification"] - $min_notif + 1)*$pas_graduation_x), + $marge_left + (($esc_svc_data["last_notification"] - $min_notif + 1) * $pas_graduation_x), $hauteur - $marge_bottom - $i + 10, $esc_svc_data["esc_name"] ); @@ -463,16 +463,16 @@ function trace_bat($x1, $y1, $x2, $y2, $esc_name) #graduation Axe X ImageLine( $image, - $marge_left+(($esc_svc_data["first_notification"] - $min_notif + 1)*$pas_graduation_x), + $marge_left + (($esc_svc_data["first_notification"] - $min_notif + 1) * $pas_graduation_x), $hauteur - $marge_bottom - 5, - $marge_left+(($esc_svc_data["first_notification"] - $min_notif + 1)*$pas_graduation_x), + $marge_left + (($esc_svc_data["first_notification"] - $min_notif + 1) * $pas_graduation_x), $hauteur - $marge_bottom + 5, $noir ); imagestring( $image, 2, - $marge_left+(($esc_svc_data["first_notification"] - $min_notif + 1)*$pas_graduation_x), + $marge_left + (($esc_svc_data["first_notification"] - $min_notif + 1) * $pas_graduation_x), $hauteur - $marge_bottom + 10, $esc_svc_data["first_notification"], $noir @@ -480,16 +480,16 @@ function trace_bat($x1, $y1, $x2, $y2, $esc_name) if ($esc_svc_data["last_notification"] != 0) { ImageLine( $image, - $marge_left + (($esc_svc_data["last_notification"] - $min_notif + 1)*$pas_graduation_x), + $marge_left + (($esc_svc_data["last_notification"] - $min_notif + 1) * $pas_graduation_x), $hauteur - $marge_bottom - 5, - $marge_left + (($esc_svc_data["last_notification"] - $min_notif + 1)*$pas_graduation_x), + $marge_left + (($esc_svc_data["last_notification"] - $min_notif + 1) * $pas_graduation_x), $hauteur - $marge_bottom + 5, $noir ); imagestring( $image, 2, - $marge_left + (($esc_svc_data["last_notification"] - $min_notif + 1)*$pas_graduation_x), + $marge_left + (($esc_svc_data["last_notification"] - $min_notif + 1) * $pas_graduation_x), $hauteur - $marge_bottom + 10, $esc_svc_data["last_notification"], $noir @@ -502,8 +502,8 @@ function trace_bat($x1, $y1, $x2, $y2, $esc_name) #show contactgroup link with the host $pas_tmp_host = ($max_contact_service * 20 > $pas_graduation_y - ? $pas_graduation_y / ($max_contact_service > 0 ? $max_contact_service : 1) - : 20); + ? $pas_graduation_y / ($max_contact_service > 0 ? $max_contact_service : 1) + : 20); for ($cnt = 0, $i = 0; $contactgroup_host = $res_cg_host->fetchRow(); $cnt++) { ($cnt == 0) ? $i += 15 : $i += $pas_tmp_host; imagestring($image, 3, 10, $hauteur - $marge_bottom - $i, $contactgroup_host["cg_name"], $rouge); @@ -551,16 +551,16 @@ function trace_bat($x1, $y1, $x2, $y2, $esc_name) imagestring($image, 2, $largeur - 10, $hauteur - $marge_bottom + 10, 'x', $noir); for ($i = 0; $esc_host_data = $res_esc_host->fetchRow();) { # retrieve contactgroup associated with the escalation host - $cmd_contactgroup = "SELECT cg.cg_name ". - "FROM contactgroup cg, escalation_contactgroup_relation ecr ". - "WHERE ecr.escalation_esc_id = ".$esc_host_data["esc_id"]." ". - "AND ecr.contactgroup_cg_id = cg.cg_id"; + $cmd_contactgroup = "SELECT cg.cg_name " . + "FROM contactgroup cg, escalation_contactgroup_relation ecr " . + "WHERE ecr.escalation_esc_id = " . $esc_host_data["esc_id"] . " " . + "AND ecr.contactgroup_cg_id = cg.cg_id"; $res_cg = $pearDB->query($cmd_contactgroup); $max_contact = $res_cg->rowCount(); $pas_tmp = ($max_contact * 20 > $pas_graduation_y - ? $pas_graduation_y / ($max_contact > 0 ? $max_contact : 1) - : 20); + ? $pas_graduation_y / ($max_contact > 0 ? $max_contact : 1) + : 20); for ($cnt = 0; $contactgroup = $res_cg->fetchRow(); $cnt++) { #show contactgroup link with the escalation of the host ($cnt == 0) ? $i += $pas_graduation_y / 2 : $i += $pas_tmp; @@ -575,7 +575,7 @@ function trace_bat($x1, $y1, $x2, $y2, $esc_name) imagestring($image, 3, 10, $hauteur - $marge_bottom - $i, $contactgroup["cg_name"], $noir); if ($esc_host_data["last_notification"] == 0) { trace_bat( - $marge_left+(($esc_host_data["first_notification"] - $min_notif + 1)*$pas_graduation_x), + $marge_left + (($esc_host_data["first_notification"] - $min_notif + 1) * $pas_graduation_x), $hauteur - $marge_bottom - $i, $largeur - 10, $hauteur - $marge_bottom - $i + 10, @@ -583,9 +583,9 @@ function trace_bat($x1, $y1, $x2, $y2, $esc_name) ); } else { trace_bat( - $marge_left+(($esc_host_data["first_notification"] - $min_notif + 1)*$pas_graduation_x), + $marge_left + (($esc_host_data["first_notification"] - $min_notif + 1) * $pas_graduation_x), $hauteur - $marge_bottom - $i, - $marge_left + (($esc_host_data["last_notification"] - $min_notif + 1)*$pas_graduation_x), + $marge_left + (($esc_host_data["last_notification"] - $min_notif + 1) * $pas_graduation_x), $hauteur - $marge_bottom - $i + 10, $esc_host_data["esc_name"] ); @@ -595,16 +595,16 @@ function trace_bat($x1, $y1, $x2, $y2, $esc_name) #graduation Axe X ImageLine( $image, - $marge_left+(($esc_host_data["first_notification"] - $min_notif + 1)*$pas_graduation_x), + $marge_left + (($esc_host_data["first_notification"] - $min_notif + 1) * $pas_graduation_x), $hauteur - $marge_bottom - 5, - $marge_left+(($esc_host_data["first_notification"] - $min_notif + 1)*$pas_graduation_x), + $marge_left + (($esc_host_data["first_notification"] - $min_notif + 1) * $pas_graduation_x), $hauteur - $marge_bottom + 5, $noir ); imagestring( $image, 2, - $marge_left+(($esc_host_data["first_notification"] - $min_notif + 1)*$pas_graduation_x), + $marge_left + (($esc_host_data["first_notification"] - $min_notif + 1) * $pas_graduation_x), $hauteur - $marge_bottom + 10, $esc_host_data["first_notification"], $noir @@ -612,16 +612,16 @@ function trace_bat($x1, $y1, $x2, $y2, $esc_name) if ($esc_host_data["last_notification"] != 0) { ImageLine( $image, - $marge_left + (($esc_host_data["last_notification"] - $min_notif + 1)*$pas_graduation_x), + $marge_left + (($esc_host_data["last_notification"] - $min_notif + 1) * $pas_graduation_x), $hauteur - $marge_bottom - 5, - $marge_left + (($esc_host_data["last_notification"] - $min_notif + 1)*$pas_graduation_x), + $marge_left + (($esc_host_data["last_notification"] - $min_notif + 1) * $pas_graduation_x), $hauteur - $marge_bottom + 5, $noir ); imagestring( $image, 2, - $marge_left + (($esc_host_data["last_notification"] - $min_notif + 1)*$pas_graduation_x), + $marge_left + (($esc_host_data["last_notification"] - $min_notif + 1) * $pas_graduation_x), $hauteur - $marge_bottom + 10, $esc_host_data["last_notification"], $noir @@ -634,23 +634,23 @@ function trace_bat($x1, $y1, $x2, $y2, $esc_name) $image, $largeur - 10, $hauteur - $marge_bottom - 5, - $largeur- 10, + $largeur - 10, $hauteur - $marge_bottom + 5, $noir ); imagestring($image, 2, $largeur - 10, $hauteur - $marge_bottom + 10, 'x', $noir); for ($i = 0, $tmp_x = 0; $esc_hostgroup_data = $res_esc_hostgroup->fetchRow();) { # retrieve contactgroup associated with the escalation hostgroup - $cmd_contactgroup = "SELECT cg.cg_name ". - "FROM contactgroup cg, escalation_contactgroup_relation ecr ". - "WHERE ecr.escalation_esc_id = ".$esc_hostgroup_data["esc_id"]." ". + $cmd_contactgroup = "SELECT cg.cg_name " . + "FROM contactgroup cg, escalation_contactgroup_relation ecr " . + "WHERE ecr.escalation_esc_id = " . $esc_hostgroup_data["esc_id"] . " " . "AND ecr.contactgroup_cg_id = cg.cg_id"; $res_cg = $pearDB->query($cmd_contactgroup); $max_contact = $res_cg->rowCount(); $pas_tmp = ($max_contact * 20 > $pas_graduation_y - ? $pas_graduation_y / ($max_contact > 0 ? $max_contact : 1) - : 20); + ? $pas_graduation_y / ($max_contact > 0 ? $max_contact : 1) + : 20); for ($cnt = 0; $contactgroup = $res_cg->fetchRow(); $cnt++) { #show contactgroup link with the escalation of the hostgroup ($cnt == 0) ? $i += $pas_graduation_y / 2 : $i += $pas_tmp; @@ -672,7 +672,7 @@ function trace_bat($x1, $y1, $x2, $y2, $esc_name) ); if ($esc_hostgroup_data["last_notification"] == 0) { trace_bat( - $marge_left+(($esc_hostgroup_data["first_notification"] - $min_notif + 1)*$pas_graduation_x), + $marge_left + (($esc_hostgroup_data["first_notification"] - $min_notif + 1) * $pas_graduation_x), $hauteur - $marge_bottom - $i, $largeur - 10, $hauteur - $marge_bottom - $i + 10, @@ -680,9 +680,9 @@ function trace_bat($x1, $y1, $x2, $y2, $esc_name) ); } else { trace_bat( - $marge_left+(($esc_hostgroup_data["first_notification"] - $min_notif + 1)*$pas_graduation_x), + $marge_left + (($esc_hostgroup_data["first_notification"] - $min_notif + 1) * $pas_graduation_x), $hauteur - $marge_bottom - $i, - $marge_left + (($esc_hostgroup_data["last_notification"] - $min_notif + 1)*$pas_graduation_x), + $marge_left + (($esc_hostgroup_data["last_notification"] - $min_notif + 1) * $pas_graduation_x), $hauteur - $marge_bottom - $i + 10, $esc_hostgroup_data["esc_name"] ); @@ -692,16 +692,16 @@ function trace_bat($x1, $y1, $x2, $y2, $esc_name) #graduation Axe X ImageLine( $image, - $marge_left+(($esc_hostgroup_data["first_notification"] - $min_notif + 1)*$pas_graduation_x), + $marge_left + (($esc_hostgroup_data["first_notification"] - $min_notif + 1) * $pas_graduation_x), $hauteur - $marge_bottom - 5, - $marge_left+(($esc_hostgroup_data["first_notification"] - $min_notif + 1)*$pas_graduation_x), + $marge_left + (($esc_hostgroup_data["first_notification"] - $min_notif + 1) * $pas_graduation_x), $hauteur - $marge_bottom + 5, $noir ); imagestring( $image, 2, - $marge_left+(($esc_hostgroup_data["first_notification"] - $min_notif + 1)*$pas_graduation_x), + $marge_left + (($esc_hostgroup_data["first_notification"] - $min_notif + 1) * $pas_graduation_x), $hauteur - $marge_bottom + 10, $esc_hostgroup_data["first_notification"], $noir @@ -709,16 +709,16 @@ function trace_bat($x1, $y1, $x2, $y2, $esc_name) if ($esc_hostgroup_data["last_notification"] != 0) { ImageLine( $image, - $marge_left + (($esc_hostgroup_data["last_notification"] - $min_notif + 1)*$pas_graduation_x), + $marge_left + (($esc_hostgroup_data["last_notification"] - $min_notif + 1) * $pas_graduation_x), $hauteur - $marge_bottom - 5, - $marge_left + (($esc_hostgroup_data["last_notification"] - $min_notif + 1)*$pas_graduation_x), + $marge_left + (($esc_hostgroup_data["last_notification"] - $min_notif + 1) * $pas_graduation_x), $hauteur - $marge_bottom + 5, $noir ); imagestring( $image, 2, - $marge_left + (($esc_hostgroup_data["last_notification"] - $min_notif + 1)*$pas_graduation_x), + $marge_left + (($esc_hostgroup_data["last_notification"] - $min_notif + 1) * $pas_graduation_x), $hauteur - $marge_bottom + 10, $esc_hostgroup_data["last_notification"], $noir From 9efcb5c6bff0c1d5523da254cecd15df5a0967af Mon Sep 17 00:00:00 2001 From: Laurent Pinsivy Date: Wed, 12 Jul 2017 10:57:13 +0200 Subject: [PATCH 005/207] It is better to get MAX(traps_id) before use it (#5415) --- www/class/centreonTraps.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/www/class/centreonTraps.class.php b/www/class/centreonTraps.class.php index b4d86678c6c..b2a9fa17f88 100644 --- a/www/class/centreonTraps.class.php +++ b/www/class/centreonTraps.class.php @@ -459,7 +459,10 @@ public function insert($ret = array()) $rq .= "'".$this->db->escape($ret["traps_timeout"])."', "; $rq .= "'".$this->db->escape($ret["traps_customcode"])."') "; $this->db->query($rq); - + + $res = $this->db->query("SELECT MAX(traps_id) FROM traps"); + $traps_id = $res->fetchRow(); + $this->setMatchingOptions($traps_id['MAX(traps_id)'], $_POST); $this->setServiceRelations($traps_id['MAX(traps_id)']); $this->setServiceTemplateRelations($traps_id['MAX(traps_id)']); @@ -468,9 +471,6 @@ public function insert($ret = array()) $this->setServiceTemplateRelations($traps_id['MAX(traps_id)'], $ret['service_templates']); } - $res = $this->db->query("SELECT MAX(traps_id) FROM traps"); - $traps_id = $res->fetchRow(); - /* Prepare value for changelog */ $fields = CentreonLogAction::prepareChanges($ret); $this->centreon->CentreonLogAction->insertLog( From 048f3432308f490f5924f1794720312240b403c6 Mon Sep 17 00:00:00 2001 From: Laurent Pinsivy Date: Wed, 12 Jul 2017 11:27:59 +0200 Subject: [PATCH 006/207] broker directory no longer existe - issue #5399 (#5416) --- .../status/ServicesServiceGroups/serviceGridBySG.php | 4 ++-- .../status/ServicesServiceGroups/serviceSummaryBySG.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/www/include/monitoring/status/ServicesServiceGroups/serviceGridBySG.php b/www/include/monitoring/status/ServicesServiceGroups/serviceGridBySG.php index 826a728756f..5a7eba20b1e 100644 --- a/www/include/monitoring/status/ServicesServiceGroups/serviceGridBySG.php +++ b/www/include/monitoring/status/ServicesServiceGroups/serviceGridBySG.php @@ -145,10 +145,10 @@ function displayingLevel1(val) _o = _o + "_" + sel2; } if (val == 'svcOVSG') { - _addrXML = "./include/monitoring/status/ServicesServiceGroups/xml/broker/serviceGridBySGXML.php"; + _addrXML = "./include/monitoring/status/ServicesServiceGroups/xml/serviceGridBySGXML.php"; _addrXSL = "./include/monitoring/status/ServicesServiceGroups/xsl/serviceGridBySG.xsl"; } else { - _addrXML = "./include/monitoring/status/ServicesServiceGroups/xml/broker/serviceSummaryBySGXML.php"; + _addrXML = "./include/monitoring/status/ServicesServiceGroups/xml/serviceSummaryBySGXML.php"; _addrXSL = "./include/monitoring/status/ServicesServiceGroups/xsl/serviceSummaryBySG.xsl"; } monitoring_refresh(); diff --git a/www/include/monitoring/status/ServicesServiceGroups/serviceSummaryBySG.php b/www/include/monitoring/status/ServicesServiceGroups/serviceSummaryBySG.php index ed80252ef76..42bfa55c860 100644 --- a/www/include/monitoring/status/ServicesServiceGroups/serviceSummaryBySG.php +++ b/www/include/monitoring/status/ServicesServiceGroups/serviceSummaryBySG.php @@ -148,10 +148,10 @@ function displayingLevel1(val) _o = _o + "_" + sel2; } if (val == 'svcOVSG') { - _addrXML = "./include/monitoring/status/ServicesServiceGroups/xml/broker/serviceGridBySGXML.php"; + _addrXML = "./include/monitoring/status/ServicesServiceGroups/xml/serviceGridBySGXML.php"; _addrXSL = "./include/monitoring/status/ServicesServiceGroups/xsl/serviceGridBySG.xsl"; } else { - _addrXML = "./include/monitoring/status/ServicesServiceGroups/xml/broker/serviceSummaryBySGXML.php"; + _addrXML = "./include/monitoring/status/ServicesServiceGroups/xml/serviceSummaryBySGXML.php"; _addrXSL = "./include/monitoring/status/ServicesServiceGroups/xsl/serviceSummaryBySG.xsl"; } monitoring_refresh(); From d5a5fe29f25291d9a7c6bcba91eb0457c5a5816f Mon Sep 17 00:00:00 2001 From: mariegallardo Date: Wed, 12 Jul 2017 13:49:55 +0200 Subject: [PATCH 007/207] Feature ACLActionAccess created (#5432) * Feature created * * fix style * Duplicates have been removed --- behat.yml | 5 + features/ACLActionsAccess.feature | 43 + .../bootstrap/ACLActionsAccessContext.php | 897 ++++++++++++++++++ 3 files changed, 945 insertions(+) create mode 100644 features/ACLActionsAccess.feature create mode 100644 features/bootstrap/ACLActionsAccessContext.php diff --git a/behat.yml b/behat.yml index b721064ef26..3a519de22da 100644 --- a/behat.yml +++ b/behat.yml @@ -223,3 +223,8 @@ default: paths: [ %paths.base%/features/NonAdminContactCreation.feature ] contexts: - NonAdminContactCreationContext + + acl_actions_access: + paths: [ %paths.base%/features/ACLActionsAccess.feature ] + contexts: + - ACLActionsAccessContext diff --git a/features/ACLActionsAccess.feature b/features/ACLActionsAccess.feature new file mode 100644 index 00000000000..e79ebf1716a --- /dev/null +++ b/features/ACLActionsAccess.feature @@ -0,0 +1,43 @@ +Feature: ACL Actions Access + As a Centreon administrator + I want to administrate Actions Access + To restrict users actions on Centreon objects + + Background: + Given I am logged in a Centreon server + And one ACL access group including a non admin user exists + And one ACL access group linked to a contact group including an admin user exists + + Scenario: Creating Actions Access linked to one non admin access groups and to one admin access group + When I add a new action access linked with the access groups + Then the action access record is saved with its properties + And all linked access group display the new actions access in authorized information tab + + Scenario: Creating action access by selecting authorized actions one by one + When I select one by one all action to authorize them in a action access record I create + Then all radio-buttons have to be checked + + Scenario: Creating actions access by selecting authorized actions by lots + When I check button-radio for a lot of actions + Then all buttons-radio of the authorized actions lot are checked + + Scenario: Remove one access group from Actions access + Given one existing action access + When I remove the access group + Then link between access group and action access must be broken + + Scenario: Duplicate one existing Actions access record + Given one existing action access + When I duplicate the action access + Then a new action access record is created with identical properties except the name + + Scenario: Modify one existing Actions access record + Given one existing action access + When I modify some properties such as name, description, comments, status or authorized actions + Then the modifications are saved + + Scenario: Delete one existing Actions access record + Given one existing action access + When I delete the action access + Then the action access record is not visible anymore in action access page + Then the links with the acl groups are broken diff --git a/features/bootstrap/ACLActionsAccessContext.php b/features/bootstrap/ACLActionsAccessContext.php new file mode 100644 index 00000000000..3b04c8cbb66 --- /dev/null +++ b/features/bootstrap/ACLActionsAccessContext.php @@ -0,0 +1,897 @@ + 'adminUserAlias', + 'name' => 'adminUserName', + 'email' => 'admin@localhost', + 'admin' => 1 + ); + + private $adminContactGroup = array( + 'name' => 'adminContactGroupName', + 'alias' => 'adminContactGroupAlias', + 'contacts' => array( + 'adminUserName' + ), + ); + + private $nonAdminUser = array( + 'alias' => 'nonAdminUserAlias', + 'name' => 'nonAdminUserName', + 'email' => 'nonAdmin@localhost', + 'admin' => 0 + ); + + private $adminAclGroup = array( + 'group_name' => 'adminAclGroupName', + 'group_alias' => 'adminAclGroupAlias', + 'contactgroups' => array( + 'adminContactGroupName' + ) + ); + + private $nonAdminAclGroup = array( + 'group_name' => 'nonAdminAclGroupName', + 'group_alias' => 'nonAdminAclGroupAlias', + 'contacts' => array( + 'nonAdminUserName' + ) + ); + + private $initialProperties = array( + 'acl_name' => 'aclActionName', + 'acl_alias' => 'aclActionAlias', + 'acl_groups' => array( + 'adminAclGroupName', + 'nonAdminAclGroupName' + ), + 'action_top_counter_overview' => 1, + 'action_top_counter_poller' => 1, + 'action_poller_listing' => 1, + 'action_generate_configuration' => 1, + 'action_generate_trap' => 0, + 'action_engine' => 0, + 'action_shutdown' => 1, + 'action_restart' => 0, + 'action_notifications' => 0, + 'action_global_service_checks' => 1, + 'action_global_service_passive_checks' => 1, + 'action_global_host_checks' => 0, + 'action_global_host_passive_checks' => 0, + 'action_event_handler' => 0, + 'action_flap_detection' => 1, + 'action_global_service_obsess' => 1, + 'action_global_host_obsess' => 0, + 'action_perf_data' => 0, + 'action_service' => 0, + 'action_service_notifications' => 0, + 'action_service_acknowledgement' => 0, + 'action_service_disacknowledgement' => 1, + 'action_service_schedule_check' => 1, + 'action_service_schedule_forced_check' => 0, + 'action_service_schedule_downtime' => 0, + 'action_service_comment' => 0, + 'action_service_event_handler' => 0, + 'action_service_flap_detection' => 1, + 'action_service_submit_result' => 0, + 'action_service_display_command' => 0, + 'action_host' => 0, + 'action_host_notifications' => 1, + 'action_host_acknowledgement' => 1, + 'action_host_disacknowledgement' => 0, + 'action_host_schedule_check' => 0, + 'action_host_schedule_forced_check' => 1, + 'action_host_schedule_downtime' => 1, + 'action_host_comment' => 1, + 'action_host_event_handler' => 1, + 'action_host_flap_detection' => 0, + 'action_host_checks_for_services' => 1, + 'action_host_notifications_for_services' => 0, + 'action_name_submit_result' => 1, + 'enabled' => 1 + ); + + private $duplicatedProperties = array( + 'acl_name' => 'aclActionName_1', + 'acl_alias' => 'aclActionAlias', + 'acl_groups' => array( + 'adminAclGroupName', + 'nonAdminAclGroupName' + ), + 'action_top_counter_overview' => 1, + 'action_top_counter_poller' => 1, + 'action_poller_listing' => 1, + 'action_generate_configuration' => 1, + 'action_generate_trap' => 0, + 'action_engine' => 0, + 'action_shutdown' => 1, + 'action_restart' => 0, + 'action_notifications' => 0, + 'action_global_service_checks' => 1, + 'action_global_service_passive_checks' => 1, + 'action_global_host_checks' => 0, + 'action_global_host_passive_checks' => 0, + 'action_event_handler' => 0, + 'action_flap_detection' => 1, + 'action_global_service_obsess' => 1, + 'action_global_host_obsess' => 0, + 'action_perf_data' => 0, + 'action_service' => 0, + 'action_service_notifications' => 0, + 'action_service_acknowledgement' => 0, + 'action_service_disacknowledgement' => 1, + 'action_service_schedule_check' => 1, + 'action_service_schedule_forced_check' => 0, + 'action_service_schedule_downtime' => 0, + 'action_service_comment' => 0, + 'action_service_event_handler' => 0, + 'action_service_flap_detection' => 1, + 'action_service_submit_result' => 0, + 'action_service_display_command' => 0, + 'action_host' => 0, + 'action_host_notifications' => 1, + 'action_host_acknowledgement' => 1, + 'action_host_disacknowledgement' => 0, + 'action_host_schedule_check' => 0, + 'action_host_schedule_forced_check' => 1, + 'action_host_schedule_downtime' => 1, + 'action_host_comment' => 1, + 'action_host_event_handler' => 1, + 'action_host_flap_detection' => 0, + 'action_host_checks_for_services' => 1, + 'action_host_notifications_for_services' => 0, + 'action_name_submit_result' => 1, + 'enabled' => 1 + ); + + private $updatedProperties = array( + 'acl_name' => 'aclActionNameChanged', + 'acl_alias' => 'aclActionAliasChanged', + 'acl_groups' => array( + 'nonAdminAclGroupName' + ), + 'action_top_counter_overview' => 0, + 'action_top_counter_poller' => 1, + 'action_poller_listing' => 1, + 'action_generate_configuration' => 0, + 'action_generate_trap' => 1, + 'action_engine' => 0, + 'action_shutdown' => 1, + 'action_restart' => 1, + 'action_notifications' => 0, + 'action_global_service_checks' => 1, + 'action_global_service_passive_checks' => 0, + 'action_global_host_checks' => 1, + 'action_global_host_passive_checks' => 1, + 'action_event_handler' => 0, + 'action_flap_detection' => 1, + 'action_global_service_obsess' => 0, + 'action_global_host_obsess' => 1, + 'action_perf_data' => 1, + 'action_service' => 0, + 'action_service_notifications' => 1, + 'action_service_acknowledgement' => 0, + 'action_service_disacknowledgement' => 1, + 'action_service_schedule_check' => 0, + 'action_service_schedule_forced_check' => 1, + 'action_service_schedule_downtime' => 0, + 'action_service_comment' => 1, + 'action_service_event_handler' => 0, + 'action_service_flap_detection' => 1, + 'action_service_submit_result' => 0, + 'action_service_display_command' => 0, + 'action_host' => 0, + 'action_host_notifications' => 1, + 'action_host_acknowledgement' => 0, + 'action_host_disacknowledgement' => 0, + 'action_host_schedule_check' => 1, + 'action_host_schedule_forced_check' => 1, + 'action_host_schedule_downtime' => 1, + 'action_host_comment' => 0, + 'action_host_event_handler' => 1, + 'action_host_flap_detection' => 1, + 'action_host_checks_for_services' => 1, + 'action_host_notifications_for_services' => 0, + 'action_name_submit_result' => 0, + 'enabled' => 0 + ); + + private $allSelected = array( + 'acl_name' => 'aclActionName', + 'acl_alias' => 'aclActionAlias', + 'acl_groups' => array( + 'adminAclGroupName', + 'nonAdminAclGroupName' + ), + 'action_top_counter_overview' => 1, + 'action_top_counter_poller' => 1, + 'action_poller_listing' => 1, + 'action_generate_configuration' => 1, + 'action_generate_trap' => 1, + 'action_engine' => 0, + 'action_shutdown' => 1, + 'action_restart' => 1, + 'action_notifications' => 1, + 'action_global_service_checks' => 1, + 'action_global_service_passive_checks' => 1, + 'action_global_host_checks' => 1, + 'action_global_host_passive_checks' => 1, + 'action_event_handler' => 1, + 'action_flap_detection' => 1, + 'action_global_service_obsess' => 1, + 'action_global_host_obsess' => 1, + 'action_perf_data' => 1, + 'action_service' => 0, + 'action_service_notifications' => 1, + 'action_service_acknowledgement' => 1, + 'action_service_disacknowledgement' => 1, + 'action_service_schedule_check' => 1, + 'action_service_schedule_forced_check' => 1, + 'action_service_schedule_downtime' => 1, + 'action_service_comment' => 1, + 'action_service_event_handler' => 1, + 'action_service_flap_detection' => 1, + 'action_service_submit_result' => 1, + 'action_service_display_command' => 1, + 'action_host' => 0, + 'action_host_notifications' => 1, + 'action_host_acknowledgement' => 1, + 'action_host_disacknowledgement' => 1, + 'action_host_schedule_check' => 1, + 'action_host_schedule_forced_check' => 1, + 'action_host_schedule_downtime' => 1, + 'action_host_comment' => 1, + 'action_host_event_handler' => 1, + 'action_host_flap_detection' => 1, + 'action_host_checks_for_services' => 1, + 'action_host_notifications_for_services' => 1, + 'action_name_submit_result' => 1, + 'enabled' => 1 + ); + + private $selectActionEngine = array( + 'acl_name' => 'testActionEngineName', + 'acl_alias' => 'testActionEngineAlia', + 'acl_groups' => array( + 'adminAclGroupName' + ), + 'action_engine' => 1 + ); + + private $checkActionEngine = array( + 'acl_name' => 'testActionEngineName', + 'acl_alias' => 'testActionEngineAlia', + 'acl_groups' => array( + 'adminAclGroupName' + ), + 'action_top_counter_overview' => 0, + 'action_top_counter_poller' => 0, + 'action_poller_listing' => 0, + 'action_generate_configuration' => 0, + 'action_generate_trap' => 0, + 'action_engine' => 0, + 'action_shutdown' => 1, + 'action_restart' => 1, + 'action_notifications' => 1, + 'action_global_service_checks' => 1, + 'action_global_service_passive_checks' => 1, + 'action_global_host_checks' => 1, + 'action_global_host_passive_checks' => 1, + 'action_event_handler' => 1, + 'action_flap_detection' => 1, + 'action_global_service_obsess' => 1, + 'action_global_host_obsess' => 1, + 'action_perf_data' => 1, + 'action_service' => 0, + 'action_service_notifications' => 0, + 'action_service_acknowledgement' => 0, + 'action_service_disacknowledgement' => 0, + 'action_service_schedule_check' => 0, + 'action_service_schedule_forced_check' => 0, + 'action_service_schedule_downtime' => 0, + 'action_service_comment' => 0, + 'action_service_event_handler' => 0, + 'action_service_flap_detection' => 0, + 'action_service_submit_result' => 0, + 'action_service_display_command' => 0, + 'action_host' => 0, + 'action_host_notifications' => 0, + 'action_host_acknowledgement' => 0, + 'action_host_disacknowledgement' => 0, + 'action_host_schedule_check' => 0, + 'action_host_schedule_forced_check' => 0, + 'action_host_schedule_downtime' => 0, + 'action_host_comment' => 0, + 'action_host_event_handler' => 0, + 'action_host_flap_detection' => 0, + 'action_host_checks_for_services' => 0, + 'action_host_notifications_for_services' => 0, + 'action_name_submit_result' => 0, + 'enabled' => 1 + ); + + private $selectActionService = array( + 'acl_name' => 'testActionServiceName', + 'acl_alias' => 'testActionServiceAlia', + 'acl_groups' => array( + 'adminAclGroupName' + ), + 'action_service' => 1 + ); + + private $checkActionService = array( + 'acl_name' => 'testActionServiceName', + 'acl_alias' => 'testActionServiceAlia', + 'acl_groups' => array( + 'adminAclGroupName' + ), + 'action_top_counter_overview' => 0, + 'action_top_counter_poller' => 0, + 'action_poller_listing' => 0, + 'action_generate_configuration' => 0, + 'action_generate_trap' => 0, + 'action_engine' => 0, + 'action_shutdown' => 0, + 'action_restart' => 0, + 'action_notifications' => 0, + 'action_global_service_checks' => 0, + 'action_global_service_passive_checks' => 0, + 'action_global_host_checks' => 0, + 'action_global_host_passive_checks' => 0, + 'action_event_handler' => 0, + 'action_flap_detection' => 0, + 'action_global_service_obsess' => 0, + 'action_global_host_obsess' => 0, + 'action_perf_data' => 0, + 'action_service' => 0, + 'action_service_notifications' => 1, + 'action_service_acknowledgement' => 1, + 'action_service_disacknowledgement' => 1, + 'action_service_schedule_check' => 1, + 'action_service_schedule_forced_check' => 1, + 'action_service_schedule_downtime' => 1, + 'action_service_comment' => 1, + 'action_service_event_handler' => 1, + 'action_service_flap_detection' => 1, + 'action_service_submit_result' => 1, + 'action_service_display_command' => 1, + 'action_host' => 0, + 'action_host_notifications' => 0, + 'action_host_acknowledgement' => 0, + 'action_host_disacknowledgement' => 0, + 'action_host_schedule_check' => 0, + 'action_host_schedule_forced_check' => 0, + 'action_host_schedule_downtime' => 0, + 'action_host_comment' => 0, + 'action_host_event_handler' => 0, + 'action_host_flap_detection' => 0, + 'action_host_checks_for_services' => 0, + 'action_host_notifications_for_services' => 0, + 'action_name_submit_result' => 0, + 'enabled' => 1 + ); + + private $selectActionHost = array( + 'acl_name' => 'testActionHostName', + 'acl_alias' => 'testActionHostAlia', + 'acl_groups' => array( + 'adminAclGroupName' + ), + 'action_host' => 1 + ); + + private $checkActionHost = array( + 'acl_name' => 'testActionHostName', + 'acl_alias' => 'testActionHostAlia', + 'acl_groups' => array( + 'adminAclGroupName' + ), + 'action_top_counter_overview' => 0, + 'action_top_counter_poller' => 0, + 'action_poller_listing' => 0, + 'action_generate_configuration' => 0, + 'action_generate_trap' => 0, + 'action_engine' => 0, + 'action_shutdown' => 0, + 'action_restart' => 0, + 'action_notifications' => 0, + 'action_global_service_checks' => 0, + 'action_global_service_passive_checks' => 0, + 'action_global_host_checks' => 0, + 'action_global_host_passive_checks' => 0, + 'action_event_handler' => 0, + 'action_flap_detection' => 0, + 'action_global_service_obsess' => 0, + 'action_global_host_obsess' => 0, + 'action_perf_data' => 0, + 'action_service' => 0, + 'action_service_notifications' => 0, + 'action_service_acknowledgement' => 0, + 'action_service_disacknowledgement' => 0, + 'action_service_schedule_check' => 0, + 'action_service_schedule_forced_check' => 0, + 'action_service_schedule_downtime' => 0, + 'action_service_comment' => 0, + 'action_service_event_handler' => 0, + 'action_service_flap_detection' => 0, + 'action_service_submit_result' => 0, + 'action_service_display_command' => 0, + 'action_host' => 0, + 'action_host_notifications' => 1, + 'action_host_acknowledgement' => 1, + 'action_host_disacknowledgement' => 1, + 'action_host_schedule_check' => 1, + 'action_host_schedule_forced_check' => 1, + 'action_host_schedule_downtime' => 1, + 'action_host_comment' => 1, + 'action_host_event_handler' => 1, + 'action_host_flap_detection' => 1, + 'action_host_checks_for_services' => 1, + 'action_host_notifications_for_services' => 1, + 'action_name_submit_result' => 1, + 'enabled' => 1 + ); + + /** + * @Given one ACL access group including a non admin user exists + */ + public function oneACLAccessGroupIncludingANonAdminUserExists() + { + $this->currentPage = new ContactConfigurationPage($this); + $this->currentPage->setProperties($this->nonAdminUser); + $this->currentPage->save(); + $this->currentPage = new ContactGroupsConfigurationPage($this); + $this->currentPage->setProperties($this->adminContactGroup); + $this->currentPage->save(); + $this->currentPage = new ACLGroupConfigurationPage($this); + $this->currentPage->setProperties($this->nonAdminAclGroup); + $this->currentPage->save(); + } + + /** + * @Given one ACL access group linked to a contact group including an admin user exists + */ + public function oneACLAccessGroupLinkedToAContactGroupIncludingAnAdminUserExists() + { + $this->currentPage = new ContactConfigurationPage($this); + $this->currentPage->setProperties($this->adminUser); + $this->currentPage->save(); + $this->currentPage = new ACLGroupConfigurationPage($this); + $this->currentPage->setProperties($this->adminAclGroup); + $this->currentPage->save(); + } + + /** + * @When I add a new action access linked with the access groups + */ + public function iAddANewActionAccessLinkedWithTheAccessGroups() + { + $this->currentPage = new ACLActionConfigurationPage($this); + $this->currentPage->setProperties($this->initialProperties); + $this->currentPage->save(); + } + + /** + * @Then the action access record is saved with its properties + */ + public function theActionAccessRecordIsSavedWithItsProperties() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new ACLActionConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['acl_name']); + $object = $this->currentPage->getProperties(); + foreach ($this->initialProperties as $key => $value) { + if ($key != 'acl_group' && $value != $object[$key]) { + $this->tableau[] = $key; + } + if ($key == 'acl_group') { + if ($object[$key] != $value) { + $this->tableau[] = $key; + } + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @Then all linked access group display the new actions access in authorized information tab + */ + public function allLinkedAccessGroupDisplayTheNewActionsAccessInAuthorizedInformationTab() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new ACLGroupConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->adminAclGroup['group_name']); + $object = $this->currentPage->getProperties(); + if (count($object['actions']) == 1 && + $object['actions'][0] != $this->initialProperties['acl_name'] + ) { + $this->tableau[] = $this->adminAclGroup['group_name']; + } + $this->currentPage = new ACLGroupConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->nonAdminAclGroup['group_name']); + $object = $this->currentPage->getProperties(); + if (count($object['actions']) == 1 && + $object['actions'][0] != $this->initialProperties['acl_name'] + ) { + $this->tableau[] = $this->nonAdminAclGroup['group_name']; + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I select one by one all action to authorize them in a action access record I create + */ + public function iSelectOneByOneAllActionToAuthorizeThemInAActionAccessRecordICreate() + { + $this->currentPage = new ACLActionConfigurationPage($this); + $this->currentPage->setProperties($this->allSelected); + $this->currentPage->save(); + } + + /** + * @Then all radio-buttons have to be checked + */ + public function allRadioButtonsHaveToBeChecked() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new ACLActionConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->allSelected['acl_name']); + $object = $this->currentPage->getProperties(); + foreach ($this->allSelected as $key => $value) { + if ($key != 'acl_group' && $value != $object[$key]) { + $this->tableau[] = $key; + } + if ($key == 'acl_group') { + if ($object[$key] != $value) { + $this->tableau[] = $key; + } + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I check button-radio for a lot of actions + */ + public function iCheckButtonRadioForALotOfActions() + { + $this->currentPage = new ACLActionConfigurationPage($this); + $this->currentPage->setProperties($this->selectActionEngine); + $this->currentPage->save(); + $this->currentPage = new ACLActionConfigurationPage($this); + $this->currentPage->setProperties($this->selectActionService); + $this->currentPage->save(); + $this->currentPage = new ACLActionConfigurationPage($this); + $this->currentPage->setProperties($this->selectActionHost); + $this->currentPage->save(); + } + + /** + * @Then all buttons-radio of the authorized actions lot are checked + */ + public function allButtonsRadioOfTheAuthorizedActionsLotAreChecked() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new ACLActionConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->checkActionEngine['acl_name']); + $object = $this->currentPage->getProperties(); + foreach ($this->checkActionEngine as $key => $value) { + if ($key != 'acl_group' && $value != $object[$key]) { + $this->tableau[] = 'test action_engine : ' . $key; + } + if ($key == 'acl_group') { + if ($object[$key] != $value) { + $this->tableau[] = 'test action_engine : ' . $key; + } + } + } + $this->currentPage = new ACLActionConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->checkActionService['acl_name']); + $object = $this->currentPage->getProperties(); + foreach ($this->checkActionService as $key => $value) { + if ($key != 'acl_group' && $value != $object[$key]) { + $this->tableau[] = 'test action_service : ' . $key; + } + if ($key == 'acl_group') { + if ($object[$key] != $value) { + $this->tableau[] = 'test action_service : ' . $key; + } + } + } + $this->currentPage = new ACLActionConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->checkActionHost['acl_name']); + $object = $this->currentPage->getProperties(); + foreach ($this->checkActionHost as $key => $value) { + if ($key != 'acl_group' && $value != $object[$key]) { + $this->tableau[] = 'test action_host : ' . $key; + } + if ($key == 'acl_group') { + if ($object[$key] != $value) { + $this->tableau[] = 'test action_host : ' . $key; + } + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @Given one existing action access + */ + public function oneExistingActionAccess() + { + $this->currentPage = new ACLActionConfigurationPage($this); + $this->currentPage->setProperties($this->initialProperties); + $this->currentPage->save(); + } + + /** + * @When I remove the access group + */ + public function iRemoveTheAccessGroup() + { + $this->currentPage = new ACLActionConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['acl_name']); + $this->currentPage->setProperties(array( + 'acl_groups' => array( + 'nonAdminAclGroupName' + ) + )); + $this->currentPage->save(); + } + + /** + * @Then link between access group and action access must be broken + */ + public function linkBetweenAccessGroupAndActionAccessMustBeBroken() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new ACLActionConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['acl_name']); + $object = $this->currentPage->getProperties(); + if ($object['acl_groups'] != array('nonAdminAclGroupName')) { + $this->tableau[] = 'acl_groups'; + } + $this->currentPage = new ACLGroupConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->adminAclGroup['group_name']); + $object = $this->currentPage->getProperties(); + if (count($object['actions']) != 0) { + $this->tableau[] = $this->adminAclGroup['group_name']; + } + $this->currentPage = new ACLGroupConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->nonAdminAclGroup['group_name']); + $object = $this->currentPage->getProperties(); + if (count($object['actions']) != 1 && + $object['actions'][0] != $this->initialProperties['acl_name'] + ) { + $this->tableau[] = $this->nonAdminAclGroup['group_name']; + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I duplicate the action access + */ + public function iDuplicateTheActionAccess() + { + $this->currentPage = new ACLActionConfigurationListingPage($this); + $object = $this->currentPage->getEntry($this->initialProperties['acl_name']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Duplicate'); + } + + /** + * @Then a new action access record is created with identical properties except the name + */ + public function aNewActionAccessRecordIsCreatedWithIdenticalPropertiesExceptTheName() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new ACLActionConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->duplicatedProperties['acl_name']); + $object = $this->currentPage->getProperties(); + foreach ($this->duplicatedProperties as $key => $value) { + if ($key != 'acl_groups' && $value != $object[$key]) { + $this->tableau[] = $key; + } + if ($key == 'acl_groups') { + if ($object[$key] != $value) { + $this->tableau[] = $key; + } + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I modify some properties such as name, description, comments, status or authorized actions + */ + public function iModifySomePropertiesSuchAsNameDescriptionCommentsStatusOrAuthorizedActions() + { + $this->currentPage = new ACLActionConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['acl_name']); + $this->currentPage->setProperties($this->updatedProperties); + $this->currentPage->save(); + } + + /** + * @Then the modifications are saved + */ + public function theModificationsAreSaved() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new ACLActionConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['acl_name']); + $object = $this->currentPage->getProperties(); + if ($object['acl_groups'] != array('nonAdminAclGroupName')) { + $this->tableau[] = 'acl_groups'; + } + $this->currentPage = new ACLGroupConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->adminAclGroup['group_name']); + $object = $this->currentPage->getProperties(); + if (count($object['actions']) != 0) { + $this->tableau[] = $this->adminAclGroup['group_name']; + } + $this->currentPage = new ACLGroupConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->nonAdminAclGroup['group_name']); + $object = $this->currentPage->getProperties(); + if (count($object['actions']) != 1 && + $object['actions'][0] != $this->initialProperties['acl_name'] + ) { + $this->tableau[] = $this->nonAdminAclGroup['group_name']; + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I delete the action access + */ + public function iDeleteTheActionAccess() + { + $this->currentPage = new ACLActionConfigurationListingPage($this); + $object = $this->currentPage->getEntry($this->initialProperties['acl_name']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Delete'); + } + + /** + * @Then the action access record is not visible anymore in action access page + */ + public function theActionAccessRecordIsNotVisibleAnymoreInActionAccessPage() + { + $this->spin( + function ($context) { + $this->currentPage = new ACLActionConfigurationListingPage($this); + $object = $this->currentPage->getEntries(); + $bool = true; + foreach ($object as $value) { + $bool = $bool && $value['name'] != $this->initialProperties['acl_name']; + } + return $bool; + }, + "The ACL Menu is not being deleted.", + 5 + ); + } + + /** + * @Then the links with the acl groups are broken + */ + public function theLinksWithTheAclGroupsAreBroken() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new ACLGroupConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->adminAclGroup['group_name']); + $object = $this->currentPage->getProperties(); + if (count($object['actions']) != 0) { + $this->tableau[] = $this->adminAclGroup['group_name']; + } + $this->currentPage = new ACLGroupConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->nonAdminAclGroup['group_name']); + $object = $this->currentPage->getProperties(); + if (count($object['actions']) != 0) { + $this->tableau[] = $this->nonAdminAclGroup['group_name']; + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } +} From 1dbc720438fa925507ac9391e343362d14ce76b1 Mon Sep 17 00:00:00 2001 From: Kevin Duret Date: Wed, 12 Jul 2017 15:34:37 +0200 Subject: [PATCH 008/207] Fix filter on HG / CG export --- .../centreonContactGroup.class.php | 32 +++++++++++++------ .../centreonHostGroup.class.php | 14 +++++--- 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/www/class/centreon-clapi/centreonContactGroup.class.php b/www/class/centreon-clapi/centreonContactGroup.class.php index f4bb11cc587..24f4e013bad 100644 --- a/www/class/centreon-clapi/centreonContactGroup.class.php +++ b/www/class/centreon-clapi/centreonContactGroup.class.php @@ -218,19 +218,33 @@ public function __call($name, $arg) */ public function export($filter_id = null, $filter_name = null) { - $filters = null; - if (!is_null($filter)) { + $filters = array(); + if (!is_null($filter_id) && $filter_id !== 0) { $filters['cg_id'] = $filter_id; } + if (!is_null($filter_name)) { + $filters['cg_name'] = $filter_name; + } parent::export($filters); - $obj = new \Centreon_Object_Relation_Contact_Group_Contact(); - $elements = $obj->getMergedParameters(array("cg_name"), array("contact_name", "contact_id"), -1, 0, "cg_name"); + $relObj = new \Centreon_Object_Relation_Contact_Group_Contact(); + $contactObj = new \Centreon_Object_Contact(); + $cgFieldName = $this->object->getUniqueLabelField(); + $cFieldName = $contactObj->getUniqueLabelField(); + $elements = $relObj->getMergedParameters( + array($cgFieldName), + array($cFieldName, "contact_id"), + -1, + 0, + $cgFieldName, + 'ASC', + $filters, + 'AND' + ); foreach ($elements as $element) { - $this->api->export_filter('CONTACT', $element['contact_id'], $element['contact_name']); - echo $this->action . $this->delim - . "addcontact" . $this->delim - . $element['cg_name'] . $this->delim - . $element['contact_name'] . "\n"; + $this->api->export_filter('CONTACT', $element['contact_id'], $element[$cgFieldName]); + echo $this->action . $this->delim . "addcontact" . + $this->delim . $element[$cgFieldName] . $this->delim . $element[$cFieldName] . + $this->delim . $element['contact_alias'] . "\n"; } } } diff --git a/www/class/centreon-clapi/centreonHostGroup.class.php b/www/class/centreon-clapi/centreonHostGroup.class.php index aad332916c0..3c1d80728ae 100644 --- a/www/class/centreon-clapi/centreonHostGroup.class.php +++ b/www/class/centreon-clapi/centreonHostGroup.class.php @@ -250,9 +250,12 @@ public function __call($name, $arg) */ public function export($filter_id = null, $filter_name = null) { - $filters = null; - if (!is_null($filter_id)) { - $filters = array('hg_id' => $filter_id); + $filters = array(); + if (!is_null($filter_id) && $filter_id !== 0) { + $filters['hg_id'] = $filter_id; + } + if (!is_null($filter_name)) { + $filters['hg_name'] = $filter_name; } parent::export($filters); @@ -267,7 +270,9 @@ public function export($filter_id = null, $filter_name = null) -1, 0, $hgFieldName, - null + 'ASC', + $filters, + 'AND' ); foreach ($elements as $element) { $this->api->export_filter('HOST', $element['host_id'], $element[$hFieldName]); @@ -275,7 +280,6 @@ public function export($filter_id = null, $filter_name = null) . "addhost" . $this->delim . $element[$hgFieldName] . $this->delim . $element[$hFieldName] . "\n"; - } } } From e600f81094c01c0f10f4a0ca1d137457bb630043 Mon Sep 17 00:00:00 2001 From: Laurent Pinsivy Date: Wed, 12 Jul 2017 15:58:56 +0200 Subject: [PATCH 009/207] Do not list meta service to link to a SNMP trap - issue #5418 (#5419) Meta services are active only and it is not necessary to link a SNMP trap --- www/include/configuration/configObject/traps/formTraps.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/include/configuration/configObject/traps/formTraps.php b/www/include/configuration/configObject/traps/formTraps.php index 82cde807163..81cbbe11ab9 100644 --- a/www/include/configuration/configObject/traps/formTraps.php +++ b/www/include/configuration/configObject/traps/formTraps.php @@ -114,7 +114,7 @@ function myReplace() ); $attrServices = array( 'datasourceOrigin' => 'ajax', - 'availableDatasetRoute' => './include/common/webServices/rest/internal.php?object=centreon_configuration_service&action=list', + 'availableDatasetRoute' => './include/common/webServices/rest/internal.php?object=centreon_configuration_service&action=list&s=s', 'multiple' => true, 'linkedObject' => 'centreonService' ); From 61ed9a0ef9a8a2169900c477fa2a80c1c082326d Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Date: Wed, 12 Jul 2017 17:38:00 +0200 Subject: [PATCH 010/207] Fix log debug path (#5431) Error in the name of the variable --- www/class/centreonLog.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/class/centreonLog.class.php b/www/class/centreonLog.class.php index d517cce16de..fd208185007 100644 --- a/www/class/centreonLog.class.php +++ b/www/class/centreonLog.class.php @@ -56,7 +56,7 @@ public function __construct($uid, $pearDB) */ $DBRESULT = $pearDB->query("SELECT * FROM `options` WHERE `key` = 'debug_path'"); while ($res = $DBRESULT->fetchRow()) { - $this->ldapInfos[$res["key"]] = $res["value"]; + $optGen[$res["key"]] = $res["value"]; } $DBRESULT->closeCursor(); From 92cfb9cb444ad34ddd0cd65d410d8a0c1528ed68 Mon Sep 17 00:00:00 2001 From: cgagnaire Date: Wed, 12 Jul 2017 17:44:42 +0200 Subject: [PATCH 011/207] typo correction in data management (#5440) * typo correction * Update form.php * Update form.php --- .../parameters/centstorage/form.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/www/include/Administration/parameters/centstorage/form.php b/www/include/Administration/parameters/centstorage/form.php index 0b7a962c9e4..f58a4a7a4fe 100644 --- a/www/include/Administration/parameters/centstorage/form.php +++ b/www/include/Administration/parameters/centstorage/form.php @@ -125,17 +125,17 @@ _("Path to RRDTool Database For Monitoring Engine Statistics"), $attrsText ); -$form->addElement('text', 'len_storage_rrd', _("RRDTool database size"), $attrsText2); -$form->addElement('text', 'len_storage_mysql', _("Retention Duration for Data in MySQL"), $attrsText2); -$form->addElement('text', 'len_storage_downtimes', _("Retention Duration for Downtimes"), $attrsText2); -$form->addElement('text', 'len_storage_comments', _("Retention Duration for Comments"), $attrsText2); -$form->addElement('text', 'archive_retention', _("Logs retention duration"), $attrsText2); -$form->addElement('text', 'reporting_retention', _("Reporting retention duration (dashboard)"), $attrsText2); +$form->addElement('text', 'len_storage_rrd', _("Retention duration for performance data in RRDTool databases"), $attrsText2); +$form->addElement('text', 'len_storage_mysql', _("Retention duration for performance data in MySQL database"), $attrsText2); +$form->addElement('text', 'len_storage_downtimes', _("Retention duration for downtimes"), $attrsText2); +$form->addElement('text', 'len_storage_comments', _("Retention duration for comments"), $attrsText2); +$form->addElement('text', 'archive_retention', _("Retention duration for logs"), $attrsText2); +$form->addElement('text', 'reporting_retention', _("Retention duration for reporting data (Dashboard)"), $attrsText2); $form->addElement('checkbox', 'audit_log_option', _("Enable/Disable audit logs")); // Parameters for Partitioning -$form->addElement('text', 'partitioning_retention', _("Retention Duration for partitioning (in days)"), $attrsText2); -$form->addElement('text', 'partitioning_retention_forward', _("Provisioning partitions (in days)"), $attrsText2); +$form->addElement('text', 'partitioning_retention', _("Retention duration for partitioning"), $attrsText2); +$form->addElement('text', 'partitioning_retention_forward', _("Forward provisioning"), $attrsText2); $form->addElement('text', 'partitioning_backup_directory', _("Backup directory for partitioning"), $attrsText); From b261fb5bb38dcbeac4a77547e38b6ef99c25e36e Mon Sep 17 00:00:00 2001 From: cgagnaire Date: Wed, 12 Jul 2017 17:50:21 +0200 Subject: [PATCH 012/207] enhance configuration handling (#5439) * enhance configuration handling * enhance configuration handling * enhance configuration handling * add space --- bin/centreon-partitioning.php | 11 +++++----- cron/centreon-partitioning.php | 11 +++++----- www/class/centreon-partition/config.class.php | 22 +++++++++++-------- 3 files changed, 25 insertions(+), 19 deletions(-) diff --git a/bin/centreon-partitioning.php b/bin/centreon-partitioning.php index eeac664c80c..502f385d976 100644 --- a/bin/centreon-partitioning.php +++ b/bin/centreon-partitioning.php @@ -50,10 +50,11 @@ } /* Create partitioned tables */ -$database = new CentreonDB('centstorage', 3, false); +$centreonDb = new CentreonDB('centreon'); +$centstorageDb = new CentreonDB('centstorage', 3, false); $partEngine = new PartEngine(); -if (!$partEngine->isCompatible($database)) { +if (!$partEngine->isCompatible($centstorageDb)) { exitProcess(PROCESS_ID, 1, "[".date(DATE_RFC822)."] CRITICAL: MySQL server is not compatible with partitioning. MySQL version must be greater or equal to 5.1\n"); } @@ -61,12 +62,12 @@ try { $configFile = _CENTREON_PATH_ . '/config/partition.d/partitioning-' . $table . '.xml'; - $config = new Config($database, $configFile); + $config = new Config($centstorageDb, $configFile, $centreonDb); $mysqlTable = $config->getTable($table); - if ($partEngine->isPartitioned($mysqlTable, $database)) { + if ($partEngine->isPartitioned($mysqlTable, $centstorageDb)) { throw new \Exception("Table " . $table . " is already partitioned\n"); } - $partEngine->migrate($mysqlTable, $database); + $partEngine->migrate($mysqlTable, $centstorageDb); } catch (\Exception $e) { echo "[" . date(DATE_RFC822) . "] " . $e->getMessage(); echo "[" . date(DATE_RFC822) . "] PARTITIONING EXITED\n"; diff --git a/cron/centreon-partitioning.php b/cron/centreon-partitioning.php index 1f061953c4e..69da8c3166c 100644 --- a/cron/centreon-partitioning.php +++ b/cron/centreon-partitioning.php @@ -44,10 +44,11 @@ echo "[" . date(DATE_RFC822) . "] PARTITIONING STARTED\n"; /* Create partitioned tables */ -$database = new CentreonDB('centstorage', 3, false); +$centreonDb = new CentreonDB('centreon'); +$centstorageDb = new CentreonDB('centstorage', 3, false); $partEngine = new PartEngine(); -if (!$partEngine->isCompatible($database)) { +if (!$partEngine->isCompatible($centstorageDb)) { exitProcess(PROCESS_ID, 1, "[".date(DATE_RFC822)."] CRITICAL: MySQL server is not compatible with partitionning. MySQL version must be greater or equal to 5.1\n"); } @@ -60,10 +61,10 @@ try { foreach ($tables as $table) { - $config = new Config($database, _CENTREON_PATH_ . '/config/partition.d/partitioning-' . $table . '.xml'); + $config = new Config($centstorageDb, _CENTREON_PATH_ . '/config/partition.d/partitioning-' . $table . '.xml', $centreonDb); $mysqlTable = $config->getTable($table); - if ($partEngine->isPartitioned($mysqlTable, $database)) { - $partEngine->updateParts($mysqlTable, $database); + if ($partEngine->isPartitioned($mysqlTable, $centstorageDb)) { + $partEngine->updateParts($mysqlTable, $centstorageDb); } } } catch (\Exception $e) { diff --git a/www/class/centreon-partition/config.class.php b/www/class/centreon-partition/config.class.php index 0bd9214b768..673d3854ac7 100644 --- a/www/class/centreon-partition/config.class.php +++ b/www/class/centreon-partition/config.class.php @@ -48,19 +48,23 @@ class Config public $XMLfile; private $defaultConfiguration; public $tables; - public $db; + public $centstorageDb; + private $centreonDb; /** * Class constructor * - * @param CentreonDB $db the centreon database - * @param string $file the xml file name + * @param CentreonDB $centstorageDb the centstorage database + * @param string $file the xml file name + * @param CentreonDB $centreonDb the centreon database */ - public function __construct($db, $file) + public function __construct($centstorageDb, $file, $centreonDb) { $this->XMLFile = $file; - $this->db = $db; + $this->centstorageDb = $centstorageDb; + $this->centreonDb = $centreonDb; $this->tables = array(); + $this->loadCentreonDefaultConfiguration(); $this->parseXML($this->XMLFile); } @@ -72,10 +76,10 @@ public function loadCentreonDefaultConfiguration() $queryOptions = 'SELECT `opt`.`key`, `opt`.`value` ' . 'FROM `options` opt ' . 'WHERE `opt`.`key` IN (' . - '`partitioning_backup_directory`, `partitioning_backup_format`, ' . - '`partitioning_retention`, `partitioning_retention_forward`' . + "'partitioning_backup_directory', 'partitioning_backup_format', " . + "'partitioning_retention', 'partitioning_retention_forward'" . ')'; - $res = $this->db->query($queryOptions); + $res = $this->centreonDb->query($queryOptions); if (\PEAR::isError($res)) { throw new \Exception("Can't load default configuration for Centreon Partitioning"); @@ -101,7 +105,7 @@ public function parseXML($xmlfile) $node = new SimpleXMLElement(file_get_contents($xmlfile)); foreach ($node->table as $table_config) { $table = new MysqlTable( - $this->db, + $this->centstorageDb, (string) $table_config["name"], (string) dbcstg ); From e46916f6b3f9f579412c119d399b8155da2da025 Mon Sep 17 00:00:00 2001 From: mariegallardo Date: Wed, 12 Jul 2017 18:00:08 +0200 Subject: [PATCH 013/207] AutologinOptions feature created (#5437) * File created * behat updated --- behat.yml | 5 ++ features/AutologinOptions.feature | 17 ++++ .../bootstrap/AutologinOptionsContext.php | 82 +++++++++++++++++++ 3 files changed, 104 insertions(+) create mode 100644 features/AutologinOptions.feature create mode 100644 features/bootstrap/AutologinOptionsContext.php diff --git a/behat.yml b/behat.yml index 3a519de22da..c86775d96b2 100644 --- a/behat.yml +++ b/behat.yml @@ -129,6 +129,11 @@ default: contexts: - AutologinContext + autologin_options: + paths: [ %paths.base%/features/AutologinOptions.feature ] + contexts: + - AutologinOptionsContext + broker: paths: [ %paths.base%/features/Broker.feature ] contexts: diff --git a/features/AutologinOptions.feature b/features/AutologinOptions.feature new file mode 100644 index 00000000000..aa047f27b33 --- /dev/null +++ b/features/AutologinOptions.feature @@ -0,0 +1,17 @@ +Feature: Autologin Options + As a Centreon user + I want to display specific Centreon web Pages on a large screen device + So that supervisors can watch the monitoring easily in the office room + + Background: + Given I am logged in a Centreon server + And one autologin key has been generated + And the autologin option is enabled + + Scenario: Autologin with full screen option + When I type the autologin url with the fullscreen option in my web browser + Then Centreon default page is displayed without the menus and the header + + Scenario: Autologin to Reporting Dashboards Hosts page + When I type the autologin url with the option page 30701 + Then Reporting > Dashboards > Hosts page is displayed diff --git a/features/bootstrap/AutologinOptionsContext.php b/features/bootstrap/AutologinOptionsContext.php new file mode 100644 index 00000000000..490d9b7cfdf --- /dev/null +++ b/features/bootstrap/AutologinOptionsContext.php @@ -0,0 +1,82 @@ +currentPage = new CurrentUserConfigurationPage($this); + $this->currentPage->setProperties(array( + 'autologin_key' => 'autolog' + )); + $this->currentPage->save(); + } + + /** + * @Given the autologin option is enabled + */ + public function theAutologinOptionIsEnabled() + { + $this->currentPage = new ParametersCentreonUIPage($this); + $this->currentPage->setProperties(array( + 'enable autologin' => true + )); + $this->currentPage->save(); + } + + /** + * @When I type the autologin url with the fullscreen option in my web browser + */ + public function iTypeTheAutologinUrlWithTheFullscreenOptionInMyWebBrowser() + { + $this->visit('main.php?autologin=1&useralias=admin&token=autolog&min=1'); + $this->currentPage = $this->getSession()->getPage(); + } + + /** + * @Then Centreon default page is displayed without the menus and the header + */ + public function centreonDefaultPageIsDisplayedWithoutTheMenusAndTheHeader() + { + $this->spin( + function ($context) { + $element = $this->currentPage->find('css', 'div.toggleEdit'); + return !is_null($element); + }, + 'The current page is not valid.', + 5 + ); + } + + /** + * @When I type the autologin url with the option page :arg1 + */ + public function iTypeTheAutologinUrlWithTheOptionPage($arg1 = 30701) + { + $this->visit('main.php?p=30701&autologin=1&useralias=admin&token=autolog'); + $this->currentPage = $this->getSession()->getPage(); + } + + /** + * @Then Reporting > Dashboards > Hosts page is displayed + */ + public function reportingDashboardsHostsPageIsDisplayed() + { + $this->spin( + function ($context) { + $element = $this->currentPage->find('css', 'select[name="host"]'); + return !is_null($element); + }, + 'The current page is not valid.', + 5 + ); + } +} From ff3db102635af1852ed5b7dbb6b719bf10d5d9b8 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Date: Wed, 12 Jul 2017 18:04:17 +0200 Subject: [PATCH 014/207] [Load views] Fixed database entry duplication (#5260) * Fixed database entry duplication * Fix coding style * Fix "unique" field in table "custom_view_user_relation" * Update Update-DB-2.8.8_to_2.9.0.sql * Update and rename Update-DB-2.8.8_to_2.9.0.sql to Update-DB-2.8.10_to_2.9.0.sql --- www/class/centreonCustomView.class.php | 26 ++++++++++++++----- www/install/createTables.sql | 3 ++- .../centreon/Update-DB-2.8.10_to_2.9.0.sql | 25 +++++++++++++++++- 3 files changed, 45 insertions(+), 9 deletions(-) diff --git a/www/class/centreonCustomView.class.php b/www/class/centreonCustomView.class.php index 7a20e358bbe..3be4868dea1 100644 --- a/www/class/centreonCustomView.class.php +++ b/www/class/centreonCustomView.class.php @@ -594,7 +594,8 @@ public function syncCustomView($customViewId, $userId = null) public function loadCustomView($params) { $isLocked = 1; - $query = 'SELECT custom_view_id, locked ' . + $update = false; + $query = 'SELECT custom_view_id, locked, user_id ' . 'FROM custom_view_user_relation ' . 'WHERE custom_view_id = :viewLoad ' . 'AND ' . @@ -616,14 +617,25 @@ public function loadCustomView($params) if ($row['locked'] == "0") { $isLocked = $row['locked']; } + if (!is_null($row['user_id']) && $row['user_id'] > 0){ + $update = true; + } } - $query = 'INSERT INTO custom_view_user_relation (custom_view_id,user_id,is_owner,locked,is_share) ' . - 'VALUES (:viewLoad, :userId, 0, :isLocked, 1)'; - $stmt = $this->db->prepare($query); - $stmt->bindParam(':viewLoad', $params['viewLoad'], PDO::PARAM_INT); - $stmt->bindParam(':userId', $this->userId, PDO::PARAM_INT); - $stmt->bindParam(':isLocked', $isLocked, PDO::PARAM_INT); + if ($update) { + $query = 'UPDATE custom_view_user_relation SET is_consumed=1 WHERE ' . + ' custom_view_id = :viewLoad AND user_id = :userId'; + $stmt = $this->db->prepare($query); + $stmt->bindParam(':viewLoad', $params['viewLoad'], PDO::PARAM_INT); + $stmt->bindParam(':userId', $this->userId, PDO::PARAM_INT); + } else { + $query = 'INSERT INTO custom_view_user_relation (custom_view_id,user_id,is_owner,locked,is_share) ' . + 'VALUES (:viewLoad, :userId, 0, :isLocked, 1)'; + $stmt = $this->db->prepare($query); + $stmt->bindParam(':viewLoad', $params['viewLoad'], PDO::PARAM_INT); + $stmt->bindParam(':userId', $this->userId, PDO::PARAM_INT); + $stmt->bindParam(':isLocked', $isLocked, PDO::PARAM_INT); + } $dbResult = $stmt->execute(); if (!$dbResult) { throw new \Exception("An error occured"); diff --git a/www/install/createTables.sql b/www/install/createTables.sql index b9cdf068f13..47839136ec8 100644 --- a/www/install/createTables.sql +++ b/www/install/createTables.sql @@ -965,7 +965,8 @@ CREATE TABLE `custom_view_user_relation` ( `is_owner` tinyint(6) DEFAULT '0', `is_share` tinyint(6) DEFAULT '0', `is_consumed` int(1) NOT NULL DEFAULT 1, - UNIQUE KEY `view_user_unique_index` (`custom_view_id`,`user_id`,`usergroup_id`), + UNIQUE KEY `view_user_unique_index` (`custom_view_id`,`user_id`), + UNIQUE KEY `view_usergroup_unique_index` (`custom_view_id`,`usergroup_id`), KEY `fk_custom_views_user_id` (`user_id`), KEY `fk_custom_views_usergroup_id` (`usergroup_id`), CONSTRAINT `fk_custom_views_user_id` FOREIGN KEY (`user_id`) REFERENCES `contact` (`contact_id`) ON DELETE CASCADE, diff --git a/www/install/sql/centreon/Update-DB-2.8.10_to_2.9.0.sql b/www/install/sql/centreon/Update-DB-2.8.10_to_2.9.0.sql index 30c44cebc9f..fde40c2de02 100644 --- a/www/install/sql/centreon/Update-DB-2.8.10_to_2.9.0.sql +++ b/www/install/sql/centreon/Update-DB-2.8.10_to_2.9.0.sql @@ -13,4 +13,27 @@ WHERE `fieldname` = 'negociation'; UPDATE `cfg_centreonbroker_info` SET `config_key` = 'negotiation' -WHERE `config_key` = 'negociation'; \ No newline at end of file +WHERE `config_key` = 'negociation'; + +-- Delete duplicate entries in custom_view_user_relation +ALTER TABLE `custom_view_user_relation` + DROP FOREIGN KEY `fk_custom_views_usergroup_id`, + DROP FOREIGN KEY `fk_custom_views_user_id`, + DROP FOREIGN KEY `fk_custom_view_user_id`, + DROP INDEX `view_user_unique_index`; +ALTER IGNORE TABLE `custom_view_user_relation` + ADD UNIQUE INDEX `view_user_unique_index` (`custom_view_id`, `user_id`), + ADD UNIQUE INDEX `view_usergroup_unique_index` (`custom_view_id`, `usergroup_id`); +ALTER TABLE `custom_view_user_relation` + ADD CONSTRAINT `fk_custom_views_usergroup_id` + FOREIGN KEY (`usergroup_id`) + REFERENCES `centreon`.`contactgroup` (`cg_id`) + ON DELETE CASCADE, + ADD CONSTRAINT `fk_custom_views_user_id` + FOREIGN KEY (`user_id`) + REFERENCES `centreon`.`contact` (`contact_id`) + ON DELETE CASCADE, + ADD CONSTRAINT `fk_custom_view_user_id` + FOREIGN KEY (`custom_view_id`) + REFERENCES `centreon`.`custom_views` (`custom_view_id`) + ON DELETE CASCADE; \ No newline at end of file From 168caf1bf5a6915666bab9ce76d165fde3d56f60 Mon Sep 17 00:00:00 2001 From: mariegallardo Date: Wed, 12 Jul 2017 18:05:26 +0200 Subject: [PATCH 015/207] New Feature ACLResourcesAccess (#5422) * New Feature ACLResourcesAccess * * fix style --- behat.yml | 5 + features/ACLResourcesAccess.feature | 33 + .../bootstrap/ACLResourcesAccessContext.php | 575 ++++++++++++++++++ 3 files changed, 613 insertions(+) create mode 100644 features/ACLResourcesAccess.feature create mode 100644 features/bootstrap/ACLResourcesAccessContext.php diff --git a/behat.yml b/behat.yml index c86775d96b2..39c8a2e116b 100644 --- a/behat.yml +++ b/behat.yml @@ -224,6 +224,11 @@ default: contexts: - ACLMenusAccessContext + acl_resources_access: + paths: [ %paths.base%/features/ACLResourcesAccess.feature ] + contexts: + - ACLResourcesAccessContext + non_admin_contact_creation: paths: [ %paths.base%/features/NonAdminContactCreation.feature ] contexts: diff --git a/features/ACLResourcesAccess.feature b/features/ACLResourcesAccess.feature new file mode 100644 index 00000000000..ccb6cf2ccba --- /dev/null +++ b/features/ACLResourcesAccess.feature @@ -0,0 +1,33 @@ +Feature: ACL Resources Access administration + As a Centreon administrator + I want to administrate Resources Access + To give access to Centreon objects to users according their role in the company + + Background: + Given I am logged in a Centreon server + And three ACL access groups including non admin users exist + + Scenario: Creating Resources Access linked to several access groups + When I add a new Resources access linked with two groups + Then the Resources access is saved with its properties + And only chosen linked access groups display the new Resources access in Authorized information tab + + Scenario: Remove one access group from Resources access + Given one existing Resources access linked with two access groups + When I remove one access group + Then link between access group and Resources access must be broken + + Scenario: Duplicate one existing Resources access record + Given one existing Resources access + When I duplicate the Resources access + Then a new Resources access record is created with identical properties except the name + + Scenario: Modify one existing Resources access record + Given one existing enabled Resources access record + When I modify some properties such as name, description, comments or status + Then the modifications are saved + + Scenario: Delete one existing Resources access record + Given one existing Resources access + When I delete the Resources access + Then the Resources access record is not visible anymore in Resources Access page diff --git a/features/bootstrap/ACLResourcesAccessContext.php b/features/bootstrap/ACLResourcesAccessContext.php new file mode 100644 index 00000000000..a1e44a95495 --- /dev/null +++ b/features/bootstrap/ACLResourcesAccessContext.php @@ -0,0 +1,575 @@ + 'aclResourceName', + 'acl_alias' => 'aclResourceAlias', + 'acl_groups' => array( + 'aclGroupName1', + 'aclGroupName2' + ), + 'enabled' => 1, + 'comments' => 'aclResourceComment', + 'all_hosts' => 0, + 'hosts' => 'hostName1', + 'all_hostgroups' => 0, + 'host_groups' => 'hostGroupName', + 'excluded_hosts' => 'hostName2', + 'all_servicegroups' => 0, + 'service_groups' => 'serviceGroupName', + 'meta_services' => 'metaServiceName', + 'pollers' => 'Central', + 'host_category' => 'hostCategoryName', + 'service_category' => 'serviceCategoryName' + )); + + protected $duplicatedProperties = (array( + 'acl_name' => 'aclResourceName_1', + 'acl_alias' => 'aclResourceAlias', + 'acl_groups' => array( + 'aclGroupName1', + 'aclGroupName2' + ), + 'enabled' => 1, + 'comments' => 'aclResourceComment', + 'all_hosts' => 0, + 'hosts' => 'hostName1', + 'all_hostgroups' => 0, + 'host_groups' => 'hostGroupName', + 'excluded_hosts' => 'hostName2', + 'all_servicegroups' => 0, + 'service_groups' => 'serviceGroupName', + 'meta_services' => 'metaServiceName', + 'pollers' => 'Central', + 'host_category' => 'hostCategoryName', + 'service_category' => 'serviceCategoryName' + )); + + protected $updatedProperties = (array( + 'acl_name' => 'aclResourceNameChanged', + 'acl_alias' => 'aclResourceAliasChanged', + 'acl_groups' => array( + 'aclGroupName3', + 'aclGroupName2' + ), + 'enabled' => 0, + 'comments' => 'aclResourceCommentChanged', + 'all_hosts' => 0, + 'hosts' => 'hostName1', + 'all_hostgroups' => 0, + 'host_groups' => 'hostGroupName', + 'excluded_hosts' => 'hostName2', + 'all_servicegroups' => 0, + 'service_groups' => 'serviceGroupName', + 'meta_services' => 'metaServiceName', + 'pollers' => 'Central', + 'host_category' => 'hostCategoryName', + 'service_category' => 'serviceCategoryName' + )); + + protected $host1 = (array( + 'name' => 'hostName1', + 'alias' => 'hostAlias1', + 'address' => 'host1@localhost' + )); + + protected $host2 = (array( + 'name' => 'hostName2', + 'alias' => 'hostAlias2', + 'address' => 'host2@localhost' + )); + + protected $hostGroup = (array( + 'name' => 'hostGroupName', + 'alias' => 'hostGroupAlias' + )); + + protected $hostCategory = (array( + 'name' => 'hostCategoryName', + 'alias' => 'hostCategoryAlias' + )); + + protected $serviceGroup = (array( + 'name' => 'serviceGroupName', + 'description' => 'serviceGroupDescription' + )); + + protected $serviceCategory = (array( + 'name' => 'serviceCategoryName', + 'description' => 'serviceCategoryDescription' + )); + + protected $metaService = (array( + 'name' => 'metaServiceName', + 'max_check_attempts' => '5' + )); + + protected $aclGroup1 = (array( + 'group_name' => 'aclGroupName1', + 'group_alias' => 'aclGroupAlias1' + )); + + protected $aclGroup2 = (array( + 'group_name' => 'aclGroupName2', + 'group_alias' => 'aclGroupAlias2' + )); + + protected $aclGroup3 = (array( + 'group_name' => 'aclGroupName3', + 'group_alias' => 'aclGroupAlias3' + )); + + protected $linkedAclResource = (array( + 'acl_name' => 'aclResourceName', + 'acl_groups' => array( + 'aclGroupName1', + 'aclGroupName2' + ) + )); + + /** + * @Given three ACL access groups including non admin users exist + */ + public function threeACLAccessGroupsIncludingNonAdminUsersExist() + { + $this->currentPage = new ACLGroupConfigurationPage($this); + $this->currentPage->setProperties($this->aclGroup1); + $this->currentPage->save(); + $this->currentPage = new ACLGroupConfigurationPage($this); + $this->currentPage->setProperties($this->aclGroup2); + $this->currentPage->save(); + $this->currentPage = new ACLGroupConfigurationPage($this); + $this->currentPage->setProperties($this->aclGroup3); + $this->currentPage->save(); + } + + /** + * @When I add a new Resources access linked with two groups + */ + public function iAddANewResourcesAccessLinkedWithTwoGroups() + { + $this->currentPage = new HostConfigurationPage($this); + $this->currentPage->setProperties($this->host1); + $this->currentPage->save(); + $this->currentPage = new HostConfigurationPage($this); + $this->currentPage->setProperties($this->host2); + $this->currentPage->save(); + $this->currentPage = new HostGroupConfigurationPage($this); + $this->currentPage->setProperties($this->hostGroup); + $this->currentPage->save(); + $this->currentPage = new HostCategoryConfigurationPage($this); + $this->currentPage->setProperties($this->hostCategory); + $this->currentPage->save(); + $this->currentPage = new ServiceGroupConfigurationPage($this); + $this->currentPage->setProperties($this->serviceGroup); + $this->currentPage->save(); + $this->currentPage = new ServiceCategoryConfigurationPage($this); + $this->currentPage->setProperties($this->serviceCategory); + $this->currentPage->save(); + $this->currentPage = new MetaServiceConfigurationPage($this); + $this->currentPage->setProperties($this->metaService); + $this->currentPage->save(); + $this->currentPage = new ACLResourceConfigurationPage($this); + $this->currentPage->setProperties($this->initialProperties); + $this->currentPage->save(); + } + + /** + * @Then the Resources access is saved with its properties + */ + public function theResourcesAccessIsSavedWithItsProperties() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new ACLResourceConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['acl_name']); + $object = $this->currentPage->getProperties(); + foreach ($this->initialProperties as $key => $value) { + if ($key != 'acl_groups' && $value != $object[$key]) { + if ($value != $object[$key][0]) { + $this->tableau[] = $key; + } + } + if ($key == 'acl_groups') { + if (count($object[$key]) != 0 && $object[$key][0] != $this->aclGroup1['group_name'] + && $object[$key][1] != $this->aclGroup2['group_name'] + ) { + $this->tableau[] = $key; + } + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @Then only chosen linked access groups display the new Resources access in Authorized information tab + */ + public function onlyChosenLinkedAccessGroupsDisplayTheNewResourcesAccessInAuthorizedInformationTab() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new ACLGroupConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->aclGroup1['group_name']); + $object = $this->currentPage->getProperties(); + if ($object['resources'][0] != $this->initialProperties['acl_name']) { + $this->tableau[] = $this->aclGroup1['group_name']; + } + $this->currentPage = new ACLGroupConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->aclGroup2['group_name']); + $object = $this->currentPage->getProperties(); + if ($object['resources'][0] != $this->initialProperties['acl_name']) { + $this->tableau[] = $this->aclGroup2['group_name']; + } + $this->currentPage = new ACLGroupConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->aclGroup3['group_name']); + $object = $this->currentPage->getProperties(); + if (count($object['resources']) != 0) { + $this->tableau[] = $this->aclGroup3['group_name']; + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + + } + + /** + * @Given one existing Resources access linked with two access groups + */ + public function oneExistingResourcesAccessLinkedWithTwoAccessGroups() + { + $this->currentPage = new ACLResourceConfigurationPage($this); + $this->currentPage->setProperties($this->linkedAclResource); + $this->currentPage->save(); + } + + /** + * @When I remove one access group + */ + public function iRemoveOneAccessGroup() + { + $this->currentPage = new ACLResourceConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->linkedAclResource['acl_name']); + $this->currentPage->setProperties(array( + 'acl_groups' => array( + 'aclGroupName1' + ) + )); + $this->currentPage->save(); + } + + /** + * @Then link between access group and Resources access must be broken + */ + public function linkBetweenAccessGroupAndResourcesAccessMustBeBroken() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new ACLResourceConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->linkedAclResource['acl_name']); + $object = $this->currentPage->getProperties(); + if (count($object['acl_groups']) != 1 || + $object['acl_groups'][0] != $this->aclGroup1['group_name'] + ) { + $this->tableau[] = $this->linkedAclResource['acl_name']; + } + $this->currentPage = new ACLGroupConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->aclGroup1['group_name']); + $object = $this->currentPage->getProperties(); + if ($object['resources'][0] != $this->initialProperties['acl_name']) { + $this->tableau[] = $this->aclGroup1['group_name']; + } + $this->currentPage = new ACLGroupConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->aclGroup2['group_name']); + $object = $this->currentPage->getProperties(); + if (count($object['resources']) != 0) { + $this->tableau[] = $this->aclGroup2['group_name']; + } + $this->currentPage = new ACLGroupConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->aclGroup3['group_name']); + $object = $this->currentPage->getProperties(); + if (count($object['resources']) != 0) { + $this->tableau[] = $this->aclGroup3['group_name']; + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @Given one existing Resources access + */ + public function oneExistingResourcesAccess() + { + $this->currentPage = new HostConfigurationPage($this); + $this->currentPage->setProperties($this->host1); + $this->currentPage->save(); + $this->currentPage = new HostConfigurationPage($this); + $this->currentPage->setProperties($this->host2); + $this->currentPage->save(); + $this->currentPage = new HostGroupConfigurationPage($this); + $this->currentPage->setProperties($this->hostGroup); + $this->currentPage->save(); + $this->currentPage = new HostCategoryConfigurationPage($this); + $this->currentPage->setProperties($this->hostCategory); + $this->currentPage->save(); + $this->currentPage = new ServiceGroupConfigurationPage($this); + $this->currentPage->setProperties($this->serviceGroup); + $this->currentPage->save(); + $this->currentPage = new ServiceCategoryConfigurationPage($this); + $this->currentPage->setProperties($this->serviceCategory); + $this->currentPage->save(); + $this->currentPage = new MetaServiceConfigurationPage($this); + $this->currentPage->setProperties($this->metaService); + $this->currentPage->save(); + $this->currentPage = new ACLResourceConfigurationPage($this); + $this->currentPage->setProperties($this->initialProperties); + $this->currentPage->save(); + } + + /** + * @When I duplicate the Resources access + */ + public function iDuplicateTheResourcesAccess() + { + $this->currentPage = new ACLResourceConfigurationListingPage($this); + $object = $this->currentPage->getEntry($this->initialProperties['acl_name']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Duplicate'); + } + + /** + * @Then a new Resources access record is created with identical properties except the name + */ + public function aNewResourcesAccessRecordIsCreatedWithIdenticalPropertiesExceptTheName() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new ACLResourceConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->duplicatedProperties['acl_name']); + $object = $this->currentPage->getProperties(); + foreach ($this->duplicatedProperties as $key => $value) { + if ($key != 'acl_groups' && $value != $object[$key]) { + if ($value != $object[$key][0]) { + $this->tableau[] = $key; + } + } + if ($key == 'acl_groups') { + if (count($object[$key]) != 0 && $object[$key][0] != $this->aclGroup1['group_name'] + && $object[$key][1] != $this->aclGroup2['group_name'] + ) { + $this->tableau[] = $key; + } + } + } + $this->currentPage = new ACLGroupConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->aclGroup1['group_name']); + $object = $this->currentPage->getProperties(); + if (count($object['resources']) == 2 + && $object['resources'][0] != $this->initialProperties['acl_name'] + && $object['resources'][1] != $this->duplicatedProperties['acl_name'] + ) { + $this->tableau[] = $this->aclGroup1['group_name']; + } + $this->currentPage = new ACLGroupConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->aclGroup2['group_name']); + $object = $this->currentPage->getProperties(); + if (count($object['resources']) == 2 + && $object['resources'][0] != $this->initialProperties['acl_name'] + && $object['resources'][1] != $this->duplicatedProperties['acl_name'] + ) { + $this->tableau[] = $this->aclGroup2['group_name']; + } + $this->currentPage = new ACLGroupConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->aclGroup3['group_name']); + $object = $this->currentPage->getProperties(); + if (count($object['resources']) != 0) { + $this->tableau[] = $this->aclGroup3['group_name']; + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @Given one existing enabled Resources access record + */ + public function oneExistingEnabledResourcesAccessRecord() + { + $this->currentPage = new HostConfigurationPage($this); + $this->currentPage->setProperties($this->host1); + $this->currentPage->save(); + $this->currentPage = new HostConfigurationPage($this); + $this->currentPage->setProperties($this->host2); + $this->currentPage->save(); + $this->currentPage = new HostGroupConfigurationPage($this); + $this->currentPage->setProperties($this->hostGroup); + $this->currentPage->save(); + $this->currentPage = new HostCategoryConfigurationPage($this); + $this->currentPage->setProperties($this->hostCategory); + $this->currentPage->save(); + $this->currentPage = new ServiceGroupConfigurationPage($this); + $this->currentPage->setProperties($this->serviceGroup); + $this->currentPage->save(); + $this->currentPage = new ServiceCategoryConfigurationPage($this); + $this->currentPage->setProperties($this->serviceCategory); + $this->currentPage->save(); + $this->currentPage = new MetaServiceConfigurationPage($this); + $this->currentPage->setProperties($this->metaService); + $this->currentPage->save(); + $this->currentPage = new ACLResourceConfigurationPage($this); + $this->currentPage->setProperties($this->initialProperties); + $this->currentPage->save(); + } + + /** + * @When I modify some properties such as name, description, comments or status + */ + public function iModifySomePropertiesSuchAsNameDescriptionCommentsOrStatus() + { + $this->currentPage = new ACLResourceConfigurationPage($this); + $this->currentPage->setProperties($this->updatedProperties); + $this->currentPage->save(); + } + + /** + * @Then the modifications are saved + */ + public function theModificationsAreSaved() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new ACLResourceConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->updatedProperties['acl_name']); + $object = $this->currentPage->getProperties(); + foreach ($this->updatedProperties as $key => $value) { + if ($key != 'acl_groups' && $value != $object[$key]) { + if ($value != $object[$key][0]) { + $this->tableau[] = $key; + } + } + if ($key == 'acl_groups') { + if (count($object[$key]) != 0 && $object[$key][0] != $this->aclGroup2['group_name'] + && $object[$key][1] != $this->aclGroup3['group_name'] + ) { + $this->tableau[] = $key; + } + } + } + $this->currentPage = new ACLGroupConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->aclGroup3['group_name']); + $object = $this->currentPage->getProperties(); + if ($object['resources'][0] != $this->updatedProperties['acl_name']) { + $this->tableau[] = $this->aclGroup3['group_name']; + } + $this->currentPage = new ACLGroupConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->aclGroup2['group_name']); + $object = $this->currentPage->getProperties(); + if (count($object['resources']) == 2 + && $object['resources'][0] != $this->initialProperties['acl_name'] + && $object['resources'][1] != $this->updatedProperties['acl_name'] + ) { + $this->tableau[] = $this->aclGroup2['group_name']; + } + $this->currentPage = new ACLGroupConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->aclGroup1['group_name']); + $object = $this->currentPage->getProperties(); + if (count($object['resources']) != 1 + && $object['resources'][0] != $this->initialProperties['acl_name'] + ) { + $this->tableau[] = $this->aclGroup1['group_name']; + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I delete the Resources access + */ + public function iDeleteResourcesAccess() + { + $this->currentPage = new ACLResourceConfigurationListingPage($this); + $object = $this->currentPage->getEntry($this->initialProperties['acl_name']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Delete'); + } + + /** + * @Then the Resources access record is not visible anymore in Resources Access page + */ + public function theResourcesAccessRecordIsNotVisibleAnymoreInResourcesAccessPage() + { + $this->spin( + function ($context) { + $this->currentPage = new ACLResourceConfigurationListingPage($this); + $object = $this->currentPage->getEntries(); + $bool = true; + foreach ($object as $value) { + $bool = $bool && $value['name'] != $this->initialProperties['acl_name']; + } + return $bool; + }, + "The ACL Resource is not being deleted.", + 5 + ); + } +} From fb2101362616e77262ec6281fa437f1a919b887a Mon Sep 17 00:00:00 2001 From: loiclau Date: Thu, 13 Jul 2017 10:14:10 +0200 Subject: [PATCH 016/207] * add new argument in install partition config --- www/install/steps/process/partitionTables.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/www/install/steps/process/partitionTables.php b/www/install/steps/process/partitionTables.php index bf7b6726a1b..7fdadcd0e25 100644 --- a/www/install/steps/process/partitionTables.php +++ b/www/install/steps/process/partitionTables.php @@ -51,6 +51,7 @@ /* Create partitioned tables */ $database = new CentreonDB('centstorage'); +$centreonDb = new CentreonDB('centreon'); $partEngine = new PartEngine(); if (!$partEngine->isCompatible($database)) { @@ -70,7 +71,9 @@ try { foreach ($tables as $table) { $config = new Config( - $database, _CENTREON_PATH_ . '/config/partition.d/partitioning-' . $table . '.xml' + $database, + _CENTREON_PATH_ . '/config/partition.d/partitioning-' . $table . '.xml', + $centreonDb ); $mysqlTable = $config->getTable($table); $partEngine->createParts($mysqlTable, $database); From c5e26b8f0570b2e4756522060b9df85fc8d4ea58 Mon Sep 17 00:00:00 2001 From: Matthieu Mandoula Date: Thu, 13 Jul 2017 11:07:55 +0200 Subject: [PATCH 017/207] Acl access groups (#5404) * AclAccessGroups configured in behat.yml * AclAccessGroups acceptance test initialized * AclAccessGroups acceptance test * put clipboard on app head and remove old lib tool.js * * fix style * method iAddANewAccessGroupWithLinkedContactGroup() updated *move js --- behat.yml | 5 + features/AclAccessGroups.feature | 37 +++ features/bootstrap/AclAccessGroupsContext.php | 258 ++++++++++++++++++ www/include/core/header/htmlHeader.php | 1 + .../template/serviceDetails.ihtml | 2 - 5 files changed, 301 insertions(+), 2 deletions(-) create mode 100644 features/AclAccessGroups.feature create mode 100644 features/bootstrap/AclAccessGroupsContext.php diff --git a/behat.yml b/behat.yml index 39c8a2e116b..1df6c7da382 100644 --- a/behat.yml +++ b/behat.yml @@ -219,6 +219,11 @@ default: contexts: - ControlLoginContext + acl_access_groups: + paths: [ %paths.base%/features/AclAccessGroups.feature ] + contexts: + - AclAccessGroupsContext + acl_menus_access: paths: [ %paths.base%/features/ACLMenusAccess.feature ] contexts: diff --git a/features/AclAccessGroups.feature b/features/AclAccessGroups.feature new file mode 100644 index 00000000000..bd2d10a1a39 --- /dev/null +++ b/features/AclAccessGroups.feature @@ -0,0 +1,37 @@ +Feature: AclAccessGroups + As a Centreon administrator + I want to administrate ACL access groups + To give access to Centreon pages to users according their role in the company + + Background: + Given I am logged in a Centreon server + + Scenario: Creating ACL access group with linked contacts + When one contact group exists including two non admin contacts + And the access group is saved with its properties + Then all linked users have the access list group displayed in Centreon authentication tab + + Scenario: Creating ACL access group with linked contact group + When I add a new access group with linked contact group + And the access group is saved with its properties + Then the Contact group has the access list group displayed in Relations informations + + Scenario: Modify ACL access group properties + Given one existing ACL access group + When I modify its properties + Then all modified properties are updated + + Scenario: Duplicate ACL access group + Given one existing ACL access group + When I duplicate the access group + Then a new access group appears with similar properties + + Scenario: Delete ACL access group + Given one existing ACL access group + When I delete the access group + Then it does not exist anymore + + Scenario: Disable ACL access group + Given one existing enabled ACL access group + When I disable it + Then its status is modified diff --git a/features/bootstrap/AclAccessGroupsContext.php b/features/bootstrap/AclAccessGroupsContext.php new file mode 100644 index 00000000000..b6ef33c1715 --- /dev/null +++ b/features/bootstrap/AclAccessGroupsContext.php @@ -0,0 +1,258 @@ +page = new ContactConfigurationPage($this); + $this->page->setProperties(array( + 'alias' => $this->firstContactAlias, + 'name' => $this->firstContactName, + 'email' => 'test@centreon.com', + 'password' => 'firstContactPassword', + 'password2' => 'firstContactPassword', + 'admin' => 0 + )); + $this->page->save(); + $this->page = new ContactConfigurationPage($this); + $this->page->setProperties(array( + 'alias' => $this->secondContactAlias, + 'name' => $this->secondContactName, + 'email' => 'test2@centreon.com', + 'password' => 'secondContactPassword', + 'password2' => 'secondContactPassword', + 'admin' => 0 + )); + $this->page->save(); + $this->page = new ContactGroupsConfigurationPage($this); + $this->page->setProperties(array( + 'name' => $this->contactGroupName, + 'alias' => $this->contactGroupAlias + )); + $this->assertFind('css', 'span[class="select2-selection select2-selection--multiple"]')->click(); + $this->spin( + function ($context) { + return $context->getSession()->getPage()->has('css', 'span ul li div[title="' + . $this->firstContactName . '"]'); + }, + 'The user: ' . $this->firstContactName . ' does not exist or has not been found', + 5 + ); + $this->assertFind('css', 'span ul li div[title="' . $this->firstContactName . '"]')->click(); + $this->assertFind('css', 'span[class="select2-selection select2-selection--multiple"]')->click(); + $this->spin( + function ($context) { + return $context->getSession()->getPage()->has('css', 'span ul li div[title="' + . $this->secondContactName . '"]'); + }, + 'The user: ' . $this->secondContactName . ' does not exist or has not been found', + 5 + ); + $this->assertFind('css', 'span ul li div[title="' . $this->secondContactName . '"]')->click(); + $this->page->save(); + } + + /** + * @When the access group is saved with its properties + */ + public function theAccessGroupIsSavedWithItsProperties() + { + $this->page = new ACLGroupConfigurationPage($this); + $this->page->setProperties(array( + 'group_name' => $this->accessContactName, + 'group_alias' => $this->accessContactAlias, + 'contacts' => array($this->firstContactName, $this->secondContactName) + )); + $this->page->save(); + } + + /** + * @Then all linked users have the access list group displayed in Centreon authentication tab + */ + public function allLinkedUsersHaveTheAccessListGroupDisplayedInCentreonAuthenticationTab() + { + $this->page = new ContactConfigurationListingPage($this); + $this->page = $this->page->inspect($this->firstContactAlias); + $this->assertFind('css', 'li#c2 a')->click(); + $value = $this->assertFind('css', 'span[title="' . $this->accessContactName . '"]')->getText(); + if ($value != $this->accessContactName) { + + throw new \Exception($this->firstContactAlias . ' have no Access list groups displayed'); + } + + $this->page = new ContactConfigurationListingPage($this); + $this->page = $this->page->inspect($this->secondContactAlias); + $this->assertFind('css', 'li#c2 a')->click(); + $value = $this->assertFind('css', 'span[title="' . $this->accessContactName . '"]')->getText(); + if ($value != $this->accessContactName) { + throw new \Exception($this->secondContactAlias . ' have no Access list groups displayed'); + } + } + + /** + * @When I add a new access group with linked contact group + */ + public function iAddANewAccessGroupWithLinkedContactGroup() + { + $this->oneContactGroupExistsIncludingTwoNonAdminContacts(); + $this->page = new ACLGroupConfigurationPage($this); + $this->page->setProperties(array( + 'group_name' => 'accessGroupLinkedContactName', + 'group_alias' => 'accessGroupLinkedContactAlias', + 'contacts' => array($this->firstContactName, $this->secondContactName) + )); + $this->page->save(); + $this->page = new ACLGroupConfigurationPage($this); + $this->page->setProperties(array( + 'group_name' => $this->accessGroupsName, + 'group_alias' => $this->accessGroupsAlias, + 'contactgroups' => $this->contactGroupName + )); + $this->page->save(); + } + + /** + * @Then the Contact group has the access list group displayed in Relations informations + */ + public function theContactGroupHasTheAccessListGroupDisplayedInRelationsInformations() + { + $this->page = new ContactGroupConfigurationListingPage($this); + $this->page = $this->page->inspect($this->contactGroupName); + $value = $this->assertFind('css', 'span[title="' . $this->accessGroupsName . '"]')->getText(); + if ($value != $this->accessGroupsName) { + throw new \Exception($this->contactGroupName . ' have no Linked ACL groups displayed'); + } + } + + /** + * @Given one existing ACL access group + */ + public function oneExistingAclAccessGroup() + { + $this->iAddANewAccessGroupWithLinkedContactGroup(); + $this->page = new ACLGroupConfigurationListingPage($this); + } + + /** + * @When I modify its properties + */ + public function iModifyItsProperties() + { + $this->page = $this->page->inspect($this->accessGroupsName); + $this->page->setProperties(array( + 'group_name' => 'newGroupName', + 'group_alias' => 'newGroupAlias' + )); + $this->page->save(); + } + + /** + * @Then all modified properties are updated + */ + public function allModifiedPropertiesAreUpdated() + { + $this->page = new ACLGroupConfigurationListingPage($this); + $objet = $this->page->getEntries(); + if (!$objet['newGroupName'] && $objet['newGroupName']['description'] != 'newGroupAlias') { + throw new \Exception('updates has not changed'); + } + } + + /** + * @When I duplicate the access group + */ + public function iDuplicateTheAccessGroup() + { + $object = $this->page->getEntry($this->accessGroupsName); + $this->page->selectMoreAction($object, 'Duplicate'); + } + + /** + * @Then a new access group appears with similar properties + */ + public function aNewAccessGroupAppearsWithSimilarProperties() + { + $objects = $this->page->getEntries(); + if ($objects['accessGroupsName_1']) { + if ($objects['accessGroupsName_1']['description'] != $this->accessGroupsAlias) { + throw new \Exception('properties has not been duplicated'); + } + } else { + throw new Exception('the duplication did not work'); + } + } + + /** + * @When I delete the access group + */ + public function iDeleteTheAccessGroup() + { + $object = $this->page->getEntry($this->accessGroupsName); + $this->page->selectMoreAction($object, 'Delete'); + } + + /** + * @Then it does not exist anymore + */ + public function itDoesNotExistAnymore() + { + $objects = $this->page->getEntries(); + if (key_exists($this->accessGroupsName, $objects)) { + throw new Exception($this->accessGroupsName . ' is still existing'); + } + } + + /** + * @Given one existing enabled ACL access group + */ + public function oneExistingEnabledAclAccessGroup() + { + $this->iAddANewAccessGroupWithLinkedContactGroup(); + $this->page = new ACLGroupConfigurationListingPage($this); + } + + /** + * @When I disable it + */ + public function iDisableIt() + { + $this->page = $this->page->inspect($this->accessGroupsName); + $this->page->setProperties(array('status' => 0)); + $this->page->save(); + } + + /** + * @Then its status is modified + */ + public function itsStatusIsModified() + { + $this->page = new ACLGroupConfigurationListingPage($this); + $object = $this->page->getEntry($this->accessGroupsName); + if ($object['status'] != 0) { + throw new Exception($this->accessGroupsName . ' is still enabled'); + } + } +} diff --git a/www/include/core/header/htmlHeader.php b/www/include/core/header/htmlHeader.php index 0860e2fe032..49eb448ace7 100644 --- a/www/include/core/header/htmlHeader.php +++ b/www/include/core/header/htmlHeader.php @@ -93,6 +93,7 @@ + diff --git a/www/include/monitoring/objectDetails/template/serviceDetails.ihtml b/www/include/monitoring/objectDetails/template/serviceDetails.ihtml index 1b419e15095..731786a0b78 100644 --- a/www/include/monitoring/objectDetails/template/serviceDetails.ihtml +++ b/www/include/monitoring/objectDetails/template/serviceDetails.ihtml @@ -1,5 +1,3 @@ - - - {if $admin} - - {/if} + + + +
From 5be7bef307d5284e81f74e5135e534b4d97531ac Mon Sep 17 00:00:00 2001 From: mariegallardo Date: Thu, 13 Jul 2017 15:19:43 +0200 Subject: [PATCH 018/207] ContactGroupConfiguration added (#5372) * ContactGroupConfiguration added * Every scenarii gathered in one scenario * Add deleted * File cleaned * * fix style * Test fixed --- behat.yml | 5 + features/ContactGroupConfiguration.feature | 12 +++ .../bootstrap/ContactConfigurationContext.php | 8 +- .../ContactGroupConfigurationContext.php | 96 +++++++++++++++++++ 4 files changed, 117 insertions(+), 4 deletions(-) create mode 100644 features/ContactGroupConfiguration.feature create mode 100644 features/bootstrap/ContactGroupConfigurationContext.php diff --git a/behat.yml b/behat.yml index 1df6c7da382..369c24f5ef7 100644 --- a/behat.yml +++ b/behat.yml @@ -189,6 +189,11 @@ default: contexts: - HostConfigurationContext + contact_group_configuration: + paths: [ %paths.base%/features/ContactGroupConfiguration.feature ] + contexts: + - ContactGroupConfigurationContext + host_duplication_check: paths: [ %paths.base%/features/HostDuplicationCheck.feature ] contexts: diff --git a/features/ContactGroupConfiguration.feature b/features/ContactGroupConfiguration.feature new file mode 100644 index 00000000000..8139550e88a --- /dev/null +++ b/features/ContactGroupConfiguration.feature @@ -0,0 +1,12 @@ +Feature: ContactGroupConfiguration + As a Centreon admin + I want to modify an host + To see if the modification is saved on the contact group page + + Background: + Given I am logged in a Centreon server + And a contact group is configured + + Scenario: Edit a contact group + When I update the contact group properties + Then the contact group properties are updated diff --git a/features/bootstrap/ContactConfigurationContext.php b/features/bootstrap/ContactConfigurationContext.php index 2f1c9f1094a..9a4f31c2af4 100644 --- a/features/bootstrap/ContactConfigurationContext.php +++ b/features/bootstrap/ContactConfigurationContext.php @@ -7,7 +7,7 @@ class ContactConfigurationContext extends CentreonContext { private $currentPage; - private $initialProperties = (array( + private $initialProperties = array( 'name' => 'contactName', 'alias' => 'contactAlias', 'email' => 'contact@localhost', @@ -17,8 +17,8 @@ class ContactConfigurationContext extends CentreonContext 'dn' => 'contactDN', 'host_notification_period' => 'workhours', 'service_notification_period' => 'nonworkhours' - )); - private $updatedProperties = (array( + ); + private $updatedProperties = array( 'name' => 'modifiedName', 'alias' => 'modifiedAlias', 'email' => 'modified@localhost', @@ -26,7 +26,7 @@ class ContactConfigurationContext extends CentreonContext 'dn' => 'modifiedDn', 'host_notification_period' => 'workhours', 'service_notification_period' => 'nonworkhours' - )); + ); /** * @Given a contact is configured diff --git a/features/bootstrap/ContactGroupConfigurationContext.php b/features/bootstrap/ContactGroupConfigurationContext.php new file mode 100644 index 00000000000..0a56d9c44ae --- /dev/null +++ b/features/bootstrap/ContactGroupConfigurationContext.php @@ -0,0 +1,96 @@ + 'contactGroupName', + 'alias' => 'contactGroupAlias', + 'status' => 0, + 'comments' => 'contactGroupComment' + ); + + protected $updatedProperties = array( + 'name' => 'contactGroupNameChanged', + 'alias' => 'contactGroupAliasChanged', + 'contacts' => 'contactName', + 'acl' => 'aclGroupName', + 'status' => 1, + 'comments' => 'contactGroupCommentChanged' + ); + + protected $aclGroup = array( + 'group_name' => 'aclGroupName', + 'group_alias' => 'aclGroupAlias' + ); + + protected $contact = array( + 'name' => 'contactName', + 'alias' => 'contactAlias', + 'email' => 'contact@localhost', + 'password' => 'pwd', + 'password2' => 'pwd', + 'admin' => 0 + ); + + /** + * @Given a contact group is configured + */ + public function aContactGroupIsConfigured() + { + $this->currentPage = new ContactGroupsConfigurationPage($this); + $this->currentPage->setProperties($this->initialProperties); + $this->currentPage->save(); + } + + /** + * @When I update the contact group properties + */ + public function iConfigureTheContactGroupProperties() + { + $this->currentPage = new ContactConfigurationPage($this); + $this->currentPage->setProperties($this->contact); + $this->currentPage->save(); + $this->currentPage = new ACLGroupConfigurationPage($this); + $this->currentPage->setProperties($this->aclGroup); + $this->currentPage->save(); + $this->currentPage = new ContactGroupConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['name']); + $this->currentPage->setProperties($this->updatedProperties); + $this->currentPage->save(); + } + + /** + * @Then the contact group properties are updated + */ + public function theContactGroupPropertiesAreUpdated() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new ContactGroupConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->updatedProperties['name']); + $object = $this->currentPage->getProperties(); + foreach ($this->updatedProperties as $key => $value) { + if ($value != $object[$key]) { + $this->tableau[] = $key; + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } +} From f3a350c54f69160689e7f545aa1bde9a0faf8db7 Mon Sep 17 00:00:00 2001 From: loiclau Date: Thu, 13 Jul 2017 15:37:31 +0200 Subject: [PATCH 019/207] * fix pear in centreon-partition --- www/class/centreon-partition/config.class.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/www/class/centreon-partition/config.class.php b/www/class/centreon-partition/config.class.php index 673d3854ac7..66a10293f71 100644 --- a/www/class/centreon-partition/config.class.php +++ b/www/class/centreon-partition/config.class.php @@ -80,11 +80,7 @@ public function loadCentreonDefaultConfiguration() "'partitioning_retention', 'partitioning_retention_forward'" . ')'; $res = $this->centreonDb->query($queryOptions); - - if (\PEAR::isError($res)) { - throw new \Exception("Can't load default configuration for Centreon Partitioning"); - } - + while ($row = $res->fetchRow()) { $this->defaultConfiguration[$row['key']] = $row['value']; } From f36032e93af9ae484cc8fe6b8fa2b032d5340237 Mon Sep 17 00:00:00 2001 From: loiclau Date: Thu, 13 Jul 2017 15:52:39 +0200 Subject: [PATCH 020/207] * fix style --- .../monitoring/status/Common/setHistory.php | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/www/include/monitoring/status/Common/setHistory.php b/www/include/monitoring/status/Common/setHistory.php index 134e8f6a911..962084794b1 100644 --- a/www/include/monitoring/status/Common/setHistory.php +++ b/www/include/monitoring/status/Common/setHistory.php @@ -35,7 +35,7 @@ require_once realpath(dirname(__FILE__) . "/../../../../../config/centreon.config.php"); -$path = _CENTREON_PATH_."/www"; +$path = _CENTREON_PATH_ . "/www"; require_once("$path/class/centreon.class.php"); require_once("$path/class/centreonSession.class.php"); require_once("$path/class/centreonDB.class.php"); @@ -48,25 +48,25 @@ exit(); } else { - $centreon = $_SESSION['centreon']; + $centreon = $_SESSION['centreon']; - if (isset($_POST["limit"]) && isset($_POST["url"])) { - $centreon->historyLimit[$_POST["url"]] = $_POST["limit"]; - } + if (isset($_POST["limit"]) && isset($_POST["url"])) { + $centreon->historyLimit[$_POST["url"]] = $_POST["limit"]; + } - if (isset($_POST["page"]) && isset($_POST["url"])) { - $centreon->historyPage[$_POST["url"]] = $_POST["page"]; - } + if (isset($_POST["page"]) && isset($_POST["url"])) { + $centreon->historyPage[$_POST["url"]] = $_POST["page"]; + } - if (isset($_POST["search"]) && isset($_POST["url"])) { - $centreon->historySearchService[$_POST["url"]] = addslashes($_POST["search"]); - } + if (isset($_POST["search"]) && isset($_POST["url"])) { + $centreon->historySearchService[$_POST["url"]] = addslashes($_POST["search"]); + } - if (isset($_POST["search_host"]) && isset($_POST["url"])) { - $centreon->historySearch[$_POST["url"]] = addslashes($_POST["search_host"]); - } + if (isset($_POST["search_host"]) && isset($_POST["url"])) { + $centreon->historySearch[$_POST["url"]] = addslashes($_POST["search_host"]); + } - if (isset($_POST["search_output"]) && isset($_POST["url"])) { - $centreon->historySearchOutput[$_POST["url"]] = addslashes($_POST["search_output"]); - } + if (isset($_POST["search_output"]) && isset($_POST["url"])) { + $centreon->historySearchOutput[$_POST["url"]] = addslashes($_POST["search_output"]); + } } From 96a68ffdae9d724d98d47a2833d125a1870518fb Mon Sep 17 00:00:00 2001 From: loiclau Date: Thu, 13 Jul 2017 16:00:25 +0200 Subject: [PATCH 021/207] * fix pear in recurrentDowntime --- .../monitoring/recurrentDowntime/help.php | 33 +- .../monitoring/recurrentDowntime/json.php | 293 +++++++++--------- 2 files changed, 180 insertions(+), 146 deletions(-) diff --git a/www/include/monitoring/recurrentDowntime/help.php b/www/include/monitoring/recurrentDowntime/help.php index 83b93028f62..4a241be131b 100644 --- a/www/include/monitoring/recurrentDowntime/help.php +++ b/www/include/monitoring/recurrentDowntime/help.php @@ -1,6 +1,10 @@ use = $use; } - /** - * convert a string from one UTF-16 char to one UTF-8 char - * - * Normally should be handled by mb_convert_encoding, but - * provides a slower PHP-only method for installations - * that lack the multibye string extension. - * - * @param string $utf16 UTF-16 character - * @return string UTF-8 character - * @access private - */ + /** + * convert a string from one UTF-16 char to one UTF-8 char + * + * Normally should be handled by mb_convert_encoding, but + * provides a slower PHP-only method for installations + * that lack the multibye string extension. + * + * @param string $utf16 UTF-16 character + * @return string UTF-8 character + * @access private + */ function utf162utf8($utf16) { // oh please oh please oh please oh please oh please @@ -165,31 +165,31 @@ function utf162utf8($utf16) // return a 2-byte UTF-8 character // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 return chr(0xC0 | (($bytes >> 6) & 0x1F)) - . chr(0x80 | ($bytes & 0x3F)); + . chr(0x80 | ($bytes & 0x3F)); case (0xFFFF & $bytes) == $bytes: // return a 3-byte UTF-8 character // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 return chr(0xE0 | (($bytes >> 12) & 0x0F)) - . chr(0x80 | (($bytes >> 6) & 0x3F)) - . chr(0x80 | ($bytes & 0x3F)); + . chr(0x80 | (($bytes >> 6) & 0x3F)) + . chr(0x80 | ($bytes & 0x3F)); } // ignoring UTF-32 for now, sorry return ''; } - /** - * convert a string from one UTF-8 char to one UTF-16 char - * - * Normally should be handled by mb_convert_encoding, but - * provides a slower PHP-only method for installations - * that lack the multibye string extension. - * - * @param string $utf8 UTF-8 character - * @return string UTF-16 character - * @access private - */ + /** + * convert a string from one UTF-8 char to one UTF-16 char + * + * Normally should be handled by mb_convert_encoding, but + * provides a slower PHP-only method for installations + * that lack the multibye string extension. + * + * @param string $utf8 UTF-8 character + * @return string UTF-16 character + * @access private + */ function utf82utf16($utf8) { // oh please oh please oh please oh please oh please @@ -207,34 +207,34 @@ function utf82utf16($utf8) // return a UTF-16 character from a 2-byte UTF-8 char // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 return chr(0x07 & (ord($utf8{0}) >> 2)) - . chr((0xC0 & (ord($utf8{0}) << 6)) - | (0x3F & ord($utf8{1}))); + . chr((0xC0 & (ord($utf8{0}) << 6)) + | (0x3F & ord($utf8{1}))); case 3: // return a UTF-16 character from a 3-byte UTF-8 char // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 return chr((0xF0 & (ord($utf8{0}) << 4)) - | (0x0F & (ord($utf8{1}) >> 2))) - . chr((0xC0 & (ord($utf8{1}) << 6)) - | (0x7F & ord($utf8{2}))); + | (0x0F & (ord($utf8{1}) >> 2))) + . chr((0xC0 & (ord($utf8{1}) << 6)) + | (0x7F & ord($utf8{2}))); } // ignoring UTF-32 for now, sorry return ''; } - /** - * encodes an arbitrary variable into JSON format - * - * @param mixed $var any number, boolean, string, array, or object to be encoded. - * see argument 1 to Services_JSON() above for array-parsing behavior. - * if var is a strng, note that encode() always expects it - * to be in ASCII or UTF-8 format! - * - * @return mixed JSON string representation of input var or an error if a problem occurs - * @access public - */ - function encode($var) + /** + * encodes an arbitrary variable into JSON format + * + * @param mixed $var any number, boolean, string, array, or object to be encoded. + * see argument 1 to Services_JSON() above for array-parsing behavior. + * if var is a strng, note that encode() always expects it + * to be in ASCII or UTF-8 format! + * + * @return mixed JSON string representation of input var or an error if a problem occurs + * @access public + */ + public function encode($var) { switch (gettype($var)) { case 'boolean': @@ -244,21 +244,21 @@ function encode($var) return 'null'; case 'integer': - return (int) $var; + return (int)$var; case 'double': case 'float': - return (float) $var; + return (float)$var; case 'string': // STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT $ascii = ''; $strlen_var = strlen($var); - /* - * Iterate over every character in the string, - * escaping with a slash or encoding to UTF-8 where necessary - */ + /* + * Iterate over every character in the string, + * escaping with a slash or encoding to UTF-8 where necessary + */ for ($c = 0; $c < $strlen_var; ++$c) { $ord_var_c = ord($var{$c}); @@ -283,7 +283,7 @@ function encode($var) case $ord_var_c == 0x2F: case $ord_var_c == 0x5C: // double quote, slash, slosh - $ascii .= '\\'.$var{$c}; + $ascii .= '\\' . $var{$c}; break; case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)): @@ -364,26 +364,26 @@ function encode($var) } } - return '"'.$ascii.'"'; + return '"' . $ascii . '"'; case 'array': - /* - * As per JSON spec if any array key is not an integer - * we must treat the the whole array as an object. We - * also try to catch a sparsely populated associative - * array with numeric keys here because some JS engines - * will create an array with empty indexes up to - * max_index which can cause memory issues and because - * the keys, which may be relevant, will be remapped - * otherwise. - * - * As per the ECMA and JSON specification an object may - * have any string as a property. Unfortunately due to - * a hole in the ECMA specification if the key is a - * ECMA reserved word or starts with a digit the - * parameter is only accessible using ECMAScript's - * bracket notation. - */ + /* + * As per JSON spec if any array key is not an integer + * we must treat the the whole array as an object. We + * also try to catch a sparsely populated associative + * array with numeric keys here because some JS engines + * will create an array with empty indexes up to + * max_index which can cause memory issues and because + * the keys, which may be relevant, will be remapped + * otherwise. + * + * As per the ECMA and JSON specification an object may + * have any string as a property. Unfortunately due to + * a hole in the ECMA specification if the key is a + * ECMA reserved word or starts with a digit the + * parameter is only accessible using ECMAScript's + * bracket notation. + */ // treat as a JSON object if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) { @@ -433,19 +433,19 @@ function encode($var) default: return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS) ? 'null' - : new Services_JSON_Error(gettype($var)." can not be encoded as JSON string"); + : new Services_JSON_Error(gettype($var) . " can not be encoded as JSON string"); } } - /** - * array-walking function for use in generating JSON-formatted name-value pairs - * - * @param string $name name of key to use - * @param mixed $value reference to an array element to be encoded - * - * @return string JSON-formatted name-value pair, like '"name":value' - * @access private - */ + /** + * array-walking function for use in generating JSON-formatted name-value pairs + * + * @param string $name name of key to use + * @param mixed $value reference to an array element to be encoded + * + * @return string JSON-formatted name-value pair, like '"name":value' + * @access private + */ function name_value($name, $value) { $encoded_value = $this->encode($value); @@ -457,46 +457,46 @@ function name_value($name, $value) return $this->encode(strval($name)) . ':' . $encoded_value; } - /** - * reduce a string by removing leading and trailing comments and whitespace - * - * @param $str string string value to strip of comments and whitespace - * - * @return string string value stripped of comments and whitespace - * @access private - */ + /** + * reduce a string by removing leading and trailing comments and whitespace + * + * @param $str string string value to strip of comments and whitespace + * + * @return string string value stripped of comments and whitespace + * @access private + */ function reduce_string($str) { $str = preg_replace(array( - // eliminate single line comments in '// ...' form - '#^\s*//(.+)$#m', + // eliminate single line comments in '// ...' form + '#^\s*//(.+)$#m', - // eliminate multi-line comments in '/* ... */' form, at start of string - '#^\s*/\*(.+)\*/#Us', + // eliminate multi-line comments in '/* ... */' form, at start of string + '#^\s*/\*(.+)\*/#Us', - // eliminate multi-line comments in '/* ... */' form, at end of string - '#/\*(.+)\*/\s*$#Us' + // eliminate multi-line comments in '/* ... */' form, at end of string + '#/\*(.+)\*/\s*$#Us' - ), '', $str); + ), '', $str); // eliminate extraneous space return trim($str); } - /** - * decodes a JSON string into appropriate variable - * - * @param string $str JSON-formatted string - * - * @return mixed number, boolean, string, array, or object - * corresponding to given JSON input string. - * See argument 1 to Services_JSON() above for object-output behavior. - * Note that decode() always returns strings - * in ASCII or UTF-8 format! - * @access public - */ - function decode($str) + /** + * decodes a JSON string into appropriate variable + * + * @param string $str JSON-formatted string + * + * @return mixed number, boolean, string, array, or object + * corresponding to given JSON input string. + * See argument 1 to Services_JSON() above for object-output behavior. + * Note that decode() always returns strings + * in ASCII or UTF-8 format! + * @access public + */ + public function decode($str) { $str = $this->reduce_string($str); @@ -562,7 +562,8 @@ function decode($str) case $substr_chrs_c_2 == '\\\\': case $substr_chrs_c_2 == '\\/': if (($delim == '"' && $substr_chrs_c_2 != '\\\'') || - ($delim == "'" && $substr_chrs_c_2 != '\\"')) { + ($delim == "'" && $substr_chrs_c_2 != '\\"') + ) { $utf8 .= $chrs{++$c}; } break; @@ -570,7 +571,7 @@ function decode($str) case preg_match('/\\\u[0-9A-F]{4}/i', substr($chrs, $c, 6)): // single, escaped unicode character $utf16 = chr(hexdec(substr($chrs, ($c + 2), 2))) - . chr(hexdec(substr($chrs, ($c + 4), 2))); + . chr(hexdec(substr($chrs, ($c + 4), 2))); $utf8 .= $this->utf162utf8($utf16); $c += 5; break; @@ -633,9 +634,11 @@ function decode($str) } } - array_push($stk, array('what' => SERVICES_JSON_SLICE, - 'where' => 0, - 'delim' => false)); + array_push($stk, array( + 'what' => SERVICES_JSON_SLICE, + 'where' => 0, + 'delim' => false + )); $chrs = substr($str, 1, -1); $chrs = $this->reduce_string($chrs); @@ -660,7 +663,8 @@ function decode($str) // found a comma that is not inside a string, array, etc., // OR we've reached the end of the character list $slice = substr($chrs, $top['where'], ($c - $top['where'])); - array_push($stk, array('what' => SERVICES_JSON_SLICE, 'where' => ($c + 1), 'delim' => false)); + array_push($stk, + array('what' => SERVICES_JSON_SLICE, 'where' => ($c + 1), 'delim' => false)); //print("Found preg_split at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n"); if (reset($stk) == SERVICES_JSON_IN_ARR) { @@ -672,7 +676,7 @@ function decode($str) // element in an associative array, // for now $parts = array(); - + if (preg_match('/^\s*(["\'].*[^\\\]["\'])\s*:\s*(\S.*),?$/Uis', $slice, $parts)) { // "name":value pair $key = $this->decode($parts[1]); @@ -697,18 +701,22 @@ function decode($str) } } elseif ((($chrs{$c} == '"') || ($chrs{$c} == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) { // found a quote, and we are not inside a string - array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c})); + array_push($stk, + array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c})); //print("Found start of string at {$c}\n"); } elseif (($chrs{$c} == $top['delim']) && - ($top['what'] == SERVICES_JSON_IN_STR) && - ((strlen(substr($chrs, 0, $c)) - strlen(rtrim(substr($chrs, 0, $c), '\\'))) % 2 != 1)) { + ($top['what'] == SERVICES_JSON_IN_STR) && + ((strlen(substr($chrs, 0, $c)) - strlen(rtrim(substr($chrs, 0, $c), '\\'))) % 2 != 1) + ) { // found a quote, we're in a string, and it's not escaped // we know that it's not escaped becase there is _not_ an // odd number of backslashes at the end of the string so far array_pop($stk); //print("Found end of string at {$c}: ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n"); } elseif (($chrs{$c} == '[') && - in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) { + in_array($top['what'], + array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ)) + ) { // found a left-bracket, and we are in an array, object, or slice array_push($stk, array('what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false)); //print("Found start of array at {$c}\n"); @@ -717,7 +725,9 @@ function decode($str) array_pop($stk); //print("Found end of array at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n"); } elseif (($chrs{$c} == '{') && - in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) { + in_array($top['what'], + array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ)) + ) { // found a left-brace, and we are in an array, object, or slice array_push($stk, array('what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false)); //print("Found start of object at {$c}\n"); @@ -726,7 +736,9 @@ function decode($str) array_pop($stk); //print("Found end of object at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n"); } elseif (($substr_chrs_c_2 == '/*') && - in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) { + in_array($top['what'], + array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ)) + ) { // found a comment start, and we are in an array, object, or slice array_push($stk, array('what' => SERVICES_JSON_IN_CMT, 'where' => $c, 'delim' => false)); $c++; @@ -753,12 +765,13 @@ function decode($str) } } - function isError($data, $code = null) + public function isError($data, $code = null) { if (class_exists('pear')) { throw new \Exception($data, $code); } elseif (is_object($data) && (get_class($data) == 'services_json_error' || - is_subclass_of($data, 'services_json_error'))) { + is_subclass_of($data, 'services_json_error')) + ) { return true; } @@ -770,7 +783,7 @@ function isError($data, $code = null) class Services_JSON_Error extends PEAR_Error { - function Services_JSON_Error( + public function Services_JSON_Error( $message = 'unknown error', $code = null, $mode = null, @@ -782,13 +795,13 @@ function Services_JSON_Error( } } else { - /** * @todo Ultimately, this class shall be descended from PEAR_Error */ + class Services_JSON_Error { - function Services_JSON_Error( + public function Services_JSON_Error( $message = 'unknown error', $code = null, $mode = null, From 3721512fde338b034d22d37912698ea4ec428fee Mon Sep 17 00:00:00 2001 From: loiclau Date: Thu, 13 Jul 2017 16:05:13 +0200 Subject: [PATCH 022/207] * fix style --- .../procedures_DB_Connector.class.php | 24 +- .../procedures_Proxy.class.php | 332 +++++++++--------- www/class/centreon-knowledge/wiki.class.php | 7 +- .../centreon-knowledge/wikiApi.class.php | 2 +- 4 files changed, 184 insertions(+), 181 deletions(-) diff --git a/www/class/centreon-knowledge/procedures_DB_Connector.class.php b/www/class/centreon-knowledge/procedures_DB_Connector.class.php index fc8f6a9b62f..baa8ad332f4 100644 --- a/www/class/centreon-knowledge/procedures_DB_Connector.class.php +++ b/www/class/centreon-knowledge/procedures_DB_Connector.class.php @@ -1,4 +1,5 @@ retry = $retry; $this->options = array('debug' => 2, 'portability' => DB_PORTABILITY_ALL ^ DB_PORTABILITY_LOWERCASE); - $this->log = new CentreonLog(); - $this->connect($db_name, $db_user, $db_host, $db_password); - $this->debug = 0; + $this->log = new CentreonLog(); + $this->connect($db_name, $db_user, $db_host, $db_password); + $this->debug = 0; } private function displayConnectionErrorPage() @@ -97,7 +99,7 @@ public function connect($db_name, $db_user, $db_host, $db_password) 'outcome' => $outcome, 'message' => $message ); - } + } /** * Disconnection diff --git a/www/class/centreon-knowledge/procedures_Proxy.class.php b/www/class/centreon-knowledge/procedures_Proxy.class.php index 722f54c175f..363e624438e 100644 --- a/www/class/centreon-knowledge/procedures_Proxy.class.php +++ b/www/class/centreon-knowledge/procedures_Proxy.class.php @@ -1,166 +1,166 @@ -DB = $pearDB; - $this->hflag = 0; - $this->sflag = 0; - $this->hostObj = new CentreonHost($this->DB); - $this->serviceObj = new CentreonService($this->DB); - - $conf = getWikiConfig($this->DB); - $this->wikiUrl = $conf['kb_wiki_url']; - $this->proc = new procedures( - 3, - $conf['kb_db_name'], - $conf['kb_db_user'], - $conf['kb_db_host'], - $conf['kb_db_password'], - $this->DB, - $conf['kb_db_prefix'] - ); - - if (isset($host_name)) { - if (isset($service_description)) { - $this->returnServiceWikiUrl($this->DB->escape($host_name), $this->DB->escape($service_description)); - } else { - $this->returnHostWikiUrl($this->DB->escape($host_name)); - } - } - } - - private function getHostId($hostName) - { - $result = $this->DB->query("SELECT host_id FROM host WHERE host_name LIKE '" . $hostName . "' "); - $row = $result->fetchRow(); - $hostId = 0; - if ($row["host_id"]) { - $hostId = $row["host_id"]; - } - return $hostId; - } - - private function getServiceId($hostName, $serviceDescription) - { - /* - * Get Services attached to hosts - */ - $query = "SELECT s.service_id " . - "FROM host h, service s, host_service_relation hsr " . - "WHERE hsr.host_host_id = h.host_id " . - "AND hsr.service_service_id = service_id " . - "AND h.host_name LIKE '" . $hostName . "' " . - "AND s.service_description LIKE '" . $serviceDescription . "' "; - $result = $this->DB->query($query); - while ($row = $result->fetchRow()) { - return $row["service_id"]; - } - $result->closeCursor(); - /* - * Get Services attached to hostgroups - */ - $query = "SELECT s.service_id " . - "FROM hostgroup_relation hgr, host h, service s, host_service_relation hsr " . - "WHERE hgr.host_host_id = h.host_id " . - "AND hsr.hostgroup_hg_id = hgr.hostgroup_hg_id " . - "AND h.host_name LIKE '" . $hostName . "' " . - "AND service_id = hsr.service_service_id " . - "AND service_description LIKZ '" . $serviceDescription . "' "; - $result = $this->DB->query($query); - while ($row = $result->fetchRow()) { - return $row["service_id"]; - } - $result->closeCursor(); - - } - - private function returnHostWikiUrl($host_name) - { - $this->proc->setHostInformations(); - - $procList = $this->proc->getProcedures(); - - /* - * Check if host has a procedure directly on Host - */ - if (isset($procList["Host_:_" . $host_name])) { - $this->url = $this->wikiUrl . "/index.php?title=Host_:_" . $host_name; - return; - } - - /* - * Check if host can get a procedure on templates - */ - $hostId = $this->getHostId($host_name); - $templates = $this->hostObj->getTemplateChain($hostId); - foreach ($templates as $template) { - $templateName = $template['host_name']; - if (isset($procList["Host-Template_:_" . $templateName])) { - $this->url = $this->wikiUrl . "/index.php?title=Host-Template_:_" . $templateName; - return; - } - } - } - - private function returnServiceWikiUrl($host_name, $service_description) - { - if ($this->hflag != 0) { - $this->proc->setHostInformations(); - } - $this->proc->setServiceInformations(); - $this->sflag; - - $procList = $this->proc->getProcedures(); - - /* - * Check Service - */ - $service_description = str_replace(' ', '_', $service_description); - - if (isset($procList["Service_:_" . trim($host_name . "_/_" . $service_description)])) { - $this->url = $this->wikiUrl . "/index.php?title=Service_:_" . $host_name . "_/_" . $service_description; - return; - } - - /* - * Check service Template - */ - $serviceId = $this->getServiceId($host_name, $service_description); - $templates = $this->serviceObj->getTemplatesChain($serviceId); - foreach ($templates as $templateId) { - $templateDescription = $this->serviceObj->getServiceDesc($templateId); - if (isset($procList["Service-Template_:_" . $templateDescription])) { - $this->url = $this->wikiUrl . "/index.php?title=Service-Template_:_" . $templateDescription; - return; - } - } - - $this->returnHostWikiUrl($host_name); - } -} +DB = $pearDB; + $this->hflag = 0; + $this->sflag = 0; + $this->hostObj = new CentreonHost($this->DB); + $this->serviceObj = new CentreonService($this->DB); + + $conf = getWikiConfig($this->DB); + $this->wikiUrl = $conf['kb_wiki_url']; + $this->proc = new procedures( + 3, + $conf['kb_db_name'], + $conf['kb_db_user'], + $conf['kb_db_host'], + $conf['kb_db_password'], + $this->DB, + $conf['kb_db_prefix'] + ); + + if (isset($host_name)) { + if (isset($service_description)) { + $this->returnServiceWikiUrl($this->DB->escape($host_name), $this->DB->escape($service_description)); + } else { + $this->returnHostWikiUrl($this->DB->escape($host_name)); + } + } + } + + private function getHostId($hostName) + { + $result = $this->DB->query("SELECT host_id FROM host WHERE host_name LIKE '" . $hostName . "' "); + $row = $result->fetchRow(); + $hostId = 0; + if ($row["host_id"]) { + $hostId = $row["host_id"]; + } + return $hostId; + } + + private function getServiceId($hostName, $serviceDescription) + { + /* + * Get Services attached to hosts + */ + $query = "SELECT s.service_id " . + "FROM host h, service s, host_service_relation hsr " . + "WHERE hsr.host_host_id = h.host_id " . + "AND hsr.service_service_id = service_id " . + "AND h.host_name LIKE '" . $hostName . "' " . + "AND s.service_description LIKE '" . $serviceDescription . "' "; + $result = $this->DB->query($query); + while ($row = $result->fetchRow()) { + return $row["service_id"]; + } + $result->closeCursor(); + /* + * Get Services attached to hostgroups + */ + $query = "SELECT s.service_id " . + "FROM hostgroup_relation hgr, host h, service s, host_service_relation hsr " . + "WHERE hgr.host_host_id = h.host_id " . + "AND hsr.hostgroup_hg_id = hgr.hostgroup_hg_id " . + "AND h.host_name LIKE '" . $hostName . "' " . + "AND service_id = hsr.service_service_id " . + "AND service_description LIKZ '" . $serviceDescription . "' "; + $result = $this->DB->query($query); + while ($row = $result->fetchRow()) { + return $row["service_id"]; + } + $result->closeCursor(); + + } + + private function returnHostWikiUrl($host_name) + { + $this->proc->setHostInformations(); + + $procList = $this->proc->getProcedures(); + + /* + * Check if host has a procedure directly on Host + */ + if (isset($procList["Host_:_" . $host_name])) { + $this->url = $this->wikiUrl . "/index.php?title=Host_:_" . $host_name; + return; + } + + /* + * Check if host can get a procedure on templates + */ + $hostId = $this->getHostId($host_name); + $templates = $this->hostObj->getTemplateChain($hostId); + foreach ($templates as $template) { + $templateName = $template['host_name']; + if (isset($procList["Host-Template_:_" . $templateName])) { + $this->url = $this->wikiUrl . "/index.php?title=Host-Template_:_" . $templateName; + return; + } + } + } + + private function returnServiceWikiUrl($host_name, $service_description) + { + if ($this->hflag != 0) { + $this->proc->setHostInformations(); + } + $this->proc->setServiceInformations(); + $this->sflag; + + $procList = $this->proc->getProcedures(); + + /* + * Check Service + */ + $service_description = str_replace(' ', '_', $service_description); + + if (isset($procList["Service_:_" . trim($host_name . "_/_" . $service_description)])) { + $this->url = $this->wikiUrl . "/index.php?title=Service_:_" . $host_name . "_/_" . $service_description; + return; + } + + /* + * Check service Template + */ + $serviceId = $this->getServiceId($host_name, $service_description); + $templates = $this->serviceObj->getTemplatesChain($serviceId); + foreach ($templates as $templateId) { + $templateDescription = $this->serviceObj->getServiceDesc($templateId); + if (isset($procList["Service-Template_:_" . $templateDescription])) { + $this->url = $this->wikiUrl . "/index.php?title=Service-Template_:_" . $templateDescription; + return; + } + } + + $this->returnHostWikiUrl($host_name); + } +} diff --git a/www/class/centreon-knowledge/wiki.class.php b/www/class/centreon-knowledge/wiki.class.php index 1f70cfed641..34db36ce1cd 100644 --- a/www/class/centreon-knowledge/wiki.class.php +++ b/www/class/centreon-knowledge/wiki.class.php @@ -67,11 +67,12 @@ public function getWikiConfig() if (!isset($options['kb_wiki_url']) || $options['kb_wiki_url'] == '') { throw new \Exception( 'Wiki is not configured. ' . - 'You can disable cron in /etc/crond.d/centreon for wiki synchronization.'); + 'You can disable cron in /etc/crond.d/centreon for wiki synchronization.' + ); } - if (!preg_match('#^http://|https://#', $options['kb_wiki_url'])) { - $options['kb_wiki_url'] = 'http://' . $options['kb_wiki_url']; + if (!preg_match('#^http://|https://#', $options['kb_wiki_url'])) { + $options['kb_wiki_url'] = 'http://' . $options['kb_wiki_url']; } return $options; diff --git a/www/class/centreon-knowledge/wikiApi.class.php b/www/class/centreon-knowledge/wikiApi.class.php index 42ee91d6aad..fdeca93d553 100644 --- a/www/class/centreon-knowledge/wikiApi.class.php +++ b/www/class/centreon-knowledge/wikiApi.class.php @@ -78,7 +78,7 @@ private function getCurl() return $curl; } - function getWikiVersion() + public function getWikiVersion() { $postfields = array( 'action' => 'query', From 080976162caed9c1edd8f18d9a1eb0814553442e Mon Sep 17 00:00:00 2001 From: loiclau Date: Thu, 13 Jul 2017 16:11:33 +0200 Subject: [PATCH 023/207] * fix style --- www/install/steps/functions.php | 57 +++++++++++-------- www/install/steps/process/configFileSetup.php | 26 +++++---- www/install/steps/process/createDbUser.php | 6 +- .../steps/process/installConfigurationDb.php | 2 +- .../steps/process/installStorageDb.php | 2 +- www/install/steps/process/process_step3.php | 4 +- www/install/steps/process/process_step4.php | 2 +- www/install/steps/process/process_step5.php | 5 +- www/install/steps/process/process_step6.php | 9 +-- www/install/steps/process/process_step8.php | 2 +- www/install/steps/process/process_step9.php | 4 +- 11 files changed, 66 insertions(+), 53 deletions(-) diff --git a/www/install/steps/functions.php b/www/install/steps/functions.php index a226f90ede0..09ecee8a809 100644 --- a/www/install/steps/functions.php +++ b/www/install/steps/functions.php @@ -5,7 +5,8 @@ * @param string $str * @return bool */ -function isSqlComment($str) { +function isSqlComment($str) +{ if (substr(trim($str), 0, 2) == "--") { return true; } @@ -18,7 +19,8 @@ function isSqlComment($str) { * @param string $dir directory of templates * @return Smarty */ -function getTemplate($dir) { +function getTemplate($dir) +{ $libDir = __DIR__ . '/../../../GPL_LIB'; require_once $libDir . '/Smarty/libs/Smarty.class.php'; $template = new \Smarty(); @@ -37,7 +39,8 @@ function getTemplate($dir) { * * @return mixed */ -function myConnect() { +function myConnect() +{ $pass = ""; if (isset($_SESSION['root_password']) && $_SESSION['root_password']) { $pass = $_SESSION['root_password']; @@ -59,7 +62,8 @@ function myConnect() { * @param string $query * @return string */ -function replaceInstallationMacros($query, $macros = array()) { +function replaceInstallationMacros($query, $macros = array()) +{ while (preg_match('/@([a-zA-Z0-9_]+)@/', $query, $matches)) { $macroValue = ""; if ($matches[1] == 'MAILER') { @@ -70,7 +74,7 @@ function replaceInstallationMacros($query, $macros = array()) { $macroValue = $_SESSION[$matches[1]]; } - $query = preg_replace('/@'.$matches[1].'@/', $macroValue, $query); + $query = preg_replace('/@' . $matches[1] . '@/', $macroValue, $query); } $query = str_replace('-MAILER-', '@MAILER@', $query); @@ -84,10 +88,11 @@ function replaceInstallationMacros($query, $macros = array()) { * @param string $file * @param string $delimiter * @param CentreonDB $connector - * @param string $tmpFile | $tmpFile will store the number of executed queries sql script can be resumed from last failure + * @param string $tmpFile | $tmpFile will store the number of executed queries sql script * @return string | returns "0" if everything is ok, or returns error message */ -function splitQueries($file, $delimiter = ';', $connector = null, $tmpFile = "", $macros = array()) { +function splitQueries($file, $delimiter = ';', $connector = null, $tmpFile = "", $macros = array()) +{ if (is_null($connector)) { $connector = myConnect(); } @@ -121,7 +126,7 @@ function splitQueries($file, $delimiter = ';', $connector = null, $tmpFile = "", throw new \Exception('Cannot execute query : ' . $query); } } catch (\Exception $e) { - return "$fileName Line $line:".$e->getMessage(); + return "$fileName Line $line:" . $e->getMessage(); } while (ob_get_level() > 0) { ob_end_flush(); @@ -149,7 +154,8 @@ function splitQueries($file, $delimiter = ';', $connector = null, $tmpFile = "", * @param string $file * @return void */ -function importFile($db, $file) { +function importFile($db, $file) +{ $db->beginTransaction(); try { splitQueries($db, $file); @@ -167,14 +173,15 @@ function importFile($db, $file) { * @param int $result | 0 = ok, 1 = nok * @param string $msg | error message */ -function exitProcess($id, $result, $msg) { +function exitProcess($id, $result, $msg) +{ $msg = str_replace('"', '\"', $msg); $msg = str_replace('\\', '\\\\', $msg); echo '{ - "id" : "'.$id.'", - "result" : "'.$result.'", - "msg" : "'.$msg.'" + "id" : "' . $id . '", + "result" : "' . $result . '", + "msg" : "' . $msg . '" }'; exit; @@ -189,14 +196,15 @@ function exitProcess($id, $result, $msg) { * @param string $msg | error message * @return void */ -function exitUpgradeProcess($result, $current, $next, $msg) { +function exitUpgradeProcess($result, $current, $next, $msg) +{ $msg = str_replace('"', '\"', $msg); $msg = str_replace('\\', '\\\\', $msg); echo '{ - "result" : "'.$result.'", - "current" : "'.$current.'", - "next" : "'.$next.'", - "msg" : "'.$msg.'" + "result" : "' . $result . '", + "current" : "' . $current . '", + "next" : "' . $next . '", + "msg" : "' . $msg . '" }'; exit; } @@ -208,12 +216,13 @@ function exitUpgradeProcess($result, $current, $next, $msg) { * @param string $objectType * @return array */ -function getParamLines($varPath, $objectType) { +function getParamLines($varPath, $objectType) +{ $contents = ""; if ($handle = opendir($varPath)) { while (false !== ($object = readdir($handle))) { if ($object == $objectType) { - $contents = file_get_contents($varPath.'/'.$object); + $contents = file_get_contents($varPath . '/' . $object); } } closedir($handle); @@ -228,7 +237,8 @@ function getParamLines($varPath, $objectType) { * @param array $conf_centreon * @return void */ -function setSessionVariables($conf_centreon) { +function setSessionVariables($conf_centreon) +{ $_SESSION['INSTALL_DIR_CENTREON'] = $conf_centreon['centreon_dir']; $_SESSION['CENTREON_ETC'] = $conf_centreon['centreon_etc']; $_SESSION['BIN_MAIL'] = $conf_centreon['mail']; @@ -250,7 +260,8 @@ function setSessionVariables($conf_centreon) { $_SESSION['CENTREONPLUGINS'] = $conf_centreon['centreon_plugins']; } -function getDatabaseVariable($db, $variable) { +function getDatabaseVariable($db, $variable) +{ $query = "SHOW VARIABLES LIKE '" . $variable . "'"; $result = $db->query($query); @@ -262,5 +273,3 @@ function getDatabaseVariable($db, $variable) { return $value; } - -?> diff --git a/www/install/steps/process/configFileSetup.php b/www/install/steps/process/configFileSetup.php index 1e30bff305f..79729bc81da 100644 --- a/www/install/steps/process/configFileSetup.php +++ b/www/install/steps/process/configFileSetup.php @@ -53,15 +53,17 @@ $host = 'localhost'; } -$patterns = array('/--ADDRESS--/', - '/--DBUSER--/', - '/--DBPASS--/', - '/--CONFDB--/', - '/--STORAGEDB--/', - '/--CENTREONDIR--/', - '/--DBPORT--/', - '/--INSTANCEMODE--/', - '/--CENTREON_VARLIB--/'); +$patterns = array( + '/--ADDRESS--/', + '/--DBUSER--/', + '/--DBPASS--/', + '/--CONFDB--/', + '/--STORAGEDB--/', + '/--CENTREONDIR--/', + '/--DBPORT--/', + '/--INSTANCEMODE--/', + '/--CENTREON_VARLIB--/' +); $replacements = array( $host, @@ -78,7 +80,7 @@ /** * centreon.conf.php */ -$centreonConfFile = rtrim($configuration['centreon_etc'], '/').'/centreon.conf.php'; +$centreonConfFile = rtrim($configuration['centreon_etc'], '/') . '/centreon.conf.php'; $contents = file_get_contents('../../var/configFileTemplate'); $contents = preg_replace($patterns, $replacements, $contents); file_put_contents($centreonConfFile, $contents); @@ -86,11 +88,11 @@ /** * conf.pm */ -$centreonConfPmFile = rtrim($configuration['centreon_etc'], '/').'/conf.pm'; +$centreonConfPmFile = rtrim($configuration['centreon_etc'], '/') . '/conf.pm'; $contents = file_get_contents('../../var/configFilePmTemplate'); $contents = preg_replace($patterns, $replacements, $contents); file_put_contents($centreonConfPmFile, $contents); $return['result'] = 0; echo json_encode($return); -exit; \ No newline at end of file +exit; diff --git a/www/install/steps/process/createDbUser.php b/www/install/steps/process/createDbUser.php index 86abe85f62d..a6d08c4d8e2 100644 --- a/www/install/steps/process/createDbUser.php +++ b/www/install/steps/process/createDbUser.php @@ -65,8 +65,8 @@ if ($parameters['address'] != "127.0.0.1" && $parameters['address'] != "localhost") { $host = $_SERVER['SERVER_ADDR']; } -$query = "GRANT ALL PRIVILEGES ON `%s`.* TO `". $dbUser . "`@`". $host . - "` IDENTIFIED BY '". $dbPass . "' WITH GRANT OPTION"; +$query = "GRANT ALL PRIVILEGES ON `%s`.* TO `" . $dbUser . "`@`" . $host . + "` IDENTIFIED BY '" . $dbPass . "' WITH GRANT OPTION"; try { $link->exec(sprintf($query, $parameters['db_configuration'])); $link->exec(sprintf($query, $parameters['db_storage'])); @@ -78,4 +78,4 @@ $return['result'] = 0; echo json_encode($return); -exit; \ No newline at end of file +exit; diff --git a/www/install/steps/process/installConfigurationDb.php b/www/install/steps/process/installConfigurationDb.php index 233d4c16b14..c8a02339b78 100644 --- a/www/install/steps/process/installConfigurationDb.php +++ b/www/install/steps/process/installConfigurationDb.php @@ -104,4 +104,4 @@ $return['result'] = 0; echo json_encode($return); -exit; \ No newline at end of file +exit; diff --git a/www/install/steps/process/installStorageDb.php b/www/install/steps/process/installStorageDb.php index 054b42c0e3d..c0f4828b4cd 100644 --- a/www/install/steps/process/installStorageDb.php +++ b/www/install/steps/process/installStorageDb.php @@ -117,4 +117,4 @@ $return['result'] = 0; echo json_encode($return); -exit; \ No newline at end of file +exit; diff --git a/www/install/steps/process/process_step3.php b/www/install/steps/process/process_step3.php index b8608a06dd2..5317d8f5cdf 100644 --- a/www/install/steps/process/process_step3.php +++ b/www/install/steps/process/process_step3.php @@ -32,7 +32,7 @@ * For more information : contact@centreon.com * */ - + session_start(); require_once __DIR__ . '/../../../../bootstrap.php'; @@ -64,4 +64,4 @@ $step->setEngineConfiguration($parameters); } -echo json_encode($err); \ No newline at end of file +echo json_encode($err); diff --git a/www/install/steps/process/process_step4.php b/www/install/steps/process/process_step4.php index 87b616455cc..6acb7a287e2 100644 --- a/www/install/steps/process/process_step4.php +++ b/www/install/steps/process/process_step4.php @@ -64,4 +64,4 @@ $step->setBrokerConfiguration($parameters); } -echo json_encode($err); \ No newline at end of file +echo json_encode($err); diff --git a/www/install/steps/process/process_step5.php b/www/install/steps/process/process_step5.php index 57ede7a280a..5ab90a4b7ca 100644 --- a/www/install/steps/process/process_step5.php +++ b/www/install/steps/process/process_step5.php @@ -57,7 +57,8 @@ } if (!in_array('admin_password', $err['required']) && !in_array('confirm_password', $err['required']) && - $parameters['admin_password'] != $parameters['confirm_password']) { + $parameters['admin_password'] != $parameters['confirm_password'] +) { $err['password'] = false; } @@ -66,4 +67,4 @@ $step->setAdminConfiguration($parameters); } -echo json_encode($err); \ No newline at end of file +echo json_encode($err); diff --git a/www/install/steps/process/process_step6.php b/www/install/steps/process/process_step6.php index 4c656469c33..85c8e131068 100644 --- a/www/install/steps/process/process_step6.php +++ b/www/install/steps/process/process_step6.php @@ -58,7 +58,8 @@ } if (!in_array('db_password', $err['required']) && !in_array('db_password_confirm', $err['required']) && - $parameters['db_password'] != $parameters['db_password_confirm']) { + $parameters['db_password'] != $parameters['db_password_confirm'] +) { $err['password'] = false; } @@ -71,8 +72,8 @@ } $link = new \PDO( 'mysql:host=' . $parameters['address'] . ';port=' . $parameters['port'], - 'root', - $parameters['root_password'] + 'root', + $parameters['root_password'] ); } catch (\PDOException $e) { $err['connection'] = $e->getMessage(); @@ -84,4 +85,4 @@ $step->setDatabaseConfiguration($parameters); } -echo json_encode($err); \ No newline at end of file +echo json_encode($err); diff --git a/www/install/steps/process/process_step8.php b/www/install/steps/process/process_step8.php index ad77547f219..c7a6fcf5959 100644 --- a/www/install/steps/process/process_step8.php +++ b/www/install/steps/process/process_step8.php @@ -57,4 +57,4 @@ } } -echo json_encode($result); \ No newline at end of file +echo json_encode($result); diff --git a/www/install/steps/process/process_step9.php b/www/install/steps/process/process_step9.php index f8e7c353405..01fba57ba31 100644 --- a/www/install/steps/process/process_step9.php +++ b/www/install/steps/process/process_step9.php @@ -43,7 +43,7 @@ try { $backupDir = realpath(__DIR__ . '/../../../../installDir/') . '/install-' . $version . '-' . date('Ymd_His'); - $installDir = realpath(__DIR__ . '/../..'); + $installDir = realpath(__DIR__ . '/../..'); $dependencyInjector['filesystem']->rename($installDir, $backupDir); if ($dependencyInjector['filesystem']->exists($installDir)) { throw new \Exception('Cannot move directory from ' . $installDir . ' to ' . $backupDir); @@ -59,4 +59,4 @@ echo json_encode(array( 'result' => $result, 'message' => $message -)); \ No newline at end of file +)); From ad3c2a8c83f5ffe4024f2c8acc654d628e39e01a Mon Sep 17 00:00:00 2001 From: loiclau Date: Thu, 13 Jul 2017 16:42:41 +0200 Subject: [PATCH 024/207] * fix style --- .../accessLists/resourcesACL/DB-Func.php | 200 ++++++++++------ .../resourcesACL/formResourcesAccess.php | 224 +++++++++++++----- .../options/accessLists/resourcesACL/help.php | 36 ++- .../resourcesACL/showUsersAccess.php | 46 ++-- 4 files changed, 356 insertions(+), 150 deletions(-) diff --git a/www/include/options/accessLists/resourcesACL/DB-Func.php b/www/include/options/accessLists/resourcesACL/DB-Func.php index 053312568ea..429d02fded9 100644 --- a/www/include/options/accessLists/resourcesACL/DB-Func.php +++ b/www/include/options/accessLists/resourcesACL/DB-Func.php @@ -46,11 +46,12 @@ function testExistence($name = null) if (isset($form)) { $id = $form->getSubmitValue('lca_id'); } - $DBRESULT = $pearDB->query("SELECT acl_res_name, acl_res_id FROM `acl_resources` WHERE acl_res_name = '".$name."'"); - $lca = $DBRESULT->fetchRow(); - if ($DBRESULT->rowCount() >= 1 && $lca["acl_res_id"] == $id) { + $query = "SELECT acl_res_name, acl_res_id FROM `acl_resources` WHERE acl_res_name = '" . $name . "'"; + $dbResult = $pearDB->query($query); + $lca = $dbResult->fetchRow(); + if ($dbResult->rowCount() >= 1 && $lca["acl_res_id"] == $id) { return true; - } elseif ($DBRESULT->rowCount() >= 1 && $lca["acl_res_id"] != $id) { + } elseif ($dbResult->rowCount() >= 1 && $lca["acl_res_id"] != $id) { return false; } else { return true; @@ -69,8 +70,13 @@ function enableLCAInDB($acl_id = null) if (!$acl_id) { return; } - $DBRESULT = $pearDB->query("UPDATE `acl_groups` SET `acl_group_changed` = '1' WHERE acl_group_id IN (SELECT acl_group_id FROM acl_res_group_relations WHERE acl_res_id = '$acl_id')"); - $DBRESULT = $pearDB->query("UPDATE `acl_resources` SET acl_res_activate = '1', `changed` = '1' WHERE `acl_res_id` = '".$acl_id."'"); + $query = "UPDATE `acl_groups` SET `acl_group_changed` = '1' " . + "WHERE acl_group_id IN (SELECT acl_group_id FROM acl_res_group_relations WHERE acl_res_id = '$acl_id')"; + $pearDB->query($query); + + $query = "UPDATE `acl_resources` SET acl_res_activate = '1', `changed` = '1' " . + "WHERE `acl_res_id` = '" . $acl_id . "'"; + $pearDB->query($query); } /** @@ -85,8 +91,13 @@ function disableLCAInDB($acl_id = null) if (!$acl_id) { return; } - $DBRESULT = $pearDB->query("UPDATE `acl_groups` SET `acl_group_changed` = '1' WHERE acl_group_id IN (SELECT acl_group_id FROM acl_res_group_relations WHERE acl_res_id = '$acl_id')"); - $DBRESULT = $pearDB->query("UPDATE `acl_resources` SET acl_res_activate = '0', `changed` = '1' WHERE `acl_res_id` = '".$acl_id."'"); + $query = "UPDATE `acl_groups` SET `acl_group_changed` = '1' " . + "WHERE acl_group_id IN (SELECT acl_group_id FROM acl_res_group_relations WHERE acl_res_id = '$acl_id')"; + $pearDB->query($query); + + $query = "UPDATE `acl_resources` SET acl_res_activate = '0', `changed` = '1' " . + "WHERE `acl_res_id` = '" . $acl_id . "'"; + $pearDB->query($query); } /** @@ -99,8 +110,11 @@ function deleteLCAInDB($acls = array()) global $pearDB; foreach ($acls as $key => $value) { - $DBRESULT = $pearDB->query("UPDATE `acl_groups` SET `acl_group_changed` = '1' WHERE acl_group_id IN (SELECT acl_group_id FROM acl_res_group_relations WHERE acl_res_id = '$key')"); - $DBRESULT = $pearDB->query("DELETE FROM `acl_resources` WHERE acl_res_id = '".$key."'"); + $query = "UPDATE `acl_groups` SET `acl_group_changed` = '1' " . + "WHERE acl_group_id IN (SELECT acl_group_id FROM acl_res_group_relations WHERE acl_res_id = '$key')"; + $pearDB->query($query); + + $pearDB->query("DELETE FROM `acl_resources` WHERE acl_res_id = '" . $key . "'"); } } @@ -115,19 +129,21 @@ function multipleLCAInDB($lcas = array(), $nbrDup = array()) global $pearDB; foreach ($lcas as $key => $value) { - $DBRESULT = $pearDB->query("SELECT * FROM `acl_resources` WHERE acl_res_id = '".$key."' LIMIT 1"); + $DBRESULT = $pearDB->query("SELECT * FROM `acl_resources` WHERE acl_res_id = '" . $key . "' LIMIT 1"); $row = $DBRESULT->fetchRow(); $row["acl_res_id"] = ''; for ($i = 1; $i <= $nbrDup[$key]; $i++) { $val = null; foreach ($row as $key2 => $value2) { - $key2 == "acl_res_name" ? ($acl_name = $value2 = $value2."_".$i) : null; - $val ? $val .= ($value2!=null?(", '".$value2."'"):", NULL") : $val .= ($value2!=null?("'".$value2."'"):"NULL"); + $key2 == "acl_res_name" ? ($acl_name = $value2 = $value2 . "_" . $i) : null; + $val + ? $val .= ($value2 != null ? (", '" . $value2 . "'") : ", NULL") + : $val .= ($value2 != null ? ("'" . $value2 . "'") : "NULL"); } if (testExistence($acl_name)) { - $val ? $rq = "INSERT INTO acl_resources VALUES (".$val.")" : $rq = null; + $val ? $rq = "INSERT INTO acl_resources VALUES (" . $val . ")" : $rq = null; $pearDB->query($rq); $DBRESULT = $pearDB->query("SELECT MAX(acl_res_id) FROM acl_resources"); @@ -150,38 +166,50 @@ function multipleLCAInDB($lcas = array(), $nbrDup = array()) */ function duplicateGroups($idTD, $acl_id, $pearDB) { - $request = "INSERT INTO acl_res_group_relations (acl_res_id, acl_group_id) SELECT '$acl_id' AS acl_res_id, acl_group_id FROM acl_res_group_relations WHERE acl_res_id = '$idTD'"; - $DBRESULT = $pearDB->query($request); + $query = "INSERT INTO acl_res_group_relations (acl_res_id, acl_group_id) " . + "SELECT '$acl_id' AS acl_res_id, acl_group_id FROM acl_res_group_relations WHERE acl_res_id = '$idTD'"; + $pearDB->query($query); //host categories - $pearDB->query("INSERT INTO acl_resources_hc_relations (acl_res_id, hc_id) - (SELECT $acl_id, hc_id FROM acl_resources_hc_relations WHERE acl_res_id = ".$pearDB->escape($idTD).")"); + $query = "INSERT INTO acl_resources_hc_relations (acl_res_id, hc_id) " . + "(SELECT $acl_id, hc_id FROM acl_resources_hc_relations WHERE acl_res_id = " . $pearDB->escape($idTD) . ")"; + $pearDB->query($query); //hostgroups - $pearDB->query("INSERT INTO acl_resources_hg_relations (acl_res_id, hg_hg_id) - (SELECT $acl_id, hg_hg_id FROM acl_resources_hg_relations WHERE acl_res_id = ".$pearDB->escape($idTD).")"); + $query = "INSERT INTO acl_resources_hg_relations (acl_res_id, hg_hg_id) " . + "(SELECT $acl_id, hg_hg_id FROM acl_resources_hg_relations WHERE acl_res_id = " . $pearDB->escape($idTD) . ")"; + $pearDB->query($query); //host exceptions - $pearDB->query("INSERT INTO acl_resources_hostex_relations (acl_res_id, host_host_id) - (SELECT $acl_id, host_host_id FROM acl_resources_hostex_relations WHERE acl_res_id = ".$pearDB->escape($idTD).")"); + $query = "INSERT INTO acl_resources_hostex_relations (acl_res_id, host_host_id) " . + "(SELECT $acl_id, host_host_id FROM acl_resources_hostex_relations WHERE acl_res_id = " . + $pearDB->escape($idTD) . ")"; + $pearDB->query($query); //hosts - $pearDB->query("INSERT INTO acl_resources_host_relations (acl_res_id, host_host_id) - (SELECT $acl_id, host_host_id FROM acl_resources_host_relations WHERE acl_res_id = ".$pearDB->escape($idTD).")"); + $query = "INSERT INTO acl_resources_host_relations (acl_res_id, host_host_id) " . + "(SELECT $acl_id, host_host_id FROM acl_resources_host_relations WHERE acl_res_id = " . + $pearDB->escape($idTD) . ")"; + $pearDB->query($query); //meta - $pearDB->query("INSERT INTO acl_resources_meta_relations (acl_res_id, meta_id) - (SELECT $acl_id, meta_id FROM acl_resources_meta_relations WHERE acl_res_id = ".$pearDB->escape($idTD).")"); + $query = "INSERT INTO acl_resources_meta_relations (acl_res_id, meta_id) " . + "(SELECT $acl_id, meta_id FROM acl_resources_meta_relations WHERE acl_res_id = " . $pearDB->escape($idTD) . ")"; + $pearDB->query($query); //poller - $pearDB->query("INSERT INTO acl_resources_poller_relations (acl_res_id, poller_id) - (SELECT $acl_id, poller_id FROM acl_resources_poller_relations WHERE acl_res_id = ".$pearDB->escape($idTD).")"); + $query = "INSERT INTO acl_resources_poller_relations (acl_res_id, poller_id) " . + "(SELECT $acl_id, poller_id FROM acl_resources_poller_relations WHERE acl_res_id = " . + $pearDB->escape($idTD) . ")"; + $pearDB->query($query); //service categories - $pearDB->query("INSERT INTO acl_resources_sc_relations (acl_res_id, sc_id) - (SELECT $acl_id, sc_id FROM acl_resources_sc_relations WHERE acl_res_id = ".$pearDB->escape($idTD).")"); + $query = "INSERT INTO acl_resources_sc_relations (acl_res_id, sc_id) " . + "(SELECT $acl_id, sc_id FROM acl_resources_sc_relations WHERE acl_res_id = " . $pearDB->escape($idTD) . ")"; + $pearDB->query($query); //service groups - $pearDB->query("INSERT INTO acl_resources_sg_relations (acl_res_id, sg_id) - (SELECT $acl_id, sg_id FROM acl_resources_sg_relations WHERE acl_res_id = ".$pearDB->escape($idTD).")"); + $query = "INSERT INTO acl_resources_sg_relations (acl_res_id, sg_id) " . + "(SELECT $acl_id, sg_id FROM acl_resources_sg_relations WHERE acl_res_id = " . $pearDB->escape($idTD) . ")"; + $pearDB->query($query); } /** @@ -192,8 +220,9 @@ function duplicateGroups($idTD, $acl_id, $pearDB) */ function duplicateContactGroups($idTD, $acl_id, $pearDB) { - $request = "INSERT INTO acl_res_group_relations (acl_res_id, acl_group_id) SELECT acl_res_id, '$acl_id' AS acl_group_id FROM acl_res_group_relations WHERE acl_group_id = '$idTD'"; - $DBRESULT = $pearDB->query($request); + $query = "INSERT INTO acl_res_group_relations (acl_res_id, acl_group_id) " . + "SELECT acl_res_id, '$acl_id' AS acl_group_id FROM acl_res_group_relations WHERE acl_group_id = '$idTD'"; + $pearDB->query($query); } /** @@ -250,15 +279,20 @@ function insertLCA() $ret = array(); $ret = $form->getSubmitValues(); $rq = "INSERT INTO `acl_resources` "; - $rq .= "(acl_res_name, acl_res_alias, all_hosts, all_hostgroups, all_servicegroups, acl_res_activate, changed, acl_res_comment) "; - $rq .= "VALUES ('".$pearDB->escape($ret["acl_res_name"])."', " . - "'".$pearDB->escape($ret["acl_res_alias"])."', " . - "'".(isset($ret["all_hosts"]["all_hosts"]) ? $pearDB->escape($ret["all_hosts"]["all_hosts"]) : 0)."', " . - "'".(isset($ret["all_hostgroups"]["all_hostgroups"]) ? $pearDB->escape($ret["all_hostgroups"]["all_hostgroups"]) : 0)."', " . - "'".(isset($ret["all_servicegroups"]["all_servicegroups"]) ? $pearDB->escape($ret["all_servicegroups"]["all_servicegroups"]) : 0)."', " . - "'".$pearDB->escape($ret["acl_res_activate"]["acl_res_activate"])."', " . - "'1', " . - "'".$pearDB->escape($ret["acl_res_comment"])."')"; + $rq .= "(acl_res_name, acl_res_alias, all_hosts, all_hostgroups, all_servicegroups, acl_res_activate, " . + "changed, acl_res_comment) "; + $rq .= "VALUES ('" . $pearDB->escape($ret["acl_res_name"]) . "', " . + "'" . $pearDB->escape($ret["acl_res_alias"]) . "', " . + "'" . (isset($ret["all_hosts"]["all_hosts"]) ? $pearDB->escape($ret["all_hosts"]["all_hosts"]) : 0) . "', " . + "'" . (isset($ret["all_hostgroups"]["all_hostgroups"]) + ? $pearDB->escape($ret["all_hostgroups"]["all_hostgroups"]) + : 0) . "', " . + "'" . (isset($ret["all_servicegroups"]["all_servicegroups"]) + ? $pearDB->escape($ret["all_servicegroups"]["all_servicegroups"]) + : 0) . "', " . + "'" . $pearDB->escape($ret["acl_res_activate"]["acl_res_activate"]) . "', " . + "'1', " . + "'" . $pearDB->escape($ret["acl_res_comment"]) . "')"; $DBRESULT = $pearDB->query($rq); $DBRESULT = $pearDB->query("SELECT MAX(acl_res_id) FROM `acl_resources`"); $acl = $DBRESULT->fetchRow(); @@ -283,15 +317,23 @@ function updateLCA($acl_id = null) $ret = $form->getSubmitValues(); $rq = "UPDATE `acl_resources` "; - $rq .= "SET acl_res_name = '".$pearDB->escape($ret["acl_res_name"])."', " . - "acl_res_alias = '".$pearDB->escape($ret["acl_res_alias"])."', " . - "all_hosts = '".(isset($ret["all_hosts"]["all_hosts"]) ? $pearDB->escape($ret["all_hosts"]["all_hosts"]) : 0)."', " . - "all_hostgroups = '".(isset($ret["all_hostgroups"]["all_hostgroups"]) ? $pearDB->escape($ret["all_hostgroups"]["all_hostgroups"]) : 0)."', " . - "all_servicegroups = '".(isset($ret["all_servicegroups"]["all_servicegroups"]) ? $pearDB->escape($ret["all_servicegroups"]["all_servicegroups"]) : 0)."', " . - "acl_res_activate = '".$pearDB->escape($ret["acl_res_activate"]["acl_res_activate"])."', " . - "acl_res_comment = '".$pearDB->escape(!isset($ret["acl_res_comment"]) ? "" : $ret["acl_res_comment"])."', " . - "changed = '1' " . - "WHERE acl_res_id = '".$acl_id."'"; + $rq .= "SET acl_res_name = '" . $pearDB->escape($ret["acl_res_name"]) . "', " . + "acl_res_alias = '" . $pearDB->escape($ret["acl_res_alias"]) . "', " . + "all_hosts = '" . (isset($ret["all_hosts"]["all_hosts"]) + ? $pearDB->escape($ret["all_hosts"]["all_hosts"]) + : 0) . "', " . + "all_hostgroups = '" . (isset($ret["all_hostgroups"]["all_hostgroups"]) + ? $pearDB->escape($ret["all_hostgroups"]["all_hostgroups"]) + : 0) . "', " . + "all_servicegroups = '" . (isset($ret["all_servicegroups"]["all_servicegroups"]) + ? $pearDB->escape($ret["all_servicegroups"]["all_servicegroups"]) + : 0) . "', " . + "acl_res_activate = '" . $pearDB->escape($ret["acl_res_activate"]["acl_res_activate"]) . "', " . + "acl_res_comment = '" . $pearDB->escape(!isset($ret["acl_res_comment"]) + ? "" + : $ret["acl_res_comment"]) . "', " . + "changed = '1' " . + "WHERE acl_res_id = '" . $acl_id . "'"; $DBRESULT = $pearDB->query($rq); } @@ -308,13 +350,15 @@ function updateGroups($acl_id = null) return; } - $DBRESULT = $pearDB->query("DELETE FROM acl_res_group_relations WHERE acl_res_id = '".$acl_id."'"); + $pearDB->query("DELETE FROM acl_res_group_relations WHERE acl_res_id = '" . $acl_id . "'"); $ret = array(); $ret = $form->getSubmitValue("acl_groups"); if (isset($ret)) { foreach ($ret as $key => $value) { if (isset($value)) { - $DBRESULT = $pearDB->query("INSERT INTO acl_res_group_relations (acl_res_id, acl_group_id) VALUES ('".$acl_id."', '".$value."')"); + $query = "INSERT INTO acl_res_group_relations (acl_res_id, acl_group_id) VALUES ('" . + $acl_id . "', '" . $value . "')"; + $DBRESULT = $pearDB->query($query); } } } @@ -333,13 +377,15 @@ function updateHosts($acl_id = null) return; } - $DBRESULT = $pearDB->query("DELETE FROM acl_resources_host_relations WHERE acl_res_id = '".$acl_id."'"); + $pearDB->query("DELETE FROM acl_resources_host_relations WHERE acl_res_id = '" . $acl_id . "'"); $ret = array(); $ret = $form->getSubmitValue("acl_hosts"); if (isset($ret)) { foreach ($ret as $key => $value) { if (isset($value)) { - $DBRESULT = $pearDB->query("INSERT INTO acl_resources_host_relations (acl_res_id, host_host_id) VALUES ('".$acl_id."', '".$value."')"); + $query = "INSERT INTO acl_resources_host_relations (acl_res_id, host_host_id) VALUES ('" . + $acl_id . "', '" . $value . "')"; + $DBRESULT = $pearDB->query($query); } } } @@ -358,13 +404,15 @@ function updatePollers($acl_id = null) return; } - $res = $pearDB->query("DELETE FROM acl_resources_poller_relations WHERE acl_res_id = '".$acl_id."'"); + $pearDB->query("DELETE FROM acl_resources_poller_relations WHERE acl_res_id = '" . $acl_id . "'"); $ret = array(); $ret = $form->getSubmitValue("acl_pollers"); if (isset($ret)) { foreach ($ret as $key => $value) { if (isset($value)) { - $res = $pearDB->query("INSERT INTO acl_resources_poller_relations (acl_res_id, poller_id) VALUES ('".$acl_id."', '".$value."')"); + $query = "INSERT INTO acl_resources_poller_relations (acl_res_id, poller_id) VALUES ('" . + $acl_id . "', '" . $value . "')"; + $res = $pearDB->query($query); } } } @@ -383,13 +431,15 @@ function updateHostexcludes($acl_id = null) return; } - $DBRESULT = $pearDB->query("DELETE FROM acl_resources_hostex_relations WHERE acl_res_id = '".$acl_id."'"); + $pearDB->query("DELETE FROM acl_resources_hostex_relations WHERE acl_res_id = '" . $acl_id . "'"); $ret = array(); $ret = $form->getSubmitValue("acl_hostexclude"); if (isset($ret)) { foreach ($ret as $key => $value) { if (isset($value)) { - $DBRESULT = $pearDB->query("INSERT INTO acl_resources_hostex_relations (acl_res_id, host_host_id) VALUES ('".$acl_id."', '".$value."')"); + $query = "INSERT INTO acl_resources_hostex_relations (acl_res_id, host_host_id) VALUES ('" . + $acl_id . "', '" . $value . "')"; + $DBRESULT = $pearDB->query($query); } } } @@ -408,13 +458,15 @@ function updateHostGroups($acl_id = null) return; } - $DBRESULT = $pearDB->query("DELETE FROM acl_resources_hg_relations WHERE acl_res_id = '".$acl_id."'"); + $pearDB->query("DELETE FROM acl_resources_hg_relations WHERE acl_res_id = '" . $acl_id . "'"); $ret = array(); $ret = $form->getSubmitValue("acl_hostgroup"); if (isset($ret)) { foreach ($ret as $key => $value) { if (isset($value)) { - $DBRESULT = $pearDB->query("INSERT INTO acl_resources_hg_relations (acl_res_id, hg_hg_id) VALUES ('".$acl_id."', '".$value."')"); + $query = "INSERT INTO acl_resources_hg_relations (acl_res_id, hg_hg_id) VALUES ('" . + $acl_id . "', '" . $value . "')"; + $DBRESULT = $pearDB->query($query); } } } @@ -433,13 +485,15 @@ function updateServiceCategories($acl_id = null) return; } - $DBRESULT = $pearDB->query("DELETE FROM acl_resources_sc_relations WHERE acl_res_id = '".$acl_id."'"); + $pearDB->query("DELETE FROM acl_resources_sc_relations WHERE acl_res_id = '" . $acl_id . "'"); $ret = array(); $ret = $form->getSubmitValue("acl_sc"); if (isset($ret)) { foreach ($ret as $key => $value) { if (isset($value)) { - $DBRESULT = $pearDB->query("INSERT INTO acl_resources_sc_relations (acl_res_id, sc_id) VALUES ('".$acl_id."', '".$value."')"); + $query = "INSERT INTO acl_resources_sc_relations (acl_res_id, sc_id) VALUES ('" . + $acl_id . "', '" . $value . "')"; + $DBRESULT = $pearDB->query($query); } } } @@ -458,13 +512,15 @@ function updateHostCategories($acl_id = null) return; } - $DBRESULT = $pearDB->query("DELETE FROM acl_resources_hc_relations WHERE acl_res_id = '".$acl_id."'"); + $pearDB->query("DELETE FROM acl_resources_hc_relations WHERE acl_res_id = '" . $acl_id . "'"); $ret = array(); $ret = $form->getSubmitValue("acl_hc"); if (isset($ret)) { foreach ($ret as $key => $value) { if (isset($value)) { - $DBRESULT = $pearDB->query("INSERT INTO acl_resources_hc_relations (acl_res_id, hc_id) VALUES ('".$acl_id."', '".$value."')"); + $query = "INSERT INTO acl_resources_hc_relations (acl_res_id, hc_id) VALUES ('" . + $acl_id . "', '" . $value . "')"; + $DBRESULT = $pearDB->query($query); } } } @@ -483,13 +539,15 @@ function updateServiceGroups($acl_id = null) return; } - $DBRESULT = $pearDB->query("DELETE FROM acl_resources_sg_relations WHERE acl_res_id = '".$acl_id."'"); + $pearDB->query("DELETE FROM acl_resources_sg_relations WHERE acl_res_id = '" . $acl_id . "'"); $ret = array(); $ret = $form->getSubmitValue("acl_sg"); if (isset($ret)) { foreach ($ret as $key => $value) { if (isset($value)) { - $DBRESULT = $pearDB->query("INSERT INTO acl_resources_sg_relations (acl_res_id, sg_id) VALUES ('".$acl_id."', '".$value."')"); + $query = "INSERT INTO acl_resources_sg_relations (acl_res_id, sg_id) VALUES ('" . + $acl_id . "', '" . $value . "')"; + $DBRESULT = $pearDB->query($query); } } } @@ -508,13 +566,15 @@ function updateMetaServices($acl_id = null) return; } - $DBRESULT = $pearDB->query("DELETE FROM acl_resources_meta_relations WHERE acl_res_id = '".$acl_id."'"); + $DBRESULT = $pearDB->query("DELETE FROM acl_resources_meta_relations WHERE acl_res_id = '" . $acl_id . "'"); $ret = array(); $ret = $form->getSubmitValue("acl_meta"); if (isset($ret)) { foreach ($ret as $key => $value) { if (isset($value)) { - $DBRESULT = $pearDB->query("INSERT INTO acl_resources_meta_relations (acl_res_id, meta_id) VALUES ('".$acl_id."', '".$value."')"); + $query = "INSERT INTO acl_resources_meta_relations (acl_res_id, meta_id) VALUES ('" . + $acl_id . "', '" . $value . "')"; + $DBRESULT = $pearDB->query($query); } } } diff --git a/www/include/options/accessLists/resourcesACL/formResourcesAccess.php b/www/include/options/accessLists/resourcesACL/formResourcesAccess.php index b43086b5319..d2ab3aceb3a 100644 --- a/www/include/options/accessLists/resourcesACL/formResourcesAccess.php +++ b/www/include/options/accessLists/resourcesACL/formResourcesAccess.php @@ -44,13 +44,14 @@ /* * Set base value */ - $DBRESULT = $pearDB->query("SELECT * FROM acl_resources WHERE acl_res_id = '".$acl_id."' LIMIT 1"); + $DBRESULT = $pearDB->query("SELECT * FROM acl_resources WHERE acl_res_id = '" . $acl_id . "' LIMIT 1"); $acl = array_map("myDecode", $DBRESULT->fetchRow()); /* * Set Poller relations */ - $DBRESULT = $pearDB->query("SELECT poller_id FROM acl_resources_poller_relations WHERE acl_res_id = '".$acl_id."'"); + $query = "SELECT poller_id FROM acl_resources_poller_relations WHERE acl_res_id = '" . $acl_id . "'"; + $DBRESULT = $pearDB->query($query); for ($i = 0; $pollers_list = $DBRESULT->fetchRow(); $i++) { $acl["acl_pollers"][$i] = $pollers_list["poller_id"]; } @@ -60,7 +61,8 @@ * Set Hosts relations */ $hostnotexludes = array(); - $DBRESULT = $pearDB->query("SELECT host_host_id FROM acl_resources_host_relations WHERE acl_res_id = '".$acl_id."'"); + $query = "SELECT host_host_id FROM acl_resources_host_relations WHERE acl_res_id = '" . $acl_id . "'"; + $DBRESULT = $pearDB->query($query); for ($i = 0; $hosts_list = $DBRESULT->fetchRow(); $i++) { $acl["acl_hosts"][$i] = $hosts_list["host_host_id"]; $hostnotexludes[$hosts_list["host_host_id"]] = 1; @@ -70,7 +72,8 @@ /* * Set Hosts exludes relations */ - $DBRESULT = $pearDB->query("SELECT host_host_id FROM acl_resources_hostex_relations WHERE acl_res_id = '".$acl_id."'"); + $query = "SELECT host_host_id FROM acl_resources_hostex_relations WHERE acl_res_id = '" . $acl_id . "'"; + $DBRESULT = $pearDB->query($query); for ($i = 0; $hosts_list = $DBRESULT->fetchRow(); $i++) { $acl["acl_hostexclude"][$i] = $hosts_list["host_host_id"]; } @@ -79,7 +82,7 @@ /* * Set Hosts Groups relations */ - $DBRESULT = $pearDB->query("SELECT hg_hg_id FROM acl_resources_hg_relations WHERE acl_res_id = '".$acl_id."'"); + $DBRESULT = $pearDB->query("SELECT hg_hg_id FROM acl_resources_hg_relations WHERE acl_res_id = '" . $acl_id . "'"); for ($i = 0; $hg_list = $DBRESULT->fetchRow(); $i++) { $acl["acl_hostgroup"][$i] = $hg_list["hg_hg_id"]; } @@ -88,7 +91,8 @@ /* * Set Groups relations */ - $DBRESULT = $pearDB->query("SELECT DISTINCT acl_group_id FROM acl_res_group_relations WHERE acl_res_id = '".$acl_id."'"); + $query = "SELECT DISTINCT acl_group_id FROM acl_res_group_relations WHERE acl_res_id = '" . $acl_id . "'"; + $DBRESULT = $pearDB->query($query); for ($i = 0; $groups = $DBRESULT->fetchRow(); $i++) { $acl["acl_groups"][$i] = $groups["acl_group_id"]; } @@ -97,7 +101,8 @@ /* * Set Service Categories relations */ - $DBRESULT = $pearDB->query("SELECT DISTINCT sc_id FROM acl_resources_sc_relations WHERE acl_res_id = '".$acl_id."'"); + $query = "SELECT DISTINCT sc_id FROM acl_resources_sc_relations WHERE acl_res_id = '" . $acl_id . "'"; + $DBRESULT = $pearDB->query($query); if ($DBRESULT->rowCount()) { for ($i = 0; $sc = $DBRESULT->fetchRow(); $i++) { $acl["acl_sc"][$i] = $sc["sc_id"]; @@ -108,7 +113,8 @@ /* * Set Host Categories */ - $DBRESULT = $pearDB->query("SELECT DISTINCT hc_id FROM acl_resources_hc_relations WHERE acl_res_id = '".$acl_id."'"); + $query = "SELECT DISTINCT hc_id FROM acl_resources_hc_relations WHERE acl_res_id = '" . $acl_id . "'"; + $DBRESULT = $pearDB->query($query); if ($DBRESULT->rowCount()) { for ($i = 0; $hc = $DBRESULT->fetchRow(); $i++) { $acl["acl_hc"][$i] = $hc["hc_id"]; @@ -119,7 +125,8 @@ /* * Set Service Groups relations */ - $DBRESULT = $pearDB->query("SELECT DISTINCT sg_id FROM acl_resources_sg_relations WHERE acl_res_id = '".$acl_id."'"); + $query = "SELECT DISTINCT sg_id FROM acl_resources_sg_relations WHERE acl_res_id = '" . $acl_id . "'"; + $DBRESULT = $pearDB->query($query); if ($DBRESULT->rowCount()) { for ($i = 0; $sg = $DBRESULT->fetchRow(); $i++) { $acl["acl_sg"][$i] = $sg["sg_id"]; @@ -130,7 +137,8 @@ /* * Set Meta Services relations */ - $DBRESULT = $pearDB->query("SELECT DISTINCT meta_id FROM acl_resources_meta_relations WHERE acl_res_id = '".$acl_id."'"); + $query = "SELECT DISTINCT meta_id FROM acl_resources_meta_relations WHERE acl_res_id = '" . $acl_id . "'"; + $DBRESULT = $pearDB->query($query); if ($DBRESULT->rowCount()) { for ($i = 0; $ms = $DBRESULT->fetchRow(); $i++) { $acl["acl_meta"][$i] = $ms["meta_id"]; @@ -205,16 +213,17 @@ /* * Var information to format the element */ -$attrsText = array("size"=>"30"); -$attrsText2 = array("size"=>"60"); +$attrsText = array("size" => "30"); +$attrsText2 = array("size" => "60"); $attrsAdvSelect = array("style" => "width: 300px; height: 220px;"); -$attrsTextarea = array("rows"=>"3", "cols"=>"80"); -$eTemplate = '
{label_2}
{unselected}
{add}


{remove}
{label_3}
{selected}
'; +$attrsTextarea = array("rows" => "3", "cols" => "80"); +$eTemplate = '
{label_2}
{unselected}
{add}
' . +'

{remove}
{label_3}
{selected}
'; /* * Form begin */ -$form = new HTML_QuickForm('Form', 'POST', "?p=".$p); +$form = new HTML_QuickForm('Form', 'POST', "?p=" . $p); if ($o == "a") { $form->addElement('header', 'title', _("Add an ACL")); } elseif ($o == "c") { @@ -241,13 +250,31 @@ /* * All ressources */ -$allHosts[] = HTML_QuickForm::createElement('checkbox', 'all_hosts', ' ', "", array('id' => 'all_hosts', 'onclick' => 'advancedDisplay(this.id)')); +$allHosts[] = HTML_QuickForm::createElement( + 'checkbox', + 'all_hosts', + ' ', + "", + array('id' => 'all_hosts', 'onclick' => 'advancedDisplay(this.id)') +); $form->addGroup($allHosts, 'all_hosts', _("Include all hosts"), '  '); -$allHostgroups[] = HTML_QuickForm::createElement('checkbox', 'all_hostgroups', ' ', "", array('id' => 'all_hostgroups', 'onclick' => 'advancedDisplay(this.id)')); +$allHostgroups[] = HTML_QuickForm::createElement( + 'checkbox', + 'all_hostgroups', + ' ', + "", + array('id' => 'all_hostgroups', 'onclick' => 'advancedDisplay(this.id)') +); $form->addGroup($allHostgroups, 'all_hostgroups', _("Include all hostgroups"), '  '); -$allServiceGroups[] = HTML_QuickForm::createElement('checkbox', 'all_servicegroups', ' ', "", array('id' => 'all_servicegroups', 'onclick' => 'advancedDisplay(this.id)')); +$allServiceGroups[] = HTML_QuickForm::createElement( + 'checkbox', + 'all_servicegroups', + ' ', + "", + array('id' => 'all_servicegroups', 'onclick' => 'advancedDisplay(this.id)') +); $form->addGroup($allServiceGroups, 'all_servicegroups', _("Include all servicegroups"), '  '); /* @@ -255,24 +282,56 @@ */ $form->addElement('header', 'contacts_infos', _("People linked to this Access list")); -$ams1 = $form->addElement('advmultiselect', 'acl_groups', array(_("Linked Groups"), _("Available"), _("Selected")), $groups, $attrsAdvSelect, SORT_ASC); -$ams1->setButtonAttributes('add', array('value' => _("Add"), "class" => "btc bt_success")); +$ams1 = $form->addElement( + 'advmultiselect', + 'acl_groups', + array(_("Linked Groups"), _("Available"), _("Selected")), + $groups, + $attrsAdvSelect, + SORT_ASC +); +$ams1->setButtonAttributes('add', array('value' => _("Add"), "class" => "btc bt_success")); $ams1->setButtonAttributes('remove', array('value' => _("Remove"), "class" => "btc bt_danger")); $ams1->setElementTemplate($eTemplate); echo $ams1->getElementJs(false); $form->addElement('header', 'Host_infos', _("Shared Resources")); $form->addElement('header', 'help', _("Help")); -$form->addElement('header', 'HSharedExplain', _("Help : Select hosts and hostgroups that can be seen by associated users. You also have the possibility to exclude host(s) from selected hostgroup(s).")); -$form->addElement('header', 'SSharedExplain', _("Help : Select services that can be seen by associated users.")); -$form->addElement('header', 'MSSharedExplain', _("Help : Select meta services that can be seen by associated users.")); -$form->addElement('header', 'FilterExplain', _("Help : Select the filter(s) you want to apply to the resource definition for a more restrictive view.")); +$form->addElement( + 'header', + 'HSharedExplain', + _("Help : Select hosts and hostgroups that can be seen by associated users. " . + "You also have the possibility to exclude host(s) from selected hostgroup(s).") +); +$form->addElement( + 'header', + 'SSharedExplain', + _("Help : Select services that can be seen by associated users.") +); +$form->addElement( + 'header', + 'MSSharedExplain', + _("Help : Select meta services that can be seen by associated users.") +); +$form->addElement( + 'header', + 'FilterExplain', + _("Help : Select the filter(s) you want to apply to the " . + "resource definition for a more restrictive view.") +); /* * Pollers */ -$ams0 = $form->addElement('advmultiselect', 'acl_pollers', array(_("Poller Filter"), _("Available"), _("Selected")), $pollers, $attrsAdvSelect, SORT_ASC); -$ams0->setButtonAttributes('add', array('value' => _("Add"), "class" => "btc bt_success")); +$ams0 = $form->addElement( + 'advmultiselect', + 'acl_pollers', + array(_("Poller Filter"), _("Available"), _("Selected")), + $pollers, + $attrsAdvSelect, + SORT_ASC +); +$ams0->setButtonAttributes('add', array('value' => _("Add"), "class" => "btc bt_success")); $ams0->setButtonAttributes('remove', array('value' => _("Remove"), "class" => "btc bt_danger")); $ams0->setElementTemplate($eTemplate); echo $ams0->getElementJs(false); @@ -281,8 +340,15 @@ * Hosts */ $attrsAdvSelect['id'] = 'hostAdvancedSelect'; -$ams2 = $form->addElement('advmultiselect', 'acl_hosts', array(_("Hosts"), _("Available"), _("Selected")), $hosts, $attrsAdvSelect, SORT_ASC); -$ams2->setButtonAttributes('add', array('value' => _("Add"), "class" => "btc bt_success")); +$ams2 = $form->addElement( + 'advmultiselect', + 'acl_hosts', + array(_("Hosts"), _("Available"), _("Selected")), + $hosts, + $attrsAdvSelect, + SORT_ASC +); +$ams2->setButtonAttributes('add', array('value' => _("Add"), "class" => "btc bt_success")); $ams2->setButtonAttributes('remove', array('value' => _("Remove"), "class" => "btc bt_danger")); $ams2->setElementTemplate($eTemplate); echo $ams2->getElementJs(false); @@ -291,16 +357,30 @@ * Host Groups */ $attrsAdvSelect['id'] = 'hostgroupAdvancedSelect'; -$ams2 = $form->addElement('advmultiselect', 'acl_hostgroup', array(_("Host Groups"), _("Available"), _("Selected")), $hostgroups, $attrsAdvSelect, SORT_ASC); -$ams2->setButtonAttributes('add', array('value' => _("Add"), "class" => "btc bt_success")); +$ams2 = $form->addElement( + 'advmultiselect', + 'acl_hostgroup', + array(_("Host Groups"), _("Available"), _("Selected")), + $hostgroups, + $attrsAdvSelect, + SORT_ASC +); +$ams2->setButtonAttributes('add', array('value' => _("Add"), "class" => "btc bt_success")); $ams2->setButtonAttributes('remove', array('value' => _("Remove"), "class" => "btc bt_danger")); $ams2->setElementTemplate($eTemplate); echo $ams2->getElementJs(false); unset($attrsAdvSelect['id']); -$ams2 = $form->addElement('advmultiselect', 'acl_hostexclude', array(_("Exclude hosts from selected host groups"), _("Available"), _("Selected")), $hosttoexcludes, $attrsAdvSelect, SORT_ASC); -$ams2->setButtonAttributes('add', array('value' => _("Add"), "class" => "btc bt_success")); +$ams2 = $form->addElement( + 'advmultiselect', + 'acl_hostexclude', + array(_("Exclude hosts from selected host groups"), _("Available"), _("Selected")), + $hosttoexcludes, + $attrsAdvSelect, + SORT_ASC +); +$ams2->setButtonAttributes('add', array('value' => _("Add"), "class" => "btc bt_success")); $ams2->setButtonAttributes('remove', array('value' => _("Remove"), "class" => "btc bt_danger")); $ams2->setElementTemplate($eTemplate); echo $ams2->getElementJs(false); @@ -308,8 +388,15 @@ /* * Service Filters */ -$ams2 = $form->addElement('advmultiselect', 'acl_sc', array(_("Service Category Filter"), _("Available"), _("Selected")), $service_categories, $attrsAdvSelect, SORT_ASC); -$ams2->setButtonAttributes('add', array('value' => _("Add"), "class" => "btc bt_success")); +$ams2 = $form->addElement( + 'advmultiselect', + 'acl_sc', + array(_("Service Category Filter"), _("Available"), _("Selected")), + $service_categories, + $attrsAdvSelect, + SORT_ASC +); +$ams2->setButtonAttributes('add', array('value' => _("Add"), "class" => "btc bt_success")); $ams2->setButtonAttributes('remove', array('value' => _("Remove"), "class" => "btc bt_danger")); $ams2->setElementTemplate($eTemplate); echo $ams2->getElementJs(false); @@ -317,8 +404,15 @@ /* * Host Filters */ -$ams2 = $form->addElement('advmultiselect', 'acl_hc', array(_("Host Category Filter"), _("Available"), _("Selected")), $host_categories, $attrsAdvSelect, SORT_ASC); -$ams2->setButtonAttributes('add', array('value' => _("Add"), "class" => "btc bt_success")); +$ams2 = $form->addElement( + 'advmultiselect', + 'acl_hc', + array(_("Host Category Filter"), _("Available"), _("Selected")), + $host_categories, + $attrsAdvSelect, + SORT_ASC +); +$ams2->setButtonAttributes('add', array('value' => _("Add"), "class" => "btc bt_success")); $ams2->setButtonAttributes('remove', array('value' => _("Remove"), "class" => "btc bt_danger")); $ams2->setElementTemplate($eTemplate); echo $ams2->getElementJs(false); @@ -327,8 +421,15 @@ * Service Groups Add */ $attrsAdvSelect['id'] = 'servicegroupAdvancedSelect'; -$ams2 = $form->addElement('advmultiselect', 'acl_sg', array(_("Service Groups"), _("Available"), _("Selected")), $service_groups, $attrsAdvSelect, SORT_ASC); -$ams2->setButtonAttributes('add', array('value' => _("Add"), "class" => "btc bt_success")); +$ams2 = $form->addElement( + 'advmultiselect', + 'acl_sg', + array(_("Service Groups"), _("Available"), _("Selected")), + $service_groups, + $attrsAdvSelect, + SORT_ASC +); +$ams2->setButtonAttributes('add', array('value' => _("Add"), "class" => "btc bt_success")); $ams2->setButtonAttributes('remove', array('value' => _("Remove"), "class" => "btc bt_danger")); $ams2->setElementTemplate($eTemplate); echo $ams2->getElementJs(false); @@ -337,8 +438,19 @@ /* * Meta Services */ -$ams2 = $form->addElement('advmultiselect', 'acl_meta', array(_("Meta Services"), _("Available"), _("Selected")), $meta_services, $attrsAdvSelect, SORT_ASC); -$ams2->setButtonAttributes('add', array('value' => _("Add"), "class" => "btc bt_success")); +$ams2 = $form->addElement( + 'advmultiselect', + 'acl_meta', + array( + _("Meta Services"), + _("Available"), + _("Selected") + ), + $meta_services, + $attrsAdvSelect, + SORT_ASC +); +$ams2->setButtonAttributes('add', array('value' => _("Add"), "class" => "btc bt_success")); $ams2->setButtonAttributes('remove', array('value' => _("Remove"), "class" => "btc bt_danger")); $ams2->setElementTemplate($eTemplate); echo $ams2->getElementJs(false); @@ -375,7 +487,10 @@ /* * Just watch a LCA information */ - $form->addElement("button", "change", _("Modify"), array("onClick"=>"javascript:window.location.href='?p=".$p."&o=c&acl_id=".$acl_id."'", "class" => "btc bt_success")); + $form->addElement("button", "change", _("Modify"), array( + "onClick" => "javascript:window.location.href='?p=" . $p . "&o=c&acl_id=" . $acl_id . "'", + "class" => "btc bt_success" + )); $form->setDefaults($acl); $form->freeze(); } elseif ($o == "c") { @@ -392,16 +507,16 @@ $subA = $form->addElement('submit', 'submitA', _("Save"), array("class" => "btc bt_success")); $res = $form->addElement('reset', 'reset', _("Delete"), array("class" => "btc bt_danger")); } -$tpl->assign('msg', array ("changeL"=>"?p=".$p."&o=c&lca_id=".$acl_id, "changeT"=>_("Modify"))); - - // prepare help texts +$tpl->assign('msg', array("changeL" => "?p=" . $p . "&o=c&lca_id=" . $acl_id, "changeT" => _("Modify"))); + +// prepare help texts $helptext = ""; include_once("help.php"); foreach ($help as $key => $text) { - $helptext .= ''."\n"; + $helptext .= '' . "\n"; } $tpl->assign("helptext", $helptext); - + $valid = false; if ($form->validate()) { $aclObj = $form->getElement('acl_res_id'); @@ -435,19 +550,16 @@ } ?> diff --git a/www/include/options/accessLists/resourcesACL/help.php b/www/include/options/accessLists/resourcesACL/help.php index cc708ffbd03..92809305b11 100644 --- a/www/include/options/accessLists/resourcesACL/help.php +++ b/www/include/options/accessLists/resourcesACL/help.php @@ -25,15 +25,28 @@ * Shared Host Resouces */ -$help['tip_hosts'] = dgettext('help', 'Hosts that will be displayed to users. Services that belong to these hosts will also be visible.'); -$help['tip_host_groups'] = dgettext('help', 'Host groups that will be displayed to users. Hosts that belong to these host groups will also be visible.'); -$help['tip_exclude_hosts_from_selected_host_groups'] = dgettext('help', 'Excluding hosts from the selected host groups will hide them from users.'); +$help['tip_hosts'] = dgettext( + 'help', + 'Hosts that will be displayed to users. Services that belong to these hosts will also be visible.' +); +$help['tip_host_groups'] = dgettext( + 'help', + 'Host groups that will be displayed to users. Hosts that belong to these host groups will also be visible.' +); +$help['tip_exclude_hosts_from_selected_host_groups'] = dgettext( + 'help', + 'Excluding hosts from the selected host groups will hide them from users.' +); /** * Shared Service Resouces */ -$help['tip_service_groups'] = dgettext('help', 'Service groups that will be displayed to users. Services that belong to these service groups will also be visible.'); +$help['tip_service_groups'] = dgettext( + 'help', + 'Service groups that will be displayed to users. ' . + 'Services that belong to these service groups will also be visible.' +); /** * Shared Meta Services Resouces @@ -45,6 +58,15 @@ * Filters */ -$help['tip_poller_filter'] = dgettext('help', 'Will only display resources that are monitored by these pollers. When blank, no filter is applied.'); -$help['tip_host_category_filter'] = dgettext('help', 'Will only display hosts that belong to these host categories. When blank, no filter is applied.'); -$help['tip_service_category_filter'] = dgettext('help', 'Will only display services that belong to these service categories. When blank, no filter is applied.'); +$help['tip_poller_filter'] = dgettext( + 'help', + 'Will only display resources that are monitored by these pollers. When blank, no filter is applied.' +); +$help['tip_host_category_filter'] = dgettext( + 'help', + 'Will only display hosts that belong to these host categories. When blank, no filter is applied.' +); +$help['tip_service_category_filter'] = dgettext( + 'help', + 'Will only display services that belong to these service categories. When blank, no filter is applied.' +); diff --git a/www/include/options/accessLists/resourcesACL/showUsersAccess.php b/www/include/options/accessLists/resourcesACL/showUsersAccess.php index e7530971747..c7fc3deb561 100644 --- a/www/include/options/accessLists/resourcesACL/showUsersAccess.php +++ b/www/include/options/accessLists/resourcesACL/showUsersAccess.php @@ -51,7 +51,8 @@ * Get user list */ $contact = array("" => null); -$DBRESULT = $pearDB->query("SELECT contact_id, contact_alias FROM contact WHERE contact_admin = '0' ORDER BY contact_alias"); +$query = "SELECT contact_id, contact_alias FROM contact WHERE contact_admin = '0' ORDER BY contact_alias"; +$DBRESULT = $pearDB->query($query); while ($ct = $DBRESULT->fetchRow()) { $contact[$ct["contact_id"]] = $ct["contact_alias"]; } @@ -60,8 +61,8 @@ /* * Object init */ -$mediaObj = new CentreonMedia($pearDB); -$host_method = new CentreonHost($pearDB); +$mediaObj = new CentreonMedia($pearDB); +$host_method = new CentreonHost($pearDB); /* * Smarty template Init @@ -90,7 +91,7 @@ if ($groups != "") { $groups .= ","; } - $groups .= "'".$key."'"; + $groups .= "'" . $key . "'"; } } } else { @@ -104,9 +105,15 @@ /* * Create select form */ -$form = new HTML_QuickForm('select_form', 'GET', "?p=".$p); +$form = new HTML_QuickForm('select_form', 'GET', "?p=" . $p); -$form->addElement('select', 'contact', _("Centreon Users"), $contact, array('id'=>'contact', 'onChange'=>'submit();')); +$form->addElement( + 'select', + 'contact', + _("Centreon Users"), + $contact, + array('id' => 'contact', 'onChange' => 'submit();') +); $form->setDefaults($formData); /* @@ -114,26 +121,31 @@ */ $elemArr = array(); $query = "SELECT DISTINCT h.name, s.description, acl.host_id, acl.service_id " - . "FROM centreon_acl acl " - . "LEFT JOIN hosts h on acl.host_id = h.host_id " - . "LEFT JOIN services s on s.service_id = acl.service_id " - . "WHERE acl.group_id IN ($groups) ORDER BY h.name, s.description"; - $DBRESULT = $pearDBO->query($query); + . "FROM centreon_acl acl " + . "LEFT JOIN hosts h on acl.host_id = h.host_id " + . "LEFT JOIN services s on s.service_id = acl.service_id " + . "WHERE acl.group_id IN ($groups) ORDER BY h.name, s.description"; +$DBRESULT = $pearDBO->query($query); for ($i = 0; $resources = $DBRESULT->fetchRow(); $i++) { if ((isset($ehiCache[$resources["host_id"]]) && $ehiCache[$resources["host_id"]])) { $host_icone = "./img/media/" . $mediaObj->getFilename($ehiCache[$resources["host_id"]]); - } elseif ($icone = $host_method->replaceMacroInString($resources["host_id"], getMyHostExtendedInfoImage($resources["host_id"], "ehi_icon_image", 1))) { + } elseif ($icone = $host_method->replaceMacroInString( + $resources["host_id"], + getMyHostExtendedInfoImage($resources["host_id"], "ehi_icon_image", 1) + ) + ) { $host_icone = "./img/media/" . $icone; } else { $host_icone = "./img/icons/host.png"; } $moptions = ""; - $elemArr[$i] = array("MenuClass"=>"list_".$style, - "RowMenu_hico" => $host_icone, - "RowMenu_host" => myDecode($resources["name"]), - "RowMenu_service" => myDecode($resources["description"]), - ); + $elemArr[$i] = array( + "MenuClass" => "list_" . $style, + "RowMenu_hico" => $host_icone, + "RowMenu_host" => myDecode($resources["name"]), + "RowMenu_service" => myDecode($resources["description"]), + ); $style != "two" ? $style = "two" : $style = "one"; } $tpl->assign("elemArr", $elemArr); From e891cc1977911ac417662d1f9167a19a92706ef2 Mon Sep 17 00:00:00 2001 From: loiclau Date: Thu, 13 Jul 2017 16:50:08 +0200 Subject: [PATCH 025/207] * fix style --- .../configuration/configObject/escalation/img_gantt.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/www/include/configuration/configObject/escalation/img_gantt.php b/www/include/configuration/configObject/escalation/img_gantt.php index f866b3b96a0..4b2487700dd 100644 --- a/www/include/configuration/configObject/escalation/img_gantt.php +++ b/www/include/configuration/configObject/escalation/img_gantt.php @@ -274,9 +274,13 @@ $largeur = ($max_notif > 50) ? 1024 : 800; //$hauteur = ($nb_esc > 5) ? 768 : 400; $hauteur = - ($nb_esc_tot * 35) + (($max_contact_service == 0 + ($nb_esc_tot * 35) + ( + ( + $max_contact_service == 0 ? $nb_esc - : $max_contact_service) * 35) + 70; + : $max_contact_service + ) * 35 + ) + 70; $marge_left = ($max_contact_length) ? $max_contact_length * 13 : 10 * 13; $marge_legende = 20; $marge_bottom = 50 + $marge_legende; From c07c6acb684951a16886ec0d4599d7e7e1cbe541 Mon Sep 17 00:00:00 2001 From: loiclau Date: Mon, 17 Jul 2017 17:28:48 +0200 Subject: [PATCH 026/207] * fix custom view duplication with user group --- features/CustomViews.feature | 10 +++++----- www/class/centreonCustomView.class.php | 6 ++++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/features/CustomViews.feature b/features/CustomViews.feature index 6265ac7ee7d..f4d7c289243 100644 --- a/features/CustomViews.feature +++ b/features/CustomViews.feature @@ -26,7 +26,7 @@ Feature: Custom views When the owner removes the view Then the view is not visible anymore for the user -# user shared locke views +# user shared locked views Scenario: Share read-only custom view with users Given a custom view shared in read only with a user When the user wishes to add a new custom view @@ -52,7 +52,7 @@ Feature: Custom views When the owner removes the view Then the view is removed for all users displaying the custom view -# user shared not locke views +# user shared not locked views Scenario: Modify a shared view Given a shared custom view When the user is using the shared view @@ -64,7 +64,7 @@ Feature: Custom views When he removes the shared view Then the view is not visible anymore And the user can use the shared view again - + Scenario: Modify an unlocked shared view and applies changes Given a shared custom view And the user is using the shared view @@ -79,7 +79,7 @@ Feature: Custom views Then the view remains visible for all users displaying the custom view And the view is removed for the owner -# contact groups shared locke views +# contact groups shared locked views Scenario: Share read-only custom view with groups Given a custom view shared in read only with a group When the user wishes to add a new custom view @@ -105,7 +105,7 @@ Feature: Custom views When the owner removes the view Then the view is removed for all users displaying the custom view -# contact groups shared not locke views +# contact groups shared not locked views Scenario: Modify a shared view with groups Given a shared custom view with a group When the user is using the shared view diff --git a/www/class/centreonCustomView.class.php b/www/class/centreonCustomView.class.php index 3be4868dea1..0f804dbbbcc 100644 --- a/www/class/centreonCustomView.class.php +++ b/www/class/centreonCustomView.class.php @@ -595,7 +595,7 @@ public function loadCustomView($params) { $isLocked = 1; $update = false; - $query = 'SELECT custom_view_id, locked, user_id ' . + $query = 'SELECT custom_view_id, locked, user_id, usergroup_id ' . 'FROM custom_view_user_relation ' . 'WHERE custom_view_id = :viewLoad ' . 'AND ' . @@ -617,7 +617,9 @@ public function loadCustomView($params) if ($row['locked'] == "0") { $isLocked = $row['locked']; } - if (!is_null($row['user_id']) && $row['user_id'] > 0){ + if ((!is_null($row['user_id']) && $row['user_id'] > 0) || + (!is_null($row['usergroup_id']) && $row['usergroup_id'] > 0) + ) { $update = true; } } From 176e2679b79bd0f1b6edee5dcccf3ec7db12264b Mon Sep 17 00:00:00 2001 From: Matthieu Mandoula Date: Mon, 17 Jul 2017 17:44:30 +0200 Subject: [PATCH 027/207] Clapi service category (#5447) * put clipboard on app head and remove old lib tool.js * setServiceTemplate and setService functions created * setservice setservicetemplate functions added * setService and SetServiceTemplate methods updated * Comments zone updated in _call method * * fix style --- .../centreonServiceCategory.class.php | 153 ++++++++++++++++-- 1 file changed, 142 insertions(+), 11 deletions(-) diff --git a/www/class/centreon-clapi/centreonServiceCategory.class.php b/www/class/centreon-clapi/centreonServiceCategory.class.php index 5e5e85aa040..29177d26092 100644 --- a/www/class/centreon-clapi/centreonServiceCategory.class.php +++ b/www/class/centreon-clapi/centreonServiceCategory.class.php @@ -83,7 +83,7 @@ public function show($parameters = null) { $filters = array(); if (isset($parameters)) { - $filters = array($this->object->getUniqueLabelField() => "%".$parameters."%"); + $filters = array($this->object->getUniqueLabelField() => "%" . $parameters . "%"); } $params = array('sc_id', 'sc_name', 'sc_description', 'level'); $paramString = str_replace("sc_", "", implode($this->delim, $params)); @@ -130,27 +130,27 @@ public function setparam($parameters) } if (($objectId = $this->getObjectId($params[self::ORDER_UNIQUENAME])) != 0) { if (!preg_match("/^sc_/", $params[1])) { - $params[1] = "sc_".$params[1]; + $params[1] = "sc_" . $params[1]; } $updateParams = array($params[1] => $params[2]); parent::setparam($objectId, $updateParams); } else { - throw new CentreonClapiException(self::OBJECT_NOT_FOUND.":".$params[self::ORDER_UNIQUENAME]); + throw new CentreonClapiException(self::OBJECT_NOT_FOUND . ":" . $params[self::ORDER_UNIQUENAME]); } } /** - * Magic method for get/set/add/del relations * - * @param string $name - * @param array $arg + * @param type $name + * @param type $arg + * @throws CentreonClapiException */ public function __call($name, $arg) { /* Get the method name */ $name = strtolower($name); /* Get the action and the object */ - if (preg_match("/^(get|add|del)(service|servicetemplate)\$/", $name, $matches)) { + if (preg_match("/^(get|add|del|set)(service|servicetemplate)\$/", $name, $matches)) { /* Parse arguments */ if (!isset($arg[0])) { throw new CentreonClapiException(self::MISSINGPARAMETER); @@ -158,7 +158,7 @@ public function __call($name, $arg) $args = explode($this->delim, $arg[0]); $hcIds = $this->object->getIdByParameter($this->object->getUniqueLabelField(), array($args[0])); if (!count($hcIds)) { - throw new CentreonClapiException(self::OBJECT_NOT_FOUND .":".$args[0]); + throw new CentreonClapiException(self::OBJECT_NOT_FOUND . ":" . $args[0]); } $categoryId = $hcIds[0]; @@ -168,7 +168,7 @@ public function __call($name, $arg) if ($matches[1] == "get") { $tab = $relobj->getTargetIdFromSourceId($relobj->getSecondKey(), $relobj->getFirstKey(), $hcIds); if ($matches[2] == "servicetemplate") { - echo "template id".$this->delim."service template description\n"; + echo "template id" . $this->delim . "service template description\n"; } elseif ($matches[2] == "service") { echo "host id" . $this->delim . "host name" . $this->delim @@ -198,6 +198,12 @@ public function __call($name, $arg) echo $value . $this->delim . $p['service_description'] . "\n"; } } + } elseif ($matches[1] == "set") { + if ($matches[2] == "servicetemplate") { + $this->setServiceTemplate($args, $relobj, $obj, $categoryId); + } elseif ($matches[2] == "service") { + $this->setService($args, $relobj, $categoryId, $hostServiceRel, $obj); + } } else { if (!isset($args[1])) { throw new CentreonClapiException(self::MISSINGPARAMETER); @@ -222,7 +228,7 @@ public function __call($name, $arg) "AND" ); if (!count($elements)) { - throw new CentreonClapiException(self::OBJECT_NOT_FOUND . ":". $tmp[0]."/".$tmp[1]); + throw new CentreonClapiException(self::OBJECT_NOT_FOUND . ":" . $tmp[0] . "/" . $tmp[1]); } $relationTable[] = $elements[0]['service_id']; } elseif ($matches[2] == "servicetemplate") { @@ -236,7 +242,7 @@ public function __call($name, $arg) "AND" ); if (!count($tab)) { - throw new CentreonClapiException(self::OBJECT_NOT_FOUND . ":".$rel); + throw new CentreonClapiException(self::OBJECT_NOT_FOUND . ":" . $rel); } $relationTable[] = $tab[0]['service_id']; } @@ -263,6 +269,131 @@ public function __call($name, $arg) } } + /** + * + * @param type $args + * @param type $relobj + * @param type $categoryId + * @param type $hostServiceRel + * @param type $obj + * @throws CentreonClapiException + */ + private function setService($args, $relobj, $categoryId, $hostServiceRel, $obj) + { + if (!isset($args[1])) { + throw new CentreonClapiException(self::MISSINGPARAMETER); + } + $relation = $args[1]; + $relations = explode("|", $relation); + $relationTable = array(); + $excludedList = $obj->getList( + 'service_id', + -1, + 0, + null, + null, + array('service_register' => '1'), + 'AND' + ); + + foreach ($relations as $rel) { + $tmp = explode(",", $rel); + if (count($tmp) < 2) { + throw new CentreonClapiException(self::MISSINGPARAMETER); + } elseif (count($tmp) > 2) { + throw new CentreonClapiException('One Service by Host Name please!'); + } + $elements = $hostServiceRel->getMergedParameters( + array('host_id'), + array('service_id'), + -1, + 0, + null, + null, + array('host_name' => $tmp[0], 'service_description' => $tmp[1], 'service_register' => '1'), + "AND" + ); + if (!count($elements)) { + throw new CentreonClapiException(self::OBJECT_NOT_FOUND . ":" . $tmp[0] . "/" . $tmp[1]); + } + $relationTable[] = $elements[0]['service_id']; + } + $existingRelationIds = $relobj->getTargetIdFromSourceId( + $relobj->getSecondKey(), + $relobj->getFirstKey(), + array($categoryId) + ); + + foreach ($excludedList as $excluded) { + $relobj->delete($categoryId, $excluded['service_id']); + } + + foreach ($relationTable as $relationId) { + $relobj->insert($categoryId, $relationId); + } + $acl = new CentreonACL(); + $acl->reload(true); + } + + /** + * + * @param type $args + * @param type $relobj + * @param type $obj + * @param type $categoryId + * @throws CentreonClapiException + */ + private function setServiceTemplate($args, $relobj, $obj, $categoryId) + { + if (!isset($args[1])) { + throw new CentreonClapiException(self::MISSINGPARAMETER); + } + $relation = $args[1]; + $relations = explode("|", $relation); + $relationTable = array(); + $excludedList = $obj->getList( + "service_id", + -1, + 0, + null, + null, + array('service_register' => 0), + "AND" + ); + + foreach ($relations as $rel) { + $tab = $obj->getList( + "service_id", + -1, + 0, + null, + null, + array('service_description' => $rel, 'service_register' => 0), + "AND" + ); + if (!count($tab)) { + throw new CentreonClapiException(self::OBJECT_NOT_FOUND . ":" . $rel); + } + $relationTable[] = $tab[0]['service_id']; + } + + $existingRelationIds = $relobj->getTargetIdFromSourceId( + $relobj->getSecondKey(), + $relobj->getFirstKey(), + array($categoryId) + ); + + foreach ($excludedList as $excluded) { + $relobj->delete($categoryId, $excluded['service_id']); + } + + foreach ($relationTable as $relationId) { + $relobj->insert($categoryId, $relationId); + } + $acl = new CentreonACL(); + $acl->reload(true); + } + /** * Export * From 5a82cb406c50e10aa8a7d223873a553796cf7e85 Mon Sep 17 00:00:00 2001 From: mariegallardo Date: Wed, 12 Jul 2017 15:28:43 +0200 Subject: [PATCH 028/207] setservice and setservicetemplate added --- .../rest_api/rest_api.postman_collection.json | 124 ++++++++++++++++++ 1 file changed, 124 insertions(+) diff --git a/tests/rest_api/rest_api.postman_collection.json b/tests/rest_api/rest_api.postman_collection.json index d2f8b3d380c..aebcb9b8f7e 100644 --- a/tests/rest_api/rest_api.postman_collection.json +++ b/tests/rest_api/rest_api.postman_collection.json @@ -43812,6 +43812,68 @@ }, "response": [] }, + { + "name": "Setservice", + "event": [ + { + "listen": "test", + "script": { + "type": "text/javascript", + "exec": [ + "tests[\"Status code is 200\"] = responseCode.code === 200;" + ] + } + } + ], + "request": { + "url": { + "raw": "http://{{url}}/centreon/api/index.php?action=action&object=centreon_clapi", + "protocol": "http", + "host": [ + "{{url}}" + ], + "path": [ + "centreon", + "api", + "index.php" + ], + "query": [ + { + "key": "action", + "value": "action", + "equals": true, + "description": "" + }, + { + "key": "object", + "value": "centreon_clapi", + "equals": true, + "description": "" + } + ], + "variable": [] + }, + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "description": "" + }, + { + "key": "centreon-auth-token", + "value": "{{token}}", + "description": "" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"action\": \"setservice\",\n \"object\": \"sc\",\n \"values\": \"{{sc_name}};{{host_name}},{{service_description}}\"\n}" + }, + "description": "" + }, + "response": [] + }, { "name": "Addservicetemplate", "event": [ @@ -44015,6 +44077,68 @@ "description": "" }, "response": [] + }, + { + "name": "Setservicetemplate", + "event": [ + { + "listen": "test", + "script": { + "type": "text/javascript", + "exec": [ + "tests[\"Status code is 200\"] = responseCode.code === 200;" + ] + } + } + ], + "request": { + "url": { + "raw": "http://{{url}}/centreon/api/index.php?action=action&object=centreon_clapi", + "protocol": "http", + "host": [ + "{{url}}" + ], + "path": [ + "centreon", + "api", + "index.php" + ], + "query": [ + { + "key": "action", + "value": "action", + "equals": true, + "description": "" + }, + { + "key": "object", + "value": "centreon_clapi", + "equals": true, + "description": "" + } + ], + "variable": [] + }, + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "description": "" + }, + { + "key": "centreon-auth-token", + "value": "{{token}}", + "description": "" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"action\": \"setservicetemplate\",\n \"object\": \"sc\",\n \"values\": \"{{sc_name}};{{stpl_description}}\"\n}" + }, + "description": "" + }, + "response": [] } ] }, From dfa32f3a9eb8155f6d0d8f3137d830ef9c58f3d2 Mon Sep 17 00:00:00 2001 From: Simon Bomm Date: Tue, 18 Jul 2017 08:42:34 +0000 Subject: [PATCH 029/207] + Enhance partitioning table status check (#5430) * + Enhance partitioning table status check Fix https://github.com/centreon/centreon/issues/5429 * + fix after review * + fix preg_match condition --- www/class/centreon-partition/partEngine.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/class/centreon-partition/partEngine.class.php b/www/class/centreon-partition/partEngine.class.php index 88869254028..106e94075c5 100644 --- a/www/class/centreon-partition/partEngine.class.php +++ b/www/class/centreon-partition/partEngine.class.php @@ -426,7 +426,7 @@ public function updateParts($table, $db) if (!isset($row["Create_options"])) { throw new Exception("Cannot find Create_options for table ".$tableName."\n"); } - if ($row["Create_options"] != "partitioned") { + if (!preg_match("/partitioned/", $row["Create_options"])) { throw new Exception("Error: cannot update non partitioned table ".$tableName."\n"); } From 90168aaa90c1b94615d88ee11aa88b2a79b8ea54 Mon Sep 17 00:00:00 2001 From: loiclau Date: Tue, 18 Jul 2017 10:45:58 +0200 Subject: [PATCH 030/207] * fix custom view --- www/class/centreonCustomView.class.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/www/class/centreonCustomView.class.php b/www/class/centreonCustomView.class.php index 0f804dbbbcc..350d7508ba4 100644 --- a/www/class/centreonCustomView.class.php +++ b/www/class/centreonCustomView.class.php @@ -604,7 +604,7 @@ public function loadCustomView($params) 'SELECT contactgroup_cg_id FROM contactgroup_contact_relation ' . 'WHERE contact_contact_id = :userId ' . ') ' . - ') '; + ') ORDER BY user_id DESC'; $stmt = $this->db->prepare($query); $stmt->bindParam(':viewLoad', $params['viewLoad'], PDO::PARAM_INT); @@ -617,9 +617,7 @@ public function loadCustomView($params) if ($row['locked'] == "0") { $isLocked = $row['locked']; } - if ((!is_null($row['user_id']) && $row['user_id'] > 0) || - (!is_null($row['usergroup_id']) && $row['usergroup_id'] > 0) - ) { + if (!is_null($row['user_id']) && $row['user_id'] > 0 && is_null($row['usergroup_id'])) { $update = true; } } From 654808ba23949650e905d6a37075fbc5f4859d89 Mon Sep 17 00:00:00 2001 From: loiclau Date: Tue, 18 Jul 2017 16:49:25 +0200 Subject: [PATCH 031/207] * xmo replace mysql_real_escape_string by PDO::quote --- www/class/centreonContactgroup.class.php | 2 +- www/include/common/quickSearch.php | 4 ++-- .../configuration/configKnowledge/pagination.php | 2 +- www/include/configuration/configNagios/DB-Func.php | 10 +++++----- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/www/class/centreonContactgroup.class.php b/www/class/centreonContactgroup.class.php index 35b4a0ef1e5..3db2cb9c3b4 100644 --- a/www/class/centreonContactgroup.class.php +++ b/www/class/centreonContactgroup.class.php @@ -263,7 +263,7 @@ public function syncWithLdap() $this->db->query($queryDeleteRelation); $queryContact = "SELECT contact_id FROM contact WHERE contact_ldap_dn IN ('" . - join("', '", array_map('mysql_real_escape_string', $members)) . "')"; + join("', '", array_map('PDO::quote', $members)) . "')"; try { $resContact = $this->db->query($queryContact); } catch (\PDOException $e) { diff --git a/www/include/common/quickSearch.php b/www/include/common/quickSearch.php index 24ead6e8de8..0bec56db3a6 100644 --- a/www/include/common/quickSearch.php +++ b/www/include/common/quickSearch.php @@ -56,14 +56,14 @@ } $searchRaw = $search; -$search = mysql_real_escape_string($search); +$search = PDO::quote($search); if (!isset($search_service)) { $search_service = ""; $search_serviceRaw = ""; } else { $search_serviceRaw = $search_service; - $search_service = mysql_real_escape_string($search_service); + $search_service = PDO::quote($search_service); } if (isset($search) && $search) { diff --git a/www/include/configuration/configKnowledge/pagination.php b/www/include/configuration/configKnowledge/pagination.php index e706ec97178..6e6a23ef222 100644 --- a/www/include/configuration/configKnowledge/pagination.php +++ b/www/include/configuration/configKnowledge/pagination.php @@ -67,7 +67,7 @@ } } -$num = mysql_real_escape_string($num); +$num = PDO::quote($num); $tab_order = array("sort_asc" => "sort_desc", "sort_desc" => "sort_asc"); diff --git a/www/include/configuration/configNagios/DB-Func.php b/www/include/configuration/configNagios/DB-Func.php index 54d9ffa30a0..9f5c766f423 100644 --- a/www/include/configuration/configNagios/DB-Func.php +++ b/www/include/configuration/configNagios/DB-Func.php @@ -456,11 +456,11 @@ function insertNagios($ret = array(), $brokerTab = array()) isset($ret["service_perfdata_file"]) && $ret["service_perfdata_file"] != null ? $rq .= "'".htmlentities($ret["service_perfdata_file"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; isset($ret["host_perfdata_file_template"]) && $ret["host_perfdata_file_template"] != null ? - $rq .= "'". mysql_real_escape_string($ret["host_perfdata_file_template"])."', " : $rq .= "NULL, "; + $rq .= "'" . PDO::quote($ret["host_perfdata_file_template"]) . "', " : $rq .= "NULL, "; isset($ret["service_perfdata_file_template"]) && $ret["service_perfdata_file_template"] != null ? - $rq .= "'".mysql_real_escape_string($ret["service_perfdata_file_template"])."', " : $rq .= "NULL, "; + $rq .= "'" . PDO::quote($ret["service_perfdata_file_template"]) . "', " : $rq .= "NULL, "; isset($ret["host_perfdata_file_mode"]["host_perfdata_file_mode"]) - && $ret["host_perfdata_file_mode"]["host_perfdata_file_mode"] != null ? + && $ret["host_perfdata_file_mode"]["host_perfdata_file_mode"] != null ? $rq .= "'".$ret["host_perfdata_file_mode"]["host_perfdata_file_mode"]."', " : $rq .= "NULL, "; isset($ret["service_perfdata_file_mode"]["service_perfdata_file_mode"]) && $ret["service_perfdata_file_mode"]["service_perfdata_file_mode"] != null ? @@ -958,11 +958,11 @@ function updateNagios($nagios_id = null) : $rq .= "service_perfdata_file = NULL, "; isset($ret["host_perfdata_file_template"]) && $ret["host_perfdata_file_template"] != null ? $rq .= "host_perfdata_file_template = '" - . mysql_real_escape_string($ret["host_perfdata_file_template"])."', " + . PDO::quote($ret["host_perfdata_file_template"])."', " : $rq .= "host_perfdata_file_template = NULL, "; isset($ret["service_perfdata_file_template"]) && $ret["service_perfdata_file_template"] != null ? $rq .= "service_perfdata_file_template = '" - . mysql_real_escape_string($ret["service_perfdata_file_template"])."', " + . PDO::quote($ret["service_perfdata_file_template"])."', " : $rq .= "service_perfdata_file_template = NULL, "; isset($ret["host_perfdata_file_mode"]["host_perfdata_file_mode"]) && $ret["host_perfdata_file_mode"]["host_perfdata_file_mode"] != null ? From 821d3efe6b7ea4e8eec42f527f2ec472f439abbc Mon Sep 17 00:00:00 2001 From: loiclau Date: Tue, 18 Jul 2017 17:12:11 +0200 Subject: [PATCH 032/207] * fix style meta service --- .../configObject/meta_service/DB-Func.php | 268 ++++++++++++------ .../configObject/meta_service/help.php | 69 ++++- .../meta_service/listMetaService.php | 162 ++++++----- .../configObject/meta_service/listMetric.php | 106 ++++--- .../configObject/meta_service/metric.php | 74 ++--- 5 files changed, 434 insertions(+), 245 deletions(-) diff --git a/www/include/configuration/configObject/meta_service/DB-Func.php b/www/include/configuration/configObject/meta_service/DB-Func.php index 3afde94dcc1..cf49a12f62c 100644 --- a/www/include/configuration/configObject/meta_service/DB-Func.php +++ b/www/include/configuration/configObject/meta_service/DB-Func.php @@ -49,7 +49,8 @@ function testExistence($name = null) if (isset($form)) { $id = $form->getSubmitValue('meta_id'); } - $DBRESULT = $pearDB->query("SELECT meta_id FROM meta_service WHERE meta_name = '".htmlentities($name, ENT_QUOTES, "UTF-8")."'"); + $query = "SELECT meta_id FROM meta_service WHERE meta_name = '" . htmlentities($name, ENT_QUOTES, "UTF-8") . "'"; + $DBRESULT = $pearDB->query($query); $meta = $DBRESULT->fetchRow(); #Modif case if ($DBRESULT->rowCount() >= 1 && $meta["meta_id"] == $id) { @@ -68,7 +69,7 @@ function enableMetaServiceInDB($meta_id = null) return; } global $pearDB; - $DBRESULT = $pearDB->query("UPDATE meta_service SET meta_activate = '1' WHERE meta_id = '".$meta_id."'"); + $pearDB->query("UPDATE meta_service SET meta_activate = '1' WHERE meta_id = '" . $meta_id . "'"); } function disableMetaServiceInDB($meta_id = null) @@ -77,15 +78,17 @@ function disableMetaServiceInDB($meta_id = null) return; } global $pearDB; - $DBRESULT = $pearDB->query("UPDATE meta_service SET meta_activate = '0' WHERE meta_id = '".$meta_id."'"); + $pearDB->query("UPDATE meta_service SET meta_activate = '0' WHERE meta_id = '" . $meta_id . "'"); } function deleteMetaServiceInDB($metas = array()) { global $pearDB; foreach ($metas as $key => $value) { - $pearDB->query("DELETE FROM meta_service WHERE meta_id = '".$pearDB->escape($key)."'"); - $pearDB->query("DELETE FROM service WHERE service_description = 'meta_".$pearDB->escape($key)."' AND service_register = '2'"); + $pearDB->query("DELETE FROM meta_service WHERE meta_id = '" . $pearDB->escape($key) . "'"); + $query = "DELETE FROM service WHERE service_description = 'meta_" . + $pearDB->escape($key) . "' AND service_register = '2'"; + $pearDB->query($query); } } @@ -95,7 +98,7 @@ function enableMetricInDB($msr_id = null) return; } global $pearDB; - $DBRESULT = $pearDB->query("UPDATE meta_service_relation SET activate = '1' WHERE msr_id = '".$msr_id."'"); + $pearDB->query("UPDATE meta_service_relation SET activate = '1' WHERE msr_id = '" . $msr_id . "'"); } function disableMetricInDB($msr_id = null) @@ -104,14 +107,14 @@ function disableMetricInDB($msr_id = null) return; } global $pearDB; - $DBRESULT = $pearDB->query("UPDATE meta_service_relation SET activate = '0' WHERE msr_id = '".$msr_id."'"); + $pearDB->query("UPDATE meta_service_relation SET activate = '0' WHERE msr_id = '" . $msr_id . "'"); } function deleteMetricInDB($metrics = array()) { global $pearDB; foreach ($metrics as $key => $value) { - $DBRESULT = $pearDB->query("DELETE FROM meta_service_relation WHERE msr_id = '".$key."'"); + $pearDB->query("DELETE FROM meta_service_relation WHERE msr_id = '" . $key . "'"); } } @@ -121,7 +124,7 @@ function multipleMetaServiceInDB($metas = array(), $nbrDup = array()) foreach ($metas as $key => $value) { global $pearDB; # Get all information about it - $DBRESULT = $pearDB->query("SELECT * FROM meta_service WHERE meta_id = '".$key."' LIMIT 1"); + $DBRESULT = $pearDB->query("SELECT * FROM meta_service WHERE meta_id = '" . $key . "' LIMIT 1"); $row = $DBRESULT->fetchRow(); $row["meta_id"] = ''; # Loop on the number of MetaService we want to duplicate @@ -129,30 +132,37 @@ function multipleMetaServiceInDB($metas = array(), $nbrDup = array()) $val = null; # Create a sentence which contains all the value foreach ($row as $key2 => $value2) { - $key2 == "meta_name" ? ($meta_name = $value2 = $value2."_".$i) : null; - $val ? $val .= ($value2!=null?(", '".$value2."'"):", NULL") : $val .= ($value2!=null?("'".$value2."'"):"NULL"); + $key2 == "meta_name" ? ($meta_name = $value2 = $value2 . "_" . $i) : null; + $val + ? $val .= ($value2 != null ? (", '" . $value2 . "'") : ", NULL") + : $val .= ($value2 != null ? ("'" . $value2 . "'") : "NULL"); } if (testExistence($meta_name)) { - $val ? $rq = "INSERT INTO meta_service VALUES (".$val.")" : $rq = null; - $DBRESULT = $pearDB->query($rq); + $val ? $rq = "INSERT INTO meta_service VALUES (" . $val . ")" : $rq = null; + $pearDB->query($rq); $DBRESULT = $pearDB->query("SELECT MAX(meta_id) FROM meta_service"); $maxId = $DBRESULT->fetchRow(); if (isset($maxId["MAX(meta_id)"])) { $metaObj = new CentreonMeta($pearDB); - $metaObj->insertVirtualService($maxIddele["MAX(meta_id)"], $meta_name); - $DBRESULT = $pearDB->query("SELECT DISTINCT cg_cg_id FROM meta_contactgroup_relation WHERE meta_id = '".$key."'"); + $metaObj->insertVirtualService($maxId["MAX(meta_id)"], $meta_name); + $query = "SELECT DISTINCT cg_cg_id FROM meta_contactgroup_relation WHERE meta_id = '" . $key . "'"; + $DBRESULT = $pearDB->query($query); while ($Cg = $DBRESULT->fetchRow()) { - $DBRESULT2 = $pearDB->query("INSERT INTO meta_contactgroup_relation VALUES ('', '".$maxId["MAX(meta_id)"]."', '".$Cg["cg_cg_id"]."')"); + $query = "INSERT INTO meta_contactgroup_relation " . + "VALUES ('', '" . $maxId["MAX(meta_id)"] . "', '" . $Cg["cg_cg_id"] . "')"; + $pearDB->query($query); } - $DBRESULT = $pearDB->query("SELECT * FROM meta_service_relation WHERE meta_id = '".$key."'"); + $DBRESULT = $pearDB->query("SELECT * FROM meta_service_relation WHERE meta_id = '" . $key . "'"); while ($metric = $DBRESULT->fetchRow()) { $val = null; $metric["msr_id"] = ''; foreach ($metric as $key2 => $value2) { $key2 == "meta_id" ? $value2 = $maxId["MAX(meta_id)"] : null; - $val ? $val .= ($value2!=null?(", '".$value2."'"):", NULL") : $val .= ($value2!=null?("'".$value2."'"):"NULL"); + $val + ? $val .= ($value2 != null ? (", '" . $value2 . "'") : ", NULL") + : $val .= ($value2 != null ? ("'" . $value2 . "'") : "NULL"); } - $DBRESULT2 = $pearDB->query("INSERT INTO meta_service_relation VALUES (".$val.")"); + $DBRESULT2 = $pearDB->query("INSERT INTO meta_service_relation VALUES (" . $val . ")"); } } } @@ -184,7 +194,7 @@ function multipleMetricInDB($metrics = array(), $nbrDup = array()) foreach ($metrics as $key => $value) { global $pearDB; # Get all information about it - $DBRESULT = $pearDB->query("SELECT * FROM meta_service_relation WHERE msr_id = '".$key."' LIMIT 1"); + $DBRESULT = $pearDB->query("SELECT * FROM meta_service_relation WHERE msr_id = '" . $key . "' LIMIT 1"); $row = $DBRESULT->fetchRow(); $row["msr_id"] = ''; # Loop on the number of Metric we want to duplicate @@ -192,9 +202,11 @@ function multipleMetricInDB($metrics = array(), $nbrDup = array()) $val = null; # Create a sentence which contains all the value foreach ($row as $key2 => $value2) { - $val ? $val .= ($value2!=null?(", '".$value2."'"):", NULL") : $val .= ($value2!=null?("'".$value2."'"):"NULL"); + $val + ? $val .= ($value2 != null ? (", '" . $value2 . "'") : ", NULL") + : $val .= ($value2 != null ? ("'" . $value2 . "'") : "NULL"); } - $val ? $rq = "INSERT INTO meta_service_relation VALUES (".$val.")" : $rq = null; + $val ? $rq = "INSERT INTO meta_service_relation VALUES (" . $val . ")" : $rq = null; $DBRESULT = $pearDB->query($rq); } } @@ -207,8 +219,7 @@ function checkMetaHost() $query = "SELECT host_id FROM host WHERE host_register = '2' AND host_name = '_Module_Meta' "; $res = $pearDB->query($query); if (!$res->rowCount()) { - $query = "INSERT INTO host (host_name, host_register) " - . "VALUES ('_Module_Meta', '2') "; + $query = "INSERT INTO host (host_name, host_register) VALUES ('_Module_Meta', '2') "; $pearDB->query($query); } } @@ -224,39 +235,83 @@ function insertMetaService($ret = array()) } $rq = "INSERT INTO meta_service " . - "(meta_name, meta_display, check_period, max_check_attempts, normal_check_interval, retry_check_interval, notification_interval, " . - "notification_period, notification_options, notifications_enabled, calcul_type, data_source_type, meta_select_mode, regexp_str, metric, warning, critical, " . - "graph_id, meta_comment, geo_coords, meta_activate) " . - "VALUES ( "; - isset($ret["meta_name"]) && $ret["meta_name"] != null ? $rq .= "'".htmlentities($ret["meta_name"], ENT_QUOTES, "UTF-8")."', ": $rq .= "NULL, "; - isset($ret["meta_display"]) && $ret["meta_display"] != null ? $rq .= "'".$ret["meta_display"]."', ": $rq .= "NULL, "; - isset($ret["check_period"]) && $ret["check_period"] != null ? $rq .= "'".$ret["check_period"]."', ": $rq .= "NULL, "; - isset($ret["max_check_attempts"]) && $ret["max_check_attempts"] != null ? $rq .= "'".$ret["max_check_attempts"]."', " : $rq .= "NULL, "; - isset($ret["normal_check_interval"]) && $ret["normal_check_interval"] != null ? $rq .= "'".$ret["normal_check_interval"]."', ": $rq .= "NULL, "; - isset($ret["retry_check_interval"]) && $ret["retry_check_interval"] != null ? $rq .= "'".$ret["retry_check_interval"]."', ": $rq .= "NULL, "; - isset($ret["notification_interval"]) && $ret["notification_interval"] != null ? $rq .= "'".$ret["notification_interval"]."', " : $rq .= "NULL, "; - isset($ret["notification_period"]) && $ret["notification_period"] != null ? $rq .= "'".$ret["notification_period"]."', ": $rq .= "NULL, "; - isset($ret["ms_notifOpts"]) && $ret["ms_notifOpts"] != null ? $rq .= "'".implode(",", array_keys($ret["ms_notifOpts"]))."', " : $rq .= "NULL, "; - isset($ret["notifications_enabled"]["notifications_enabled"]) && $ret["notifications_enabled"]["notifications_enabled"] != 2 ? $rq .= "'".$ret["notifications_enabled"]["notifications_enabled"]."', " : $rq .= "'2', "; - isset($ret["calcul_type"]) ? $rq .= "'".$ret["calcul_type"]."', " : $rq .= "NULL, "; - isset($ret["data_source_type"]) ? $rq .= "'".$ret["data_source_type"]."', " : $rq .= "0, "; - isset($ret["meta_select_mode"]["meta_select_mode"]) ? $rq .= "'".$ret["meta_select_mode"]["meta_select_mode"]."', " : $rq .= "NULL, "; - isset($ret["regexp_str"]) && $ret["regexp_str"] != null ? $rq .= "'".htmlentities($ret["regexp_str"])."', " : $rq .= "NULL, "; - isset($ret["metric"]) && $ret["metric"] != null ? $rq .= "'".htmlentities($ret["metric"])."', " : $rq .= "NULL, "; - isset($ret["warning"]) && $ret["warning"] != null ? $rq .= "'".htmlentities($ret["warning"])."', " : $rq .= "NULL, "; - isset($ret["critical"]) && $ret["critical"] != null ? $rq .= "'".htmlentities($ret["critical"])."', " : $rq .= "NULL, "; - isset($ret["graph_id"]) && $ret["graph_id"] != null ? $rq .= "'".$ret["graph_id"]."', " : $rq .= "NULL, "; - isset($ret["meta_comment"]) && $ret["meta_comment"] != null ? $rq .= "'".htmlentities($ret["meta_comment"])."', " : $rq .= "NULL, "; - isset($ret["geo_coords"]) && $ret["geo_coords"] != null ? $rq .= "'".htmlentities($ret["geo_coords"])."', " : $rq .= "NULL, "; - isset($ret["meta_activate"]["meta_activate"]) && $ret["meta_activate"]["meta_activate"] != null ? $rq .= "'".$ret["meta_activate"]["meta_activate"]."'" : $rq .= "NULL"; + "(meta_name, meta_display, check_period, max_check_attempts, normal_check_interval, retry_check_interval, " . + "notification_interval, notification_period, notification_options, notifications_enabled, calcul_type, " . + "data_source_type, meta_select_mode, regexp_str, metric, warning, critical, " . + "graph_id, meta_comment, geo_coords, meta_activate) " . + "VALUES ( "; + isset($ret["meta_name"]) && $ret["meta_name"] != null + ? $rq .= "'" . htmlentities($ret["meta_name"], ENT_QUOTES, "UTF-8") . "', " + : $rq .= "NULL, "; + isset($ret["meta_display"]) && $ret["meta_display"] != null + ? $rq .= "'" . $ret["meta_display"] . "', " + : $rq .= "NULL, "; + isset($ret["check_period"]) && $ret["check_period"] != null + ? $rq .= "'" . $ret["check_period"] . "', " + : $rq .= "NULL, "; + isset($ret["max_check_attempts"]) && $ret["max_check_attempts"] != null + ? $rq .= "'" . $ret["max_check_attempts"] . "', " + : $rq .= "NULL, "; + isset($ret["normal_check_interval"]) && $ret["normal_check_interval"] != null + ? $rq .= "'" . $ret["normal_check_interval"] . "', " + : $rq .= "NULL, "; + isset($ret["retry_check_interval"]) && $ret["retry_check_interval"] != null + ? $rq .= "'" . $ret["retry_check_interval"] . "', " + : $rq .= "NULL, "; + isset($ret["notification_interval"]) && $ret["notification_interval"] != null + ? $rq .= "'" . $ret["notification_interval"] . "', " + : $rq .= "NULL, "; + isset($ret["notification_period"]) && $ret["notification_period"] != null + ? $rq .= "'" . $ret["notification_period"] . "', " + : $rq .= "NULL, "; + isset($ret["ms_notifOpts"]) && $ret["ms_notifOpts"] != null + ? $rq .= "'" . implode(",", array_keys($ret["ms_notifOpts"])) . "', " + : $rq .= "NULL, "; + isset($ret["notifications_enabled"]["notifications_enabled"]) && + $ret["notifications_enabled"]["notifications_enabled"] != 2 + ? $rq .= "'" . $ret["notifications_enabled"]["notifications_enabled"] . "', " + : $rq .= "'2', "; + isset($ret["calcul_type"]) ? $rq .= "'" . $ret["calcul_type"] . "', " : $rq .= "NULL, "; + isset($ret["data_source_type"]) ? $rq .= "'" . $ret["data_source_type"] . "', " : $rq .= "0, "; + isset($ret["meta_select_mode"]["meta_select_mode"]) + ? $rq .= "'" . $ret["meta_select_mode"]["meta_select_mode"] . "', " + : $rq .= "NULL, "; + isset($ret["regexp_str"]) && $ret["regexp_str"] != null + ? $rq .= "'" . htmlentities($ret["regexp_str"]) . "', " + : $rq .= "NULL, "; + isset($ret["metric"]) && $ret["metric"] != null + ? $rq .= "'" . htmlentities($ret["metric"]) . "', " + : $rq .= "NULL, "; + isset($ret["warning"]) && $ret["warning"] != null + ? $rq .= "'" . htmlentities($ret["warning"]) . "', " + : $rq .= "NULL, "; + isset($ret["critical"]) && $ret["critical"] != null + ? $rq .= "'" . htmlentities($ret["critical"]) . "', " + : $rq .= "NULL, "; + isset($ret["graph_id"]) && $ret["graph_id"] != null ? $rq .= "'" . $ret["graph_id"] . "', " : $rq .= "NULL, "; + isset($ret["meta_comment"]) && $ret["meta_comment"] != null + ? $rq .= "'" . htmlentities($ret["meta_comment"]) . "', " + : $rq .= "NULL, "; + isset($ret["geo_coords"]) && $ret["geo_coords"] != null + ? $rq .= "'" . htmlentities($ret["geo_coords"]) . "', " + : $rq .= "NULL, "; + isset($ret["meta_activate"]["meta_activate"]) && $ret["meta_activate"]["meta_activate"] != null + ? $rq .= "'" . $ret["meta_activate"]["meta_activate"] . "'" + : $rq .= "NULL"; $rq .= ")"; - $DBRESULT = $pearDB->query($rq); + $pearDB->query($rq); $DBRESULT = $pearDB->query("SELECT MAX(meta_id) FROM meta_service"); $meta_id = $DBRESULT->fetchRow(); /* Prepare value for changelog */ $fields = CentreonLogAction::prepareChanges($ret); - $centreon->CentreonLogAction->insertLog("meta", $meta_id["MAX(meta_id)"], CentreonDB::escape($ret["meta_name"]), "a", $fields); + $centreon->CentreonLogAction->insertLog( + "meta", + $meta_id["MAX(meta_id)"], + CentreonDB::escape($ret["meta_name"]), + "a", + $fields + ); $metaObj = new CentreonMeta($pearDB); $metaObj->insertVirtualService($meta_id["MAX(meta_id)"], CentreonDB::escape($ret["meta_name"])); @@ -276,53 +331,71 @@ function updateMetaService($meta_id = null) $ret = array(); $ret = $form->getSubmitValues(); - $rq = "UPDATE meta_service SET " ; + $rq = "UPDATE meta_service SET "; $rq .= "meta_name = "; - $ret["meta_name"] != null ? $rq .= "'".htmlentities($ret["meta_name"], ENT_QUOTES, "UTF-8")."', ": $rq .= "NULL, "; + $ret["meta_name"] != null + ? $rq .= "'" . htmlentities($ret["meta_name"], ENT_QUOTES, "UTF-8") . "', " + : $rq .= "NULL, "; $rq .= "meta_display = "; - $ret["meta_display"] != null ? $rq .= "'".htmlentities($ret["meta_display"], ENT_QUOTES, "UTF-8")."', ": $rq .= "NULL, "; + $ret["meta_display"] != null + ? $rq .= "'" . htmlentities($ret["meta_display"], ENT_QUOTES, "UTF-8") . "', " + : $rq .= "NULL, "; $rq .= "check_period = "; - $ret["check_period"] != null ? $rq .= "'".$ret["check_period"]."', ": $rq .= "NULL, "; + $ret["check_period"] != null ? $rq .= "'" . $ret["check_period"] . "', " : $rq .= "NULL, "; $rq .= "max_check_attempts = "; - $ret["max_check_attempts"] != null ? $rq .= "'".$ret["max_check_attempts"]."', " : $rq .= "NULL, "; + $ret["max_check_attempts"] != null ? $rq .= "'" . $ret["max_check_attempts"] . "', " : $rq .= "NULL, "; $rq .= "normal_check_interval = "; - $ret["normal_check_interval"] != null ? $rq .= "'".$ret["normal_check_interval"]."', ": $rq .= "NULL, "; + $ret["normal_check_interval"] != null ? $rq .= "'" . $ret["normal_check_interval"] . "', " : $rq .= "NULL, "; $rq .= "retry_check_interval = "; - $ret["retry_check_interval"] != null ? $rq .= "'".$ret["retry_check_interval"]."', ": $rq .= "NULL, "; + $ret["retry_check_interval"] != null ? $rq .= "'" . $ret["retry_check_interval"] . "', " : $rq .= "NULL, "; $rq .= "notification_interval = "; - $ret["notification_interval"] != null ? $rq .= "'".$ret["notification_interval"]."', " : $rq .= "NULL, "; + $ret["notification_interval"] != null ? $rq .= "'" . $ret["notification_interval"] . "', " : $rq .= "NULL, "; $rq .= "notification_period = "; - $ret["notification_period"] != null ? $rq .= "'".$ret["notification_period"]."', " : $rq .= "NULL, "; + $ret["notification_period"] != null ? $rq .= "'" . $ret["notification_period"] . "', " : $rq .= "NULL, "; $rq .= "notification_options = "; - isset($ret["ms_notifOpts"]) && $ret["ms_notifOpts"] != null ? $rq .= "'".implode(",", array_keys($ret["ms_notifOpts"]))."', " : $rq .= "NULL, "; + isset($ret["ms_notifOpts"]) && $ret["ms_notifOpts"] != null + ? $rq .= "'" . implode(",", array_keys($ret["ms_notifOpts"])) . "', " + : $rq .= "NULL, "; $rq .= "notifications_enabled = "; - $ret["notifications_enabled"]["notifications_enabled"] != 2 ? $rq .= "'".$ret["notifications_enabled"]["notifications_enabled"]."', " : $rq .= "'2', "; + $ret["notifications_enabled"]["notifications_enabled"] != 2 + ? $rq .= "'" . $ret["notifications_enabled"]["notifications_enabled"] . "', " + : $rq .= "'2', "; $rq .= "calcul_type = "; - $ret["calcul_type"] ? $rq .= "'".$ret["calcul_type"]."', " : $rq .= "NULL, "; + $ret["calcul_type"] ? $rq .= "'" . $ret["calcul_type"] . "', " : $rq .= "NULL, "; $rq .= "data_source_type = "; - $ret["data_source_type"] ? $rq .= "'".$ret["data_source_type"]."', " : $rq .= "0, "; + $ret["data_source_type"] ? $rq .= "'" . $ret["data_source_type"] . "', " : $rq .= "0, "; $rq .= "meta_select_mode = "; - $ret["meta_select_mode"]["meta_select_mode"] != null ? $rq .= "'".$ret["meta_select_mode"]["meta_select_mode"]."', " : $rq .= "NULL, "; + $ret["meta_select_mode"]["meta_select_mode"] != null + ? $rq .= "'" . $ret["meta_select_mode"]["meta_select_mode"] . "', " + : $rq .= "NULL, "; $rq .= "regexp_str = "; - $ret["regexp_str"] != null ? $rq .= "'".htmlentities($ret["regexp_str"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $ret["regexp_str"] != null + ? $rq .= "'" . htmlentities($ret["regexp_str"], ENT_QUOTES, "UTF-8") . "', " + : $rq .= "NULL, "; $rq .= "metric = "; - $ret["metric"] != null ? $rq .= "'".htmlentities($ret["metric"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $ret["metric"] != null ? $rq .= "'" . htmlentities($ret["metric"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; $rq .= "warning = "; - $ret["warning"] != null ? $rq .= "'".htmlentities($ret["warning"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $ret["warning"] != null ? $rq .= "'" . htmlentities($ret["warning"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; $rq .= "critical = "; - $ret["critical"] != null ? $rq .= "'".htmlentities($ret["critical"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $ret["critical"] != null + ? $rq .= "'" . htmlentities($ret["critical"], ENT_QUOTES, "UTF-8") . "', " + : $rq .= "NULL, "; $rq .= "graph_id = "; - $ret["graph_id"] != null ? $rq .= "'".$ret["graph_id"]."', " : $rq .= "NULL, "; + $ret["graph_id"] != null ? $rq .= "'" . $ret["graph_id"] . "', " : $rq .= "NULL, "; $rq .= "meta_comment = "; - $ret["meta_comment"] != null ? $rq .= "'".htmlentities($ret["meta_comment"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $ret["meta_comment"] != null + ? $rq .= "'" . htmlentities($ret["meta_comment"], ENT_QUOTES, "UTF-8") . "', " + : $rq .= "NULL, "; $rq .= "meta_activate = "; - $ret["meta_activate"]["meta_activate"] != null ? $rq .= "'".$ret["meta_activate"]["meta_activate"]."' " : $rq .= "NULL "; - $rq .= " WHERE meta_id = '".$meta_id."'"; + $ret["meta_activate"]["meta_activate"] != null + ? $rq .= "'" . $ret["meta_activate"]["meta_activate"] . "' " + : $rq .= "NULL "; + $rq .= " WHERE meta_id = '" . $meta_id . "'"; /* Prepare value for changelog */ $fields = CentreonLogAction::prepareChanges($ret); $centreon->CentreonLogAction->insertLog("meta", $meta_id, CentreonDB::escape($ret["meta_name"]), "c", $fields); - + $DBRESULT = $pearDB->query($rq); $metaObj = new CentreonMeta($pearDB); @@ -340,7 +413,7 @@ function updateMetaServiceContact($meta_id) /* Purge old relation */ $queryPurge = "DELETE FROM meta_contact WHERE meta_id = " . $meta_id; $pearDB->query($queryPurge); - + /* Add relation between metaservice and contact */ $ret = array(); $ret = CentreonUtils::mergeWithInitialValues($form, 'ms_cs'); @@ -361,7 +434,7 @@ function updateMetaServiceContactGroup($meta_id = null) global $form; global $pearDB; $rq = "DELETE FROM meta_contactgroup_relation "; - $rq .= "WHERE meta_id = '".$meta_id."'"; + $rq .= "WHERE meta_id = '" . $meta_id . "'"; $DBRESULT = $pearDB->query($rq); $ret = array(); @@ -379,7 +452,7 @@ function updateMetaServiceContactGroup($meta_id = null) $rq = "INSERT INTO meta_contactgroup_relation "; $rq .= "(meta_id, cg_cg_id) "; $rq .= "VALUES "; - $rq .= "('".$meta_id."', '".$ret[$i]."')"; + $rq .= "('" . $meta_id . "', '" . $ret[$i] . "')"; $DBRESULT = $pearDB->query($rq); } } @@ -406,19 +479,26 @@ function insertMetric($ret = array()) global $centreon; $ret = $form->getSubmitValues(); $rq = "INSERT INTO meta_service_relation " . - "(meta_id, host_id, metric_id, msr_comment, activate) " . - "VALUES ( "; - isset($ret["meta_id"]) && $ret["meta_id"] != null ? $rq .= "'".$ret["meta_id"]."', ": $rq .= "NULL, "; - isset($ret["host_id"]) && $ret["host_id"] != null ? $rq .= "'".$ret["host_id"]."', ": $rq .= "NULL, "; - isset($ret["metric_sel"][1]) && $ret["metric_sel"][1] != null ? $rq .= "'".$ret["metric_sel"][1]."', ": $rq .= "NULL, "; - isset($ret["msr_comment"]) && $ret["msr_comment"] != null ? $rq .= "'".htmlentities($ret["msr_comment"])."', " : $rq .= "NULL, "; - isset($ret["activate"]["activate"]) && $ret["activate"]["activate"] != null ? $rq .= "'".$ret["activate"]["activate"]."'" : $rq .= "NULL"; - $rq .= ")"; + "(meta_id, host_id, metric_id, msr_comment, activate) " . + "VALUES ( "; + isset($ret["meta_id"]) && $ret["meta_id"] != null ? $rq .= "'" . $ret["meta_id"] . "', " : $rq .= "NULL, "; + isset($ret["host_id"]) && $ret["host_id"] != null ? $rq .= "'" . $ret["host_id"] . "', " : $rq .= "NULL, "; + isset($ret["metric_sel"][1]) && $ret["metric_sel"][1] != null + ? $rq .= "'" . $ret["metric_sel"][1] . "', " + : $rq .= "NULL, "; + isset($ret["msr_comment"]) && $ret["msr_comment"] != null + ? $rq .= "'" . htmlentities($ret["msr_comment"]) . "', " + : $rq .= "NULL, "; + isset($ret["activate"]["activate"]) && $ret["activate"]["activate"] != null + ? $rq .= "'" . $ret["activate"]["activate"] . "'" + : $rq .= "NULL"; + $rq .= ")"; $DBRESULT = $pearDB->query($rq); $DBRESULT = $pearDB->query("SELECT MAX(msr_id) FROM meta_service_relation"); $msr_id = $DBRESULT->fetchRow(); return ($msr_id["MAX(msr_id)"]); } + function updateMetric($msr_id = null) { if (!$msr_id) { @@ -427,17 +507,19 @@ function updateMetric($msr_id = null) global $form; global $pearDB; $ret = $form->getSubmitValues(); - $rq = "UPDATE meta_service_relation SET " ; + $rq = "UPDATE meta_service_relation SET "; $rq .= "meta_id = "; - $ret["meta_id"] != null ? $rq .= "'".$ret["meta_id"]."', ": $rq .= "NULL, "; + $ret["meta_id"] != null ? $rq .= "'" . $ret["meta_id"] . "', " : $rq .= "NULL, "; $rq .= "host_id = "; - $ret["host_id"] != null ? $rq .= "'".$ret["host_id"]."', ": $rq .= "NULL, "; + $ret["host_id"] != null ? $rq .= "'" . $ret["host_id"] . "', " : $rq .= "NULL, "; $rq .= "metric_id = "; - $ret["metric_sel"][1] != null ? $rq .= "'".$ret["metric_sel"][1]."', ": $rq .= "NULL, "; + $ret["metric_sel"][1] != null ? $rq .= "'" . $ret["metric_sel"][1] . "', " : $rq .= "NULL, "; $rq .= "msr_comment = "; - $ret["msr_comment"] != null ? $rq .= "'".htmlentities($ret["msr_comment"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $ret["msr_comment"] != null + ? $rq .= "'" . htmlentities($ret["msr_comment"], ENT_QUOTES, "UTF-8") . "', " + : $rq .= "NULL, "; $rq .= "activate = "; - $ret["activate"]["activate"] != null ? $rq .= "'".$ret["activate"]["activate"]."' " : $rq .= "NULL "; - $rq .= " WHERE msr_id = '".$msr_id."'"; - $DBRESULT = $pearDB->query($rq); + $ret["activate"]["activate"] != null ? $rq .= "'" . $ret["activate"]["activate"] . "' " : $rq .= "NULL "; + $rq .= " WHERE msr_id = '" . $msr_id . "'"; + $pearDB->query($rq); } diff --git a/www/include/configuration/configObject/meta_service/help.php b/www/include/configuration/configObject/meta_service/help.php index fad9cde4d39..6eb7b733449 100644 --- a/www/include/configuration/configObject/meta_service/help.php +++ b/www/include/configuration/configObject/meta_service/help.php @@ -2,24 +2,71 @@ $help = array(); $help["name"] = dgettext("help", "Name used for identification of this meta service."); -$help["display"] = dgettext("help", "Optional format string used for displaying the status of this meta service. The variable '%d' may be used and will be replaced by the calculated value."); +$help["display"] = dgettext( + "help", + "Optional format string used for displaying the status of this meta service. The variable '%d' may be " . + "used and will be replaced by the calculated value." +); $help["warning"] = dgettext("help", "Absolute value for warning level (low threshold)."); $help["critical"] = dgettext("help", "Absolute value for critical level (low threshold)."); $help["calcul_type"] = dgettext("help", "Function to be applied to calculate the meta service status."); $help["data_source_type"] = dgettext("help", "Data source type of the meta service."); -$help["select_mode"] = dgettext("help", "Selection mode for services to be considered for this meta service. In service list mode, mark selected services in the options on meta service list. In SQL matching mode, specify a search string to be used in an SQL query."); +$help["select_mode"] = dgettext( + "help", + "Selection mode for services to be considered for this meta service. In service list mode, mark selected " . + "services in the options on meta service list. In SQL matching mode, specify a search string to " . + "be used in an SQL query." +); $help["regexp"] = dgettext("help", "Search string to be used in a SQL LIKE query for service selection."); $help["metric"] = dgettext("help", "Select the metric to measure for meta service status."); $help["check_period"] = dgettext("help", "Specify the time period during which the meta service status is measured."); -$help["max_check_attempts"] = dgettext("help", "Define the number of times that Centreon will retry the service check command if it returns any state other than an OK state. Setting this value to 1 will cause Centreon to generate an alert without retrying the service check again."); -$help["check_interval"] = dgettext("help", "Define the number of minutes between regularly scheduled checks of the meta service. \"Regular\" checks are those that occur when the service is in an OK state or when the service is in a non-OK state, but has already been rechecked max check attempts number of times."); -$help["retry_interval"] = dgettext("help", "Define the number of minutes to wait before scheduling a re-check for this service after a non-OK state was detected. Once the service has been retried max check attempts times without a change in its status, it will revert to being scheduled at its \"normal\" check interval rate."); +$help["max_check_attempts"] = dgettext( + "help", + "Define the number of times that Centreon will retry the service check command if it returns any state other " . + "than an OK state. Setting this value to 1 will cause Centreon to generate an alert without " . + "retrying the service check again." +); +$help["check_interval"] = dgettext( + "help", + "Define the number of minutes between regularly scheduled checks of the meta service. \"Regular\" checks are " . + "those that occur when the service is in an OK state or when the service is in a non-OK state, " . + "but has already been rechecked max check attempts number of times." +); +$help["retry_interval"] = dgettext( + "help", + "Define the number of minutes to wait before scheduling a re-check for this service after a non-OK " . + "state was detected. Once the service has been retried max check attempts times without a change in its status, " . + "it will revert to being scheduled at its \"normal\" check interval rate." +); -$help["notifications_enabled"] = dgettext("help", "Specify whether or not notifications for this meta service are enabled."); -$help["contact_groups"] = dgettext("help", "This is a list of contact groups that should be notified whenever there are problems (or recoveries) with this service."); -$help["notification_interval"] = dgettext("help", "Define the number of minutes to wait before re-notifying a contact that this service is still in a non-OK condition. A value of 0 disables re-notifications of contacts about problems for this service - only one problem notification will be sent out."); -$help["notification_period"] = dgettext("help", "Specify the time period during which notifications of events for this service can be sent out to contacts. If a state change occurs during a time which is not covered by the time period, no notifications will be sent out."); -$help["notification_options"] = dgettext("help", "Define the states of the service for which notifications should be sent out. If you do not specify any notification options, Centreon will assume that you want notifications to be sent out for all possible states."); +$help["notifications_enabled"] = dgettext( + "help", + "Specify whether or not notifications for this meta service are enabled." +); +$help["contact_groups"] = dgettext( + "help", + "This is a list of contact groups that should be notified whenever there are " . + "problems (or recoveries) with this service." +); +$help["notification_interval"] = dgettext( + "help", + "Define the number of minutes to wait before re-notifying a contact that this service is still in a " . + "non-OK condition. A value of 0 disables re-notifications of contacts about problems for this service - " . + "only one problem notification will be sent out." +); +$help["notification_period"] = dgettext( + "help", + "Specify the time period during which notifications of events for this service can be sent out to contacts. " . + "If a state change occurs during a time which is not covered by the time period, no notifications will be sent out." +); +$help["notification_options"] = dgettext( + "help", + "Define the states of the service for which notifications should be sent out. If you do not specify any " . + "notification options, Centreon will assume that you want notifications to be sent out for all possible states." +); -$help["graph_template"] = dgettext("help", "The optional definition of a graph template will be used as default graph template for this service."); +$help["graph_template"] = dgettext( + "help", + "The optional definition of a graph template will be used as default graph template for this service." +); diff --git a/www/include/configuration/configObject/meta_service/listMetaService.php b/www/include/configuration/configObject/meta_service/listMetaService.php index a5078d24373..9905a4e10bb 100644 --- a/www/include/configuration/configObject/meta_service/listMetaService.php +++ b/www/include/configuration/configObject/meta_service/listMetaService.php @@ -45,14 +45,14 @@ $search = ''; if (isset($_POST['searchMS']) && $_POST['searchMS'] != "") { $search = $_POST['searchMS']; - $DBRESULT = $pearDB->query("SELECT COUNT(*) - FROM meta_service - WHERE meta_name LIKE '%".htmlentities($search, ENT_QUOTES, "UTF-8")."%' ". - $acl->queryBuilder('AND', 'meta_id', $metaStr)); + $query = "SELECT COUNT(*) FROM meta_service " . + "WHERE meta_name LIKE '%" . htmlentities($search, ENT_QUOTES, "UTF-8") . "%' " . + $acl->queryBuilder('AND', 'meta_id', $metaStr); + $DBRESULT = $pearDB->query($query); } else { $DBRESULT = $pearDB->query("SELECT COUNT(*) - FROM meta_service ". - $acl->queryBuilder('WHERE', 'meta_id', $metaStr)); + FROM meta_service " . + $acl->queryBuilder('WHERE', 'meta_id', $metaStr)); } $tmp = $DBRESULT->fetchRow(); $rows = $tmp["COUNT(*)"]; @@ -79,28 +79,24 @@ $tpl->assign("headerMenu_status", _("Status")); $tpl->assign("headerMenu_options", _("Options")); -$calcType = array("AVE"=>_("Average"), "SOM"=>_("Sum"), "MIN"=>_("Min"), "MAX"=>_("Max")); +$calcType = array("AVE" => _("Average"), "SOM" => _("Sum"), "MIN" => _("Min"), "MAX" => _("Max")); /* * Meta Service list */ if ($search) { - $rq = "SELECT * - FROM meta_service - WHERE meta_name LIKE '%".htmlentities($search, ENT_QUOTES, "UTF-8")."%' ". - $acl->queryBuilder("AND", "meta_id", $metaStr). - "ORDER BY meta_name - LIMIT ".$num * $limit.", ".$limit; + $rq = "SELECT * FROM meta_service " . + "WHERE meta_name LIKE '%" . htmlentities($search, ENT_QUOTES, "UTF-8") . "%' " . + $acl->queryBuilder("AND", "meta_id", $metaStr) . + "ORDER BY meta_name LIMIT " . $num * $limit . ", " . $limit; } else { - $rq = "SELECT * - FROM meta_service ". - $acl->queryBuilder("WHERE", "meta_id", $metaStr). - "ORDER BY meta_name - LIMIT ".$num * $limit.", ".$limit; + $rq = "SELECT * FROM meta_service " . + $acl->queryBuilder("WHERE", "meta_id", $metaStr) . + "ORDER BY meta_name LIMIT " . $num * $limit . ", " . $limit; } $DBRESULT = $pearDB->query($rq); -$form = new HTML_QuickForm('select_form', 'GET', "?p=".$p); +$form = new HTML_QuickForm('select_form', 'GET', "?p=" . $p); /* * Different style between each lines @@ -113,32 +109,43 @@ $elemArr = array(); for ($i = 0; $ms = $DBRESULT->fetchRow(); $i++) { $moptions = ""; - $selectedElements = $form->addElement('checkbox', "select[".$ms['meta_id']."]"); + $selectedElements = $form->addElement('checkbox', "select[" . $ms['meta_id'] . "]"); if ($ms["meta_select_mode"] == 1) { - $moptions = ""._("View")."  "; + $moptions = "" .
+            _("View") . "  "; } else { $moptions = ""; } if ($ms["meta_activate"]) { - $moptions .= ""._("Disabled")."  "; + $moptions .= "" . _("Disabled") . "  "; } else { - $moptions .= ""._("Enabled")."  "; + $moptions .= "" . _("Enabled") . "  "; } $moptions .= " "; - $moptions .= " 31 && (event.keyCode < 45 || event.keyCode > 57)) event.returnValue = false; if(event.which > 31 && (event.which < 45 || event.which > 57)) return false;\" maxlength=\"3\" size=\"3\" value='1' style=\"margin-bottom:0px;\" name='dupNbr[".$ms['meta_id']."]'>"; - - $elemArr[$i] = array("MenuClass"=>"list_".$style, - "RowMenu_select"=>$selectedElements->toHtml(), - "RowMenu_name"=>CentreonUtils::escapeSecure($ms["meta_name"]), - "RowMenu_link"=>"?p=".$p."&o=c&meta_id=".$ms['meta_id'], - "RowMenu_type"=>CentreonUtils::escapeSecure($calcType[$ms["calcul_type"]]), - "RowMenu_levelw"=>isset($ms["warning"]) && $ms["warning"] ? $ms["warning"] : "-", - "RowMenu_levelc"=>isset($ms["critical"]) && $ms["critical"] ? $ms["critical"] : "-", - "RowMenu_status"=>$ms["meta_activate"] ? _("Enabled") : _("Disabled"), - "RowMenu_badge" => $ms["meta_activate"] ? "service_ok" : "service_critical", - "RowMenu_options"=>$moptions); + $moptions .= " 31 && (event.keyCode < 45 || event.keyCode > 57)) " . + "event.returnValue = false; if(event.which > 31 && (event.which < 45 || event.which > 57)) " . + "return false;\" maxlength=\"3\" size=\"3\" value='1' style=\"margin-bottom:0px;\" " . + "name='dupNbr[" . $ms['meta_id'] . "]' />"; + + $elemArr[$i] = array( + "MenuClass" => "list_" . $style, + "RowMenu_select" => $selectedElements->toHtml(), + "RowMenu_name" => CentreonUtils::escapeSecure($ms["meta_name"]), + "RowMenu_link" => "?p=" . $p . "&o=c&meta_id=" . $ms['meta_id'], + "RowMenu_type" => CentreonUtils::escapeSecure($calcType[$ms["calcul_type"]]), + "RowMenu_levelw" => isset($ms["warning"]) && $ms["warning"] ? $ms["warning"] : "-", + "RowMenu_levelc" => isset($ms["critical"]) && $ms["critical"] ? $ms["critical"] : "-", + "RowMenu_status" => $ms["meta_activate"] ? _("Enabled") : _("Disabled"), + "RowMenu_badge" => $ms["meta_activate"] ? "service_ok" : "service_critical", + "RowMenu_options" => $moptions + ); $style != "two" ? $style = "two" : $style = "one"; } $tpl->assign("elemArr", $elemArr); @@ -146,47 +153,72 @@ /* * Different messages we put in the template */ -$tpl->assign('msg', array ("addL"=>"?p=".$p."&o=a", "addT"=>_("Add"), "delConfirm"=>_("Do you confirm the deletion ?"))); +$tpl->assign( + 'msg', + array( + "addL" => "?p=" . $p . "&o=a", + "addT" => _("Add"), + "delConfirm" => _("Do you confirm the deletion ?") + ) +); /* * Toolbar select */ ?> - + "javascript: " . - " var bChecked = isChecked(); ". - " if (this.form.elements['o1'].selectedIndex != 0 && !bChecked) {". - " alert('"._("Please select one or more items")."'); return false;} " . - "if (this.form.elements['o1'].selectedIndex == 1 && confirm('"._("Do you confirm the duplication ?")."')) {" . - " setO(this.form.elements['o1'].value); submit();} " . - "else if (this.form.elements['o1'].selectedIndex == 2 && confirm('"._("Do you confirm the deletion ?")."')) {" . - " setO(this.form.elements['o1'].value); submit();} " . - "else if (this.form.elements['o1'].selectedIndex == 3) {" . - " setO(this.form.elements['o1'].value); submit();} " . - ""); -$form->addElement('select', 'o1', null, array(null=>_("More actions..."), "m"=>_("Duplicate"), "d"=>_("Delete")), $attrs1); + 'onchange' => "javascript: " . + " var bChecked = isChecked(); " . + " if (this.form.elements['o1'].selectedIndex != 0 && !bChecked) {" . + " alert('" . _("Please select one or more items") . "'); return false;} " . + "if (this.form.elements['o1'].selectedIndex == 1 && confirm('" + . _("Do you confirm the duplication ?") . "')) {" . + " setO(this.form.elements['o1'].value); submit();} " . + "else if (this.form.elements['o1'].selectedIndex == 2 && confirm('" + . _("Do you confirm the deletion ?") . "')) {" . + " setO(this.form.elements['o1'].value); submit();} " . + "else if (this.form.elements['o1'].selectedIndex == 3) {" . + " setO(this.form.elements['o1'].value); submit();} " . + "" +); +$form->addElement( + 'select', + 'o1', + null, + array(null => _("More actions..."), "m" => _("Duplicate"), "d" => _("Delete")), + $attrs1 +); $form->setDefaults(array('o1' => null)); $attrs2 = array( - 'onchange'=>"javascript: " . - " var bChecked = isChecked(); ". - " if (this.form.elements['o2'].selectedIndex != 0 && !bChecked) {". - " alert('"._("Please select one or more items")."'); return false;} " . - "if (this.form.elements['o2'].selectedIndex == 1 && confirm('"._("Do you confirm the duplication ?")."')) {" . - " setO(this.form.elements['o2'].value); submit();} " . - "else if (this.form.elements['o2'].selectedIndex == 2 && confirm('"._("Do you confirm the deletion ?")."')) {" . - " setO(this.form.elements['o2'].value); submit();} " . - "else if (this.form.elements['o2'].selectedIndex == 3) {" . - " setO(this.form.elements['o2'].value); submit();} " . - ""); -$form->addElement('select', 'o2', null, array(null=>_("More actions..."), "m"=>_("Duplicate"), "d"=>_("Delete")), $attrs2); + 'onchange' => "javascript: " . + " var bChecked = isChecked(); " . + " if (this.form.elements['o2'].selectedIndex != 0 && !bChecked) {" . + " alert('" . _("Please select one or more items") . "'); return false;} " . + "if (this.form.elements['o2'].selectedIndex == 1 && confirm('" . + _("Do you confirm the duplication ?") . "')) {" . + " setO(this.form.elements['o2'].value); submit();} " . + "else if (this.form.elements['o2'].selectedIndex == 2 && confirm('" . + _("Do you confirm the deletion ?") . "')) {" . + " setO(this.form.elements['o2'].value); submit();} " . + "else if (this.form.elements['o2'].selectedIndex == 3) {" . + " setO(this.form.elements['o2'].value); submit();} " . + "" +); +$form->addElement( + 'select', + 'o2', + null, + array(null => _("More actions..."), "m" => _("Duplicate"), "d" => _("Delete")), + $attrs2 +); $form->setDefaults(array('o2' => null)); $o1 = $form->getElement('o1'); diff --git a/www/include/configuration/configObject/meta_service/listMetric.php b/www/include/configuration/configObject/meta_service/listMetric.php index 080080f151b..210f7174daa 100644 --- a/www/include/configuration/configObject/meta_service/listMetric.php +++ b/www/include/configuration/configObject/meta_service/listMetric.php @@ -33,13 +33,13 @@ * */ -$calcType = array("AVE"=>_("Average"), "SOM"=>_("Sum"), "MIN"=>_("Min"), "MAX"=>_("Max")); +$calcType = array("AVE" => _("Average"), "SOM" => _("Sum"), "MIN" => _("Min"), "MAX" => _("Max")); if (!isset($oreon)) { exit(); } - include_once("./class/centreonUtils.class.php"); +include_once("./class/centreonUtils.class.php"); include("./include/common/autoNumLimit.php"); @@ -56,12 +56,14 @@ require_once("./class/centreonDB.class.php"); $pearDBO = new CentreonDB("centstorage"); -$DBRESULT = $pearDB->query("SELECT * FROM meta_service WHERE meta_id = '".$meta_id."'"); +$DBRESULT = $pearDB->query("SELECT * FROM meta_service WHERE meta_id = '" . $meta_id . "'"); $meta = $DBRESULT->fetchRow(); -$tpl->assign("meta", array( "meta" => _("Meta Service"), - "name" => $meta["meta_name"], - "calc_type" => $calcType[$meta["calcul_type"]])); +$tpl->assign("meta", array( + "meta" => _("Meta Service"), + "name" => $meta["meta_name"], + "calc_type" => $calcType[$meta["calcul_type"]] +)); $DBRESULT->closeCursor(); /* @@ -78,18 +80,18 @@ if (!$oreon->user->admin) { $aclFrom = ", $aclDbName.centreon_acl acl "; $aclCond = " AND acl.host_id = msr.host_id - AND acl.group_id IN (".$acl->getAccessGroupsString().") "; + AND acl.group_id IN (" . $acl->getAccessGroupsString() . ") "; } $rq = "SELECT DISTINCT msr.* FROM `meta_service_relation` msr $aclFrom - WHERE msr.meta_id = '".$meta_id."' + WHERE msr.meta_id = '" . $meta_id . "' $aclCond ORDER BY host_id"; $results = $pearDB->query($rq); $ar_relations = array(); -$form = new HTML_QuickForm('Form', 'POST', "?p=".$p); +$form = new HTML_QuickForm('Form', 'POST', "?p=" . $p); /* * Construct request @@ -101,10 +103,13 @@ $ar_relations[$row['metric_id']][] = array("activate" => $row['activate'], "msr_id" => $row['msr_id']); $metrics[] = $row['metric_id']; } -$in_statement= implode(",", $metrics); +$in_statement = implode(",", $metrics); if ($in_statement != "") { - $DBRESULTO = $pearDBO->query("SELECT * FROM metrics m, index_data i WHERE m.metric_id IN ($in_statement) and m.index_id=i.id ORDER BY i.host_name, i.service_description, m.metric_name"); + $query = "SELECT * FROM metrics m, index_data i " . + "WHERE m.metric_id IN ($in_statement) " . + "AND m.index_id=i.id ORDER BY i.host_name, i.service_description, m.metric_name"; + $DBRESULTO = $pearDBO->query($query); /* * Different style between each lines */ @@ -116,26 +121,35 @@ $i = 0; while ($metric = $DBRESULTO->fetchRow()) { foreach ($ar_relations[$metric['metric_id']] as $relation) { - $moptions = ""; - $selectedElements = $form->addElement('checkbox', "select[".$relation['msr_id']."]"); + $moptions = ""; + $selectedElements = $form->addElement('checkbox', "select[" . $relation['msr_id'] . "]"); if ($relation["activate"]) { - $moptions .= ""._("Disabled")."  "; + $moptions .= "" .
+                    _("Disabled") . "  "; } else { - $moptions .= ""._("Enabled")."  "; + $moptions .= "" .
+                    _("Enabled") . "  "; } - $metric["service_description"] = str_replace("#S#", "/", $metric["service_description"]); - $metric["service_description"] = str_replace("#BS#", "\\", $metric["service_description"]); - $elemArr1[$i] = array( "MenuClass"=>"list_".$style, - "RowMenu_select"=>$selectedElements->toHtml(), - "RowMenu_host"=>htmlentities($metric["host_name"], ENT_QUOTES, "UTF-8"), - "RowMenu_link"=>"?p=".$p."&o=cs&msr_id=".$relation['msr_id'], - "RowMenu_service"=>htmlentities($metric["service_description"], ENT_QUOTES, "UTF-8"), - "RowMenu_metric"=>CentreonUtils::escapeSecure($metric["metric_name"]." (".$metric["unit_name"].")"), - "RowMenu_status"=>$relation["activate"] ? _("Enabled") : _("Disabled"), - "RowMenu_badge" => $relation["activate"] ? "service_ok" : "service_critical", - "RowMenu_options"=>$moptions); - $style != "two" ? $style = "two" : $style = "one"; - $i++; + $metric["service_description"] = str_replace("#S#", "/", $metric["service_description"]); + $metric["service_description"] = str_replace("#BS#", "\\", $metric["service_description"]); + $elemArr1[$i] = array( + "MenuClass" => "list_" . $style, + "RowMenu_select" => $selectedElements->toHtml(), + "RowMenu_host" => htmlentities($metric["host_name"], ENT_QUOTES, "UTF-8"), + "RowMenu_link" => "?p=" . $p . "&o=cs&msr_id=" . $relation['msr_id'], + "RowMenu_service" => htmlentities($metric["service_description"], ENT_QUOTES, "UTF-8"), + "RowMenu_metric" => + CentreonUtils::escapeSecure($metric["metric_name"] . " (" . $metric["unit_name"] . ")"), + "RowMenu_status" => $relation["activate"] ? _("Enabled") : _("Disabled"), + "RowMenu_badge" => $relation["activate"] ? "service_ok" : "service_critical", + "RowMenu_options" => $moptions + ); + $style != "two" ? $style = "two" : $style = "one"; + $i++; } } } @@ -148,39 +162,45 @@ /* * Different messages we put in the template */ -$tpl->assign('msg', array ("addL1"=>"?p=".$p."&o=as&meta_id=".$meta_id, "addT"=>_("Add"), "delConfirm"=>_("Do you confirm the deletion ?"))); +$tpl->assign('msg', array( + "addL1" => "?p=" . $p . "&o=as&meta_id=" . $meta_id, + "addT" => _("Add"), + "delConfirm" => _("Do you confirm the deletion ?") +)); /* * Element we need when we reload the page */ $form->addElement('hidden', 'p'); $form->addElement('hidden', 'meta_id'); -$tab = array ("p" => $p, "meta_id"=>$meta_id); +$tab = array("p" => $p, "meta_id" => $meta_id); $form->setDefaults($tab); /* * Toolbar select */ ?> - + "javascript: " . - "if (this.form.elements['o1'].selectedIndex == 1 && confirm('"._("Do you confirm the deletion ?")."')) {" . - " setO(this.form.elements['o1'].value); submit();} "); -$form->addElement('select', 'o1', null, array(null=>_("More actions..."), "ds"=>_("Delete")), $attrs1); + 'onchange' => "javascript: " . + "if (this.form.elements['o1'].selectedIndex == 1 && confirm('" . _("Do you confirm the deletion ?") . "')) {" . + " setO(this.form.elements['o1'].value); submit();} " +); +$form->addElement('select', 'o1', null, array(null => _("More actions..."), "ds" => _("Delete")), $attrs1); $form->setDefaults(array('o1' => null)); $attrs2 = array( - 'onchange'=>"javascript: " . - "if (this.form.elements['o2'].selectedIndex == 1 && confirm('"._("Do you confirm the deletion ?")."')) {" . - " setO(this.form.elements['o2'].value); submit();} "); -$form->addElement('select', 'o2', null, array(null=>_("More actions..."), "ds"=>_("Delete")), $attrs2); + 'onchange' => "javascript: " . + "if (this.form.elements['o2'].selectedIndex == 1 && confirm('" . _("Do you confirm the deletion ?") . "')) {" . + " setO(this.form.elements['o2'].value); submit();} " +); +$form->addElement('select', 'o2', null, array(null => _("More actions..."), "ds" => _("Delete")), $attrs2); $form->setDefaults(array('o2' => null)); $o1 = $form->getElement('o1'); diff --git a/www/include/configuration/configObject/meta_service/metric.php b/www/include/configuration/configObject/meta_service/metric.php index 1b9cfac0953..b530afa5af9 100644 --- a/www/include/configuration/configObject/meta_service/metric.php +++ b/www/include/configuration/configObject/meta_service/metric.php @@ -32,7 +32,7 @@ * For more information : contact@centreon.com * */ - + /* * Database retrieve information */ @@ -43,12 +43,14 @@ $metric = array(); if (($o == 'cs') && $msr_id) { # Set base value - $DBRESULT = $pearDB->query("SELECT * FROM meta_service_relation WHERE msr_id = '".$msr_id."'"); + $DBRESULT = $pearDB->query("SELECT * FROM meta_service_relation WHERE msr_id = '" . $msr_id . "'"); # Set base value $metric1 = array_map("myDecode", $DBRESULT->fetchRow()); if (!isset($host_id) || $metric1['host_id'] == $host_id) { - $DBRESULT = $pearDBO->query("SELECT * FROM metrics, index_data WHERE metric_id = '" . $metric1["metric_id"] . "' and metrics.index_id = index_data.id"); + $query = "SELECT * FROM metrics, index_data WHERE metric_id = '" . $metric1["metric_id"] . + "' and metrics.index_id = index_data.id"; + $DBRESULT = $pearDBO->query($query); $metric2 = array_map("myDecode", $DBRESULT->fetchRow()); $metric = array_merge($metric1, $metric2); $host_id = $metric1["host_id"]; @@ -64,34 +66,38 @@ /* * Host comes from DB -> Store in $hosts Array */ -$hosts = array(null => null) + $acl->getHostAclConf( - null, - 'broker', - array( - 'fields' => array('host.host_id', 'host.host_name'), - 'keys' => array('host_id'), - 'get_row' => 'host_name', - 'order' => array('host.host_name') - ) -); +$hosts = + array(null => null) + $acl->getHostAclConf( + null, + 'broker', + array( + 'fields' => array('host.host_id', 'host.host_name'), + 'keys' => array('host_id'), + 'get_row' => 'host_name', + 'order' => array('host.host_name') + ) + ); $services1 = array(null => null); $services2 = array(null => null); if ($host_id) { - $services = array(null => null) + $acl->getHostServiceAclConf( - $host_id, - 'broker', - array( - 'fields' => array('s.service_id', 's.service_description'), - 'keys' => array('service_id'), - 'get_row' => 'service_description', - 'order' => array('service_description')) - ); + $services = + array(null => null) + $acl->getHostServiceAclConf( + $host_id, + 'broker', + array( + 'fields' => array('s.service_id', 's.service_description'), + 'keys' => array('service_id'), + 'get_row' => 'service_description', + 'order' => array('service_description') + ) + ); + foreach ($services as $key => $value) { $DBRESULT = $pearDBO->query("SELECT DISTINCT metric_name, metric_id, unit_name FROM metrics m, index_data i - WHERE i.host_name = '".$pearDBO->escape(getMyHostName($host_id))."' - AND i.service_description = '".$pearDBO->escape($value)."' + WHERE i.host_name = '" . $pearDBO->escape(getMyHostName($host_id)) . "' + AND i.service_description = '" . $pearDBO->escape($value) . "' AND i.id = m.index_id ORDER BY metric_name, unit_name"); @@ -99,21 +105,21 @@ $services1[$key] = $value; $metricSV["metric_name"] = str_replace("#S#", "/", $metricSV["metric_name"]); $metricSV["metric_name"] = str_replace("#BS#", "\\", $metricSV["metric_name"]); - $services2[$key][$metricSV["metric_id"]] = $metricSV["metric_name"]." (".$metricSV["unit_name"].")"; + $services2[$key][$metricSV["metric_id"]] = $metricSV["metric_name"] . " (" . $metricSV["unit_name"] . ")"; } } $DBRESULT->closeCursor(); } $debug = 0; -$attrsTextI = array("size"=>"3"); -$attrsText = array("size"=>"30"); -$attrsTextarea = array("rows"=>"5", "cols"=>"40"); +$attrsTextI = array("size" => "3"); +$attrsText = array("size" => "30"); +$attrsTextarea = array("rows" => "5", "cols" => "40"); /* * Form begin */ -$form = new HTML_QuickForm('Form', 'post', "?p=".$p); +$form = new HTML_QuickForm('Form', 'post', "?p=" . $p); if ($o == "as") { $form->addElement('header', 'title', _("Add a Meta Service indicator")); } elseif ($o == "cs") { @@ -132,7 +138,7 @@ $formMetricId = $form->addElement('hidden', 'metric_id'); $formMetricId->setValue($metric_id); -$hn = $form->addElement('select', 'host_id', _("Host"), $hosts, array("onChange"=>"this.form.submit()")); +$hn = $form->addElement('select', 'host_id', _("Host"), $hosts, array("onChange" => "this.form.submit()")); $sel = $form->addElement('hierselect', 'metric_sel', _("Service")); $sel->setOptions(array($services1, $services2)); @@ -147,7 +153,7 @@ $tab[] = HTML_QuickForm::createElement('radio', 'action', null, _("List"), '1'); $tab[] = HTML_QuickForm::createElement('radio', 'action', null, _("Form"), '0'); $form->addGroup($tab, 'action', _("Post Validation"), ' '); -$form->setDefaults(array('action'=>'1')); +$form->setDefaults(array('action' => '1')); $form->addRule('host_id', _("Compulsory Field"), 'required'); @@ -179,7 +185,9 @@ function checkMetric() } $valid = false; -if (((isset($_POST["submitA"]) && $_POST["submitA"]) || (isset($_POST["submitC"]) && $_POST["submitC"])) && $form->validate()) { +if (((isset($_POST["submitA"]) && $_POST["submitA"]) || (isset($_POST["submitC"]) && $_POST["submitC"])) && + $form->validate() +) { $msrObj = $form->getElement('msr_id'); if ($form->getSubmitValue("submitA")) { $msrObj->setValue(insertMetric($meta_id)); @@ -191,7 +199,7 @@ function checkMetric() $action = $form->getSubmitValue("action"); if ($valid) { - require_once($path."listMetric.php"); + require_once($path . "listMetric.php"); } else { /* * Smarty template Init From 46006acd54830238587362a5cf81156430215d6d Mon Sep 17 00:00:00 2001 From: Laurent Pinsivy Date: Tue, 18 Jul 2017 15:26:08 +0200 Subject: [PATCH 033/207] Lpinsivy traps whyadmin (#5417) * duplication and useless to check admin access * useless to check admin access * Update formTraps.php * Update formTraps.ihtml --- www/class/centreonTraps.class.php | 3 --- .../configObject/traps/formTraps.ihtml | 9 +++++---- .../configObject/traps/formTraps.php | 20 +++++++++++-------- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/www/class/centreonTraps.class.php b/www/class/centreonTraps.class.php index b2a9fa17f88..d2c60191345 100644 --- a/www/class/centreonTraps.class.php +++ b/www/class/centreonTraps.class.php @@ -467,9 +467,6 @@ public function insert($ret = array()) $this->setServiceRelations($traps_id['MAX(traps_id)']); $this->setServiceTemplateRelations($traps_id['MAX(traps_id)']); $this->setPreexec($traps_id['MAX(traps_id)']); - if ($this->centreon->user->admin) { - $this->setServiceTemplateRelations($traps_id['MAX(traps_id)'], $ret['service_templates']); - } /* Prepare value for changelog */ $fields = CentreonLogAction::prepareChanges($ret); diff --git a/www/include/configuration/configObject/traps/formTraps.ihtml b/www/include/configuration/configObject/traps/formTraps.ihtml index d13ef1b8eaf..6b2b9ad79df 100644 --- a/www/include/configuration/configObject/traps/formTraps.ihtml +++ b/www/include/configuration/configObject/traps/formTraps.ihtml @@ -99,9 +99,10 @@ {$form.services.html}
{$serviceTemplateTxt}{$form.service_templates.html}
{$serviceTemplateTxt}{$form.service_templates.html}
@@ -192,4 +193,4 @@ {$form.hidden} -{$helptext} \ No newline at end of file +{$helptext} diff --git a/www/include/configuration/configObject/traps/formTraps.php b/www/include/configuration/configObject/traps/formTraps.php index 81cbbe11ab9..19709a8ce81 100644 --- a/www/include/configuration/configObject/traps/formTraps.php +++ b/www/include/configuration/configObject/traps/formTraps.php @@ -209,17 +209,21 @@ function myReplace() $attrService1 = array_merge( $attrServices, - array('defaultDatasetRoute' => './include/common/webServices/rest/internal.php?object=centreon_configuration_service&action=defaultValues&target=traps&field=services&id=' . $traps_id) + array( + 'defaultDatasetRoute' => './api/internal.php?object=centreon_configuration_service&action=defaultValues' . + '&target=traps&field=services&id=' . $traps_id + ) ); $form->addElement('select2', 'services', _("Linked Services"), array(), $attrService1); -if ($centreon->user->admin) { - $attrServicetemplate1 = array_merge( - $attrServicetemplates, - array('defaultDatasetRoute' => './include/common/webServices/rest/internal.php?object=centreon_configuration_servicetemplate&action=defaultValues&target=traps&field=service_templates&id=' . $traps_id) - ); - $form->addElement('select2', 'service_templates', _("Linked Service Templates"), array(), $attrServicetemplate1); -} +$attrServicetemplate1 = array_merge( + $attrServicetemplates, + array( + 'defaultDatasetRoute' => './api/internal.php?object=centreon_configuration_servicetemplate&action=defaultValues' . + '&target=traps&field=service_templates&id=' . $traps_id + ) +); +$form->addElement('select2', 'service_templates', _("Linked Service Templates"), array(), $attrServicetemplate1); /* * Routing From e7841feac0f0ad9d63d027d5fa1ec595171589ad Mon Sep 17 00:00:00 2001 From: mariegallardo Date: Wed, 19 Jul 2017 09:12:43 +0200 Subject: [PATCH 034/207] Feature created (#5445) --- behat.yml | 5 + features/TimePeriodConfiguration.feature | 27 ++ .../TimePeriodConfigurationContext.php | 288 ++++++++++++++++++ 3 files changed, 320 insertions(+) create mode 100644 features/TimePeriodConfiguration.feature create mode 100644 features/bootstrap/TimePeriodConfigurationContext.php diff --git a/behat.yml b/behat.yml index 369c24f5ef7..d4d8542fe7c 100644 --- a/behat.yml +++ b/behat.yml @@ -248,3 +248,8 @@ default: paths: [ %paths.base%/features/ACLActionsAccess.feature ] contexts: - ACLActionsAccessContext + + time_period_configuration: + paths: [ %paths.base%/features/TimePeriodConfiguration.feature ] + contexts: + - TimePeriodConfigurationContext diff --git a/features/TimePeriodConfiguration.feature b/features/TimePeriodConfiguration.feature new file mode 100644 index 00000000000..42bbf04a733 --- /dev/null +++ b/features/TimePeriodConfiguration.feature @@ -0,0 +1,27 @@ +Feature: Time period Configuration + As a Centreon user + I want to configure various types of time periods + To avoid useless monitoring checks during company closing + + Background: + Given I am logged in a Centreon server + + # jours à exclure : 1er janvier, 1er mai, 14 juillet, 25 décembre + Scenario: Time period excluding holidays + When I create a time period with separated holidays dates excluded + Then all properties of my time period are saved + + # période à exclure : du 1er au 31 août + Scenario: Time period excluding a range of dates + When I create a time period with a range of dates to exclude + Then all properties of my time period are saved with the exclusions + + Scenario: Duplicating an existing time period + Given an existing time period + When I duplicate the time period + Then a new time period is created with identical properties except the name + + Scenario: Delete an existing time period + Given an existing time period + When I delete the time period + Then the time period disappears from the time periods list diff --git a/features/bootstrap/TimePeriodConfigurationContext.php b/features/bootstrap/TimePeriodConfigurationContext.php new file mode 100644 index 00000000000..0ae0a28f2ba --- /dev/null +++ b/features/bootstrap/TimePeriodConfigurationContext.php @@ -0,0 +1,288 @@ + 'timePeriodName', + 'alias' => 'timePeriodAlias', + 'sunday' => '14:00-16:00', + 'monday' => '07:00-12:00,13:00-18:00', + 'tuesday' => '07:00-18:00', + 'wednesday' => '07:00-12:00,13:00-17:00', + 'thursday' => '07:00-18:00', + 'friday' => '07:00-18:00', + 'saturday' => '10:00-16:00', + 'templates' => 'none', + 'exceptions' => array ( + array ( + 'day' => 'december 25', + 'timeRange' => '00:00-22:59,23:00-24:00' + ), + array ( + 'day' => 'january 1', + 'timeRange' => '00:00-24:00' + ), + array ( + 'day' => 'july 14', + 'timeRange' => '00:00-24:00' + ), + array ( + 'day' => 'may 25', + 'timeRange' => '00:00-24:00' + ) + ) + ); + + private $duplicatedProperties = array ( + 'name' => 'timePeriodName_1', + 'alias' => 'timePeriodAlias', + 'sunday' => '14:00-16:00', + 'monday' => '07:00-12:00,13:00-18:00', + 'tuesday' => '07:00-18:00', + 'wednesday' => '07:00-12:00,13:00-17:00', + 'thursday' => '07:00-18:00', + 'friday' => '07:00-18:00', + 'saturday' => '10:00-16:00', + 'templates' => 'none', + 'exceptions' => array ( + array ( + 'day' => 'december 25', + 'timeRange' => '00:00-22:59,23:00-24:00' + ), + array ( + 'day' => 'january 1', + 'timeRange' => '00:00-24:00' + ), + array ( + 'day' => 'july 14', + 'timeRange' => '00:00-24:00' + ), + array ( + 'day' => 'may 25', + 'timeRange' => '00:00-24:00' + ) + ) + ); + + private $AugustHolidays = array ( + 'name' => 'timePeriodName', + 'alias' => 'timePeriodAlias', + 'sunday' => '14:00-16:00', + 'monday' => '07:00-12:00,13:00-18:00', + 'tuesday' => '07:00-18:00', + 'wednesday' => '07:00-12:00,13:00-17:00', + 'thursday' => '07:00-18:00', + 'friday' => '07:00-18:00', + 'saturday' => '10:00-16:00', + 'templates' => 'none', + 'exceptions' => array ( + array ( + 'day' => 'august 1 - 31', + 'timeRange' => '00:00-24:00' + ) + ) + ); + + /** + * @When I create a time period with separated holidays dates excluded + */ + public function iCreateATimePeriodWithSeparatedHolidaysDatesExcluded() + { + $this->currentPage = new TimeperiodConfigurationPage($this); + $this->currentPage->setProperties($this->initialProperties); + $this->currentPage->save(); + } + + /** + * @Then all properties of my time period are saved + */ + public function allPropertiesOfMyTimePeriodAreSaved() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new TimeperiodConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['name']); + $object = $this->currentPage->getProperties(); + foreach ($this->initialProperties as $key => $value) { + if ($key != 'exceptions' && $value != $object[$key]) { + $this->tableau[] = $key; + } + if ($key == 'exceptions') { + $stringValue = ''; + foreach($value as $array) { + $stringValue = $stringValue . implode(',', $array) . ' '; + } + $stringObject = ''; + foreach($object[$key] as $array) { + $stringObject = $stringObject . implode(',', $array) . ' '; + } + if ($stringValue != $stringObject) { + $this->tableau[] = $key; + } + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I create a time period with a range of dates to exclude + */ + public function iCreateATimePeriodWithARangeOfDatesToExclude() + { + $this->currentPage = new TimeperiodConfigurationPage($this); + $this->currentPage->setProperties($this->AugustHolidays); + $this->currentPage->save(); + } + + /** + * @Then all properties of my time period are saved with the exclusions + */ + public function allPropertiesOfMyTimePeriodAreSavedWithTheExclusions() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new TimeperiodConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->AugustHolidays['name']); + $object = $this->currentPage->getProperties(); + foreach ($this->AugustHolidays as $key => $value) { + if ($key != 'exceptions' && $value != $object[$key]) { + $this->tableau[] = $key; + } + if ($key == 'exceptions') { + $stringValue = ''; + foreach($value as $array) { + $stringValue = $stringValue . implode(',', $array) . ' '; + } + $stringObject = ''; + foreach($object[$key] as $array) { + $stringObject = $stringObject . implode(',', $array) . ' '; + } + if (strcmp($stringValue, $stringObject) !== 0) { + $this->tableau[] = $key; + } + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @Given an existing time period + */ + public function anExistingTimePeriod() + { + $this->currentPage = new TimeperiodConfigurationPage($this); + $this->currentPage->setProperties($this->initialProperties); + $this->currentPage->save(); + } + + /** + * @When I duplicate the time period + */ + public function iDuplicateTheTimePeriod() + { + $this->currentPage = new TimeperiodConfigurationListingPage($this); + $object = $this->currentPage->getEntry($this->initialProperties['name']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Duplicate'); + } + + /** + * @Then a new time period is created with identical properties except the name + */ + public function aNewTimePeriodIsCreatedWithIdenticalPropertiesExceptTheName() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new TimeperiodConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->duplicatedProperties['name']); + $object = $this->currentPage->getProperties(); + foreach ($this->duplicatedProperties as $key => $value) { + if ($key != 'exceptions' && $value != $object[$key]) { + $this->tableau[] = $key; + } + if ($key == 'exceptions') { + $stringValue = ''; + foreach($value as $array) { + $stringValue = $stringValue . implode(',', $array) . ' '; + } + $stringObject = ''; + foreach($object[$key] as $array) { + $stringObject = $stringObject . implode(',', $array) . ' '; + } + if (strcmp($stringValue, $stringObject) !== 0) { + $this->tableau[] = $key; + } + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I delete the time period + */ + public function iDeleteTheTimePeriod() + { + $this->currentPage = new TimeperiodConfigurationListingPage($this); + $object = $this->currentPage->getEntry($this->initialProperties['name']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Delete'); + } + + /** + * @Then the time period disappears from the time periods list + */ + public function theTimePeriodDisappearsFromTheTimePeriodsList() + { + $this->spin( + function ($context) { + $this->currentPage = new TimeperiodConfigurationListingPage($this); + $object = $this->currentPage->getEntries(); + $bool = true; + foreach ($object as $value) { + $bool = $bool && $value['name'] != $this->initialProperties['name']; + } + return $bool; + }, + "The contact group was not deleted.", + 30 + ); + } +} From c8887d36532c9c4effb04b9965a7e24a01298280 Mon Sep 17 00:00:00 2001 From: loiclau Date: Wed, 19 Jul 2017 11:03:59 +0200 Subject: [PATCH 035/207] * fix pdo quote --- www/class/centreonContactgroup.class.php | 10 +- www/include/common/quickSearch.php | 5 +- .../configKnowledge/pagination.php | 6 +- .../configuration/configNagios/DB-Func.php | 746 +++++++++--------- 4 files changed, 389 insertions(+), 378 deletions(-) diff --git a/www/class/centreonContactgroup.class.php b/www/class/centreonContactgroup.class.php index 3db2cb9c3b4..7f8dc206c71 100644 --- a/www/class/centreonContactgroup.class.php +++ b/www/class/centreonContactgroup.class.php @@ -261,9 +261,15 @@ public function syncWithLdap() $queryDeleteRelation = "DELETE FROM contactgroup_contact_relation WHERE contactgroup_cg_id = " . $row['cg_id']; $this->db->query($queryDeleteRelation); + + $contact = ''; + foreach ($members as $member){ + $contact = $this->db->quote($member) .','; + } + $contact = rtrim($contact, ","); + $queryContact = "SELECT contact_id FROM contact - WHERE contact_ldap_dn IN ('" . - join("', '", array_map('PDO::quote', $members)) . "')"; + WHERE contact_ldap_dn IN ('" .$contact . "')"; try { $resContact = $this->db->query($queryContact); } catch (\PDOException $e) { diff --git a/www/include/common/quickSearch.php b/www/include/common/quickSearch.php index 0bec56db3a6..ac0ad11c85b 100644 --- a/www/include/common/quickSearch.php +++ b/www/include/common/quickSearch.php @@ -33,6 +33,7 @@ * */ +require_once realpath(dirname(__FILE__) . "/../../../bootstrap.php"); global $search; if (!isset($oreon)) { @@ -56,14 +57,14 @@ } $searchRaw = $search; -$search = PDO::quote($search); +$search = $dependencyInjector['configuration_db']->quote($search); if (!isset($search_service)) { $search_service = ""; $search_serviceRaw = ""; } else { $search_serviceRaw = $search_service; - $search_service = PDO::quote($search_service); + $search_service = $dependencyInjector['configuration_db']->quote($search_service); } if (isset($search) && $search) { diff --git a/www/include/configuration/configKnowledge/pagination.php b/www/include/configuration/configKnowledge/pagination.php index 6e6a23ef222..da19e6013aa 100644 --- a/www/include/configuration/configKnowledge/pagination.php +++ b/www/include/configuration/configKnowledge/pagination.php @@ -56,7 +56,6 @@ } } - if (isset($_GET["num"])) { $num = $_GET["num"]; } else { @@ -67,7 +66,7 @@ } } -$num = PDO::quote($num); +$num = $pearDB->quote($num); $tab_order = array("sort_asc" => "sort_desc", "sort_desc" => "sort_asc"); @@ -94,7 +93,8 @@ } if (!isset($_GET["search_type_host"]) && !isset($oreon->search_type_host) && - !isset($_GET["search_type_service"]) && !isset($oreon->search_type_service)) { + !isset($_GET["search_type_service"]) && !isset($oreon->search_type_service) +) { $search_type_host = 1; $oreon->search_type_host = 1; $search_type_service = 1; diff --git a/www/include/configuration/configNagios/DB-Func.php b/www/include/configuration/configNagios/DB-Func.php index 9f5c766f423..da9a4be0b3b 100644 --- a/www/include/configuration/configNagios/DB-Func.php +++ b/www/include/configuration/configNagios/DB-Func.php @@ -64,16 +64,16 @@ function enableNagiosInDB($nagios_id = null) } $DBRESULT = $pearDB->query( - "SELECT `nagios_server_id` FROM cfg_nagios WHERE nagios_id = '".$nagios_id."'" + "SELECT `nagios_server_id` FROM cfg_nagios WHERE nagios_id = '" . $nagios_id . "'" ); $data = $DBRESULT->fetchRow(); $DBRESULT = $pearDB->query( - "UPDATE `cfg_nagios` SET `nagios_activate` = '0' WHERE `nagios_server_id` = '".$data["nagios_server_id"]."'" + "UPDATE `cfg_nagios` SET `nagios_activate` = '0' WHERE `nagios_server_id` = '" . $data["nagios_server_id"] . "'" ); $DBRESULT = $pearDB->query( - "UPDATE cfg_nagios SET nagios_activate = '1' WHERE nagios_id = '".$nagios_id."'" + "UPDATE cfg_nagios SET nagios_activate = '1' WHERE nagios_id = '" . $nagios_id . "'" ); $centreon->Nagioscfg = array(); } @@ -87,21 +87,21 @@ function disableNagiosInDB($nagios_id = null) } $DBRESULT = $pearDB->query( - "SELECT `nagios_server_id` FROM cfg_nagios WHERE nagios_id = '".$nagios_id."'" + "SELECT `nagios_server_id` FROM cfg_nagios WHERE nagios_id = '" . $nagios_id . "'" ); $data = $DBRESULT->fetchRow(); $DBRESULT = $pearDB->query( - "UPDATE cfg_nagios SET nagios_activate = '0' WHERE `nagios_server_id` = '".$data["nagios_server_id"]."'" + "UPDATE cfg_nagios SET nagios_activate = '0' WHERE `nagios_server_id` = '" . $data["nagios_server_id"] . "'" ); $DBRESULT = $pearDB->query( - "SELECT MAX(nagios_id) FROM cfg_nagios WHERE nagios_id != '".$nagios_id."'" + "SELECT MAX(nagios_id) FROM cfg_nagios WHERE nagios_id != '" . $nagios_id . "'" ); $maxId = $DBRESULT->fetchRow(); if (isset($maxId["MAX(nagios_id)"])) { $DBRESULT2 = $pearDB->query( - "UPDATE cfg_nagios SET nagios_activate = '1' WHERE nagios_id = '".$maxId["MAX(nagios_id)"]."'" + "UPDATE cfg_nagios SET nagios_activate = '1' WHERE nagios_id = '" . $maxId["MAX(nagios_id)"] . "'" ); $centreon->Nagioscfg = array(); $DBRESULT2 = $pearDB->query( @@ -118,10 +118,10 @@ function deleteNagiosInDB($nagios = array()) foreach ($nagios as $key => $value) { $DBRESULT = $pearDB->query( - "DELETE FROM cfg_nagios WHERE nagios_id = '".$key."'" + "DELETE FROM cfg_nagios WHERE nagios_id = '" . $key . "'" ); $DBRESULT = $pearDB->query( - "DELETE FROM cfg_nagios_broker_module WHERE cfg_nagios_id = '".$key."'" + "DELETE FROM cfg_nagios_broker_module WHERE cfg_nagios_id = '" . $key . "'" ); } $DBRESULT = $pearDB->query( @@ -133,7 +133,7 @@ function deleteNagiosInDB($nagios = array()) ); $nagios_id = $DBRESULT2->fetchRow(); $DBRESULT2 = $pearDB->query( - "UPDATE cfg_nagios SET nagios_activate = '1' WHERE nagios_id = '".$nagios_id["MAX(nagios_id)"]."'" + "UPDATE cfg_nagios SET nagios_activate = '1' WHERE nagios_id = '" . $nagios_id["MAX(nagios_id)"] . "'" ); } $DBRESULT->closeCursor(); @@ -144,7 +144,7 @@ function multipleNagiosInDB($nagios = array(), $nbrDup = array()) foreach ($nagios as $key => $value) { global $pearDB; $DBRESULT = $pearDB->query( - "SELECT * FROM cfg_nagios WHERE nagios_id = '".$key."' LIMIT 1" + "SELECT * FROM cfg_nagios WHERE nagios_id = '" . $key . "' LIMIT 1" ); $row = $DBRESULT->fetchRow(); $row["nagios_id"] = ''; @@ -152,7 +152,7 @@ function multipleNagiosInDB($nagios = array(), $nbrDup = array()) $DBRESULT->closeCursor(); $rowBks = array(); $DBRESULT = $pearDB->query( - "SELECT * FROM cfg_nagios_broker_module WHERE cfg_nagios_id='".$key."'" + "SELECT * FROM cfg_nagios_broker_module WHERE cfg_nagios_id='" . $key . "'" ); while ($rowBk = $DBRESULT->fetchRow()) { $rowBks[] = $rowBk; @@ -161,12 +161,12 @@ function multipleNagiosInDB($nagios = array(), $nbrDup = array()) for ($i = 1; $i <= $nbrDup[$key]; $i++) { $val = null; foreach ($row as $key2 => $value2) { - $key2 == "nagios_name" ? ($nagios_name = $value2 = $value2."_".$i) : null; - $val ? $val .= ($value2!=null?(", '".$value2."'"):", NULL") - : $val .= ($value2!=null?("'".$value2."'"):"NULL"); + $key2 == "nagios_name" ? ($nagios_name = $value2 = $value2 . "_" . $i) : null; + $val ? $val .= ($value2 != null ? (", '" . $value2 . "'") : ", NULL") + : $val .= ($value2 != null ? ("'" . $value2 . "'") : "NULL"); } if (testExistence($nagios_name)) { - $val ? $rq = "INSERT INTO cfg_nagios VALUES (".$val.")" : $rq = null; + $val ? $rq = "INSERT INTO cfg_nagios VALUES (" . $val . ")" : $rq = null; $DBRESULT = $pearDB->query($rq); /* Find the new last nagios_id once */ $DBRESULT = $pearDB->query("SELECT MAX(nagios_id) FROM cfg_nagios"); @@ -175,7 +175,7 @@ function multipleNagiosInDB($nagios = array(), $nbrDup = array()) foreach ($rowBks as $keyBk => $valBk) { if ($valBk["broker_module"]) { $rqBk = "INSERT INTO cfg_nagios_broker_module (`cfg_nagios_id`, `broker_module`) VALUES ('" - . $nagios_id["MAX(nagios_id)"] . "', '" . $valBk["broker_module"] . "')"; + . $nagios_id["MAX(nagios_id)"] . "', '" . $valBk["broker_module"] . "')"; } $DBRESULT = $pearDB->query($rqBk); } @@ -205,7 +205,7 @@ function insertNagios($ret = array(), $brokerTab = array()) if (!count($ret)) { $ret = $form->getSubmitValues(); } - + $rq = "INSERT INTO cfg_nagios (" . "`nagios_id` , `nagios_name` , `use_timezone`, `nagios_server_id`, `log_file` , `cfg_dir` , " . "`temp_file` , " @@ -257,262 +257,266 @@ function insertNagios($ret = array(), $brokerTab = array()) $rq .= "VALUES ("; $rq .= "NULL, "; isset($ret["nagios_name"]) && $ret["nagios_name"] != null ? - $rq .= "'".htmlentities($ret["nagios_name"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["nagios_name"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["use_timezone"]) && $ret["use_timezone"] != null ? - $rq .= "'".htmlentities($ret["use_timezone"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["use_timezone"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["nagios_server_id"]) && $ret["nagios_server_id"] != null ? - $rq .= "'".htmlentities($ret["nagios_server_id"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["nagios_server_id"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["log_file"]) && $ret["log_file"] != null ? - $rq .= "'".htmlentities($ret["log_file"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["log_file"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["cfg_dir"]) && $ret["cfg_dir"] != null ? - $rq .= "'".htmlentities($ret["cfg_dir"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["cfg_dir"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["temp_file"]) && $ret["temp_file"] != null ? - $rq .= "'".htmlentities($ret["temp_file"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["temp_file"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["check_result_path"]) && $ret["check_result_path"] != null ? - $rq .= "'".htmlentities($ret["check_result_path"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["check_result_path"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["max_check_result_file_age"]) && $ret["max_check_result_file_age"] != null ? - $rq .= "'".htmlentities($ret["max_check_result_file_age"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["max_check_result_file_age"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["status_file"]) && $ret["status_file"] != null ? - $rq .= "'".htmlentities($ret["status_file"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["status_file"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["status_update_interval"]) && $ret["status_update_interval"] != null ? - $rq .= "'".(int)$ret["status_update_interval"]."', " : $rq .= "NULL, "; + $rq .= "'" . (int)$ret["status_update_interval"] . "', " : $rq .= "NULL, "; isset($ret["nagios_user"]) && $ret["nagios_user"] != null ? - $rq .= "'".htmlentities($ret["nagios_user"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["nagios_user"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["nagios_group"]) && $ret["nagios_group"] != null ? - $rq .= "'".htmlentities($ret["nagios_group"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["nagios_group"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["enable_notifications"]["enable_notifications"]) - && $ret["enable_notifications"]["enable_notifications"] != 2 ? - $rq .= "'".$ret["enable_notifications"]["enable_notifications"]."', " : $rq .= "'2', "; + && $ret["enable_notifications"]["enable_notifications"] != 2 ? + $rq .= "'" . $ret["enable_notifications"]["enable_notifications"] . "', " : $rq .= "'2', "; isset($ret["execute_service_checks"]["execute_service_checks"]) - && $ret["execute_service_checks"]["execute_service_checks"] != 2 ? - $rq .= "'".$ret["execute_service_checks"]["execute_service_checks"]."', " : $rq .= "'2', "; + && $ret["execute_service_checks"]["execute_service_checks"] != 2 ? + $rq .= "'" . $ret["execute_service_checks"]["execute_service_checks"] . "', " : $rq .= "'2', "; isset($ret["accept_passive_service_checks"]["accept_passive_service_checks"]) - && $ret["accept_passive_service_checks"]["accept_passive_service_checks"] != 2 ? - $rq .= "'".$ret["accept_passive_service_checks"]["accept_passive_service_checks"]."', " : $rq .= "'2', "; + && $ret["accept_passive_service_checks"]["accept_passive_service_checks"] != 2 ? + $rq .= "'" . $ret["accept_passive_service_checks"]["accept_passive_service_checks"] . "', " : $rq .= "'2', "; isset($ret["execute_host_checks"]["execute_host_checks"]) - && $ret["execute_host_checks"]["execute_host_checks"] != 2 ? - $rq .= "'".$ret["execute_host_checks"]["execute_host_checks"]."', " : $rq .= "'2', "; + && $ret["execute_host_checks"]["execute_host_checks"] != 2 ? + $rq .= "'" . $ret["execute_host_checks"]["execute_host_checks"] . "', " : $rq .= "'2', "; isset($ret["accept_passive_host_checks"]["accept_passive_host_checks"]) - && $ret["accept_passive_host_checks"]["accept_passive_host_checks"] != 2 ? - $rq .= "'".$ret["accept_passive_host_checks"]["accept_passive_host_checks"]."', " : $rq .= "'2', "; + && $ret["accept_passive_host_checks"]["accept_passive_host_checks"] != 2 ? + $rq .= "'" . $ret["accept_passive_host_checks"]["accept_passive_host_checks"] . "', " : $rq .= "'2', "; isset($ret["enable_event_handlers"]["enable_event_handlers"]) - && $ret["enable_event_handlers"]["enable_event_handlers"] != 2 ? - $rq .= "'".$ret["enable_event_handlers"]["enable_event_handlers"]."', " : $rq .= "'2', "; + && $ret["enable_event_handlers"]["enable_event_handlers"] != 2 ? + $rq .= "'" . $ret["enable_event_handlers"]["enable_event_handlers"] . "', " : $rq .= "'2', "; isset($ret["log_rotation_method"]["log_rotation_method"]) - && $ret["log_rotation_method"]["log_rotation_method"] != 2 ? - $rq .= "'".$ret["log_rotation_method"]["log_rotation_method"]."', " : $rq .= "'2', "; + && $ret["log_rotation_method"]["log_rotation_method"] != 2 ? + $rq .= "'" . $ret["log_rotation_method"]["log_rotation_method"] . "', " : $rq .= "'2', "; isset($ret["log_archive_path"]) && $ret["log_archive_path"] != null ? - $rq .= "'".htmlentities($ret["log_archive_path"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["log_archive_path"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["check_external_commands"]["check_external_commands"]) - && $ret["check_external_commands"]["check_external_commands"] != 2 ? - $rq .= "'".$ret["check_external_commands"]["check_external_commands"]."', " : $rq .= "'2', "; + && $ret["check_external_commands"]["check_external_commands"] != 2 ? + $rq .= "'" . $ret["check_external_commands"]["check_external_commands"] . "', " : $rq .= "'2', "; isset($ret["command_check_interval"]) && $ret["command_check_interval"] != null ? - $rq .= "'".htmlentities($ret["command_check_interval"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["command_check_interval"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["command_file"]) && $ret["command_file"] != null ? - $rq .= "'".htmlentities($ret["command_file"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["command_file"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["downtime_file"]) && $ret["downtime_file"] != null ? - $rq .= "'".htmlentities($ret["downtime_file"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["downtime_file"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["comment_file"]) && $ret["comment_file"] != null ? - $rq .= "'".htmlentities($ret["comment_file"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["comment_file"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["lock_file"]) && $ret["lock_file"] != null ? - $rq .= "'".htmlentities($ret["lock_file"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["lock_file"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["retain_state_information"]["retain_state_information"]) - && $ret["retain_state_information"]["retain_state_information"] != 2 ? - $rq .= "'".$ret["retain_state_information"]["retain_state_information"]."', " : $rq .= "'2', "; + && $ret["retain_state_information"]["retain_state_information"] != 2 ? + $rq .= "'" . $ret["retain_state_information"]["retain_state_information"] . "', " : $rq .= "'2', "; isset($ret["state_retention_file"]) && $ret["state_retention_file"] != null ? - $rq .= "'".htmlentities($ret["state_retention_file"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["state_retention_file"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["retention_update_interval"]) && $ret["retention_update_interval"] != null ? - $rq .= "'".htmlentities($ret["retention_update_interval"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["retention_update_interval"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["use_retained_program_state"]["use_retained_program_state"]) - && $ret["use_retained_program_state"]["use_retained_program_state"] != 2 ? - $rq .= "'".$ret["use_retained_program_state"]["use_retained_program_state"]."', " : $rq .= "'2', "; + && $ret["use_retained_program_state"]["use_retained_program_state"] != 2 ? + $rq .= "'" . $ret["use_retained_program_state"]["use_retained_program_state"] . "', " : $rq .= "'2', "; isset($ret["use_retained_scheduling_info"]["use_retained_scheduling_info"]) - && $ret["use_retained_scheduling_info"]["use_retained_scheduling_info"] != 2 ? - $rq .= "'".$ret["use_retained_scheduling_info"]["use_retained_scheduling_info"]."', " : $rq .= "'2', "; + && $ret["use_retained_scheduling_info"]["use_retained_scheduling_info"] != 2 ? + $rq .= "'" . $ret["use_retained_scheduling_info"]["use_retained_scheduling_info"] . "', " : $rq .= "'2', "; isset($ret["retained_contact_host_attribute_mask"]) && $ret["retained_contact_host_attribute_mask"] != null ? - $rq .= "'".htmlentities($ret["retained_contact_host_attribute_mask"], ENT_QUOTES, "UTF-8")."', " + $rq .= "'" . htmlentities($ret["retained_contact_host_attribute_mask"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["retained_contact_service_attribute_mask"]) && $ret["retained_contact_service_attribute_mask"] != null ? - $rq .= "'".htmlentities($ret["retained_contact_service_attribute_mask"], ENT_QUOTES, "UTF-8")."', " + $rq .= "'" . htmlentities($ret["retained_contact_service_attribute_mask"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["retained_process_host_attribute_mask"]) && $ret["retained_process_host_attribute_mask"] != null ? - $rq .= "'".htmlentities($ret["retained_process_host_attribute_mask"], ENT_QUOTES, "UTF-8")."', " + $rq .= "'" . htmlentities($ret["retained_process_host_attribute_mask"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["retained_process_service_attribute_mask"]) && $ret["retained_process_service_attribute_mask"] != null ? - $rq .= "'".htmlentities($ret["retained_process_service_attribute_mask"], ENT_QUOTES, "UTF-8")."', " + $rq .= "'" . htmlentities($ret["retained_process_service_attribute_mask"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["retained_host_attribute_mask"]) && $ret["retained_host_attribute_mask"] != null ? - $rq .= "'".htmlentities($ret["retained_host_attribute_mask"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["retained_host_attribute_mask"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["retained_service_attribute_mask"]) && $ret["retained_service_attribute_mask"] != null ? - $rq .= "'".htmlentities($ret["retained_service_attribute_mask"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["retained_service_attribute_mask"], ENT_QUOTES, + "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["use_syslog"]["use_syslog"]) && $ret["use_syslog"]["use_syslog"] != 2 ? - $rq .= "'".$ret["use_syslog"]["use_syslog"]."', " : $rq .= "'2', "; + $rq .= "'" . $ret["use_syslog"]["use_syslog"] . "', " : $rq .= "'2', "; isset($ret["log_notifications"]["log_notifications"]) && $ret["log_notifications"]["log_notifications"] != 2 ? - $rq .= "'".$ret["log_notifications"]["log_notifications"]."', " : $rq .= "'2', "; + $rq .= "'" . $ret["log_notifications"]["log_notifications"] . "', " : $rq .= "'2', "; isset($ret["log_service_retries"]["log_service_retries"]) - && $ret["log_service_retries"]["log_service_retries"] != 2 ? - $rq .= "'".$ret["log_service_retries"]["log_service_retries"]."', " : $rq .= "'2', "; + && $ret["log_service_retries"]["log_service_retries"] != 2 ? + $rq .= "'" . $ret["log_service_retries"]["log_service_retries"] . "', " : $rq .= "'2', "; isset($ret["log_host_retries"]["log_host_retries"]) - && $ret["log_host_retries"]["log_host_retries"] != 2 ? - $rq .= "'".$ret["log_host_retries"]["log_host_retries"]."', " : $rq .= "'2', "; + && $ret["log_host_retries"]["log_host_retries"] != 2 ? + $rq .= "'" . $ret["log_host_retries"]["log_host_retries"] . "', " : $rq .= "'2', "; isset($ret["log_event_handlers"]["log_event_handlers"]) - && $ret["log_event_handlers"]["log_event_handlers"] != 2 ? - $rq .= "'".$ret["log_event_handlers"]["log_event_handlers"]."', " : $rq .= "'2', "; + && $ret["log_event_handlers"]["log_event_handlers"] != 2 ? + $rq .= "'" . $ret["log_event_handlers"]["log_event_handlers"] . "', " : $rq .= "'2', "; isset($ret["log_external_commands"]["log_external_commands"]) - && $ret["log_external_commands"]["log_external_commands"] != 2 ? - $rq .= "'".$ret["log_external_commands"]["log_external_commands"]."', " : $rq .= "'2', "; + && $ret["log_external_commands"]["log_external_commands"] != 2 ? + $rq .= "'" . $ret["log_external_commands"]["log_external_commands"] . "', " : $rq .= "'2', "; isset($ret["log_passive_checks"]["log_passive_checks"]) - && $ret["log_passive_checks"]["log_passive_checks"] != 2 ? - $rq .= "'".$ret["log_passive_checks"]["log_passive_checks"]."', " : $rq .= "'2', "; + && $ret["log_passive_checks"]["log_passive_checks"] != 2 ? + $rq .= "'" . $ret["log_passive_checks"]["log_passive_checks"] . "', " : $rq .= "'2', "; isset($ret["global_host_event_handler"]) && $ret["global_host_event_handler"] != null ? - $rq .= "'".$ret["global_host_event_handler"]."', " : $rq .= "NULL, "; + $rq .= "'" . $ret["global_host_event_handler"] . "', " : $rq .= "NULL, "; isset($ret["global_service_event_handler"]) && $ret["global_service_event_handler"] != null ? - $rq .= "'".$ret["global_service_event_handler"]."', " : $rq .= "NULL, "; + $rq .= "'" . $ret["global_service_event_handler"] . "', " : $rq .= "NULL, "; isset($ret["sleep_time"]) && $ret["sleep_time"] != null ? - $rq .= "'".htmlentities($ret["sleep_time"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["sleep_time"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["service_inter_check_delay_method"]) && $ret["service_inter_check_delay_method"] != null ? - $rq .= "'".$ret["service_inter_check_delay_method"]."', " : $rq .= "NULL, "; + $rq .= "'" . $ret["service_inter_check_delay_method"] . "', " : $rq .= "NULL, "; isset($ret["host_inter_check_delay_method"]) && $ret["host_inter_check_delay_method"] != null ? - $rq .= "'".$ret["host_inter_check_delay_method"]."', " : $rq .= "NULL, "; + $rq .= "'" . $ret["host_inter_check_delay_method"] . "', " : $rq .= "NULL, "; isset($ret["service_interleave_factor"]["service_interleave_factor"]) - && $ret["service_interleave_factor"]["service_interleave_factor"] != 2 ? - $rq .= "'".$ret["service_interleave_factor"]["service_interleave_factor"]."', " : $rq .= "'2', "; + && $ret["service_interleave_factor"]["service_interleave_factor"] != 2 ? + $rq .= "'" . $ret["service_interleave_factor"]["service_interleave_factor"] . "', " : $rq .= "'2', "; isset($ret["max_concurrent_checks"]) && $ret["max_concurrent_checks"] != null ? - $rq .= "'".htmlentities($ret["max_concurrent_checks"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["max_concurrent_checks"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["max_service_check_spread"]) && $ret["max_service_check_spread"] != null ? - $rq .= "'".htmlentities($ret["max_service_check_spread"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["max_service_check_spread"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["max_host_check_spread"]) && $ret["max_host_check_spread"] != null ? - $rq .= "'".htmlentities($ret["max_host_check_spread"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; - isset($ret["check_result_reaper_frequency"]) && $ret["check_result_reaper_frequency"] != null ? - $rq .= "'".htmlentities($ret["check_result_reaper_frequency"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["max_host_check_spread"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; + isset($ret["check_result_reaper_frequency"]) && $ret["check_result_reaper_frequency"] != null + ? $rq .= "'" . htmlentities($ret["check_result_reaper_frequency"], ENT_QUOTES,"UTF-8") . "', " + : $rq .= "NULL, "; isset($ret["max_check_result_reaper_time"]) && $ret["max_check_result_reaper_time"] != null ? - $rq .= "'".htmlentities($ret["max_check_result_reaper_time"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["max_check_result_reaper_time"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["auto_reschedule_checks"]["auto_reschedule_checks"]) - && $ret["auto_reschedule_checks"]["auto_reschedule_checks"] != 2 ? - $rq .= "'".$ret["auto_reschedule_checks"]["auto_reschedule_checks"]."', " : $rq .= "'2', "; + && $ret["auto_reschedule_checks"]["auto_reschedule_checks"] != 2 ? + $rq .= "'" . $ret["auto_reschedule_checks"]["auto_reschedule_checks"] . "', " : $rq .= "'2', "; isset($ret["auto_rescheduling_interval"]) && $ret["auto_rescheduling_interval"] != null ? - $rq .= "'".htmlentities($ret["auto_rescheduling_interval"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["auto_rescheduling_interval"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["auto_rescheduling_window"]) && $ret["auto_rescheduling_window"] != null ? - $rq .= "'".htmlentities($ret["auto_rescheduling_window"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["auto_rescheduling_window"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["use_aggressive_host_checking"]["use_aggressive_host_checking"]) - && $ret["use_aggressive_host_checking"]["use_aggressive_host_checking"] != 0 ? - $rq .= "'".$ret["use_aggressive_host_checking"]["use_aggressive_host_checking"]."', " : $rq .= "'0', "; + && $ret["use_aggressive_host_checking"]["use_aggressive_host_checking"] != 0 ? + $rq .= "'" . $ret["use_aggressive_host_checking"]["use_aggressive_host_checking"] . "', " : $rq .= "'0', "; isset($ret["enable_predictive_host_dependency_checks"]["enable_predictive_host_dependency_checks"]) - && $ret["enable_predictive_host_dependency_checks"]["enable_predictive_host_dependency_checks"] != 2 ? - $rq .= "'".$ret["enable_predictive_host_dependency_checks"]["enable_predictive_host_dependency_checks"]."', " + && $ret["enable_predictive_host_dependency_checks"]["enable_predictive_host_dependency_checks"] != 2 ? + $rq .= "'" . + $ret["enable_predictive_host_dependency_checks"]["enable_predictive_host_dependency_checks"] . "', " : $rq .= "'2', "; isset($ret["enable_flap_detection"]["enable_flap_detection"]) - && $ret["enable_flap_detection"]["enable_flap_detection"] != 2 ? - $rq .= "'".$ret["enable_flap_detection"]["enable_flap_detection"]."', " : $rq .= "'2', "; + && $ret["enable_flap_detection"]["enable_flap_detection"] != 2 ? + $rq .= "'" . $ret["enable_flap_detection"]["enable_flap_detection"] . "', " : $rq .= "'2', "; isset($ret["low_service_flap_threshold"]) && $ret["low_service_flap_threshold"] != null ? - $rq .= "'".htmlentities($ret["low_service_flap_threshold"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["low_service_flap_threshold"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["high_service_flap_threshold"]) && $ret["high_service_flap_threshold"] != null ? - $rq .= "'".htmlentities($ret["high_service_flap_threshold"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["high_service_flap_threshold"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["low_host_flap_threshold"]) && $ret["low_host_flap_threshold"] != null ? - $rq .= "'".htmlentities($ret["low_host_flap_threshold"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["low_host_flap_threshold"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["high_host_flap_threshold"]) && $ret["high_host_flap_threshold"] != null ? - $rq .= "'".htmlentities($ret["high_host_flap_threshold"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["high_host_flap_threshold"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["soft_state_dependencies"]["soft_state_dependencies"]) - && $ret["soft_state_dependencies"]["soft_state_dependencies"] != 2 ? - $rq .= "'".$ret["soft_state_dependencies"]["soft_state_dependencies"]."', " : $rq .= "'2', "; + && $ret["soft_state_dependencies"]["soft_state_dependencies"] != 2 ? + $rq .= "'" . $ret["soft_state_dependencies"]["soft_state_dependencies"] . "', " : $rq .= "'2', "; isset($ret["enable_predictive_service_dependency_checks"]["enable_predictive_service_dependency_checks"]) - && $ret["enable_predictive_service_dependency_checks"]["enable_predictive_service_dependency_checks"] != 2 ? - $rq .= "'".$ret["enable_predictive_service_dependency_checks"]["enable_predictive_service_dependency_checks"] - ."', " + && $ret["enable_predictive_service_dependency_checks"]["enable_predictive_service_dependency_checks"] != 2 ? + $rq .= "'" . $ret["enable_predictive_service_dependency_checks"]["enable_predictive_service_dependency_checks"] + . "', " : $rq .= "'2', "; isset($ret["service_check_timeout"]) && $ret["service_check_timeout"] != null ? - $rq .= "'".htmlentities($ret["service_check_timeout"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["service_check_timeout"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["host_check_timeout"]) && $ret["host_check_timeout"] != null ? - $rq .= "'".htmlentities($ret["host_check_timeout"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["host_check_timeout"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["event_handler_timeout"]) && $ret["event_handler_timeout"] != null ? - $rq .= "'".htmlentities($ret["event_handler_timeout"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["event_handler_timeout"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["notification_timeout"]) && $ret["notification_timeout"] != null ? - $rq .= "'".htmlentities($ret["notification_timeout"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["notification_timeout"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["ocsp_timeout"]) && $ret["ocsp_timeout"] != null ? - $rq .= "'".htmlentities($ret["ocsp_timeout"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["ocsp_timeout"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["ochp_timeout"]) && $ret["ochp_timeout"] != null ? - $rq .= "'".htmlentities($ret["ochp_timeout"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["ochp_timeout"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["perfdata_timeout"]) && $ret["perfdata_timeout"] != null ? - $rq .= "'".htmlentities($ret["perfdata_timeout"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["perfdata_timeout"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["obsess_over_services"]["obsess_over_services"]) - && $ret["obsess_over_services"]["obsess_over_services"] != 2 ? - $rq .= "'".$ret["obsess_over_services"]["obsess_over_services"]."', " : $rq .= "'2', "; + && $ret["obsess_over_services"]["obsess_over_services"] != 2 ? + $rq .= "'" . $ret["obsess_over_services"]["obsess_over_services"] . "', " : $rq .= "'2', "; isset($ret["ocsp_command"]) && $ret["ocsp_command"] != null ? - $rq .= "'".htmlentities($ret["ocsp_command"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["ocsp_command"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["obsess_over_hosts"]["obsess_over_hosts"]) - && $ret["obsess_over_hosts"]["obsess_over_hosts"] != 2 ? - $rq .= "'".$ret["obsess_over_hosts"]["obsess_over_hosts"]."', " : $rq .= "'2', "; + && $ret["obsess_over_hosts"]["obsess_over_hosts"] != 2 ? + $rq .= "'" . $ret["obsess_over_hosts"]["obsess_over_hosts"] . "', " : $rq .= "'2', "; isset($ret["ochp_command"]) && $ret["ochp_command"] != null ? - $rq .= "'".htmlentities($ret["ochp_command"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["ochp_command"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["process_performance_data"]["process_performance_data"]) - && $ret["process_performance_data"]["process_performance_data"] != 2 ? - $rq .= "'".$ret["process_performance_data"]["process_performance_data"]."', " : $rq .= "'2', "; + && $ret["process_performance_data"]["process_performance_data"] != 2 ? + $rq .= "'" . $ret["process_performance_data"]["process_performance_data"] . "', " : $rq .= "'2', "; isset($ret["host_perfdata_command"]) && $ret["host_perfdata_command"] != null ? - $rq .= "'".htmlentities($ret["host_perfdata_command"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["host_perfdata_command"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["service_perfdata_command"]) && $ret["service_perfdata_command"] != null ? - $rq .= "'".htmlentities($ret["service_perfdata_command"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["service_perfdata_command"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["host_perfdata_file"]) && $ret["host_perfdata_file"] != null ? - $rq .= "'".htmlentities($ret["host_perfdata_file"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["host_perfdata_file"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["service_perfdata_file"]) && $ret["service_perfdata_file"] != null ? - $rq .= "'".htmlentities($ret["service_perfdata_file"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["service_perfdata_file"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["host_perfdata_file_template"]) && $ret["host_perfdata_file_template"] != null ? - $rq .= "'" . PDO::quote($ret["host_perfdata_file_template"]) . "', " : $rq .= "NULL, "; + $rq .= "'" . $pearDB->quote($ret["host_perfdata_file_template"]) . "', " : $rq .= "NULL, "; isset($ret["service_perfdata_file_template"]) && $ret["service_perfdata_file_template"] != null ? - $rq .= "'" . PDO::quote($ret["service_perfdata_file_template"]) . "', " : $rq .= "NULL, "; + $rq .= "'" . $pearDB->quote($ret["service_perfdata_file_template"]) . "', " : $rq .= "NULL, "; isset($ret["host_perfdata_file_mode"]["host_perfdata_file_mode"]) && $ret["host_perfdata_file_mode"]["host_perfdata_file_mode"] != null ? - $rq .= "'".$ret["host_perfdata_file_mode"]["host_perfdata_file_mode"]."', " : $rq .= "NULL, "; + $rq .= "'" . $ret["host_perfdata_file_mode"]["host_perfdata_file_mode"] . "', " : $rq .= "NULL, "; isset($ret["service_perfdata_file_mode"]["service_perfdata_file_mode"]) - && $ret["service_perfdata_file_mode"]["service_perfdata_file_mode"] != null ? - $rq .= "'".$ret["service_perfdata_file_mode"]["service_perfdata_file_mode"]."', " : $rq .= "NULL, "; + && $ret["service_perfdata_file_mode"]["service_perfdata_file_mode"] != null ? + $rq .= "'" . $ret["service_perfdata_file_mode"]["service_perfdata_file_mode"] . "', " : $rq .= "NULL, "; isset($ret["host_perfdata_file_processing_interval"]) - && $ret["host_perfdata_file_processing_interval"] != null ? - $rq .= "'".htmlentities($ret["host_perfdata_file_processing_interval"], ENT_QUOTES, "UTF-8")."', " + && $ret["host_perfdata_file_processing_interval"] != null ? + $rq .= "'" . htmlentities($ret["host_perfdata_file_processing_interval"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["service_perfdata_file_processing_interval"]) - && $ret["service_perfdata_file_processing_interval"] != null ? - $rq .= "'".htmlentities($ret["service_perfdata_file_processing_interval"], ENT_QUOTES, "UTF-8")."', " + && $ret["service_perfdata_file_processing_interval"] != null ? + $rq .= "'" . htmlentities($ret["service_perfdata_file_processing_interval"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["host_perfdata_file_processing_command"]) - && $ret["host_perfdata_file_processing_command"] != null ? - $rq .= "'".htmlentities($ret["host_perfdata_file_processing_command"])."', " : $rq .= "NULL, "; + && $ret["host_perfdata_file_processing_command"] != null ? + $rq .= "'" . htmlentities($ret["host_perfdata_file_processing_command"]) . "', " : $rq .= "NULL, "; isset($ret["service_perfdata_file_processing_command"]) - && $ret["service_perfdata_file_processing_command"] != null ? - $rq .= "'".htmlentities($ret["service_perfdata_file_processing_command"], ENT_QUOTES, "UTF-8")."', " + && $ret["service_perfdata_file_processing_command"] != null ? + $rq .= "'" . htmlentities($ret["service_perfdata_file_processing_command"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["check_for_orphaned_services"]["check_for_orphaned_services"]) - && $ret["check_for_orphaned_services"]["check_for_orphaned_services"] != 2 ? - $rq .= "'".$ret["check_for_orphaned_services"]["check_for_orphaned_services"]."', " : $rq .= "'2', "; + && $ret["check_for_orphaned_services"]["check_for_orphaned_services"] != 2 ? + $rq .= "'" . $ret["check_for_orphaned_services"]["check_for_orphaned_services"] . "', " : $rq .= "'2', "; isset($ret["check_service_freshness"]["check_service_freshness"]) - && $ret["check_service_freshness"]["check_service_freshness"] != 2 ? - $rq .= "'".$ret["check_service_freshness"]["check_service_freshness"]."', " : $rq .= "'2', "; + && $ret["check_service_freshness"]["check_service_freshness"] != 2 ? + $rq .= "'" . $ret["check_service_freshness"]["check_service_freshness"] . "', " : $rq .= "'2', "; isset($ret["service_freshness_check_interval"]) && $ret["service_freshness_check_interval"] != null ? - $rq .= "'".htmlentities($ret["service_freshness_check_interval"], ENT_QUOTES, "UTF-8")."', " + $rq .= "'" . htmlentities($ret["service_freshness_check_interval"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["cached_host_check_horizon"]) && $ret["cached_host_check_horizon"] != null ? - $rq .= "'".htmlentities($ret["cached_host_check_horizon"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["cached_host_check_horizon"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["cached_service_check_horizon"]) && $ret["cached_service_check_horizon"] != null ? - $rq .= "'".htmlentities($ret["cached_service_check_horizon"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["cached_service_check_horizon"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["additional_freshness_latency"]) && $ret["additional_freshness_latency"] != null ? - $rq .= "'".htmlentities($ret["additional_freshness_latency"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["additional_freshness_latency"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["check_host_freshness"]["check_host_freshness"]) - && $ret["check_host_freshness"]["check_host_freshness"] != 2 ? - $rq .= "'".$ret["check_host_freshness"]["check_host_freshness"]."', " : $rq .= "'2', "; + && $ret["check_host_freshness"]["check_host_freshness"] != 2 ? + $rq .= "'" . $ret["check_host_freshness"]["check_host_freshness"] . "', " : $rq .= "'2', "; isset($ret["host_freshness_check_interval"]) && $ret["host_freshness_check_interval"] != null ? - $rq .= "'".htmlentities($ret["host_freshness_check_interval"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["host_freshness_check_interval"], ENT_QUOTES, + "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["date_format"]) && $ret["date_format"] != null ? - $rq .= "'".htmlentities($ret["date_format"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["date_format"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["illegal_object_name_chars"]) && $ret["illegal_object_name_chars"] != null - ? $rq .= "'".$pearDB->quote($ret["illegal_object_name_chars"])."', " + ? $rq .= "'" . $pearDB->quote($ret["illegal_object_name_chars"]) . "', " : $rq .= "NULL, "; isset($ret["illegal_macro_output_chars"]) && $ret["illegal_macro_output_chars"] != null - ? $rq .= "'".$pearDB->quote($ret["illegal_macro_output_chars"])."', " + ? $rq .= "'" . $pearDB->quote($ret["illegal_macro_output_chars"]) . "', " : $rq .= "NULL, "; isset($ret["use_large_installation_tweaks"]["use_large_installation_tweaks"]) - && $ret["use_large_installation_tweaks"]["use_large_installation_tweaks"] != 2 ? - $rq .= "'".$ret["use_large_installation_tweaks"]["use_large_installation_tweaks"]."', " : $rq .= "'2', "; + && $ret["use_large_installation_tweaks"]["use_large_installation_tweaks"] != 2 ? + $rq .= "'" . $ret["use_large_installation_tweaks"]["use_large_installation_tweaks"] . "', " : $rq .= "'2', "; isset($ret["debug_file"]) && $ret["debug_file"] != null ? - $rq .= "'".htmlentities($ret["debug_file"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["debug_file"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; $level = 0; if (isset($ret["nagios_debug_level"]) && $ret["nagios_debug_level"] != null) { foreach ($ret["nagios_debug_level"] as $key => $value) { @@ -521,54 +525,54 @@ function insertNagios($ret = array(), $brokerTab = array()) } $rq .= "'.$level.', "; isset($ret["nagios_debug_level"]) && $ret["nagios_debug_level"] != null ? - $rq .= "'".implode(",", array_keys($ret["nagios_debug_level"]))."', " : $rq .= "'0', "; + $rq .= "'" . implode(",", array_keys($ret["nagios_debug_level"])) . "', " : $rq .= "'0', "; isset($ret["debug_verbosity"]["debug_verbosity"]) - && $ret["debug_verbosity"]["debug_verbosity"] != 2 ? - $rq .= "'".$ret["debug_verbosity"]["debug_verbosity"]."', " : $rq .= "'2', "; + && $ret["debug_verbosity"]["debug_verbosity"] != 2 ? + $rq .= "'" . $ret["debug_verbosity"]["debug_verbosity"] . "', " : $rq .= "'2', "; isset($ret["max_debug_file_size"]) && $ret["max_debug_file_size"] != null ? - $rq .= "'".htmlentities($ret["max_debug_file_size"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["max_debug_file_size"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["daemon_dumps_core"]["daemon_dumps_core"]) - && $ret["daemon_dumps_core"]["daemon_dumps_core"] ? + && $ret["daemon_dumps_core"]["daemon_dumps_core"] ? $rq .= "'1', " : $rq .= "'0', "; isset($ret["enable_environment_macros"]["enable_environment_macros"]) - && $ret["enable_environment_macros"]["enable_environment_macros"] != 2 ? - $rq .= "'".$ret["enable_environment_macros"]["enable_environment_macros"]."', " : $rq .= "'2', "; + && $ret["enable_environment_macros"]["enable_environment_macros"] != 2 ? + $rq .= "'" . $ret["enable_environment_macros"]["enable_environment_macros"] . "', " : $rq .= "'2', "; isset($ret["use_setpgid"]["use_setpgid"]) && $ret["use_setpgid"]["use_setpgid"] != 2 ? - $rq .= "'".$ret["use_setpgid"]["use_setpgid"]."', " : $rq .= "'2', "; + $rq .= "'" . $ret["use_setpgid"]["use_setpgid"] . "', " : $rq .= "'2', "; isset($ret["use_regexp_matching"]["use_regexp_matching"]) - && $ret["use_regexp_matching"]["use_regexp_matching"] != 2 ? - $rq .= "'".$ret["use_regexp_matching"]["use_regexp_matching"]."', " : $rq .= "'2', "; + && $ret["use_regexp_matching"]["use_regexp_matching"] != 2 ? + $rq .= "'" . $ret["use_regexp_matching"]["use_regexp_matching"] . "', " : $rq .= "'2', "; isset($ret["use_true_regexp_matching"]["use_true_regexp_matching"]) - && $ret["use_true_regexp_matching"]["use_true_regexp_matching"] != 2 ? - $rq .= "'".$ret["use_true_regexp_matching"]["use_true_regexp_matching"]."', " : $rq .= "'2', "; + && $ret["use_true_regexp_matching"]["use_true_regexp_matching"] != 2 ? + $rq .= "'" . $ret["use_true_regexp_matching"]["use_true_regexp_matching"] . "', " : $rq .= "'2', "; isset($ret["admin_email"]) && $ret["admin_email"] != null ? - $rq .= "'".htmlentities($ret["admin_email"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["admin_email"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["admin_pager"]) && $ret["admin_pager"] != null ? - $rq .= "'".htmlentities($ret["admin_pager"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["admin_pager"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["nagios_comment"]) && $ret["nagios_comment"] != null ? - $rq .= "'".htmlentities($ret["nagios_comment"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["nagios_comment"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["nagios_activate"]["nagios_activate"]) - && $ret["nagios_activate"]["nagios_activate"] != null ? - $rq .= "'".$ret["nagios_activate"]["nagios_activate"]."'," : $rq .= "'0',"; + && $ret["nagios_activate"]["nagios_activate"] != null ? + $rq .= "'" . $ret["nagios_activate"]["nagios_activate"] . "'," : $rq .= "'0',"; isset($ret["event_broker_options"]) && $ret["event_broker_options"] != null ? - $rq .= "'".htmlentities($ret["event_broker_options"], ENT_QUOTES, "UTF-8")."', " : $rq .= "'-1', "; + $rq .= "'" . htmlentities($ret["event_broker_options"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "'-1', "; isset($ret["translate_passive_host_checks"]["translate_passive_host_checks"]) - && $ret["translate_passive_host_checks"]["translate_passive_host_checks"] != 2 ? - $rq .= "'".$ret["translate_passive_host_checks"]["translate_passive_host_checks"]."', " : $rq .= "'2', "; + && $ret["translate_passive_host_checks"]["translate_passive_host_checks"] != 2 ? + $rq .= "'" . $ret["translate_passive_host_checks"]["translate_passive_host_checks"] . "', " : $rq .= "'2', "; isset($ret["passive_host_checks_are_soft"]["passive_host_checks_are_soft"]) - && $ret["passive_host_checks_are_soft"]["passive_host_checks_are_soft"] != 2 ? - $rq .= "'".$ret["passive_host_checks_are_soft"]["passive_host_checks_are_soft"]."', " : $rq .= "'2', "; + && $ret["passive_host_checks_are_soft"]["passive_host_checks_are_soft"] != 2 ? + $rq .= "'" . $ret["passive_host_checks_are_soft"]["passive_host_checks_are_soft"] . "', " : $rq .= "'2', "; isset($ret["check_for_orphaned_hosts"]["check_for_orphaned_hosts"]) - && $ret["check_for_orphaned_hosts"]["check_for_orphaned_hosts"] != 2 ? - $rq .= "'".$ret["check_for_orphaned_hosts"]["check_for_orphaned_hosts"]."', " : $rq .= "'2', "; + && $ret["check_for_orphaned_hosts"]["check_for_orphaned_hosts"] != 2 ? + $rq .= "'" . $ret["check_for_orphaned_hosts"]["check_for_orphaned_hosts"] . "', " : $rq .= "'2', "; isset($ret["external_command_buffer_slots"]["external_command_buffer_slots"]) - && $ret["external_command_buffer_slots"]["external_command_buffer_slots"] != 2 ? - $rq .= "'".$ret["external_command_buffer_slots"]["external_command_buffer_slots"]."', " : $rq .= "'2', "; + && $ret["external_command_buffer_slots"]["external_command_buffer_slots"] != 2 ? + $rq .= "'" . $ret["external_command_buffer_slots"]["external_command_buffer_slots"] . "', " : $rq .= "'2', "; isset($ret["cfg_file"]) && $ret["cfg_file"] != null ? - $rq .= "'".htmlentities($ret["cfg_file"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + $rq .= "'" . htmlentities($ret["cfg_file"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; isset($ret["log_pid"]["log_pid"]) && $ret["log_pid"]["log_pid"] ? $rq .= "'1', " : $rq .= "'0', "; isset($ret['use_check_result_path']['use_check_result_path']) - && $ret['use_check_result_path']['use_check_result_path'] ? + && $ret['use_check_result_path']['use_check_result_path'] ? $rq .= "'1')" : $rq .= "'0')"; $DBRESULT = $pearDB->query($rq); @@ -580,13 +584,13 @@ function insertNagios($ret = array(), $brokerTab = array()) $mainCfg = new CentreonConfigEngine($pearDB); $mainCfg->insertBrokerDirectives($nagios_id["MAX(nagios_id)"], $_REQUEST['in_broker']); } - + /* Manage the case where you have to main.cfg on the same poller */ if (isset($ret["nagios_activate"]["nagios_activate"]) && $ret["nagios_activate"]["nagios_activate"]) { $DBRESULT = $pearDB->query( "UPDATE cfg_nagios SET nagios_activate = '0' WHERE nagios_id != '" . $nagios_id["MAX(nagios_id)"] - . "' AND nagios_server_id = '".$ret['nagios_server_id']."'" + . "' AND nagios_server_id = '" . $ret['nagios_server_id'] . "'" ); $centreon->Nagioscfg = array(); $DBRESULT = $pearDB->query("SELECT * FROM `cfg_nagios` WHERE `nagios_activate` = '1' LIMIT 1"); @@ -616,424 +620,424 @@ function updateNagios($nagios_id = null) } if (isset($ret["nagios_server_id"])) { - $DBRESULT = $pearDB->query("UPDATE cfg_nagios SET `nagios_server_id` != '".$ret["nagios_server_id"]."'"); + $DBRESULT = $pearDB->query("UPDATE cfg_nagios SET `nagios_server_id` != '" . $ret["nagios_server_id"] . "'"); } $ret = array(); $ret = $form->getSubmitValues(); $rq = "UPDATE cfg_nagios SET "; isset($ret["nagios_name"]) && $ret["nagios_name"] != null ? - $rq .= "nagios_name = '".htmlentities($ret["nagios_name"], ENT_QUOTES, "UTF-8")."', " + $rq .= "nagios_name = '" . htmlentities($ret["nagios_name"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "nagios_name = NULL, "; isset($ret["nagios_server_id"]) && $ret["nagios_server_id"] != null ? - $rq .= "nagios_server_id = '".htmlentities($ret["nagios_server_id"], ENT_QUOTES, "UTF-8")."', " + $rq .= "nagios_server_id = '" . htmlentities($ret["nagios_server_id"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "nagios_server_id = NULL, "; isset($ret["use_timezone"]) && $ret["use_timezone"] != null ? - $rq .= "use_timezone = '".htmlentities($ret["use_timezone"], ENT_QUOTES, "UTF-8")."', " + $rq .= "use_timezone = '" . htmlentities($ret["use_timezone"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "use_timezone = NULL, "; isset($ret["log_file"]) && $ret["log_file"] != null ? - $rq .= "log_file = '".htmlentities($ret["log_file"], ENT_QUOTES, "UTF-8")."', " + $rq .= "log_file = '" . htmlentities($ret["log_file"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "log_file = NULL, "; isset($ret["cfg_dir"]) && $ret["cfg_dir"] != null ? - $rq .= "cfg_dir = '".htmlentities($ret["cfg_dir"], ENT_QUOTES, "UTF-8")."', " + $rq .= "cfg_dir = '" . htmlentities($ret["cfg_dir"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "cfg_dir = NULL, "; isset($ret["temp_file"]) && $ret["temp_file"] != null ? - $rq .= "temp_file = '".htmlentities($ret["temp_file"], ENT_QUOTES, "UTF-8")."', " + $rq .= "temp_file = '" . htmlentities($ret["temp_file"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "temp_file = NULL, "; isset($ret["check_result_path"]) && $ret["check_result_path"] != null ? - $rq .= "check_result_path = '".htmlentities($ret["check_result_path"], ENT_QUOTES, "UTF-8")."', " + $rq .= "check_result_path = '" . htmlentities($ret["check_result_path"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "check_result_path = NULL, "; isset($ret["max_check_result_file_age"]) && $ret["max_check_result_file_age"] != null ? $rq .= "max_check_result_file_age = '" - . htmlentities($ret["max_check_result_file_age"], ENT_QUOTES, "UTF-8")."', " + . htmlentities($ret["max_check_result_file_age"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "max_check_result_file_age = NULL, "; isset($ret["status_file"]) && $ret["status_file"] != null ? - $rq .= "status_file = '".htmlentities($ret["status_file"], ENT_QUOTES, "UTF-8")."', " + $rq .= "status_file = '" . htmlentities($ret["status_file"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "status_file = NULL, "; isset($ret["status_update_interval"]) && $ret["status_update_interval"] != null ? - $rq .= "status_update_interval = '".(int)$ret["status_update_interval"]."', " + $rq .= "status_update_interval = '" . (int)$ret["status_update_interval"] . "', " : $rq .= "status_update_interval = NULL, "; isset($ret["nagios_user"]) && $ret["nagios_user"] != null ? - $rq .= "nagios_user = '".htmlentities($ret["nagios_user"], ENT_QUOTES, "UTF-8")."', " + $rq .= "nagios_user = '" . htmlentities($ret["nagios_user"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "nagios_user = NULL, "; isset($ret["nagios_group"]) && $ret["nagios_group"] != null ? - $rq .= "nagios_group = '".htmlentities($ret["nagios_group"], ENT_QUOTES, "UTF-8")."', " + $rq .= "nagios_group = '" . htmlentities($ret["nagios_group"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "nagios_group = NULL, "; isset($ret["enable_notifications"]["enable_notifications"]) - && $ret["enable_notifications"]["enable_notifications"] != 2 ? + && $ret["enable_notifications"]["enable_notifications"] != 2 ? $rq .= "enable_notifications = '" - . $ret["enable_notifications"]["enable_notifications"]."', " + . $ret["enable_notifications"]["enable_notifications"] . "', " : $rq .= "enable_notifications = '2', "; isset($ret["execute_service_checks"]["execute_service_checks"]) - && $ret["execute_service_checks"]["execute_service_checks"] != 2 ? + && $ret["execute_service_checks"]["execute_service_checks"] != 2 ? $rq .= "execute_service_checks = '" - . $ret["execute_service_checks"]["execute_service_checks"]."', " + . $ret["execute_service_checks"]["execute_service_checks"] . "', " : $rq .= "execute_service_checks = '2', "; isset($ret["accept_passive_service_checks"]["accept_passive_service_checks"]) - && $ret["accept_passive_service_checks"]["accept_passive_service_checks"] != 2 ? + && $ret["accept_passive_service_checks"]["accept_passive_service_checks"] != 2 ? $rq .= "accept_passive_service_checks = '" - . $ret["accept_passive_service_checks"]["accept_passive_service_checks"]."', " + . $ret["accept_passive_service_checks"]["accept_passive_service_checks"] . "', " : $rq .= "accept_passive_service_checks = '2', "; isset($ret["execute_host_checks"]["execute_host_checks"]) - && $ret["execute_host_checks"]["execute_host_checks"] != 2 ? - $rq .= "execute_host_checks = '".$ret["execute_host_checks"]["execute_host_checks"]."', " + && $ret["execute_host_checks"]["execute_host_checks"] != 2 ? + $rq .= "execute_host_checks = '" . $ret["execute_host_checks"]["execute_host_checks"] . "', " : $rq .= "execute_host_checks = '2', "; isset($ret["accept_passive_host_checks"]["accept_passive_host_checks"]) - && $ret["accept_passive_host_checks"]["accept_passive_host_checks"] != 2 ? + && $ret["accept_passive_host_checks"]["accept_passive_host_checks"] != 2 ? $rq .= "accept_passive_host_checks = '" - . $ret["accept_passive_host_checks"]["accept_passive_host_checks"]."', " + . $ret["accept_passive_host_checks"]["accept_passive_host_checks"] . "', " : $rq .= "accept_passive_host_checks = '2', "; isset($ret["enable_event_handlers"]["enable_event_handlers"]) - && $ret["enable_event_handlers"]["enable_event_handlers"] != 2 ? + && $ret["enable_event_handlers"]["enable_event_handlers"] != 2 ? $rq .= "enable_event_handlers = '" - . $ret["enable_event_handlers"]["enable_event_handlers"]."', " + . $ret["enable_event_handlers"]["enable_event_handlers"] . "', " : $rq .= "enable_event_handlers = '2', "; isset($ret["log_rotation_method"]["log_rotation_method"]) - && $ret["log_rotation_method"]["log_rotation_method"] != 2 ? + && $ret["log_rotation_method"]["log_rotation_method"] != 2 ? $rq .= "log_rotation_method = '" - . $ret["log_rotation_method"]["log_rotation_method"]."', " + . $ret["log_rotation_method"]["log_rotation_method"] . "', " : $rq .= "log_rotation_method = '2', "; isset($ret["log_archive_path"]) && $ret["log_archive_path"] != null ? $rq .= "log_archive_path = '" - . htmlentities($ret["log_archive_path"], ENT_QUOTES, "UTF-8")."', " + . htmlentities($ret["log_archive_path"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "log_archive_path = NULL, "; isset($ret["check_external_commands"]["check_external_commands"]) - && $ret["check_external_commands"]["check_external_commands"] != 2 ? + && $ret["check_external_commands"]["check_external_commands"] != 2 ? $rq .= "check_external_commands = '" - . $ret["check_external_commands"]["check_external_commands"]."', " + . $ret["check_external_commands"]["check_external_commands"] . "', " : $rq .= "check_external_commands = '2', "; isset($ret["command_check_interval"]) && $ret["command_check_interval"] != null ? $rq .= "command_check_interval = '" - . htmlentities($ret["command_check_interval"], ENT_QUOTES, "UTF-8")."', " + . htmlentities($ret["command_check_interval"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "command_check_interval = NULL, "; isset($ret["command_file"]) && $ret["command_file"] != null ? - $rq .= "command_file = '".htmlentities($ret["command_file"], ENT_QUOTES, "UTF-8")."', " + $rq .= "command_file = '" . htmlentities($ret["command_file"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "command_file = NULL, "; isset($ret["downtime_file"]) && $ret["downtime_file"] != null ? - $rq .= "downtime_file = '".htmlentities($ret["downtime_file"], ENT_QUOTES, "UTF-8")."', " + $rq .= "downtime_file = '" . htmlentities($ret["downtime_file"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "downtime_file = NULL, "; isset($ret["comment_file"]) && $ret["comment_file"] != null ? - $rq .= "comment_file = '".htmlentities($ret["comment_file"], ENT_QUOTES, "UTF-8")."', " + $rq .= "comment_file = '" . htmlentities($ret["comment_file"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "comment_file = NULL, "; isset($ret["lock_file"]) && $ret["lock_file"] != null ? - $rq .= "lock_file = '".htmlentities($ret["lock_file"], ENT_QUOTES, "UTF-8")."', " + $rq .= "lock_file = '" . htmlentities($ret["lock_file"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "lock_file = NULL, "; isset($ret["retain_state_information"]["retain_state_information"]) - && $ret["retain_state_information"]["retain_state_information"] != 2 ? + && $ret["retain_state_information"]["retain_state_information"] != 2 ? $rq .= "retain_state_information = '" - . $ret["retain_state_information"]["retain_state_information"]."', " + . $ret["retain_state_information"]["retain_state_information"] . "', " : $rq .= "retain_state_information = '2', "; isset($ret["state_retention_file"]) && $ret["state_retention_file"] != null ? $rq .= "state_retention_file = '" - . htmlentities($ret["state_retention_file"], ENT_QUOTES, "UTF-8")."', " + . htmlentities($ret["state_retention_file"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "state_retention_file = NULL, "; isset($ret["retention_update_interval"]) && $ret["retention_update_interval"] != null ? $rq .= "retention_update_interval = '" - . htmlentities($ret["retention_update_interval"], ENT_QUOTES, "UTF-8")."', " + . htmlentities($ret["retention_update_interval"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "retention_update_interval = NULL, "; isset($ret["use_retained_program_state"]["use_retained_program_state"]) - && $ret["use_retained_program_state"]["use_retained_program_state"] != 2 ? + && $ret["use_retained_program_state"]["use_retained_program_state"] != 2 ? $rq .= "use_retained_program_state = '" - . $ret["use_retained_program_state"]["use_retained_program_state"]."', " + . $ret["use_retained_program_state"]["use_retained_program_state"] . "', " : $rq .= "use_retained_program_state = '2', "; isset($ret["use_retained_scheduling_info"]["use_retained_scheduling_info"]) - && $ret["use_retained_scheduling_info"]["use_retained_scheduling_info"] != 2 ? + && $ret["use_retained_scheduling_info"]["use_retained_scheduling_info"] != 2 ? $rq .= "use_retained_scheduling_info = '" - . $ret["use_retained_scheduling_info"]["use_retained_scheduling_info"]."', " + . $ret["use_retained_scheduling_info"]["use_retained_scheduling_info"] . "', " : $rq .= "use_retained_scheduling_info = '2', "; isset($ret["retained_contact_host_attribute_mask"]) - && $ret["retained_contact_host_attribute_mask"] != null ? + && $ret["retained_contact_host_attribute_mask"] != null ? $rq .= "retained_contact_host_attribute_mask = '" - . htmlentities($ret["retained_contact_host_attribute_mask"], ENT_QUOTES, "UTF-8")."', " + . htmlentities($ret["retained_contact_host_attribute_mask"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "retained_contact_host_attribute_mask = NULL, "; isset($ret["retained_contact_service_attribute_mask"]) - && $ret["retained_contact_service_attribute_mask"] != null ? + && $ret["retained_contact_service_attribute_mask"] != null ? $rq .= "retained_contact_service_attribute_mask = '" - . htmlentities($ret["retained_contact_service_attribute_mask"], ENT_QUOTES, "UTF-8")."', " + . htmlentities($ret["retained_contact_service_attribute_mask"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "retained_contact_service_attribute_mask = NULL, "; isset($ret["retained_process_host_attribute_mask"]) - && $ret["retained_process_host_attribute_mask"] != null ? + && $ret["retained_process_host_attribute_mask"] != null ? $rq .= "retained_process_host_attribute_mask = '" - . htmlentities($ret["retained_process_host_attribute_mask"], ENT_QUOTES, "UTF-8")."', " + . htmlentities($ret["retained_process_host_attribute_mask"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "retained_process_host_attribute_mask = NULL, "; isset($ret["retained_process_service_attribute_mask"]) - && $ret["retained_process_service_attribute_mask"] != null ? + && $ret["retained_process_service_attribute_mask"] != null ? $rq .= "retained_process_service_attribute_mask = '" - . htmlentities($ret["retained_process_service_attribute_mask"], ENT_QUOTES, "UTF-8")."', " + . htmlentities($ret["retained_process_service_attribute_mask"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "retained_process_service_attribute_mask = NULL, "; isset($ret["retained_host_attribute_mask"]) && $ret["retained_host_attribute_mask"] != null ? $rq .= "retained_host_attribute_mask = '" - . htmlentities($ret["retained_host_attribute_mask"], ENT_QUOTES, "UTF-8")."', " + . htmlentities($ret["retained_host_attribute_mask"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "retained_host_attribute_mask = NULL, "; isset($ret["retained_service_attribute_mask"]) - && $ret["retained_service_attribute_mask"] != null ? + && $ret["retained_service_attribute_mask"] != null ? $rq .= "retained_service_attribute_mask = '" - . htmlentities($ret["retained_service_attribute_mask"], ENT_QUOTES, "UTF-8")."', " + . htmlentities($ret["retained_service_attribute_mask"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "retained_service_attribute_mask = NULL, "; isset($ret["use_syslog"]["use_syslog"]) && $ret["use_syslog"]["use_syslog"] != 2 ? - $rq .= "use_syslog = '".$ret["use_syslog"]["use_syslog"]."', " + $rq .= "use_syslog = '" . $ret["use_syslog"]["use_syslog"] . "', " : $rq .= "use_syslog = '2', "; isset($ret["log_notifications"]["log_notifications"]) - && $ret["log_notifications"]["log_notifications"] != 2 ? - $rq .= "log_notifications = '".$ret["log_notifications"]["log_notifications"]."', " + && $ret["log_notifications"]["log_notifications"] != 2 ? + $rq .= "log_notifications = '" . $ret["log_notifications"]["log_notifications"] . "', " : $rq .= "log_notifications = '2', "; isset($ret["log_service_retries"]["log_service_retries"]) - && $ret["log_service_retries"]["log_service_retries"] != 2 ? + && $ret["log_service_retries"]["log_service_retries"] != 2 ? $rq .= "log_service_retries = '" - . $ret["log_service_retries"]["log_service_retries"]."', " + . $ret["log_service_retries"]["log_service_retries"] . "', " : $rq .= "log_service_retries = '2', "; isset($ret["log_host_retries"]["log_host_retries"]) - && $ret["log_host_retries"]["log_host_retries"] != 2 ? - $rq .= "log_host_retries = '".$ret["log_host_retries"]["log_host_retries"]."', " + && $ret["log_host_retries"]["log_host_retries"] != 2 ? + $rq .= "log_host_retries = '" . $ret["log_host_retries"]["log_host_retries"] . "', " : $rq .= "log_host_retries = '2', "; isset($ret["log_event_handlers"]["log_event_handlers"]) - && $ret["log_event_handlers"]["log_event_handlers"] != 2 ? - $rq .= "log_event_handlers = '".$ret["log_event_handlers"]["log_event_handlers"]."', " + && $ret["log_event_handlers"]["log_event_handlers"] != 2 ? + $rq .= "log_event_handlers = '" . $ret["log_event_handlers"]["log_event_handlers"] . "', " : $rq .= "log_event_handlers = '2', "; isset($ret["log_external_commands"]["log_external_commands"]) - && $ret["log_external_commands"]["log_external_commands"] != 2 ? - $rq .= "log_external_commands = '".$ret["log_external_commands"]["log_external_commands"]."', " + && $ret["log_external_commands"]["log_external_commands"] != 2 ? + $rq .= "log_external_commands = '" . $ret["log_external_commands"]["log_external_commands"] . "', " : $rq .= "log_external_commands = '2', "; isset($ret["log_passive_checks"]["log_passive_checks"]) - && $ret["log_passive_checks"]["log_passive_checks"] != 2 ? - $rq .= "log_passive_checks = '".$ret["log_passive_checks"]["log_passive_checks"]."', " + && $ret["log_passive_checks"]["log_passive_checks"] != 2 ? + $rq .= "log_passive_checks = '" . $ret["log_passive_checks"]["log_passive_checks"] . "', " : $rq .= "log_passive_checks = '2', "; isset($ret["global_host_event_handler"]) && $ret["global_host_event_handler"] != null ? - $rq .= "global_host_event_handler = '".$ret["global_host_event_handler"]."', " + $rq .= "global_host_event_handler = '" . $ret["global_host_event_handler"] . "', " : $rq .= "global_host_event_handler = NULL, "; isset($ret["global_service_event_handler"]) && $ret["global_service_event_handler"] != null ? - $rq .= "global_service_event_handler = '".$ret["global_service_event_handler"]."', " + $rq .= "global_service_event_handler = '" . $ret["global_service_event_handler"] . "', " : $rq .= "global_service_event_handler = NULL, "; isset($ret["sleep_time"]) && $ret["sleep_time"] != null ? - $rq .= "sleep_time = '".htmlentities($ret["sleep_time"], ENT_QUOTES, "UTF-8")."', " + $rq .= "sleep_time = '" . htmlentities($ret["sleep_time"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "sleep_time = NULL, "; isset($ret["service_inter_check_delay_method"]) - && $ret["service_inter_check_delay_method"] != null ? - $rq .= "service_inter_check_delay_method = '".$ret["service_inter_check_delay_method"]."', " + && $ret["service_inter_check_delay_method"] != null ? + $rq .= "service_inter_check_delay_method = '" . $ret["service_inter_check_delay_method"] . "', " : $rq .= "service_inter_check_delay_method = NULL, "; isset($ret["max_service_check_spread"]) && $ret["max_service_check_spread"] != null ? $rq .= "max_service_check_spread = '" - . htmlentities($ret["max_service_check_spread"], ENT_QUOTES, "UTF-8")."', " + . htmlentities($ret["max_service_check_spread"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "max_service_check_spread = NULL, "; isset($ret["service_interleave_factor"]["service_interleave_factor"]) - && $ret["service_interleave_factor"]["service_interleave_factor"] != 2 ? + && $ret["service_interleave_factor"]["service_interleave_factor"] != 2 ? $rq .= "service_interleave_factor = '" - . $ret["service_interleave_factor"]["service_interleave_factor"]."', " + . $ret["service_interleave_factor"]["service_interleave_factor"] . "', " : $rq .= "service_interleave_factor = '2', "; isset($ret["max_concurrent_checks"]) && $ret["max_concurrent_checks"] != null ? $rq .= "max_concurrent_checks = '" - . htmlentities($ret["max_concurrent_checks"], ENT_QUOTES, "UTF-8")."', " + . htmlentities($ret["max_concurrent_checks"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "max_concurrent_checks = NULL, "; isset($ret["check_result_reaper_frequency"]) && $ret["check_result_reaper_frequency"] != null ? $rq .= "check_result_reaper_frequency = '" - . htmlentities($ret["check_result_reaper_frequency"], ENT_QUOTES, "UTF-8")."', " + . htmlentities($ret["check_result_reaper_frequency"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "check_result_reaper_frequency = NULL, "; isset($ret["max_check_result_reaper_time"]) && $ret["max_check_result_reaper_time"] != null ? $rq .= "max_check_result_reaper_time = '" - . htmlentities($ret["max_check_result_reaper_time"], ENT_QUOTES, "UTF-8")."', " + . htmlentities($ret["max_check_result_reaper_time"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "max_check_result_reaper_time = NULL, "; isset($ret["host_inter_check_delay_method"]) && $ret["host_inter_check_delay_method"] != null ? - $rq .= "host_inter_check_delay_method = '" . $ret["host_inter_check_delay_method"]."', " + $rq .= "host_inter_check_delay_method = '" . $ret["host_inter_check_delay_method"] . "', " : $rq .= "host_inter_check_delay_method = NULL, "; isset($ret["max_host_check_spread"]) && $ret["max_host_check_spread"] != null ? $rq .= "max_host_check_spread = '" - . htmlentities($ret["max_host_check_spread"], ENT_QUOTES, "UTF-8")."', " + . htmlentities($ret["max_host_check_spread"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "max_host_check_spread = NULL, "; isset($ret["auto_reschedule_checks"]["auto_reschedule_checks"]) - && $ret["auto_reschedule_checks"]["auto_reschedule_checks"] != 2 ? - $rq .= "auto_reschedule_checks = '".$ret["auto_reschedule_checks"]["auto_reschedule_checks"]."', " + && $ret["auto_reschedule_checks"]["auto_reschedule_checks"] != 2 ? + $rq .= "auto_reschedule_checks = '" . $ret["auto_reschedule_checks"]["auto_reschedule_checks"] . "', " : $rq .= "auto_reschedule_checks = '2', "; isset($ret["auto_rescheduling_interval"]) && $ret["auto_rescheduling_interval"] != null ? $rq .= "auto_rescheduling_interval = '" - . htmlentities($ret["auto_rescheduling_interval"], ENT_QUOTES, "UTF-8")."', " + . htmlentities($ret["auto_rescheduling_interval"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "auto_rescheduling_interval = NULL, "; isset($ret["auto_rescheduling_window"]) && $ret["auto_rescheduling_window"] != null ? $rq .= "auto_rescheduling_window = '" - . htmlentities($ret["auto_rescheduling_window"], ENT_QUOTES, "UTF-8")."', " + . htmlentities($ret["auto_rescheduling_window"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "auto_rescheduling_window = NULL, "; isset($ret["use_aggressive_host_checking"]["use_aggressive_host_checking"]) - && $ret["use_aggressive_host_checking"]["use_aggressive_host_checking"] != 2 ? + && $ret["use_aggressive_host_checking"]["use_aggressive_host_checking"] != 2 ? $rq .= "use_aggressive_host_checking = '" - . $ret["use_aggressive_host_checking"]["use_aggressive_host_checking"]."', " + . $ret["use_aggressive_host_checking"]["use_aggressive_host_checking"] . "', " : $rq .= "use_aggressive_host_checking = '2', "; isset($ret["enable_predictive_host_dependency_checks"]["enable_predictive_host_dependency_checks"]) - && $ret["enable_predictive_host_dependency_checks"]["enable_predictive_host_dependency_checks"] != 2 ? + && $ret["enable_predictive_host_dependency_checks"]["enable_predictive_host_dependency_checks"] != 2 ? $rq .= "enable_predictive_host_dependency_checks = '" - . $ret["enable_predictive_host_dependency_checks"]["enable_predictive_host_dependency_checks"]."', " + . $ret["enable_predictive_host_dependency_checks"]["enable_predictive_host_dependency_checks"] . "', " : $rq .= "enable_predictive_host_dependency_checks = '2', "; isset($ret["enable_flap_detection"]["enable_flap_detection"]) - && $ret["enable_flap_detection"]["enable_flap_detection"] != 2 ? - $rq .= "enable_flap_detection = '".$ret["enable_flap_detection"]["enable_flap_detection"]."', " + && $ret["enable_flap_detection"]["enable_flap_detection"] != 2 ? + $rq .= "enable_flap_detection = '" . $ret["enable_flap_detection"]["enable_flap_detection"] . "', " : $rq .= "enable_flap_detection = '2', "; isset($ret["low_service_flap_threshold"]) && $ret["low_service_flap_threshold"] != null ? $rq .= "low_service_flap_threshold = '" - . htmlentities($ret["low_service_flap_threshold"], ENT_QUOTES, "UTF-8")."', " + . htmlentities($ret["low_service_flap_threshold"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "low_service_flap_threshold = NULL, "; isset($ret["high_service_flap_threshold"]) && $ret["high_service_flap_threshold"] != null ? $rq .= "high_service_flap_threshold = '" - . htmlentities($ret["high_service_flap_threshold"], ENT_QUOTES, "UTF-8")."', " + . htmlentities($ret["high_service_flap_threshold"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "high_service_flap_threshold = NULL, "; isset($ret["low_host_flap_threshold"]) && $ret["low_host_flap_threshold"] != null ? $rq .= "low_host_flap_threshold = '" - . htmlentities($ret["low_host_flap_threshold"], ENT_QUOTES, "UTF-8")."', " + . htmlentities($ret["low_host_flap_threshold"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "low_host_flap_threshold = NULL, "; isset($ret["high_host_flap_threshold"]) && $ret["high_host_flap_threshold"] != null ? $rq .= "high_host_flap_threshold = '" - . htmlentities($ret["high_host_flap_threshold"], ENT_QUOTES, "UTF-8")."', " + . htmlentities($ret["high_host_flap_threshold"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "high_host_flap_threshold = NULL, "; isset($ret["soft_state_dependencies"]["soft_state_dependencies"]) - && $ret["soft_state_dependencies"]["soft_state_dependencies"] != 2 ? - $rq .= "soft_state_dependencies = '".$ret["soft_state_dependencies"]["soft_state_dependencies"]."', " + && $ret["soft_state_dependencies"]["soft_state_dependencies"] != 2 ? + $rq .= "soft_state_dependencies = '" . $ret["soft_state_dependencies"]["soft_state_dependencies"] . "', " : $rq .= "soft_state_dependencies = '2', "; isset($ret["enable_predictive_service_dependency_checks"]["enable_predictive_service_dependency_checks"]) - && $ret["enable_predictive_service_dependency_checks"]["enable_predictive_service_dependency_checks"] != 2 ? + && $ret["enable_predictive_service_dependency_checks"]["enable_predictive_service_dependency_checks"] != 2 ? $rq .= "enable_predictive_service_dependency_checks = '" - . $ret["enable_predictive_service_dependency_checks"]["enable_predictive_service_dependency_checks"]."', " + . $ret["enable_predictive_service_dependency_checks"]["enable_predictive_service_dependency_checks"] . "', " : $rq .= "enable_predictive_service_dependency_checks = '2', "; isset($ret["service_check_timeout"]) && $ret["service_check_timeout"] != null ? $rq .= "service_check_timeout = '" - . htmlentities($ret["service_check_timeout"], ENT_QUOTES, "UTF-8")."', " + . htmlentities($ret["service_check_timeout"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "service_check_timeout = NULL, "; isset($ret["host_check_timeout"]) && $ret["host_check_timeout"] != null ? $rq .= "host_check_timeout = '" - . htmlentities($ret["host_check_timeout"], ENT_QUOTES, "UTF-8")."', " + . htmlentities($ret["host_check_timeout"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "host_check_timeout = NULL, "; isset($ret["event_handler_timeout"]) && $ret["event_handler_timeout"] != null ? $rq .= "event_handler_timeout = '" - . htmlentities($ret["event_handler_timeout"], ENT_QUOTES, "UTF-8")."', " + . htmlentities($ret["event_handler_timeout"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "event_handler_timeout = NULL, "; isset($ret["notification_timeout"]) && $ret["notification_timeout"] != null ? $rq .= "notification_timeout = '" - . htmlentities($ret["notification_timeout"], ENT_QUOTES, "UTF-8")."', " + . htmlentities($ret["notification_timeout"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "notification_timeout = NULL, "; isset($ret["ocsp_timeout"]) && $ret["ocsp_timeout"] != null ? $rq .= "ocsp_timeout = '" - . htmlentities($ret["ocsp_timeout"], ENT_QUOTES, "UTF-8")."', " + . htmlentities($ret["ocsp_timeout"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "ocsp_timeout = NULL, "; isset($ret["ochp_timeout"]) && $ret["ochp_timeout"] != null ? $rq .= "ochp_timeout = '" - . htmlentities($ret["ochp_timeout"], ENT_QUOTES, "UTF-8")."', " + . htmlentities($ret["ochp_timeout"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "ochp_timeout = NULL, "; isset($ret["perfdata_timeout"]) && $ret["perfdata_timeout"] != null ? $rq .= "perfdata_timeout = '" - . htmlentities($ret["perfdata_timeout"], ENT_QUOTES, "UTF-8")."', " + . htmlentities($ret["perfdata_timeout"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "perfdata_timeout = NULL, "; isset($ret["obsess_over_services"]["obsess_over_services"]) - && $ret["obsess_over_services"]["obsess_over_services"] != 2 ? + && $ret["obsess_over_services"]["obsess_over_services"] != 2 ? $rq .= "obsess_over_services = '" - . $ret["obsess_over_services"]["obsess_over_services"]."', " + . $ret["obsess_over_services"]["obsess_over_services"] . "', " : $rq .= "obsess_over_services = '2', "; isset($ret["ocsp_command"]) && $ret["ocsp_command"] != null ? $rq .= "ocsp_command = '" - . htmlentities($ret["ocsp_command"], ENT_QUOTES, "UTF-8")."', " + . htmlentities($ret["ocsp_command"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "ocsp_command = NULL, "; isset($ret["obsess_over_hosts"]["obsess_over_hosts"]) - && $ret["obsess_over_hosts"]["obsess_over_hosts"] != 2 ? - $rq .= "obsess_over_hosts = '".$ret["obsess_over_hosts"]["obsess_over_hosts"]."', " + && $ret["obsess_over_hosts"]["obsess_over_hosts"] != 2 ? + $rq .= "obsess_over_hosts = '" . $ret["obsess_over_hosts"]["obsess_over_hosts"] . "', " : $rq .= "obsess_over_hosts = '2', "; isset($ret["ochp_command"]) && $ret["ochp_command"] != null ? $rq .= "ochp_command = '" - . htmlentities($ret["ochp_command"], ENT_QUOTES, "UTF-8")."', " + . htmlentities($ret["ochp_command"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "ochp_command = NULL, "; isset($ret["process_performance_data"]["process_performance_data"]) - && $ret["process_performance_data"]["process_performance_data"] != 2 ? + && $ret["process_performance_data"]["process_performance_data"] != 2 ? $rq .= "process_performance_data = '" - . $ret["process_performance_data"]["process_performance_data"]."', " + . $ret["process_performance_data"]["process_performance_data"] . "', " : $rq .= "process_performance_data = '2', "; isset($ret["host_perfdata_command"]) && $ret["host_perfdata_command"] != null ? $rq .= "host_perfdata_command = '" - . htmlentities($ret["host_perfdata_command"], ENT_QUOTES, "UTF-8")."', " + . htmlentities($ret["host_perfdata_command"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "host_perfdata_command = NULL, "; isset($ret["service_perfdata_command"]) && $ret["service_perfdata_command"] != null ? $rq .= "service_perfdata_command = '" - . htmlentities($ret["service_perfdata_command"], ENT_QUOTES, "UTF-8")."', " + . htmlentities($ret["service_perfdata_command"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "service_perfdata_command = NULL, "; isset($ret["host_perfdata_file"]) && $ret["host_perfdata_file"] != null ? $rq .= "host_perfdata_file = '" - . htmlentities($ret["host_perfdata_file"], ENT_QUOTES, "UTF-8")."', " + . htmlentities($ret["host_perfdata_file"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "host_perfdata_file = NULL, "; isset($ret["service_perfdata_file"]) && $ret["service_perfdata_file"] != null ? $rq .= "service_perfdata_file = '" - . htmlentities($ret["service_perfdata_file"], ENT_QUOTES, "UTF-8")."', " + . htmlentities($ret["service_perfdata_file"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "service_perfdata_file = NULL, "; isset($ret["host_perfdata_file_template"]) && $ret["host_perfdata_file_template"] != null ? $rq .= "host_perfdata_file_template = '" - . PDO::quote($ret["host_perfdata_file_template"])."', " + . $pearDB->quote($ret["host_perfdata_file_template"]) . "', " : $rq .= "host_perfdata_file_template = NULL, "; isset($ret["service_perfdata_file_template"]) && $ret["service_perfdata_file_template"] != null ? $rq .= "service_perfdata_file_template = '" - . PDO::quote($ret["service_perfdata_file_template"])."', " + . $pearDB->quote($ret["service_perfdata_file_template"]) . "', " : $rq .= "service_perfdata_file_template = NULL, "; isset($ret["host_perfdata_file_mode"]["host_perfdata_file_mode"]) - && $ret["host_perfdata_file_mode"]["host_perfdata_file_mode"] != null ? + && $ret["host_perfdata_file_mode"]["host_perfdata_file_mode"] != null ? $rq .= "host_perfdata_file_mode = '" - . $ret["host_perfdata_file_mode"]["host_perfdata_file_mode"]."', " + . $ret["host_perfdata_file_mode"]["host_perfdata_file_mode"] . "', " : $rq .= "host_perfdata_file_mode = NULL, "; isset($ret["service_perfdata_file_mode"]["service_perfdata_file_mode"]) - && $ret["service_perfdata_file_mode"]["service_perfdata_file_mode"] != null ? + && $ret["service_perfdata_file_mode"]["service_perfdata_file_mode"] != null ? $rq .= "service_perfdata_file_mode = '" - . $ret["service_perfdata_file_mode"]["service_perfdata_file_mode"]."', " + . $ret["service_perfdata_file_mode"]["service_perfdata_file_mode"] . "', " : $rq .= "service_perfdata_file_mode = NULL, "; isset($ret["host_perfdata_file_processing_interval"]) - && $ret["host_perfdata_file_processing_interval"] != null ? + && $ret["host_perfdata_file_processing_interval"] != null ? $rq .= "host_perfdata_file_processing_interval = '" - . htmlentities($ret["host_perfdata_file_processing_interval"], ENT_QUOTES, "UTF-8")."', " + . htmlentities($ret["host_perfdata_file_processing_interval"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "host_perfdata_file_processing_interval = NULL, "; isset($ret["service_perfdata_file_processing_interval"]) - && $ret["service_perfdata_file_processing_interval"] != null ? + && $ret["service_perfdata_file_processing_interval"] != null ? $rq .= "service_perfdata_file_processing_interval = '" - . htmlentities($ret["service_perfdata_file_processing_interval"], ENT_QUOTES, "UTF-8")."', " + . htmlentities($ret["service_perfdata_file_processing_interval"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "service_perfdata_file_processing_interval = NULL, "; isset($ret["host_perfdata_file_processing_command"]) - && $ret["host_perfdata_file_processing_command"] != null ? + && $ret["host_perfdata_file_processing_command"] != null ? $rq .= "host_perfdata_file_processing_command = '" - . htmlentities($ret["host_perfdata_file_processing_command"])."', " + . htmlentities($ret["host_perfdata_file_processing_command"]) . "', " : $rq .= "host_perfdata_file_processing_command = NULL, "; isset($ret["service_perfdata_file_processing_command"]) - && $ret["service_perfdata_file_processing_command"] != null ? + && $ret["service_perfdata_file_processing_command"] != null ? $rq .= "service_perfdata_file_processing_command = '" - . htmlentities($ret["service_perfdata_file_processing_command"], ENT_QUOTES, "UTF-8")."', " + . htmlentities($ret["service_perfdata_file_processing_command"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "service_perfdata_file_processing_command = NULL, "; isset($ret["check_for_orphaned_services"]["check_for_orphaned_services"]) - && $ret["check_for_orphaned_services"]["check_for_orphaned_services"] != 2 ? + && $ret["check_for_orphaned_services"]["check_for_orphaned_services"] != 2 ? $rq .= "check_for_orphaned_services = '" - . $ret["check_for_orphaned_services"]["check_for_orphaned_services"]."', " + . $ret["check_for_orphaned_services"]["check_for_orphaned_services"] . "', " : $rq .= "check_for_orphaned_services = '2', "; isset($ret["check_service_freshness"]["check_service_freshness"]) - && $ret["check_service_freshness"]["check_service_freshness"] != 2 ? + && $ret["check_service_freshness"]["check_service_freshness"] != 2 ? $rq .= "check_service_freshness = '" - . $ret["check_service_freshness"]["check_service_freshness"]."', " + . $ret["check_service_freshness"]["check_service_freshness"] . "', " : $rq .= "check_service_freshness = '2', "; isset($ret["service_freshness_check_interval"]) - && $ret["service_freshness_check_interval"] != null ? + && $ret["service_freshness_check_interval"] != null ? $rq .= "service_freshness_check_interval = '" - . htmlentities($ret["service_freshness_check_interval"], ENT_QUOTES, "UTF-8")."', " + . htmlentities($ret["service_freshness_check_interval"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "service_freshness_check_interval = NULL, "; isset($ret["cached_host_check_horizon"]) && $ret["cached_host_check_horizon"] != null ? $rq .= "cached_host_check_horizon = '" - . htmlentities($ret["cached_host_check_horizon"], ENT_QUOTES, "UTF-8")."', " + . htmlentities($ret["cached_host_check_horizon"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "cached_host_check_horizon = NULL, "; isset($ret["cached_service_check_horizon"]) && $ret["cached_service_check_horizon"] != null ? $rq .= "cached_service_check_horizon = '" - . htmlentities($ret["cached_service_check_horizon"], ENT_QUOTES, "UTF-8")."', " + . htmlentities($ret["cached_service_check_horizon"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "cached_service_check_horizon = NULL, "; isset($ret["additional_freshness_latency"]) && $ret["additional_freshness_latency"] != null ? $rq .= "additional_freshness_latency = '" - . htmlentities($ret["additional_freshness_latency"], ENT_QUOTES, "UTF-8")."', " + . htmlentities($ret["additional_freshness_latency"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "additional_freshness_latency = NULL, "; isset($ret["check_host_freshness"]["check_host_freshness"]) - && $ret["check_host_freshness"]["check_host_freshness"] != 2 ? + && $ret["check_host_freshness"]["check_host_freshness"] != 2 ? $rq .= "check_host_freshness = '" - . $ret["check_host_freshness"]["check_host_freshness"]."', " + . $ret["check_host_freshness"]["check_host_freshness"] . "', " : $rq .= "check_host_freshness = '2', "; isset($ret["host_freshness_check_interval"]) - && $ret["host_freshness_check_interval"] != null ? + && $ret["host_freshness_check_interval"] != null ? $rq .= "host_freshness_check_interval = '" - . htmlentities($ret["host_freshness_check_interval"], ENT_QUOTES, "UTF-8")."', " + . htmlentities($ret["host_freshness_check_interval"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "host_freshness_check_interval = NULL, "; isset($ret["date_format"]) && $ret["date_format"] != null ? $rq .= "date_format = '" - . htmlentities($ret["date_format"], ENT_QUOTES, "UTF-8")."', " + . htmlentities($ret["date_format"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "date_format = NULL, "; isset($ret["illegal_object_name_chars"]) && $ret["illegal_object_name_chars"] != null ? $rq .= "illegal_object_name_chars = " . $pearDB->quote($ret["illegal_object_name_chars"]) . ", " @@ -1042,46 +1046,46 @@ function updateNagios($nagios_id = null) ? $rq .= "illegal_macro_output_chars = " . $pearDB->quote($ret["illegal_macro_output_chars"]) . ", " : $rq .= "illegal_macro_output_chars = NULL, "; isset($ret["use_large_installation_tweaks"]["use_large_installation_tweaks"]) - && $ret["use_large_installation_tweaks"]["use_large_installation_tweaks"] != 2 ? + && $ret["use_large_installation_tweaks"]["use_large_installation_tweaks"] != 2 ? $rq .= "use_large_installation_tweaks = '" - . $ret["use_large_installation_tweaks"]["use_large_installation_tweaks"]."', " + . $ret["use_large_installation_tweaks"]["use_large_installation_tweaks"] . "', " : $rq .= "use_large_installation_tweaks = '2', "; isset($ret["enable_environment_macros"]["enable_environment_macros"]) - && $ret["enable_environment_macros"]["enable_environment_macros"] != 2 ? + && $ret["enable_environment_macros"]["enable_environment_macros"] != 2 ? $rq .= "enable_environment_macros = '" - . $ret["enable_environment_macros"]["enable_environment_macros"]."', " + . $ret["enable_environment_macros"]["enable_environment_macros"] . "', " : $rq .= "enable_environment_macros = '2', "; isset($ret["use_setpgid"]["use_setpgid"]) && $ret["use_setpgid"]["use_setpgid"] != 2 ? - $rq .= "use_setpgid = '".$ret["use_setpgid"]["use_setpgid"]."', " + $rq .= "use_setpgid = '" . $ret["use_setpgid"]["use_setpgid"] . "', " : $rq .= "use_setpgid = '2', "; isset($ret["use_regexp_matching"]["use_regexp_matching"]) - && $ret["use_regexp_matching"]["use_regexp_matching"] != 2 ? - $rq .= "use_regexp_matching = '".$ret["use_regexp_matching"]["use_regexp_matching"]."', " + && $ret["use_regexp_matching"]["use_regexp_matching"] != 2 ? + $rq .= "use_regexp_matching = '" . $ret["use_regexp_matching"]["use_regexp_matching"] . "', " : $rq .= "use_regexp_matching = '2', "; isset($ret["use_true_regexp_matching"]["use_true_regexp_matching"]) - && $ret["use_true_regexp_matching"]["use_true_regexp_matching"] != 2 ? + && $ret["use_true_regexp_matching"]["use_true_regexp_matching"] != 2 ? $rq .= "use_true_regexp_matching = '" - . $ret["use_true_regexp_matching"]["use_true_regexp_matching"]."', " + . $ret["use_true_regexp_matching"]["use_true_regexp_matching"] . "', " : $rq .= "use_true_regexp_matching = '2', "; isset($ret["admin_email"]) && $ret["admin_email"] != null ? $rq .= "admin_email = '" - . htmlentities($ret["admin_email"], ENT_QUOTES, "UTF-8")."', " + . htmlentities($ret["admin_email"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "admin_email = NULL, "; isset($ret["admin_pager"]) && $ret["admin_pager"] != null ? $rq .= "admin_pager = '" - . htmlentities($ret["admin_pager"], ENT_QUOTES, "UTF-8")."', " + . htmlentities($ret["admin_pager"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "admin_pager = NULL, "; isset($ret["nagios_comment"]) && $ret["nagios_comment"] != null ? $rq .= "nagios_comment = '" - . htmlentities($ret["nagios_comment"], ENT_QUOTES, "UTF-8")."', " + . htmlentities($ret["nagios_comment"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "nagios_comment = NULL, "; isset($ret["event_broker_options"]) && $ret["event_broker_options"] != null ? $rq .= "event_broker_options = '" - . htmlentities($ret["event_broker_options"], ENT_QUOTES, "UTF-8")."', " + . htmlentities($ret["event_broker_options"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "event_broker_options = '-1', "; isset($ret["debug_file"]) && $ret["debug_file"] != null ? $rq .= "debug_file = '" - . htmlentities($ret["debug_file"], ENT_QUOTES, "UTF-8")."', " + . htmlentities($ret["debug_file"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "debug_file = NULL, "; $level = 0; if (isset($ret["nagios_debug_level"]) && $ret["nagios_debug_level"] != null) { @@ -1089,58 +1093,58 @@ function updateNagios($nagios_id = null) $level += $key; } } - $rq .= "debug_level = '".$level."', "; + $rq .= "debug_level = '" . $level . "', "; isset($ret["nagios_debug_level"]) && $ret["nagios_debug_level"] != null ? - $rq .= "debug_level_opt = '".implode(",", array_keys($ret["nagios_debug_level"]))."', " + $rq .= "debug_level_opt = '" . implode(",", array_keys($ret["nagios_debug_level"])) . "', " : $rq .= "debug_level = NULL, "; isset($ret["debug_verbosity"]["debug_verbosity"]) - && $ret["debug_verbosity"]["debug_verbosity"] != 2 ? - $rq .= "debug_verbosity = '".$ret["debug_verbosity"]["debug_verbosity"]."', " + && $ret["debug_verbosity"]["debug_verbosity"] != 2 ? + $rq .= "debug_verbosity = '" . $ret["debug_verbosity"]["debug_verbosity"] . "', " : $rq .= "debug_verbosity = '2', "; isset($ret["max_debug_file_size"]) && $ret["max_debug_file_size"] != null ? $rq .= "max_debug_file_size = '" - . htmlentities($ret["max_debug_file_size"], ENT_QUOTES, "UTF-8")."', " + . htmlentities($ret["max_debug_file_size"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "max_debug_file_size = NULL, "; isset($ret["daemon_dumps_core"]["daemon_dumps_core"]) - && $ret["daemon_dumps_core"]["daemon_dumps_core"] ? + && $ret["daemon_dumps_core"]["daemon_dumps_core"] ? $rq .= "daemon_dumps_core = '1', " : $rq .= "daemon_dumps_core = '0', "; isset($ret["translate_passive_host_checks"]["translate_passive_host_checks"]) - && $ret["translate_passive_host_checks"]["translate_passive_host_checks"] != null ? + && $ret["translate_passive_host_checks"]["translate_passive_host_checks"] != null ? $rq .= "translate_passive_host_checks = '" - . htmlentities($ret["translate_passive_host_checks"]["translate_passive_host_checks"], ENT_QUOTES, "UTF-8") - . "', " + . htmlentities($ret["translate_passive_host_checks"]["translate_passive_host_checks"], ENT_QUOTES, "UTF-8") + . "', " : $rq .= "translate_passive_host_checks = NULL, "; isset($ret["passive_host_checks_are_soft"]["passive_host_checks_are_soft"]) - && $ret["passive_host_checks_are_soft"]["passive_host_checks_are_soft"] != null ? + && $ret["passive_host_checks_are_soft"]["passive_host_checks_are_soft"] != null ? $rq .= "passive_host_checks_are_soft = '" - . htmlentities($ret["passive_host_checks_are_soft"]["passive_host_checks_are_soft"], ENT_QUOTES, "UTF-8") - . "', " + . htmlentities($ret["passive_host_checks_are_soft"]["passive_host_checks_are_soft"], ENT_QUOTES, "UTF-8") + . "', " : $rq .= "passive_host_checks_are_soft = NULL, "; isset($ret["check_for_orphaned_hosts"]["check_for_orphaned_hosts"]) - && $ret["check_for_orphaned_hosts"]["check_for_orphaned_hosts"] != null ? + && $ret["check_for_orphaned_hosts"]["check_for_orphaned_hosts"] != null ? $rq .= "check_for_orphaned_hosts = '" - . htmlentities($ret["check_for_orphaned_hosts"]["check_for_orphaned_hosts"], ENT_QUOTES, "UTF-8") - . "', " + . htmlentities($ret["check_for_orphaned_hosts"]["check_for_orphaned_hosts"], ENT_QUOTES, "UTF-8") + . "', " : $rq .= "check_for_orphaned_hosts = NULL, "; - isset($ret["external_command_buffer_slots"]) && $ret["external_command_buffer_slots"]!= null ? + isset($ret["external_command_buffer_slots"]) && $ret["external_command_buffer_slots"] != null ? $rq .= "external_command_buffer_slots = '" - . htmlentities($ret["external_command_buffer_slots"], ENT_QUOTES, "UTF-8")."', " + . htmlentities($ret["external_command_buffer_slots"], ENT_QUOTES, "UTF-8") . "', " : $rq .= " external_command_buffer_slots = NULL, "; - + isset($ret["cfg_file"]) && $ret["cfg_file"] != null ? $rq .= "cfg_file = '" - . htmlentities($ret["cfg_file"], ENT_QUOTES, "UTF-8")."', " + . htmlentities($ret["cfg_file"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "cfg_file = NULL, "; isset($ret["log_pid"]["log_pid"]) && $ret["log_pid"]["log_pid"] ? $rq .= "log_pid = '1', " : $rq .= "log_pid = '0', "; isset($ret['use_check_result_path']['use_check_result_path']) - && $ret['use_check_result_path']['use_check_result_path'] ? + && $ret['use_check_result_path']['use_check_result_path'] ? $rq .= "use_check_result_path = '1', " : $rq .= "use_check_result_path = '0', "; - - $rq .= "nagios_activate = '".$ret["nagios_activate"]["nagios_activate"]."' "; - $rq .= "WHERE nagios_id = '".$nagios_id."'"; + + $rq .= "nagios_activate = '" . $ret["nagios_activate"]["nagios_activate"] . "' "; + $rq .= "WHERE nagios_id = '" . $nagios_id . "'"; $DBRESULT = $pearDB->query($rq); $mainCfg = new CentreonConfigEngine($pearDB); From 2c15b130f0938ead9467a550c2012f42ba4dab57 Mon Sep 17 00:00:00 2001 From: loiclau Date: Wed, 19 Jul 2017 11:06:50 +0200 Subject: [PATCH 036/207] * fix style --- .../TimePeriodConfigurationContext.php | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/features/bootstrap/TimePeriodConfigurationContext.php b/features/bootstrap/TimePeriodConfigurationContext.php index 0ae0a28f2ba..76ddccfe6c0 100644 --- a/features/bootstrap/TimePeriodConfigurationContext.php +++ b/features/bootstrap/TimePeriodConfigurationContext.php @@ -8,7 +8,7 @@ class TimePeriodConfigurationContext extends CentreonContext { private $currentPage; - private $initialProperties = array ( + private $initialProperties = array( 'name' => 'timePeriodName', 'alias' => 'timePeriodAlias', 'sunday' => '14:00-16:00', @@ -19,27 +19,27 @@ class TimePeriodConfigurationContext extends CentreonContext 'friday' => '07:00-18:00', 'saturday' => '10:00-16:00', 'templates' => 'none', - 'exceptions' => array ( - array ( + 'exceptions' => array( + array( 'day' => 'december 25', 'timeRange' => '00:00-22:59,23:00-24:00' ), - array ( + array( 'day' => 'january 1', 'timeRange' => '00:00-24:00' ), - array ( + array( 'day' => 'july 14', 'timeRange' => '00:00-24:00' ), - array ( + array( 'day' => 'may 25', 'timeRange' => '00:00-24:00' ) ) ); - private $duplicatedProperties = array ( + private $duplicatedProperties = array( 'name' => 'timePeriodName_1', 'alias' => 'timePeriodAlias', 'sunday' => '14:00-16:00', @@ -50,27 +50,27 @@ class TimePeriodConfigurationContext extends CentreonContext 'friday' => '07:00-18:00', 'saturday' => '10:00-16:00', 'templates' => 'none', - 'exceptions' => array ( - array ( + 'exceptions' => array( + array( 'day' => 'december 25', 'timeRange' => '00:00-22:59,23:00-24:00' ), - array ( + array( 'day' => 'january 1', 'timeRange' => '00:00-24:00' ), - array ( + array( 'day' => 'july 14', 'timeRange' => '00:00-24:00' ), - array ( + array( 'day' => 'may 25', 'timeRange' => '00:00-24:00' ) ) ); - private $AugustHolidays = array ( + private $AugustHolidays = array( 'name' => 'timePeriodName', 'alias' => 'timePeriodAlias', 'sunday' => '14:00-16:00', @@ -81,8 +81,8 @@ class TimePeriodConfigurationContext extends CentreonContext 'friday' => '07:00-18:00', 'saturday' => '10:00-16:00', 'templates' => 'none', - 'exceptions' => array ( - array ( + 'exceptions' => array( + array( 'day' => 'august 1 - 31', 'timeRange' => '00:00-24:00' ) @@ -117,11 +117,11 @@ function ($context) { } if ($key == 'exceptions') { $stringValue = ''; - foreach($value as $array) { + foreach ($value as $array) { $stringValue = $stringValue . implode(',', $array) . ' '; } $stringObject = ''; - foreach($object[$key] as $array) { + foreach ($object[$key] as $array) { $stringObject = $stringObject . implode(',', $array) . ' '; } if ($stringValue != $stringObject) { @@ -168,11 +168,11 @@ function ($context) { } if ($key == 'exceptions') { $stringValue = ''; - foreach($value as $array) { + foreach ($value as $array) { $stringValue = $stringValue . implode(',', $array) . ' '; } $stringObject = ''; - foreach($object[$key] as $array) { + foreach ($object[$key] as $array) { $stringObject = $stringObject . implode(',', $array) . ' '; } if (strcmp($stringValue, $stringObject) !== 0) { @@ -231,11 +231,11 @@ function ($context) { } if ($key == 'exceptions') { $stringValue = ''; - foreach($value as $array) { + foreach ($value as $array) { $stringValue = $stringValue . implode(',', $array) . ' '; } $stringObject = ''; - foreach($object[$key] as $array) { + foreach ($object[$key] as $array) { $stringObject = $stringObject . implode(',', $array) . ' '; } if (strcmp($stringValue, $stringObject) !== 0) { From 7c3ee1386570bfa8343b84194185af60824a66e5 Mon Sep 17 00:00:00 2001 From: loiclau Date: Wed, 19 Jul 2017 14:12:49 +0200 Subject: [PATCH 037/207] * restore time range exceptions --- .../timeperiod/formTimeperiod.php | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/www/include/configuration/configObject/timeperiod/formTimeperiod.php b/www/include/configuration/configObject/timeperiod/formTimeperiod.php index c2ec57b7431..4855850eca0 100644 --- a/www/include/configuration/configObject/timeperiod/formTimeperiod.php +++ b/www/include/configuration/configObject/timeperiod/formTimeperiod.php @@ -39,15 +39,29 @@ $tp = array(); if (($o == "c" || $o == "w") && $tp_id) { - $DBRESULT = $pearDB->query("SELECT * FROM timeperiod WHERE tp_id = '" . $tp_id . "' LIMIT 1"); + $dbResult = $pearDB->query("SELECT * FROM timeperiod WHERE tp_id = '" . $tp_id . "' LIMIT 1"); /* * Set base value */ - $tp = array_map("myDecode", $DBRESULT->fetchRow()); + $tp = array_map("myDecode", $dbResult->fetchRow()); $tp["contact_exclude"] = array(); } +$j = 0; +$query = "SELECT exception_id, timeperiod_id, days, timerange FROM timeperiod_exceptions " . + "WHERE timeperiod_id = '" . $tp_id . "' ORDER BY `days`"; +$dbResult = $pearDB->query($query); +while ($exceptionTab = $dbResult->fetchRow()) { + $exception_id[$j] = $exceptionTab["exception_id"]; + $exception_days[$j] = $exceptionTab["days"]; + $exception_timerange[$j] = $exceptionTab["timerange"]; + $exception_timeperiod_id[$j] = $exceptionTab["timeperiod_id"]; + $j++; +} +$dbResult->closeCursor(); + + /* * Var information to format the element */ @@ -118,6 +132,9 @@ $mTp[$k] = $multiTp["exception_id"]; $k++; } + +var_dump($k); + $DBRESULT->closeCursor(); /* From 71dd74ee4b4ec67ac4367f023d49a99d436837ba Mon Sep 17 00:00:00 2001 From: loiclau Date: Wed, 19 Jul 2017 14:48:26 +0200 Subject: [PATCH 038/207] * fix kb pagination --- www/include/configuration/configKnowledge/pagination.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/www/include/configuration/configKnowledge/pagination.php b/www/include/configuration/configKnowledge/pagination.php index da19e6013aa..19ea3b8e1cd 100644 --- a/www/include/configuration/configKnowledge/pagination.php +++ b/www/include/configuration/configKnowledge/pagination.php @@ -57,17 +57,15 @@ } if (isset($_GET["num"])) { - $num = $_GET["num"]; + $num = (int)$_GET["num"]; } else { if (!isset($_GET["num"]) && isset($oreon->historyPage[$url]) && $oreon->historyPage[$url]) { - $num = $oreon->historyPage[$url]; + $num = (int)$oreon->historyPage[$url]; } else { $num = 0; } } -$num = $pearDB->quote($num); - $tab_order = array("sort_asc" => "sort_desc", "sort_desc" => "sort_asc"); if (isset($_GET["search_type_service"])) { From 192b0f4bb5b3140e429b761a62c34a9569636e4f Mon Sep 17 00:00:00 2001 From: loiclau Date: Wed, 19 Jul 2017 15:17:51 +0200 Subject: [PATCH 039/207] * fix style servicegroup --- .../configObject/servicegroup/DB-Func.php | 177 ++++++++++++------ .../servicegroup/formServiceGroup.php | 163 ++++++++-------- .../configObject/servicegroup/help.php | 56 +++++- .../servicegroup/listServiceGroup.php | 147 +++++++++------ 4 files changed, 346 insertions(+), 197 deletions(-) diff --git a/www/include/configuration/configObject/servicegroup/DB-Func.php b/www/include/configuration/configObject/servicegroup/DB-Func.php index 3ae959cbb78..4af56f2755a 100644 --- a/www/include/configuration/configObject/servicegroup/DB-Func.php +++ b/www/include/configuration/configObject/servicegroup/DB-Func.php @@ -47,7 +47,9 @@ function testServiceGroupExistence($name = null) $id = $form->getSubmitValue('sg_id'); } - $DBRESULT = $pearDB->query("SELECT sg_name, sg_id FROM servicegroup WHERE sg_name = '".htmlentities($centreon->checkIllegalChar($name), ENT_QUOTES, "UTF-8")."'"); + $query = "SELECT sg_name, sg_id FROM servicegroup " . + "WHERE sg_name = '" . htmlentities($centreon->checkIllegalChar($name), ENT_QUOTES, "UTF-8") . "'"; + $DBRESULT = $pearDB->query($query); $sg = $DBRESULT->fetchRow(); if ($DBRESULT->rowCount() >= 1 && $sg["sg_id"] == $id) { # Modif @@ -66,8 +68,8 @@ function enableServiceGroupInDB($sg_id = null) return; } global $pearDB, $centreon; - $DBRESULT = $pearDB->query("UPDATE servicegroup SET sg_activate = '1' WHERE sg_id = '".$sg_id."'"); - $DBRESULT2 = $pearDB->query("SELECT sg_name FROM `servicegroup` WHERE `sg_id` = '".$sg_id."' LIMIT 1"); + $pearDB->query("UPDATE servicegroup SET sg_activate = '1' WHERE sg_id = '" . $sg_id . "'"); + $DBRESULT2 = $pearDB->query("SELECT sg_name FROM `servicegroup` WHERE `sg_id` = '" . $sg_id . "' LIMIT 1"); $row = $DBRESULT2->fetchRow(); $centreon->CentreonLogAction->insertLog("servicegroup", $sg_id, $row['sg_name'], "enable"); } @@ -78,8 +80,8 @@ function disableServiceGroupInDB($sg_id = null) return; } global $pearDB, $centreon; - $DBRESULT = $pearDB->query("UPDATE servicegroup SET sg_activate = '0' WHERE sg_id = '".$sg_id."'"); - $DBRESULT2 = $pearDB->query("SELECT sg_name FROM `servicegroup` WHERE `sg_id` = '".$sg_id."' LIMIT 1"); + $pearDB->query("UPDATE servicegroup SET sg_activate = '0' WHERE sg_id = '" . $sg_id . "'"); + $DBRESULT2 = $pearDB->query("SELECT sg_name FROM `servicegroup` WHERE `sg_id` = '" . $sg_id . "' LIMIT 1"); $row = $DBRESULT2->fetchRow(); $centreon->CentreonLogAction->insertLog("servicegroup", $sg_id, $row['sg_name'], "disable"); } @@ -89,9 +91,9 @@ function deleteServiceGroupInDB($serviceGroups = array()) global $pearDB, $centreon; foreach ($serviceGroups as $key => $value) { - $DBRESULT2 = $pearDB->query("SELECT sg_name FROM `servicegroup` WHERE `sg_id` = '".$key."' LIMIT 1"); + $DBRESULT2 = $pearDB->query("SELECT sg_name FROM `servicegroup` WHERE `sg_id` = '" . $key . "' LIMIT 1"); $row = $DBRESULT2->fetchRow(); - $DBRESULT = $pearDB->query("DELETE FROM servicegroup WHERE sg_id = '".$key."'"); + $pearDB->query("DELETE FROM servicegroup WHERE sg_id = '" . $key . "'"); $centreon->CentreonLogAction->insertLog("servicegroup", $key, $row['sg_name'], "d"); } $centreon->user->access->updateACL(); @@ -100,18 +102,20 @@ function deleteServiceGroupInDB($serviceGroups = array()) function multipleServiceGroupInDB($serviceGroups = array(), $nbrDup = array()) { global $pearDB, $centreon, $is_admin; - + $sgAcl = array(); foreach ($serviceGroups as $key => $value) { - $DBRESULT = $pearDB->query("SELECT * FROM servicegroup WHERE sg_id = '".$key."' LIMIT 1"); + $DBRESULT = $pearDB->query("SELECT * FROM servicegroup WHERE sg_id = '" . $key . "' LIMIT 1"); $row = $DBRESULT->fetchRow(); $row["sg_id"] = ''; for ($i = 1; $i <= $nbrDup[$key]; $i++) { $val = null; $rq = null; foreach ($row as $key2 => $value2) { - $key2 == "sg_name" ? ($sg_name = $value2 = $value2."_".$i) : null; - $val ? $val .= ($value2!=null?(", '".$value2."'"):", NULL") : $val .= ($value2!=null?("'".$value2."'"):"NULL"); + $key2 == "sg_name" ? ($sg_name = $value2 = $value2 . "_" . $i) : null; + $val + ? $val .= ($value2 != null ? (", '" . $value2 . "'") : ", NULL") + : $val .= ($value2 != null ? ("'" . $value2 . "'") : "NULL"); if ($key2 != "sg_id") { $fields[$key2] = $value2; } @@ -120,25 +124,38 @@ function multipleServiceGroupInDB($serviceGroups = array(), $nbrDup = array()) } } if (testServiceGroupExistence($sg_name)) { - $val ? $rq = "INSERT INTO servicegroup VALUES (".$val.")" : $rq = null; - $DBRESULT = $pearDB->query($rq); + $val ? $rq = "INSERT INTO servicegroup VALUES (" . $val . ")" : $rq = null; + $pearDB->query($rq); $DBRESULT = $pearDB->query("SELECT MAX(sg_id) FROM servicegroup"); $maxId = $DBRESULT->fetchRow(); if (isset($maxId["MAX(sg_id)"])) { - $sgAcl[$maxId["MAX(sg_id)"]] = $key; + $sgAcl[$maxId["MAX(sg_id)"]] = $key; $DBRESULT->closeCursor(); - $DBRESULT = $pearDB->query("SELECT DISTINCT sgr.host_host_id, sgr.hostgroup_hg_id, sgr.service_service_id FROM servicegroup_relation sgr WHERE sgr.servicegroup_sg_id = '".$key."'"); + $query = "SELECT DISTINCT sgr.host_host_id, sgr.hostgroup_hg_id, sgr.service_service_id " . + "FROM servicegroup_relation sgr WHERE sgr.servicegroup_sg_id = '" . $key . "'"; + $DBRESULT = $pearDB->query($query); $fields["sg_hgServices"] = ""; while ($service = $DBRESULT->fetchRow()) { $val = null; foreach ($service as $key2 => $value2) { - $val ? $val .= ($value2!=null?(", '".$value2."'"):", NULL") : $val .= ($value2!=null?("'".$value2."'"):"NULL"); + $val + ? $val .= ($value2 != null ? (", '" . $value2 . "'") : ", NULL") + : $val .= ($value2 != null ? ("'" . $value2 . "'") : "NULL"); } - $DBRESULT2 = $pearDB->query("INSERT INTO servicegroup_relation (host_host_id, hostgroup_hg_id, service_service_id, servicegroup_sg_id) VALUES (".$val.", '".$maxId["MAX(sg_id)"]."')"); + $query = "INSERT INTO servicegroup_relation (host_host_id, hostgroup_hg_id, " . + "service_service_id, servicegroup_sg_id) VALUES (" . $val . + ", '" . $maxId["MAX(sg_id)"] . "')"; + $pearDB->query($query); $fields["sg_hgServices"] .= $service["service_service_id"] . ","; } $fields["sg_hgServices"] = trim($fields["sg_hgServices"], ","); - $centreon->CentreonLogAction->insertLog("servicegroup", $maxId["MAX(sg_id)"], $sg_name, "a", $fields); + $centreon->CentreonLogAction->insertLog( + "servicegroup", + $maxId["MAX(sg_id)"], + $sg_name, + "a", + $fields + ); } } } @@ -149,24 +166,24 @@ function multipleServiceGroupInDB($serviceGroups = array(), $nbrDup = array()) function insertServiceGroupInDB($ret = array()) { - global $centreon; + global $centreon; - $sg_id = insertServiceGroup($ret); - updateServiceGroupServices($sg_id, $ret); - $centreon->user->access->updateACL(); - return $sg_id; + $sg_id = insertServiceGroup($ret); + updateServiceGroupServices($sg_id, $ret); + $centreon->user->access->updateACL(); + return $sg_id; } function updateServiceGroupInDB($sg_id = null, $ret = array(), $increment = false) { - global $centreon; + global $centreon; if (!$sg_id) { return; } - updateServiceGroup($sg_id, $ret); - updateServiceGroupServices($sg_id, $ret, $increment); - $centreon->user->access->updateACL(); + updateServiceGroup($sg_id, $ret); + updateServiceGroupServices($sg_id, $ret, $increment); + $centreon->user->access->updateACL(); } function insertServiceGroup($ret = array()) @@ -180,13 +197,23 @@ function insertServiceGroup($ret = array()) $rq = "INSERT INTO servicegroup (sg_name, sg_alias, sg_comment, geo_coords, sg_activate) "; $rq .= "VALUES ("; - isset($ret["sg_name"]) && $ret["sg_name"] != null ? $rq .= "'".htmlentities($ret["sg_name"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; - isset($ret["sg_alias"]) && $ret["sg_alias"] != null ? $rq .= "'".htmlentities($ret["sg_alias"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; - isset($ret["sg_comment"]) && $ret["sg_comment"] != null ? $rq .= "'".htmlentities($ret["sg_comment"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; - isset($ret["geo_coords"]) && $ret["geo_coords"] != null ? $rq .= "'".htmlentities($ret["geo_coords"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; - isset($ret["sg_activate"]["sg_activate"]) && $ret["sg_activate"]["sg_activate"] != null ? $rq .= "'".$ret["sg_activate"]["sg_activate"]."'" : $rq .= "'0'"; + isset($ret["sg_name"]) && $ret["sg_name"] != null + ? $rq .= "'" . htmlentities($ret["sg_name"], ENT_QUOTES, "UTF-8") . "', " + : $rq .= "NULL, "; + isset($ret["sg_alias"]) && $ret["sg_alias"] != null + ? $rq .= "'" . htmlentities($ret["sg_alias"], ENT_QUOTES, "UTF-8") . "', " + : $rq .= "NULL, "; + isset($ret["sg_comment"]) && $ret["sg_comment"] != null + ? $rq .= "'" . htmlentities($ret["sg_comment"], ENT_QUOTES, "UTF-8") . "', " + : $rq .= "NULL, "; + isset($ret["geo_coords"]) && $ret["geo_coords"] != null + ? $rq .= "'" . htmlentities($ret["geo_coords"], ENT_QUOTES, "UTF-8") . "', " + : $rq .= "NULL, "; + isset($ret["sg_activate"]["sg_activate"]) && $ret["sg_activate"]["sg_activate"] != null + ? $rq .= "'" . $ret["sg_activate"]["sg_activate"] . "'" + : $rq .= "'0'"; $rq .= ")"; - $DBRESULT = $pearDB->query($rq); + $pearDB->query($rq); $DBRESULT = $pearDB->query("SELECT MAX(sg_id) FROM servicegroup"); $sg_id = $DBRESULT->fetchRow(); @@ -194,7 +221,13 @@ function insertServiceGroup($ret = array()) /* Prepare value for changelog */ $fields = CentreonLogAction::prepareChanges($ret); - $centreon->CentreonLogAction->insertLog("servicegroup", $sg_id["MAX(sg_id)"], htmlentities($ret["sg_name"], ENT_QUOTES, "UTF-8"), "a", $fields); + $centreon->CentreonLogAction->insertLog( + "servicegroup", + $sg_id["MAX(sg_id)"], + htmlentities($ret["sg_name"], ENT_QUOTES, "UTF-8"), + "a", + $fields + ); return ($sg_id["MAX(sg_id)"]); } @@ -214,17 +247,33 @@ function updateServiceGroup($sg_id, $ret = array()) $ret["sg_name"] = $centreon->checkIllegalChar($ret["sg_name"]); $rq = "UPDATE servicegroup SET "; - isset($ret["sg_name"]) && $ret["sg_name"] != null ? $rq .= "sg_name = '" . $ret["sg_name"] . "', " : $rq .= "sg_name = NULL,"; - isset($ret["sg_alias"]) && $ret["sg_alias"] != null ? $rq.= "sg_alias = '" . $ret["sg_alias"] ."', " : $rq .= "sg_alias = NULL"; - isset($ret["sg_comment"]) && $ret["sg_comment"] != null ? $rq .= "sg_comment = '".htmlentities($ret["sg_comment"], ENT_QUOTES, "UTF-8")."', " : $rq .= "sg_comment = NULL,"; - isset($ret["geo_coords"]) && $ret["geo_coords"] != null ? $rq .= "geo_coords = '".htmlentities($ret["geo_coords"], ENT_QUOTES, "UTF-8")."', " : $rq .= "geo_coords = NULL,"; - isset($ret["sg_activate"]["sg_activate"]) && $ret["sg_activate"]["sg_activate"] != null ? $rq .= "sg_activate = '".$ret["sg_activate"]["sg_activate"]."' " : $rq .= "sg_activate = '0'"; - $rq .= "WHERE sg_id = '".$sg_id."'"; - $DBRESULT = $pearDB->query($rq); + isset($ret["sg_name"]) && $ret["sg_name"] != null + ? $rq .= "sg_name = '" . $ret["sg_name"] . "', " + : $rq .= "sg_name = NULL,"; + isset($ret["sg_alias"]) && $ret["sg_alias"] != null + ? $rq .= "sg_alias = '" . $ret["sg_alias"] . "', " + : $rq .= "sg_alias = NULL"; + isset($ret["sg_comment"]) && $ret["sg_comment"] != null + ? $rq .= "sg_comment = '" . htmlentities($ret["sg_comment"], ENT_QUOTES, "UTF-8") . "', " + : $rq .= "sg_comment = NULL,"; + isset($ret["geo_coords"]) && $ret["geo_coords"] != null + ? $rq .= "geo_coords = '" . htmlentities($ret["geo_coords"], ENT_QUOTES, "UTF-8") . "', " + : $rq .= "geo_coords = NULL,"; + isset($ret["sg_activate"]["sg_activate"]) && $ret["sg_activate"]["sg_activate"] != null + ? $rq .= "sg_activate = '" . $ret["sg_activate"]["sg_activate"] . "' " + : $rq .= "sg_activate = '0'"; + $rq .= "WHERE sg_id = '" . $sg_id . "'"; + $pearDB->query($rq); /* Prepare value for changelog */ $fields = CentreonLogAction::prepareChanges($ret); - $centreon->CentreonLogAction->insertLog("servicegroup", $sg_id, htmlentities($ret["sg_name"], ENT_QUOTES, "UTF-8"), "c", $fields); + $centreon->CentreonLogAction->insertLog( + "servicegroup", + $sg_id, + htmlentities($ret["sg_name"], ENT_QUOTES, "UTF-8"), + "c", + $fields + ); } function updateServiceGroupServices($sg_id, $ret = array(), $increment = false) @@ -235,9 +284,9 @@ function updateServiceGroupServices($sg_id, $ret = array(), $increment = false) global $pearDB, $form; if ($increment == false) { - $rq = "DELETE FROM servicegroup_relation "; - $rq .= "WHERE servicegroup_sg_id = '".$sg_id."'"; - $DBRESULT = $pearDB->query($rq); + $rq = "DELETE FROM servicegroup_relation "; + $rq .= "WHERE servicegroup_sg_id = '" . $sg_id . "'"; + $pearDB->query($rq); } /* service templates */ @@ -245,35 +294,51 @@ function updateServiceGroupServices($sg_id, $ret = array(), $increment = false) for ($i = 0; $i < count($retTmp); $i++) { if (isset($retTmp[$i]) && $retTmp[$i]) { $t = preg_split("/\-/", $retTmp[$i]); - $resTest = $pearDB->query("SELECT servicegroup_sg_id service FROM servicegroup_relation WHERE host_host_id = ".$t[0]." AND service_service_id = ".$t[1]." AND servicegroup_sg_id = ".$sg_id); + $query = "SELECT servicegroup_sg_id service FROM servicegroup_relation " . + "WHERE host_host_id = " . $t[0] . " AND service_service_id = " . $t[1] . + " AND servicegroup_sg_id = " . $sg_id; + $resTest = $pearDB->query($query); if (!$resTest->rowCount()) { - $rq = "INSERT INTO servicegroup_relation (host_host_id, service_service_id, servicegroup_sg_id) VALUES ('".$t[0]."', '".$t[1]."', '".$sg_id."')"; - $DBRESULT = $pearDB->query($rq); + $query = "INSERT INTO servicegroup_relation (host_host_id, service_service_id, servicegroup_sg_id) " . + "VALUES ('" . $t[0] . "', '" . $t[1] . "', '" . $sg_id . "')"; + $pearDB->query($query); } } } /* regular services */ - $retTmp = isset($ret["sg_hServices"]) ? $ret["sg_hServices"] : CentreonUtils::mergeWithInitialValues($form, 'sg_hServices'); + $retTmp = isset($ret["sg_hServices"]) + ? $ret["sg_hServices"] + : CentreonUtils::mergeWithInitialValues($form, 'sg_hServices'); for ($i = 0; $i < count($retTmp); $i++) { if (isset($retTmp[$i]) && $retTmp[$i]) { $t = preg_split("/\-/", $retTmp[$i]); - $resTest = $pearDB->query("SELECT servicegroup_sg_id service FROM servicegroup_relation WHERE host_host_id = ".$t[0]." AND service_service_id = ".$t[1]." AND servicegroup_sg_id = ".$sg_id); + $query = "SELECT servicegroup_sg_id service FROM servicegroup_relation " . + "WHERE host_host_id = " . $t[0] . " AND service_service_id = " . $t[1] . + " AND servicegroup_sg_id = " . $sg_id; + $resTest = $pearDB->query($query); if (!$resTest->rowCount()) { - $rq = "INSERT INTO servicegroup_relation (host_host_id, service_service_id, servicegroup_sg_id) VALUES ('".$t[0]."', '".$t[1]."', '".$sg_id."')"; - $DBRESULT = $pearDB->query($rq); + $query = "INSERT INTO servicegroup_relation (host_host_id, service_service_id, servicegroup_sg_id) " . + "VALUES ('" . $t[0] . "', '" . $t[1] . "', '" . $sg_id . "')"; + $pearDB->query($query); } } } /* hostgroup services */ - $retTmp = isset($ret["sg_hgServices"]) ? $ret["sg_hgServices"] : CentreonUtils::mergeWithInitialValues($form, 'sg_hgServices'); + $retTmp = isset($ret["sg_hgServices"]) + ? $ret["sg_hgServices"] + : CentreonUtils::mergeWithInitialValues($form, 'sg_hgServices'); for ($i = 0; $i < count($retTmp); $i++) { $t = preg_split("/\-/", $retTmp[$i]); - $resTest = $pearDB->query("SELECT servicegroup_sg_id service FROM servicegroup_relation WHERE hostgroup_hg_id = ".$t[0]." AND service_service_id = ".$t[1]." AND servicegroup_sg_id = ".$sg_id); + $query = "SELECT servicegroup_sg_id service FROM servicegroup_relation " . + "WHERE hostgroup_hg_id = " . $t[0] . " AND service_service_id = " . $t[1] . + " AND servicegroup_sg_id = " . $sg_id; + $resTest = $pearDB->query($query); if (!$resTest->rowCount()) { - $rq = "INSERT INTO servicegroup_relation (hostgroup_hg_id, service_service_id, servicegroup_sg_id) VALUES ('".$t[0]."', '".$t[1]."', '".$sg_id."')"; - $DBRESULT = $pearDB->query($rq); + $query = "INSERT INTO servicegroup_relation (hostgroup_hg_id, service_service_id, servicegroup_sg_id) " . + "VALUES ('" . $t[0] . "', '" . $t[1] . "', '" . $sg_id . "')"; + $pearDB->query($query); } } } diff --git a/www/include/configuration/configObject/servicegroup/formServiceGroup.php b/www/include/configuration/configObject/servicegroup/formServiceGroup.php index 819cc28552a..b85d446badc 100644 --- a/www/include/configuration/configObject/servicegroup/formServiceGroup.php +++ b/www/include/configuration/configObject/servicegroup/formServiceGroup.php @@ -36,9 +36,9 @@ if (!isset($centreon)) { exit(); } - + if (!$centreon->user->admin) { - if ($sg_id && false === strpos($sgString, "'".$sg_id."'")) { + if ($sg_id && false === strpos($sgString, "'" . $sg_id . "'")) { $msg = new CentreonMsg(); $msg->setImage("./img/icons/warning.png"); $msg->setTextStyle("bold"); @@ -55,33 +55,37 @@ $sg = array(); $hServices = array(); if (($o == "c" || $o == "w") && $sg_id) { - $DBRESULT = $pearDB->query("SELECT * FROM servicegroup WHERE sg_id = '".$sg_id."' LIMIT 1"); + $DBRESULT = $pearDB->query("SELECT * FROM servicegroup WHERE sg_id = '" . $sg_id . "' LIMIT 1"); // Set base value $sg = array_map("myDecode", $DBRESULT->fetchRow()); } -$attrsText = array("size"=>"30"); +$attrsText = array("size" => "30"); $attrsAdvSelect = array("style" => "width: 400px; height: 250px;"); -$attrsTextarea = array("rows"=>"5", "cols"=>"40"); -$eTemplate = '
{label_2}
{unselected}
{add}


{remove}
{label_3}
{selected}
'; +$attrsTextarea = array("rows" => "5", "cols" => "40"); +$eTemplate = '
{label_2}
{unselected}
{add}
' . + '

{remove}
{label_3}
{selected}
'; +$route = './include/common/webServices/rest/internal.php?object=centreon_configuration_service&action=list'; $attrServices = array( 'datasourceOrigin' => 'ajax', - 'availableDatasetRoute' => './include/common/webServices/rest/internal.php?object=centreon_configuration_service&action=list', + 'availableDatasetRoute' => $route, 'multiple' => true, 'linkedObject' => 'centreonService' ); +$route = './include/common/webServices/rest/internal.php?object=centreon_configuration_servicetemplate&action=list&l=1'; $attrServicetemplates = array( 'datasourceOrigin' => 'ajax', - 'availableDatasetRoute' => './include/common/webServices/rest/internal.php?object=centreon_configuration_servicetemplate&action=list&l=1', + 'availableDatasetRoute' => $route, 'multiple' => true, 'linkedObject' => 'centreonServicetemplates', 'defaultDatasetOptions' => array('withHosttemplate' => true) ); +$route = './include/common/webServices/rest/internal.php?object=centreon_configuration_service&action=list&t=hostgroup'; $attrHostgroups = array( 'datasourceOrigin' => 'ajax', - 'availableDatasetRoute' => './include/common/webServices/rest/internal.php?object=centreon_configuration_service&action=list&t=hostgroup', + 'availableDatasetRoute' => $route, 'multiple' => true, 'linkedObject' => 'centreonHostgroups' ); @@ -89,7 +93,7 @@ # ## Form begin # -$form = new HTML_QuickForm('Form', 'post', "?p=".$p); +$form = new HTML_QuickForm('Form', 'post', "?p=" . $p); if ($o == "a") { $form->addElement('header', 'title', _("Add a Service Group")); } elseif ($o == "c") { @@ -108,23 +112,27 @@ $form->addElement('header', 'relation', _("Relations")); +$route = './include/common/webServices/rest/internal.php?object=centreon_configuration_service' . + '&action=defaultValues&target=servicegroups&field=sg_hServices&id=' . $sg_id; $attrService1 = array_merge( $attrServices, - array('defaultDatasetRoute' => './include/common/webServices/rest/internal.php?object=centreon_configuration_service&action=defaultValues&target=servicegroups&field=sg_hServices&id=' . $sg_id) + array('defaultDatasetRoute' => $route) ); $form->addElement('select2', 'sg_hServices', _("Linked Host Services"), array(), $attrService1); +$route = './include/common/webServices/rest/internal.php?object=centreon_configuration_service' . + '&action=defaultValues&target=servicegroups&field=sg_hgServices&id=' . $sg_id; $attrHostgroup1 = array_merge( $attrHostgroups, - array( - 'defaultDatasetRoute' => './include/common/webServices/rest/internal.php?object=centreon_configuration_service&action=defaultValues&target=servicegroups&field=sg_hgServices&id=' . $sg_id - ) + array('defaultDatasetRoute' => $route) ); $form->addElement('select2', 'sg_hgServices', _("Linked Host Group Services"), array(), $attrHostgroup1); +$route = './include/common/webServices/rest/internal.php?object=centreon_configuration_servicetemplate' . + '&action=defaultValues&target=servicegroups&field=sg_tServices&id=' . $sg_id; $attrServicetemplate1 = array_merge( $attrServicetemplates, - array('defaultDatasetRoute' => './include/common/webServices/rest/internal.php?object=centreon_configuration_servicetemplate&action=defaultValues&target=servicegroups&field=sg_tServices&id=' . $sg_id) + array('defaultDatasetRoute' => $route) ); $form->addElement('select2', 'sg_tServices', _("Linked Service Templates"), array(), $attrServicetemplate1); @@ -155,13 +163,14 @@ function myReplace() $ret = $form->getSubmitValues(); return (str_replace(" ", "_", $ret["sg_name"])); } + $form->applyFilter('__ALL__', 'myTrim'); $form->applyFilter('sg_name', 'myReplace'); $form->addRule('sg_name', _("Compulsory Name"), 'required'); $form->addRule('sg_alias', _("Compulsory Description"), 'required'); $form->registerRule('exist', 'callback', 'testServiceGroupExistence'); $form->addRule('sg_name', _("Name is already in use"), 'exist'); -$form->setRequiredNote("* ". _("Required fields")); +$form->setRequiredNote("* " . _("Required fields")); # Smarty template Init $tpl = new Smarty(); @@ -170,7 +179,12 @@ function myReplace() # Just watch a Service Group information if ($o == "w") { if ($centreon->user->access->page($p) != 2) { - $form->addElement("button", "change", _("Modify"), array("onClick"=>"javascript:window.location.href='?p=".$p."&o=c&sg_id=".$sg_id."'")); + $form->addElement( + "button", + "change", + _("Modify"), + array("onClick" => "javascript:window.location.href='?p=" . $p . "&o=c&sg_id=" . $sg_id . "'") + ); } $form->setDefaults($sg); $form->freeze(); @@ -186,13 +200,18 @@ function myReplace() } $tpl->assign('nagios', $oreon->user->get_version()); -$tpl->assign("helpattr", 'TITLE, "'._("Help").'", CLOSEBTN, true, FIX, [this, 0, 5], BGCOLOR, "#ffff99", BORDERCOLOR, "orange", TITLEFONTCOLOR, "black", TITLEBGCOLOR, "orange", CLOSEBTNCOLORS, ["","black", "white", "red"], WIDTH, -300, SHADOW, true, TEXTALIGN, "justify"'); +$tpl->assign( + "helpattr", + 'TITLE, "' . _("Help") . '", CLOSEBTN, true, FIX, [this, 0, 5], BGCOLOR, "#ffff99", BORDERCOLOR, "orange", ' . + 'TITLEFONTCOLOR, "black", TITLEBGCOLOR, "orange", CLOSEBTNCOLORS, ["","black", "white", "red"], WIDTH, -300, ' . + 'SHADOW, true, TEXTALIGN, "justify"' +); # prepare help texts $helptext = ""; include_once("help.php"); foreach ($help as $key => $text) { - $helptext .= ''."\n"; + $helptext .= '' . "\n"; } $tpl->assign("helptext", $helptext); @@ -210,7 +229,7 @@ function myReplace() $action = $form->getSubmitValue("action"); if ($valid) { - require_once($path."listServiceGroup.php"); + require_once($path . "listServiceGroup.php"); } else { // Apply a template definition $renderer = new HTML_QuickForm_Renderer_ArraySmarty($tpl, true); @@ -223,69 +242,67 @@ function myReplace() } ?> diff --git a/www/include/configuration/configObject/servicegroup/help.php b/www/include/configuration/configObject/servicegroup/help.php index 058721af463..c14eb099b4e 100644 --- a/www/include/configuration/configObject/servicegroup/help.php +++ b/www/include/configuration/configObject/servicegroup/help.php @@ -1,18 +1,56 @@ sg_sg_search; } - $DBRESULT = $pearDB->query("SELECT COUNT(*) - FROM servicegroup - WHERE (sg_name LIKE '%".htmlentities($search, ENT_QUOTES, "UTF-8")."%' OR sg_alias LIKE '%".htmlentities($search, ENT_QUOTES, "UTF-8")."%')". - $acl->queryBuilder('AND', 'sg_id', $sgString)); + + $DBRESULT = $pearDB->query("SELECT COUNT(*) FROM servicegroup " . + "WHERE (sg_name LIKE '%" . htmlentities($search, ENT_QUOTES, "UTF-8") . + "%' OR sg_alias LIKE '%" . htmlentities($search, ENT_QUOTES, "UTF-8") . "%')" . + $acl->queryBuilder('AND', 'sg_id', $sgString)); } else { $DBRESULT = $pearDB->query("SELECT COUNT(*) - FROM servicegroup ". - $acl->queryBuilder('WHERE', 'sg_id', $sgString)); + FROM servicegroup " . + $acl->queryBuilder('WHERE', 'sg_id', $sgString)); } $tmp = $DBRESULT->fetchRow(); @@ -80,24 +81,23 @@ $tpl->assign("headerMenu_options", _("Options")); if ($search) { - $rq = "SELECT sg_id, sg_name, sg_alias, sg_activate - FROM servicegroup WHERE (sg_name LIKE '%".htmlentities($search, ENT_QUOTES, "UTF-8")."%' OR sg_alias LIKE '%".htmlentities($search, ENT_QUOTES, "UTF-8")."%') ". - $acl->queryBuilder('AND', 'sg_id', $sgString). - " ORDER BY sg_name - LIMIT ".$num * $limit.", ".$limit; + $rq = "SELECT sg_id, sg_name, sg_alias, sg_activate FROM servicegroup " . + "WHERE (sg_name LIKE '%" . htmlentities($search, ENT_QUOTES, "UTF-8") . + "%' OR sg_alias LIKE '%" . htmlentities($search, ENT_QUOTES, "UTF-8") . "%') " . + $acl->queryBuilder('AND', 'sg_id', $sgString) . + " ORDER BY sg_name + LIMIT " . $num * $limit . ", " . $limit; } else { - $rq = "SELECT sg_id, sg_name, sg_alias, sg_activate - FROM servicegroup ". - $acl->queryBuilder('WHERE', 'sg_id', $sgString). - " ORDER BY sg_name - LIMIT ".$num * $limit.", ".$limit; + $rq = "SELECT sg_id, sg_name, sg_alias, sg_activate FROM servicegroup " . + $acl->queryBuilder('WHERE', 'sg_id', $sgString) . + " ORDER BY sg_name LIMIT " . $num * $limit . ", " . $limit; } $DBRESULT = $pearDB->query($rq); $search = tidySearchKey($search, $advanced_search); -$form = new HTML_QuickForm('select_form', 'POST', "?p=".$p); +$form = new HTML_QuickForm('select_form', 'POST', "?p=" . $p); /* * Different style between each lines */ @@ -108,22 +108,30 @@ */ $elemArr = array(); for ($i = 0; $sg = $DBRESULT->fetchRow(); $i++) { - $selectedElements = $form->addElement('checkbox', "select[".$sg['sg_id']."]"); + $selectedElements = $form->addElement('checkbox', "select[" . $sg['sg_id'] . "]"); $moptions = ""; if ($sg["sg_activate"]) { - $moptions .= ""._("Disabled").""; + $moptions .= "" . _("Disabled") . ""; } else { - $moptions .= ""._("Enabled").""; + $moptions .= "" . _("Enabled") . ""; } - $moptions .= "  31 && (event.keyCode < 45 || event.keyCode > 57)) event.returnValue = false; if(event.which > 31 && (event.which < 45 || event.which > 57)) return false;\" maxlength=\"3\" size=\"3\" value='1' style=\"margin-bottom:0px;\" name='dupNbr[".$sg['sg_id']."]'>"; - $elemArr[$i] = array( "MenuClass"=>"list_".$style, - "RowMenu_select"=>$selectedElements->toHtml(), - "RowMenu_name"=>CentreonUtils::escapeSecure($sg["sg_name"]), - "RowMenu_link"=>"?p=".$p."&o=c&sg_id=".$sg['sg_id'], - "RowMenu_desc"=>CentreonUtils::escapeSecure($sg["sg_alias"]), - "RowMenu_status"=>$sg["sg_activate"] ? _("Enabled") : _("Disabled"), - "RowMenu_badge" => $sg["sg_activate"] ? "service_ok" : "service_critical", - "RowMenu_options"=>$moptions); + $moptions .= "  31 && (event.keyCode < 45 || event.keyCode > 57)) " . + "event.returnValue = false; if(event.which > 31 && (event.which < 45 || event.which > 57)) return false;\" " . + "maxlength=\"3\" size=\"3\" value='1' style=\"margin-bottom:0px;\" name='dupNbr[" . $sg['sg_id'] . "]' />"; + $elemArr[$i] = array( + "MenuClass" => "list_" . $style, + "RowMenu_select" => $selectedElements->toHtml(), + "RowMenu_name" => CentreonUtils::escapeSecure($sg["sg_name"]), + "RowMenu_link" => "?p=" . $p . "&o=c&sg_id=" . $sg['sg_id'], + "RowMenu_desc" => CentreonUtils::escapeSecure($sg["sg_alias"]), + "RowMenu_status" => $sg["sg_activate"] ? _("Enabled") : _("Disabled"), + "RowMenu_badge" => $sg["sg_activate"] ? "service_ok" : "service_critical", + "RowMenu_options" => $moptions + ); $style != "two" ? $style = "two" : $style = "one"; } @@ -132,47 +140,68 @@ /* * Different messages we put in the template */ -$tpl->assign('msg', array ("addL"=>"?p=".$p."&o=a", "addT"=>_("Add"), "delConfirm"=>_("Do you confirm the deletion ?"))); +$tpl->assign( + 'msg', + array("addL" => "?p=" . $p . "&o=a", "addT" => _("Add"), "delConfirm" => _("Do you confirm the deletion ?")) +); /* * Toolbar select */ ?> - + "javascript: " . - " var bChecked = isChecked(); ". - " if (this.form.elements['o1'].selectedIndex != 0 && !bChecked) {". - " alert('"._("Please select one or more items")."'); return false;} " . - "if (this.form.elements['o1'].selectedIndex == 1 && confirm('"._("Do you confirm the duplication ?")."')) {" . - " setO(this.form.elements['o1'].value); submit();} " . - "else if (this.form.elements['o1'].selectedIndex == 2 && confirm('"._("Do you confirm the deletion ?")."')) {" . - " setO(this.form.elements['o1'].value); submit();} " . - "else if (this.form.elements['o1'].selectedIndex == 3) {" . - " setO(this.form.elements['o1'].value); submit();} " . - ""); -$form->addElement('select', 'o1', null, array(null=>_("More actions..."), "m"=>_("Duplicate"), "d"=>_("Delete")), $attrs1); + 'onchange' => "javascript: " . + " var bChecked = isChecked(); " . + " if (this.form.elements['o1'].selectedIndex != 0 && !bChecked) {" . + " alert('" . _("Please select one or more items") . "'); return false;} " . + "if (this.form.elements['o1'].selectedIndex == 1 && confirm('" . + _("Do you confirm the duplication ?") . "')) {" . + " setO(this.form.elements['o1'].value); submit();} " . + "else if (this.form.elements['o1'].selectedIndex == 2 && confirm('" . + _("Do you confirm the deletion ?") . "')) {" . + " setO(this.form.elements['o1'].value); submit();} " . + "else if (this.form.elements['o1'].selectedIndex == 3) {" . + " setO(this.form.elements['o1'].value); submit();} " . + "" +); +$form->addElement( + 'select', + 'o1', + null, + array(null => _("More actions..."), "m" => _("Duplicate"), "d" => _("Delete")), + $attrs1 +); $o1 = $form->getElement('o1'); $o1->setValue(null); $attrs = array( - 'onchange'=>"javascript: " . - " var bChecked = isChecked(); ". - " if (this.form.elements['o2'].selectedIndex != 0 && !bChecked) {". - " alert('"._("Please select one or more items")."'); return false;} " . - "if (this.form.elements['o2'].selectedIndex == 1 && confirm('"._("Do you confirm the duplication ?")."')) {" . - " setO(this.form.elements['o2'].value); submit();} " . - "else if (this.form.elements['o2'].selectedIndex == 2 && confirm('"._("Do you confirm the deletion ?")."')) {" . - " setO(this.form.elements['o2'].value); submit();} " . - "else if (this.form.elements['o2'].selectedIndex == 3) {" . - " setO(this.form.elements['o2'].value); submit();} " . - ""); -$form->addElement('select', 'o2', null, array(null=>_("More actions..."), "m"=>_("Duplicate"), "d"=>_("Delete")), $attrs); + 'onchange' => "javascript: " . + " var bChecked = isChecked(); " . + " if (this.form.elements['o2'].selectedIndex != 0 && !bChecked) {" . + " alert('" . _("Please select one or more items") . "'); return false;} " . + "if (this.form.elements['o2'].selectedIndex == 1 && confirm('" . + _("Do you confirm the duplication ?") . "')) {" . + " setO(this.form.elements['o2'].value); submit();} " . + "else if (this.form.elements['o2'].selectedIndex == 2 && confirm('" . + _("Do you confirm the deletion ?") . "')) {" . + " setO(this.form.elements['o2'].value); submit();} " . + "else if (this.form.elements['o2'].selectedIndex == 3) {" . + " setO(this.form.elements['o2'].value); submit();} " . + "" +); +$form->addElement( + 'select', + 'o2', + null, + array(null => _("More actions..."), "m" => _("Duplicate"), "d" => _("Delete")), + $attrs +); $o2 = $form->getElement('o2'); $o2->setValue(null); From fe31056f9347660136cc0e141c62a7f5a2eb8cf1 Mon Sep 17 00:00:00 2001 From: loiclau Date: Wed, 19 Jul 2017 15:27:33 +0200 Subject: [PATCH 040/207] * fix style service categories --- .../service_categories/DB-Func.php | 103 ++++--- .../configObject/service_categories/help.php | 22 +- .../listServiceCategories.php | 275 ++++++++++-------- 3 files changed, 236 insertions(+), 164 deletions(-) diff --git a/www/include/configuration/configObject/service_categories/DB-Func.php b/www/include/configuration/configObject/service_categories/DB-Func.php index 70db6bcb92d..85c4ae711a8 100644 --- a/www/include/configuration/configObject/service_categories/DB-Func.php +++ b/www/include/configuration/configObject/service_categories/DB-Func.php @@ -37,9 +37,9 @@ exit(); } - /** - * Rule that checks whether severity data is set - */ +/** + * Rule that checks whether severity data is set + */ function checkSeverity($fields) { $arr = array(); @@ -54,7 +54,7 @@ function checkSeverity($fields) } return true; } - + function testServiceCategorieExistence($name = null) { global $pearDB, $form; @@ -62,7 +62,9 @@ function testServiceCategorieExistence($name = null) if (isset($form)) { $id = $form->getSubmitValue('sc_id'); } - $DBRESULT = $pearDB->query("SELECT `sc_name`, `sc_id` FROM `service_categories` WHERE `sc_name` = '".htmlentities($name, ENT_QUOTES, "UTF-8")."'"); + $query = "SELECT `sc_name`, `sc_id` FROM `service_categories` " . + "WHERE `sc_name` = '" . htmlentities($name, ENT_QUOTES, "UTF-8") . "'"; + $DBRESULT = $pearDB->query($query); $sc = $DBRESULT->fetchRow(); if ($DBRESULT->rowCount() >= 1 && $sc["sc_id"] == $id) { return true; @@ -84,33 +86,37 @@ function shouldNotBeEqTo0($value) function multipleServiceCategorieInDB($sc = array(), $nbrDup = array()) { - global $pearDB, $centreon; - - $scAcl = array(); + global $pearDB, $centreon; + + $scAcl = array(); foreach ($sc as $key => $value) { - $DBRESULT = $pearDB->query("SELECT * FROM `service_categories` WHERE `sc_id` = '".$key."' LIMIT 1"); + $DBRESULT = $pearDB->query("SELECT * FROM `service_categories` WHERE `sc_id` = '" . $key . "' LIMIT 1"); $row = $DBRESULT->fetchRow(); $row["sc_id"] = ''; for ($i = 1; $i <= $nbrDup[$key]; $i++) { $val = null; foreach ($row as $key2 => $value2) { - $key2 == "sc_name" ? ($sc_name = $value2 = $value2."_".$i) : null; + $key2 == "sc_name" ? ($sc_name = $value2 = $value2 . "_" . $i) : null; $key2 == "sc_description" ? ($sc_alias = $value2 = $value2) : null; - $val ? $val .= ($value2!=null?(", '".$value2."'"):", NULL") : $val .= ($value2 != null?("'".$value2."'"):"NULL"); + $val + ? $val .= ($value2 != null ? (", '" . $value2 . "'") : ", NULL") + : $val .= ($value2 != null ? ("'" . $value2 . "'") : "NULL"); } if (testServiceCategorieExistence($sc_name)) { - $val ? $rq = "INSERT INTO `service_categories` VALUES (".$val.")" : $rq = null; - $DBRESULT = $pearDB->query($rq); + $val ? $rq = "INSERT INTO `service_categories` VALUES (" . $val . ")" : $rq = null; + $pearDB->query($rq); $DBRESULT = $pearDB->query("SELECT MAX(sc_id) as maxid FROM `service_categories`"); $maxId = $DBRESULT->fetchRow(); - $scAcl[$maxId['MAX(sc_id)']] = $key; - $query = "INSERT INTO service_categories_relation (service_service_id, sc_id) (SELECT service_service_id, ".$maxId['maxid']." FROM service_categories_relation WHERE sc_id = ".$pearDB->escape($key).")"; + $scAcl[$maxId['MAX(sc_id)']] = $key; + $query = "INSERT INTO service_categories_relation (service_service_id, sc_id) " . + "(SELECT service_service_id, " . $maxId['maxid'] . + " FROM service_categories_relation WHERE sc_id = " . $pearDB->escape($key) . ")"; $pearDB->query($query); } } } - CentreonACL::duplicateScAcl($scAcl); - $centreon->user->access->updateACL(); + CentreonACL::duplicateScAcl($scAcl); + $centreon->user->access->updateACL(); } function enableServiceCategorieInDB($sc_id = null, $sc_arr = array()) @@ -120,10 +126,10 @@ function enableServiceCategorieInDB($sc_id = null, $sc_arr = array()) } global $pearDB; if ($sc_id) { - $sc_arr = array($sc_id=>"1"); + $sc_arr = array($sc_id => "1"); } foreach ($sc_arr as $key => $value) { - $DBRESULT = $pearDB->query("UPDATE service_categories SET sc_activate = '1' WHERE sc_id = '".$key."'"); + $pearDB->query("UPDATE service_categories SET sc_activate = '1' WHERE sc_id = '" . $key . "'"); } } @@ -134,10 +140,10 @@ function disableServiceCategorieInDB($sc_id = null, $sc_arr = array()) } global $pearDB; if ($sc_id) { - $sc_arr = array($sc_id=>"1"); + $sc_arr = array($sc_id => "1"); } foreach ($sc_arr as $key => $value) { - $DBRESULT = $pearDB->query("UPDATE service_categories SET sc_activate = '0' WHERE sc_id = '".$key."'"); + $pearDB->query("UPDATE service_categories SET sc_activate = '0' WHERE sc_id = '" . $key . "'"); } } @@ -146,13 +152,24 @@ function insertServiceCategorieInDB() global $pearDB, $centreon; if (testServiceCategorieExistence($_POST["sc_name"])) { - $DBRESULT = $pearDB->query("INSERT INTO `service_categories` (`sc_name`, `sc_description`, `level`, `icon_id`, `sc_activate` ) - VALUES ('".$pearDB->escape($_POST["sc_name"])."', '".$pearDB->escape($_POST["sc_description"])."', ". - (isset($_POST['sc_severity_level']) && $_POST['sc_type'] ? $pearDB->escape($_POST['sc_severity_level']):"NULL").", ". - (isset($_POST['sc_severity_icon']) && $_POST['sc_type'] ? $pearDB->escape($_POST['sc_severity_icon']) : "NULL").", ". - "'".$_POST["sc_activate"]["sc_activate"]."')"); - $DBRESULT = $pearDB->query("SELECT MAX(sc_id) FROM `service_categories` WHERE sc_name LIKE '".$pearDB->escape($_POST["sc_name"])."'"); - $data = $DBRESULT->fetchRow(); + + $query = "INSERT INTO `service_categories` (`sc_name`, `sc_description`, `level`, `icon_id`, `sc_activate` ) " . + "VALUES ('" . $pearDB->escape($_POST["sc_name"]) . "', '" . + $pearDB->escape($_POST["sc_description"]) . "', " . + (isset($_POST['sc_severity_level']) && $_POST['sc_type'] + ? $pearDB->escape($_POST['sc_severity_level']) + : "NULL") . + ", " . (isset($_POST['sc_severity_icon']) && $_POST['sc_type'] + ? $pearDB->escape($_POST['sc_severity_icon']) + : "NULL") . + ", " . "'" . $_POST["sc_activate"]["sc_activate"] . "')"; + + $pearDB->query($query); + + $query = "SELECT MAX(sc_id) FROM `service_categories` " . + "WHERE sc_name LIKE '" . $pearDB->escape($_POST["sc_name"]) . "'"; + $DBRESULT = $pearDB->query($query); + $data = $DBRESULT->fetchRow(); } updateServiceCategoriesServices($data["MAX(sc_id)"]); $centreon->user->access->updateACL(); @@ -162,13 +179,18 @@ function updateServiceCategorieInDB() { global $pearDB, $centreon; - $DBRESULT = $pearDB->query("UPDATE `service_categories` SET - `sc_name` = '".$_POST["sc_name"]."' , - `sc_description` = '".$_POST["sc_description"]."' , - `level` = ".(isset($_POST['sc_severity_level']) && $_POST['sc_type'] ? $pearDB->escape($_POST['sc_severity_level']):"NULL").", - `icon_id` = ".(isset($_POST['sc_severity_icon']) && $_POST['sc_type'] ? $pearDB->escape($_POST['sc_severity_icon']) : "NULL").", - `sc_activate` = '".$_POST["sc_activate"]["sc_activate"]."' - WHERE `sc_id` = '".$_POST["sc_id"]."'"); + + $query = "UPDATE `service_categories` SET `sc_name` = '" . $_POST["sc_name"] . + "' , `sc_description` = '" . $_POST["sc_description"] . + "' , `level` = " . (isset($_POST['sc_severity_level']) && $_POST['sc_type'] + ? $pearDB->escape($_POST['sc_severity_level']) + : "NULL") . + ", `icon_id` = " . (isset($_POST['sc_severity_icon']) && $_POST['sc_type'] + ? $pearDB->escape($_POST['sc_severity_icon']) + : "NULL") . + ",`sc_activate` = '" . $_POST["sc_activate"]["sc_activate"] . + "' WHERE `sc_id` = '" . $_POST["sc_id"] . "'"; + $pearDB->query($query); updateServiceCategoriesServices(htmlentities($_POST["sc_id"], ENT_QUOTES, "UTF-8")); $centreon->user->access->updateACL(); } @@ -179,7 +201,7 @@ function deleteServiceCategorieInDB($sc_id = null) $select = $_POST["select"]; foreach ($select as $key => $value) { - $DBRESULT = $pearDB->query("DELETE FROM `service_categories` WHERE `sc_id` = '".$key."'"); + $pearDB->query("DELETE FROM `service_categories` WHERE `sc_id` = '" . $key . "'"); } $centreon->user->access->updateACL(); } @@ -192,11 +214,14 @@ function updateServiceCategoriesServices($sc_id) return; } - $DBRESULT = $pearDB->query("DELETE FROM service_categories_relation WHERE sc_id = '".$sc_id."' AND service_service_id IN (SELECT service_id FROM service WHERE service_register = '0')"); + $query = "DELETE FROM service_categories_relation WHERE sc_id = '" . $sc_id . + "' AND service_service_id IN (SELECT service_id FROM service WHERE service_register = '0')"; + $pearDB->query($query); if (isset($_POST["sc_svcTpl"])) { foreach ($_POST["sc_svcTpl"] as $key) { - $rq = "INSERT INTO service_categories_relation (service_service_id, sc_id) VALUES ('".$key."', '".$sc_id."')"; - $DBRESULT = $pearDB->query($rq); + $query = "INSERT INTO service_categories_relation (service_service_id, sc_id) " . + "VALUES ('" . $key . "', '" . $sc_id . "')"; + $pearDB->query($query); } } } diff --git a/www/include/configuration/configObject/service_categories/help.php b/www/include/configuration/configObject/service_categories/help.php index 51fdec57b08..46c042cc9fb 100644 --- a/www/include/configuration/configObject/service_categories/help.php +++ b/www/include/configuration/configObject/service_categories/help.php @@ -1,9 +1,23 @@ user->admin && $scString != "''") { if (is_null($SearchTool)) { $clause = " WHERE "; @@ -59,142 +60,174 @@ $aclCond .= $acl->queryBuilder($clause, "sc_id", $scString); } - $DBRESULT = $pearDB->query("SELECT COUNT(*) FROM service_categories $SearchTool $aclCond"); - - $tmp = $DBRESULT->fetchRow(); - $DBRESULT->closeCursor(); - $rows = $tmp["COUNT(*)"]; - - include("./include/common/checkPagination.php"); - - /* - * Smarty template Init - */ - $tpl = new Smarty(); - $tpl = initSmartyTpl($path, $tpl); - - /* Access level */ - ($centreon->user->access->page($p) == 1) ? $lvl_access = 'w' : $lvl_access = 'r'; - $tpl->assign('mode_access', $lvl_access); - - /* - * start header menu - */ - $tpl->assign("headerMenu_name", _("Name")); - $tpl->assign("headerMenu_desc", _("Description")); - $tpl->assign("headerMenu_status", _("Status")); - $tpl->assign("headerMenu_linked_svc", _("Number of linked services")); - $tpl->assign("headerMenu_sc_type", _("Type")); - $tpl->assign("headerMenu_options", _("Options")); - - /* - * Services Categories Lists - */ - $DBRESULT = $pearDB->query("SELECT * +$DBRESULT = $pearDB->query("SELECT COUNT(*) FROM service_categories $SearchTool $aclCond"); + +$tmp = $DBRESULT->fetchRow(); +$DBRESULT->closeCursor(); +$rows = $tmp["COUNT(*)"]; + +include("./include/common/checkPagination.php"); + +/* + * Smarty template Init + */ +$tpl = new Smarty(); +$tpl = initSmartyTpl($path, $tpl); + +/* Access level */ +($centreon->user->access->page($p) == 1) ? $lvl_access = 'w' : $lvl_access = 'r'; +$tpl->assign('mode_access', $lvl_access); + +/* + * start header menu + */ +$tpl->assign("headerMenu_name", _("Name")); +$tpl->assign("headerMenu_desc", _("Description")); +$tpl->assign("headerMenu_status", _("Status")); +$tpl->assign("headerMenu_linked_svc", _("Number of linked services")); +$tpl->assign("headerMenu_sc_type", _("Type")); +$tpl->assign("headerMenu_options", _("Options")); + +/* + * Services Categories Lists + */ +$DBRESULT = $pearDB->query("SELECT * FROM service_categories $SearchTool $aclCond ORDER BY sc_name - LIMIT ".$num * $limit.", ".$limit); + LIMIT " . $num * $limit . ", " . $limit); - $search = tidySearchKey($search, $advanced_search); +$search = tidySearchKey($search, $advanced_search); - $form = new HTML_QuickForm('select_form', 'POST', "?p=".$p); +$form = new HTML_QuickForm('select_form', 'POST', "?p=" . $p); - /* - * Different style between each lines - */ - $style = "one"; +/* + * Different style between each lines + */ +$style = "one"; - /* - * Fill a tab with a mutlidimensionnal Array we put in $tpl - */ - $elemArr = array(); +/* + * Fill a tab with a mutlidimensionnal Array we put in $tpl + */ +$elemArr = array(); for ($i = 0; $sc = $DBRESULT->fetchRow(); $i++) { $moptions = ""; - $DBRESULT2 = $pearDB->query("SELECT COUNT(*) FROM `service_categories_relation` WHERE `sc_id` = '".$sc['sc_id']."'"); + $query = "SELECT COUNT(*) FROM `service_categories_relation` WHERE `sc_id` = '" . $sc['sc_id'] . "'"; + $DBRESULT2 = $pearDB->query($query); $nb_svc = $DBRESULT2->fetchRow(); - $selectedElements = $form->addElement('checkbox', "select[".$sc['sc_id']."]"); + $selectedElements = $form->addElement('checkbox', "select[" . $sc['sc_id'] . "]"); if ($sc["sc_activate"]) { - $moptions .= ""._("Disabled")."  "; + $moptions .= "" . _("Disabled") . "  "; } else { - $moptions .= ""._("Enabled")."  "; + $moptions .= "" . _("Enabled") . "  "; } $moptions .= " "; - $moptions .= " 31 && (event.keyCode < 45 || event.keyCode > 57)) event.returnValue = false; if(event.which > 31 && (event.which < 45 || event.which > 57)) return false;\" maxlength=\"3\" size=\"3\" value='1' style=\"margin-bottom:0px;\" name='dupNbr[".$sc['sc_id']."]'>"; - - $elemArr[$i] = array("MenuClass" => "list_".$style, - "RowMenu_select" => $selectedElements->toHtml(), - "sc_name" => htmlentities($sc["sc_name"], ENT_QUOTES, "UTF-8"), - "sc_link" => "?p=".$p."&o=c&sc_id=".$sc['sc_id'], - "sc_description" => htmlentities($sc["sc_description"], ENT_QUOTES, "UTF-8"), - "svc_linked" => $nb_svc["COUNT(*)"], - "sc_type" => ($sc['level'] ? _('Severity') . ' ('.$sc['level'].')' : _('Regular')), - "sc_activated" => $sc["sc_activate"] ? _("Enabled") : _("Disabled"), - "RowMenu_badge" => $sc["sc_activate"] ? "service_ok" : "service_critical", - "RowMenu_options" => $moptions); + $moptions .= " 31 && (event.keyCode < 45 || event.keyCode > 57)) " . + "event.returnValue = false; if(event.which > 31 && (event.which < 45 || event.which > 57)) " . + "return false;\" maxlength=\"3\" size=\"3\" value='1' style=\"margin-bottom:0px;\" " . + "name='dupNbr[" . $sc['sc_id'] . "]' />"; + + $elemArr[$i] = array( + "MenuClass" => "list_" . $style, + "RowMenu_select" => $selectedElements->toHtml(), + "sc_name" => htmlentities($sc["sc_name"], ENT_QUOTES, "UTF-8"), + "sc_link" => "?p=" . $p . "&o=c&sc_id=" . $sc['sc_id'], + "sc_description" => htmlentities($sc["sc_description"], ENT_QUOTES, "UTF-8"), + "svc_linked" => $nb_svc["COUNT(*)"], + "sc_type" => ($sc['level'] ? _('Severity') . ' (' . $sc['level'] . ')' : _('Regular')), + "sc_activated" => $sc["sc_activate"] ? _("Enabled") : _("Disabled"), + "RowMenu_badge" => $sc["sc_activate"] ? "service_ok" : "service_critical", + "RowMenu_options" => $moptions + ); $style != "two" ? $style = "two" : $style = "one"; } - $tpl->assign("elemArr", $elemArr); +$tpl->assign("elemArr", $elemArr); - /* - * Different messages we put in the template - */ - $tpl->assign('msg', array ("addL" => "?p=".$p."&o=a", "addT" => _("Add"))); +/* + * Different messages we put in the template + */ +$tpl->assign('msg', array("addL" => "?p=" . $p . "&o=a", "addT" => _("Add"))); - ?> - - "javascript: " . - " var bChecked = isChecked(); ". - " if (this.form.elements['o1'].selectedIndex != 0 && !bChecked) {". - " alert('"._("Please select one or more items")."'); return false;} " . - "if (this.form.elements['o1'].selectedIndex == 1 && confirm('"._("Do you confirm the duplication ?")."')) {" . - " setO(this.form.elements['o1'].value); submit();} " . - "else if (this.form.elements['o1'].selectedIndex == 2 && confirm('"._("Do you confirm the deletion ?")."')) {" . - " setO(this.form.elements['o1'].value); submit();} " . - "else if (this.form.elements['o1'].selectedIndex == 3 || this.form.elements['o1'].selectedIndex == 4 ||this.form.elements['o1'].selectedIndex == 5){" . - " setO(this.form.elements['o1'].value); submit();} " . - "this.form.elements['o1'].selectedIndex = 0"); - $form->addElement('select', 'o1', null, array(null=>_("More actions..."), "m"=>_("Duplicate"), "d"=>_("Delete"), "mc"=>_("Massive Change"), "ms"=>_("Enable"), "mu"=>_("Disable")), $attrs1); - $form->setDefaults(array('o1' => null)); - - $attrs2 = array( - 'onchange'=>"javascript: " . - " var bChecked = isChecked(); ". - " if (this.form.elements['o2'].selectedIndex != 0 && !bChecked) {". - " alert('"._("Please select one or more items")."'); return false;} " . - "if (this.form.elements['o2'].selectedIndex == 1 && confirm('"._("Do you confirm the duplication ?")."')) {" . - " setO(this.form.elements['o2'].value); submit();} " . - "else if (this.form.elements['o2'].selectedIndex == 2 && confirm('"._("Do you confirm the deletion ?")."')) {" . - " setO(this.form.elements['o2'].value); submit();} " . - "else if (this.form.elements['o2'].selectedIndex == 3 || this.form.elements['o2'].selectedIndex == 4 ||this.form.elements['o2'].selectedIndex == 5){" . - " setO(this.form.elements['o2'].value); submit();} " . - "this.form.elements['o2'].selectedIndex = 0"); - $form->addElement('select', 'o2', null, array(null=>_("More actions"), "m"=>_("Duplicate"), "d"=>_("Delete"), "mc"=>_("Massive Change"), "ms"=>_("Enable"), "mu"=>_("Disable")), $attrs2); - $form->setDefaults(array('o2' => null)); - - $o1 = $form->getElement('o1'); - $o1->setValue(null); - $o1->setSelected(null); - - $o2 = $form->getElement('o2'); - $o2->setValue(null); - $o2->setSelected(null); - - $tpl->assign('limit', $limit); - $tpl->assign('searchSC', $search); - - /* - * Apply a template definition - */ - $renderer = new HTML_QuickForm_Renderer_ArraySmarty($tpl); - $form->accept($renderer); - $tpl->assign('form', $renderer->toArray()); - $tpl->display("listServiceCategories.ihtml"); + + "javascript: " . + " var bChecked = isChecked(); " . + " if (this.form.elements['o1'].selectedIndex != 0 && !bChecked) {" . + " alert('" . _("Please select one or more items") . "'); return false;} " . + "if (this.form.elements['o1'].selectedIndex == 1 && confirm('" . + _("Do you confirm the duplication ?") . "')) {" . + " setO(this.form.elements['o1'].value); submit();} " . + "else if (this.form.elements['o1'].selectedIndex == 2 && confirm('" . + _("Do you confirm the deletion ?") . "')) {" . + " setO(this.form.elements['o1'].value); submit();} " . + "else if (this.form.elements['o1'].selectedIndex == 3 || this.form.elements['o1'].selectedIndex == 4 " . + "||this.form.elements['o1'].selectedIndex == 5){" . + " setO(this.form.elements['o1'].value); submit();} " . + "this.form.elements['o1'].selectedIndex = 0" +); +$form->addElement('select', 'o1', null, array( + null => _("More actions..."), + "m" => _("Duplicate"), + "d" => _("Delete"), + "mc" => _("Massive Change"), + "ms" => _("Enable"), + "mu" => _("Disable") +), $attrs1); +$form->setDefaults(array('o1' => null)); + +$attrs2 = array( + 'onchange' => "javascript: " . + " var bChecked = isChecked(); " . + " if (this.form.elements['o2'].selectedIndex != 0 && !bChecked) {" . + " alert('" . _("Please select one or more items") . "'); return false;} " . + "if (this.form.elements['o2'].selectedIndex == 1 && confirm('" . + _("Do you confirm the duplication ?") . "')) {" . + " setO(this.form.elements['o2'].value); submit();} " . + "else if (this.form.elements['o2'].selectedIndex == 2 && confirm('" . + _("Do you confirm the deletion ?") . "')) {" . + " setO(this.form.elements['o2'].value); submit();} " . + "else if (this.form.elements['o2'].selectedIndex == 3 || " . + "this.form.elements['o2'].selectedIndex == 4 ||this.form.elements['o2'].selectedIndex == 5){" . + " setO(this.form.elements['o2'].value); submit();} " . + "this.form.elements['o2'].selectedIndex = 0" +); +$form->addElement('select', 'o2', null, array( + null => _("More actions"), + "m" => _("Duplicate"), + "d" => _("Delete"), + "mc" => _("Massive Change"), + "ms" => _("Enable"), + "mu" => _("Disable") +), $attrs2); +$form->setDefaults(array('o2' => null)); + +$o1 = $form->getElement('o1'); +$o1->setValue(null); +$o1->setSelected(null); + +$o2 = $form->getElement('o2'); +$o2->setValue(null); +$o2->setSelected(null); + +$tpl->assign('limit', $limit); +$tpl->assign('searchSC', $search); + +/* + * Apply a template definition + */ +$renderer = new HTML_QuickForm_Renderer_ArraySmarty($tpl); +$form->accept($renderer); +$tpl->assign('form', $renderer->toArray()); +$tpl->display("listServiceCategories.ihtml"); ?> From 3e0af455c1648174101b453a99036fa812fc53ae Mon Sep 17 00:00:00 2001 From: loiclau Date: Wed, 19 Jul 2017 15:50:21 +0200 Subject: [PATCH 041/207] * fix style tests --- tests/php/CentreonLegacy/Core/Widget/UpgraderTest.php | 9 ++++++++- tests/php/CentreonLegacy/Core/Widget/WidgetTest.php | 1 - 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/php/CentreonLegacy/Core/Widget/UpgraderTest.php b/tests/php/CentreonLegacy/Core/Widget/UpgraderTest.php index 8b956f69db8..9b545df7629 100644 --- a/tests/php/CentreonLegacy/Core/Widget/UpgraderTest.php +++ b/tests/php/CentreonLegacy/Core/Widget/UpgraderTest.php @@ -99,7 +99,14 @@ public function setUp() $this->information = $this->getMockBuilder('CentreonLegacy\Core\Widget\Information') ->disableOriginalConstructor() ->setMethods( - array('getConfiguration', 'getTypes', 'getParameters', 'isInstalled', 'getIdByName', 'getParameterIdByName') + array( + 'getConfiguration', + 'getTypes', + 'getParameters', + 'isInstalled', + 'getIdByName', + 'getParameterIdByName' + ) ) ->getMock(); diff --git a/tests/php/CentreonLegacy/Core/Widget/WidgetTest.php b/tests/php/CentreonLegacy/Core/Widget/WidgetTest.php index 76086c82753..a520759e21c 100644 --- a/tests/php/CentreonLegacy/Core/Widget/WidgetTest.php +++ b/tests/php/CentreonLegacy/Core/Widget/WidgetTest.php @@ -113,7 +113,6 @@ public function setUp() $this->utils->expects($this->any()) ->method('buildPath') ->willReturn('/'); - } public function tearDown() From 904240ef2159b36ec3e31ca50129c8edd9bd0485 Mon Sep 17 00:00:00 2001 From: loiclau Date: Wed, 19 Jul 2017 15:52:52 +0200 Subject: [PATCH 042/207] * fix style main --- www/main.php | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/www/main.php b/www/main.php index c83e3102924..d4d59d447ad 100644 --- a/www/main.php +++ b/www/main.php @@ -43,9 +43,9 @@ /* * Purge Values */ -if (function_exists('filter_var')){ - foreach ($_GET as $key => $value){ - if (!is_array($value)){ +if (function_exists('filter_var')) { + foreach ($_GET as $key => $value) { + if (!is_array($value)) { $_GET[$key] = filter_var($value, FILTER_SANITIZE_SPECIAL_CHARS); } } @@ -101,7 +101,7 @@ $is_admin = $centreon->user->admin; $query = "SELECT topology_parent,topology_name,topology_id,topology_url,topology_page " . - " FROM topology WHERE topology_page = '".$p."'"; + " FROM topology WHERE topology_page = '" . $p . "'"; $DBRESULT = $pearDB->query($query); $redirect = $DBRESULT->fetch(); @@ -208,21 +208,26 @@ } if (!$centreon->user->showDiv("header")) { -?> + user->showDiv("menu_3")) { -?> + user->showDiv("menu_2")) { -?> + Date: Wed, 19 Jul 2017 15:57:12 +0200 Subject: [PATCH 043/207] * fix style index api --- www/api/exceptions.php | 20 ++++++++++---------- www/api/index.php | 17 ++++++++++------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/www/api/exceptions.php b/www/api/exceptions.php index 37f9dd9fd9f..3ff2a70f9fd 100644 --- a/www/api/exceptions.php +++ b/www/api/exceptions.php @@ -47,7 +47,7 @@ public function __construct($message = "", $code = 0, $previous = null) class RestBadRequestException extends RestException { protected $code = 400; - + public function __construct($message = "", $code = 0, $previous = null) { parent::__construct($message, $this->code, $previous); @@ -57,7 +57,7 @@ public function __construct($message = "", $code = 0, $previous = null) class RestUnauthorizedException extends RestException { protected $code = 401; - + public function __construct($message = "", $code = 0, $previous = null) { parent::__construct($message, $this->code, $previous); @@ -67,7 +67,7 @@ public function __construct($message = "", $code = 0, $previous = null) class RestForbiddenException extends RestException { protected $code = 403; - + public function __construct($message = "", $code = 0, $previous = null) { parent::__construct($message, $this->code, $previous); @@ -77,7 +77,7 @@ public function __construct($message = "", $code = 0, $previous = null) class RestNotFoundException extends RestException { protected $code = 404; - + public function __construct($message = "", $code = 0, $previous = null) { parent::__construct($message, $this->code, $previous); @@ -87,7 +87,7 @@ public function __construct($message = "", $code = 0, $previous = null) class RestMethodNotAllowedException extends RestException { protected $code = 405; - + public function __construct($message = "", $code = 0, $previous = null) { parent::__construct($message, $this->code, $previous); @@ -97,7 +97,7 @@ public function __construct($message = "", $code = 0, $previous = null) class RestConflictException extends RestException { protected $code = 409; - + public function __construct($message = "", $code = 0, $previous = null) { parent::__construct($message, $this->code, $previous); @@ -107,7 +107,7 @@ public function __construct($message = "", $code = 0, $previous = null) class RestInternalServerErrorException extends RestException { protected $code = 500; - + public function __construct($message = "", $code = 0, $previous = null) { parent::__construct($message, $this->code, $previous); @@ -117,7 +117,7 @@ public function __construct($message = "", $code = 0, $previous = null) class RestBadGatewayException extends RestException { protected $code = 502; - + public function __construct($message = "", $code = 0, $previous = null) { parent::__construct($message, $this->code, $previous); @@ -127,7 +127,7 @@ public function __construct($message = "", $code = 0, $previous = null) class RestServiceUnavailableException extends RestException { protected $code = 503; - + public function __construct($message = "", $code = 0, $previous = null) { parent::__construct($message, $this->code, $previous); @@ -137,7 +137,7 @@ public function __construct($message = "", $code = 0, $previous = null) class RestGatewayTimeOutException extends RestException { protected $code = 504; - + public function __construct($message = "", $code = 0, $previous = null) { parent::__construct($message, $this->code, $previous); diff --git a/www/api/index.php b/www/api/index.php index f68d54f08ec..e03c41c4216 100644 --- a/www/api/index.php +++ b/www/api/index.php @@ -46,15 +46,16 @@ /* Test if the call is for authenticate */ if ($_SERVER['REQUEST_METHOD'] === 'POST' && - isset($_GET['action']) && $_GET['action'] == 'authenticate') { + isset($_GET['action']) && $_GET['action'] == 'authenticate' +) { if (false === isset($_POST['username']) || false === isset($_POST['password'])) { CentreonWebService::sendResult("Bad parameters", 400); } - + /* @todo Check if user already have valid token */ require_once _CENTREON_PATH_ . "/www/class/centreonLog.class.php"; require_once _CENTREON_PATH_ . "/www/class/centreonAuth.class.php"; - + /* Authenticate the user */ $log = new CentreonUserLog(0, $pearDB); $auth = new CentreonAuth($_POST['username'], $_POST['password'], 0, $pearDB, $log, 1, "", "API"); @@ -62,17 +63,19 @@ CentreonWebService::sendResult("Bad credentials", 403); exit(); } - + /* Check if user exists in contact table */ $reachAPI = 0; - $res = $pearDB->prepare("SELECT contact_id, reach_api, contact_admin FROM contact WHERE contact_activate = '1' AND contact_register = '1' AND contact_alias = ?"); + $query = "SELECT contact_id, reach_api, contact_admin FROM contact " . + "WHERE contact_activate = '1' AND contact_register = '1' AND contact_alias = ?"; + $res = $pearDB->prepare($query); $res->execute(array($_POST['username'])); while ($data = $res->fetch()) { - if (isset($data['contact_admin']) && $data['contact_admin'] == 1) { + if (isset($data['contact_admin']) && $data['contact_admin'] == 1) { $reachAPI = 1; } else { if (isset($data['reach_api']) && $data['reach_api'] == 1) { - $reachAPI = 1; + $reachAPI = 1; } } } From 0477f5ac9d3cb6e055971fb5847bfd7657248e69 Mon Sep 17 00:00:00 2001 From: loiclau Date: Wed, 19 Jul 2017 15:59:12 +0200 Subject: [PATCH 044/207] * fix style api class --- .../class/centreon_configuration_broker.class.php | 12 +++++++----- www/api/class/centreon_performance_service.class.php | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/www/api/class/centreon_configuration_broker.class.php b/www/api/class/centreon_configuration_broker.class.php index e2e38b465fc..9a0cd9afdb0 100644 --- a/www/api/class/centreon_configuration_broker.class.php +++ b/www/api/class/centreon_configuration_broker.class.php @@ -48,8 +48,7 @@ class CentreonConfigurationBroker extends CentreonConfigurationObjects */ public function getBlock() { - if ( - !isset($this->arguments['page']) || + if (!isset($this->arguments['page']) || !isset($this->arguments['position']) || !isset($this->arguments['blockId']) || !isset($this->arguments['tag']) @@ -64,7 +63,7 @@ public function getBlock() $cbObj = new CentreonConfigCentreonBroker($this->pearDB); - $form = $cbObj->quickFormById($blockId, $page, $position, "new_".rand(100, 1000)); + $form = $cbObj->quickFormById($blockId, $page, $position, "new_" . rand(100, 1000)); $helps = array(); list($tagId, $typeId) = explode('_', $blockId); @@ -80,7 +79,10 @@ public function getBlock() $fieldname .= $cbObj->getParentGroups($field['group']); } $fieldname .= $field['fieldname']; - $helps[] = array('name' => $tag . '[' . $position . '][' . $fieldname . ']', 'desc' => _($field['description'])); + $helps[] = array( + 'name' => $tag . '[' . $position . '][' . $fieldname . ']', + 'desc' => _($field['description']) + ); } textdomain('messages'); @@ -92,7 +94,7 @@ public function getBlock() $tpl->compile_dir = $libDir . '/SmartyCache/compile'; $tpl->config_dir = $libDir . '/SmartyCache/config'; $tpl->cache_dir = $libDir . '/SmartyCache/cache'; - $tpl->template_dir = _CENTREON_PATH_ . '/www/include/configuration/configCentreonBroker/'; + $tpl->template_dir = _CENTREON_PATH_ . '/www/include/configuration/configCentreonBroker/'; $tpl->caching = 0; $tpl->compile_check = true; $tpl->force_compile = true; diff --git a/www/api/class/centreon_performance_service.class.php b/www/api/class/centreon_performance_service.class.php index 1a5d148a822..4add8dbefdd 100644 --- a/www/api/class/centreon_performance_service.class.php +++ b/www/api/class/centreon_performance_service.class.php @@ -174,7 +174,7 @@ public function getList() $stmt = $this->pearDBMonitoring->prepare($query); $stmt->bindValue(':fullName', $bindParams[':fullName'], PDO::PARAM_STR); unset($bindParams[':fullName']); - foreach($bindParams as $k => $v) { + foreach ($bindParams as $k => $v) { $stmt->bindValue($k, $v, PDO::PARAM_INT); } From 9041a7685bcd831421eada89d8774426259468d6 Mon Sep 17 00:00:00 2001 From: loiclau Date: Wed, 19 Jul 2017 16:19:29 +0200 Subject: [PATCH 045/207] * fix style class --- www/class/centreonAuth.SSO.class.php | 18 +- www/class/centreonConnector.class.php | 44 +- www/class/centreonContactgroup.class.php | 27 +- www/class/centreonDBStatement.class.php | 5 +- www/class/centreonDuration.class.php | 59 +- www/class/centreonExternalCommand.class.php | 12 +- www/class/centreonGraph.class.php | 561 ++++++++++++++------ www/class/centreonGraphPoller.class.php | 7 +- www/class/centreonLDAP.class.php | 103 ++-- www/class/centreonMetrics.class.php | 13 +- www/class/centreonPurgeEngine.class.php | 45 +- www/class/centreonService.class.php | 277 +++++----- www/class/centreonSession.class.php | 3 +- 13 files changed, 718 insertions(+), 456 deletions(-) diff --git a/www/class/centreonAuth.SSO.class.php b/www/class/centreonAuth.SSO.class.php index cee14126df4..0be4e9f35aa 100644 --- a/www/class/centreonAuth.SSO.class.php +++ b/www/class/centreonAuth.SSO.class.php @@ -51,18 +51,20 @@ public function __construct( $token = "", $generalOptions = array() ) { - + $this->options_sso = $generalOptions; - + if (isset($this->options_sso['sso_enable']) && $this->options_sso['sso_enable'] == 1 && isset($this->options_sso['sso_header_username']) && $this->options_sso['sso_header_username'] != '' && - isset($_SERVER[$this->options_sso['sso_header_username']])) { + isset($_SERVER[$this->options_sso['sso_header_username']]) + ) { $this->sso_username = $_SERVER[$this->options_sso['sso_header_username']]; if ($this->checkSsoClient()) { $this->sso_mandatory = 1; $username = $this->sso_username; if (isset($this->options_sso['sso_username_pattern']) && - $this->options_sso['sso_username_pattern'] != '') { + $this->options_sso['sso_username_pattern'] != '' + ) { $username = preg_replace( $this->options_sso['sso_username_pattern'], $this->options_sso['sso_username_replace'], @@ -78,7 +80,7 @@ public function __construct( global $msg_error; $msg_error = "Invalid User. SSO Protection (user=" . $this->sso_username . ")"; } - + } protected function checkSsoClient() @@ -111,14 +113,14 @@ protected function checkSsoClient() protected function checkPassword($password, $token, $autoimport = false) { if ($this->sso_mandatory == 1) { - # Mode LDAP autoimport. Need to call it + # Mode LDAP autoimport. Need to call it if ($autoimport) { # Password is only because it needs one... parent::checkPassword('test', $token, $autoimport); } - # We delete old sessions with same SID + # We delete old sessions with same SID global $pearDB; - $pearDB->query("DELETE FROM session WHERE session_id = '".session_id()."'"); + $pearDB->query("DELETE FROM session WHERE session_id = '" . session_id() . "'"); $this->passwdOk = 1; } else { # local connect (when sso not enabled and 'sso_mode' == 1 diff --git a/www/class/centreonConnector.class.php b/www/class/centreonConnector.class.php index 9e7f972f17c..5d181a69da2 100644 --- a/www/class/centreonConnector.class.php +++ b/www/class/centreonConnector.class.php @@ -167,9 +167,9 @@ public function create(array $connector, $returnId = false) if (isset($connector["command_id"])) { foreach ($connector["command_id"] as $key => $value) { try { - $updateResult = $this->dbConnection->query( - "UPDATE `command` SET connector_id = '" . $lastId['id'] . "' WHERE `command_id` = '$value'" - ); + $query = "UPDATE `command` SET connector_id = '" . $lastId['id'] . "' " . + "WHERE `command_id` = '" . $value . "'"; + $this->dbConnection->query($query); } catch (\PDOException $e) { throw new RuntimeException('Cannot update connector'); } @@ -213,10 +213,10 @@ public function read($id) $connector = $result->fetchRow(); - $connector['id'] = (int) $connector['id']; - $connector['enabled'] = (boolean) $connector['enabled']; - $connector['created'] = (int) $connector['created']; - $connector['modified'] = (int) $connector['modified']; + $connector['id'] = (int)$connector['id']; + $connector['enabled'] = (boolean)$connector['enabled']; + $connector['created'] = (int)$connector['created']; + $connector['modified'] = (int)$connector['modified']; $connector['command_id'] = array(); $DBRESULT = $this->dbConnection->query("SELECT command_id FROM command WHERE connector_id = '$id'"); @@ -291,7 +291,7 @@ public function update($id, $connector = array()) } catch (\PDOException $e) { throw new RuntimeException('Cannot update connector'); } - + if (isset($connector["command_id"])) { foreach ($connector["command_id"] as $key => $value) { try { @@ -303,8 +303,8 @@ public function update($id, $connector = array()) } } } - - + + return $this; } @@ -393,10 +393,10 @@ public function getList($onlyEnabled = true, $page = false, $perPage = 30, $used } $connectors = array(); while ($connector = $connectorsResult->fetchRow()) { - $connector['id'] = (int) $connector['id']; - $connector['enabled'] = (boolean) $connector['enabled']; - $connector['created'] = (int) $connector['created']; - $connector['modified'] = (int) $connector['modified']; + $connector['id'] = (int)$connector['id']; + $connector['enabled'] = (boolean)$connector['enabled']; + $connector['created'] = (int)$connector['created']; + $connector['modified'] = (int)$connector['modified']; $connectors[] = $connector; } return $connectors; @@ -501,7 +501,7 @@ public function isNameAvailable($name, $connectorId = null) 'SELECT `id` FROM `connector` WHERE `id` = ? AND `name` = ? LIMIT 1', array($connectorId, $name) ); - if ((boolean) $existsResult->fetchRow()) { + if ((boolean)$existsResult->fetchRow()) { return true; } } @@ -516,9 +516,9 @@ public function isNameAvailable($name, $connectorId = null) 'Cannot verify if connector name already in use; Query not valid; Check the database schema' ); } - return !((boolean) $existsResult->fetchRow()); + return !((boolean)$existsResult->fetchRow()); } - + /** * * @param integer $field @@ -541,12 +541,12 @@ public static function getDefaultValuesParameters($field) $parameters['externalObject']['name'] = 'command_name'; $parameters['externalObject']['comparator'] = 'command_id'; break; - + } - + return $parameters; } - + /** * * @param array $values @@ -555,7 +555,7 @@ public static function getDefaultValuesParameters($field) public function getObjectForSelect2($values = array(), $options = array()) { $items = array(); - + $explodedValues = implode(',', $values); if (empty($explodedValues)) { $explodedValues = "''"; @@ -566,7 +566,7 @@ public function getObjectForSelect2($values = array(), $options = array()) . "FROM connector " . "WHERE id IN (" . $explodedValues . ") " . "ORDER BY name "; - + $resRetrieval = $this->db->query($query); while ($row = $resRetrieval->fetchRow()) { $items[] = array( diff --git a/www/class/centreonContactgroup.class.php b/www/class/centreonContactgroup.class.php index 7f8dc206c71..268855b2776 100644 --- a/www/class/centreonContactgroup.class.php +++ b/www/class/centreonContactgroup.class.php @@ -120,7 +120,8 @@ public function getLdapContactgroups($filter = '') foreach ($cg_ldap as $cg_name) { if (false === array_search($cg_name . " (LDAP : " . $ldaprow['ar_name'] . ")", $cgs) && - preg_match('/' . $filter . '/i', $cg_name)) { + preg_match('/' . $filter . '/i', $cg_name) + ) { $cgs["[" . $ldaprow['ar_id'] . "]" . $cg_name] = $this->formatLdapContactgroupName( $cg_name, $ldaprow['ar_name'] @@ -176,7 +177,7 @@ public function insertLdapGroup($cg_name) (cg_name, cg_alias, cg_activate, cg_type, cg_ldap_dn, ar_id) VALUES ('" . $this->db->escape($cg_name) . "', '" . $this->db->escape($cg_name) . "', '1', 'ldap', '" . - $this->db->escape($ldap_dn) . "', " . CentreonDB::escape($ar_id) . ")"; + $this->db->escape($ldap_dn) . "', " . CentreonDB::escape($ar_id) . ")"; try { $res = $this->db->query($query); } catch (\PDOException $e) { @@ -211,7 +212,7 @@ public function syncWithLdap() $ldapres = $this->db->query($query); $msg = array(); - + /* * Connect to LDAP Server */ @@ -263,13 +264,13 @@ public function syncWithLdap() $this->db->query($queryDeleteRelation); $contact = ''; - foreach ($members as $member){ - $contact = $this->db->quote($member) .','; + foreach ($members as $member) { + $contact = $this->db->quote($member) . ','; } $contact = rtrim($contact, ","); $queryContact = "SELECT contact_id FROM contact - WHERE contact_ldap_dn IN ('" .$contact . "')"; + WHERE contact_ldap_dn IN ('" . $contact . "')"; try { $resContact = $this->db->query($queryContact); } catch (\PDOException $e) { @@ -283,7 +284,7 @@ public function syncWithLdap() try { $this->db->query($queryAddRelation); } catch (\PDOException $e) { - $msg[] ="Error insert relation between contactgroup " . $row['cg_id'] . + $msg[] = "Error insert relation between contactgroup " . $row['cg_id'] . " and contact " . $rowContact['contact_id']; } } @@ -297,7 +298,7 @@ public function syncWithLdap() } return $msg; } - + /** * Get contact group name from contact group id * @@ -316,7 +317,7 @@ public function getNameFromCgId($cgId) throw Exception('No contact group name found'); } } - + /** * Verified if ldap contactgroup as not the same name of a Centreon contactgroup * @@ -337,7 +338,7 @@ public static function verifiedExists($listCgs) /* Query test if exists */ $query = "SELECT COUNT(*) as nb FROM contactgroup - WHERE cg_name = '" . $pearDB->escape($cg_name) ."' AND cg_type != 'ldap' "; + WHERE cg_name = '" . $pearDB->escape($cg_name) . "' AND cg_type != 'ldap' "; try { $res = $pearDB->query($query); } catch (\PDOException $e) { @@ -351,7 +352,7 @@ public static function verifiedExists($listCgs) } return true; } - + /** * * @param integer $field @@ -387,7 +388,7 @@ public static function getDefaultValuesParameters($field) $parameters['relationObject']['comparator'] = 'cg_cg_id'; break; } - + return $parameters; } @@ -405,7 +406,7 @@ public function getObjectForSelect2($values = array(), $options = array()) if (!$centreon->user->access->admin) { $cgAcl = $centreon->user->access->getContactGroupAclConf( array( - 'fields' => array('cg_id'), + 'fields' => array('cg_id'), 'get_row' => 'cg_id', 'keys' => array('cg_id'), 'conditions' => array( diff --git a/www/class/centreonDBStatement.class.php b/www/class/centreonDBStatement.class.php index 7849da67ed7..73230d88137 100644 --- a/www/class/centreonDBStatement.class.php +++ b/www/class/centreonDBStatement.class.php @@ -42,7 +42,8 @@ class CentreonDBStatement extends \PDOStatement public $fetchAll; - protected function __construct($dbh) { + protected function __construct($dbh) + { $this->dbh = $dbh; $this->fetchAll = null; } @@ -51,7 +52,7 @@ public function fetch() { if (is_null($this->fetchAll)) { return parent::fetch(); - } else if (count($this->fetchAll) <= 0) { + } elseif (count($this->fetchAll) <= 0) { return false; } else { return array_shift($this->fetchAll); diff --git a/www/class/centreonDuration.class.php b/www/class/centreonDuration.class.php index 6525450aad0..93b7f2a69ca 100644 --- a/www/class/centreonDuration.class.php +++ b/www/class/centreonDuration.class.php @@ -1,4 +1,5 @@ 31556926, - 'M' => 2629743, - 'w' => 604800, - 'd' => 86400, - 'h' => 3600, - 'm' => 60, - 's' => 1 - ); + $periods = array( + 'y' => 31556926, + 'M' => 2629743, + 'w' => 604800, + 'd' => 86400, + 'h' => 3600, + 'm' => 60, + 's' => 1 + ); } - + // Loop - $seconds = (int) $seconds; + $seconds = (int)$seconds; foreach ($periods as $period => $value) { $count = floor($seconds / $value); - + if ($count == 0) { continue; } - + $values[$period] = $count; $seconds = $seconds % $value; } - + // Return if (empty($values)) { $values = null; } return $values; } - + public static function array2string($duration) { if (!is_array($duration)) { @@ -106,38 +107,38 @@ public static function toString($duration, $periods = null) } return DurationHoursMinutes::array2string($duration); } - + public static function int2array($seconds, $periods = null) { // Define time periods if (!is_array($periods)) { - $periods = array ( - 'h' => 3600, - 'm' => 60, - 's' => 1 - ); + $periods = array( + 'h' => 3600, + 'm' => 60, + 's' => 1 + ); } - + // Loop - $seconds = (int) $seconds; + $seconds = (int)$seconds; foreach ($periods as $period => $value) { $count = floor($seconds / $value); if ($count == 0) { continue; } - + $values[$period] = $count; $seconds = $seconds % $value; } - + // Return if (empty($values)) { $values = null; } - + return $values; } - + public static function array2string($duration) { if (!is_array($duration)) { @@ -145,7 +146,7 @@ public static function array2string($duration) } foreach ($duration as $key => $value) { - $array[] = $value."".$key; + $array[] = $value . "" . $key; } unset($segment); $str = implode(' ', $array); diff --git a/www/class/centreonExternalCommand.class.php b/www/class/centreonExternalCommand.class.php index fba5dcfb2b7..5f2698c16ff 100644 --- a/www/class/centreonExternalCommand.class.php +++ b/www/class/centreonExternalCommand.class.php @@ -265,11 +265,13 @@ public function getPollerID($host = null) * Check if $host is an id or a name */ if (preg_match("/^[0-9]*$/", $host)) { - $DBRESULT = CentreonDBInstance::getMonInstance()->query("SELECT instance_id FROM hosts WHERE hosts.host_id = '" . - CentreonDB::escape($host) . "' AND hosts.enabled = '1'"); + $query = "SELECT instance_id FROM hosts " . + "WHERE hosts.host_id = '" . CentreonDB::escape($host) . "' AND hosts.enabled = '1'"; + $DBRESULT = CentreonDBInstance::getMonInstance()->query($query); } else { - $DBRESULT = CentreonDBInstance::getMonInstance()->query("SELECT instance_id FROM hosts WHERE hosts.name = '" . - CentreonDB::escape($host) . "' AND hosts.enabled = '1' LIMIT 1"); + $query = "SELECT instance_id FROM hosts " . + "WHERE hosts.name = '" . CentreonDB::escape($host) . "' AND hosts.enabled = '1' LIMIT 1"; + $DBRESULT = CentreonDBInstance::getMonInstance()->query($query); } $row = $DBRESULT->fetchRow(); if (isset($row['instance_id'])) { @@ -372,7 +374,7 @@ public function addHostDowntime( * Get poller for this host */ $poller_id = $this->getPollerID($host); - + /* * Send command */ diff --git a/www/class/centreonGraph.class.php b/www/class/centreonGraph.class.php index b8611a08901..b39f898fe6b 100644 --- a/www/class/centreonGraph.class.php +++ b/www/class/centreonGraph.class.php @@ -49,6 +49,7 @@ * Class for XML/Ajax request * */ + class CentreonGraph { /** @@ -134,7 +135,7 @@ public function __construct($user_id, $index = null, $debug = 0, $compress = nul } (!isset($compress)) ? $this->compress = 1 : $this->compress = $compress; - + /* * User ID / Contact ID */ @@ -145,14 +146,14 @@ public function __construct($user_id, $index = null, $debug = 0, $compress = nul /* * Enable Database Connexions */ - $this->DB = new CentreonDB(); - $this->DBC = new CentreonDB("centstorage"); + $this->DB = new CentreonDB(); + $this->DBC = new CentreonDB("centstorage"); /* * Init Objects */ - $this->hostObj = new CentreonHost($this->DB); - $this->serviceObj = new CentreonService($this->DB); + $this->hostObj = new CentreonHost($this->DB); + $this->serviceObj = new CentreonService($this->DB); /* * Timezone management @@ -176,14 +177,14 @@ public function __construct($user_id, $index = null, $debug = 0, $compress = nul $this->getIndexData(); - $this->filename = $this->indexData["host_name"]. "-".$this->indexData["service_description"]; + $this->filename = $this->indexData["host_name"] . "-" . $this->indexData["service_description"]; $this->filename = str_replace(array("/", "\\"), array("-", "-"), $this->filename); $this->templateInformations = array(); $this->metricsEnabled = array(); $this->rmetrics = array(); $this->vmetrics = array(); - $this->mpointer = array(0,0); + $this->mpointer = array(0, 0); $this->mlist = array(); $this->vname = array(); $this->metrics = array(); @@ -266,25 +267,25 @@ public function __construct($user_id, $index = null, $debug = 0, $compress = nul protected function cleanupDsName($dsname, $reverse = false) { if ($reverse === true) { - $newDsName = str_replace(array("slash_", "bslash_", "pct_", "\\#"), array("/","\\", "%", "#"), $dsname); + $newDsName = str_replace(array("slash_", "bslash_", "pct_", "\\#"), array("/", "\\", "%", "#"), $dsname); } else { - $newDsName = str_replace(array("/","\\", "%", "#"), array("slash_", "bslash_", "pct_", "\\#"), $dsname); + $newDsName = str_replace(array("/", "\\", "%", "#"), array("slash_", "bslash_", "pct_", "\\#"), $dsname); } $newDsName = preg_replace("/[^\w\-_]/", "-", $newDsName); return $newDsName; } /** - * Clean up ds name in Legend - * - * @param string $dsname - * @param bool $reverse set to true if we want to retrieve the original string to display - * @return string - */ + * Clean up ds name in Legend + * + * @param string $dsname + * @param bool $reverse set to true if we want to retrieve the original string to display + * @return string + */ protected function cleanupDsNameForLegend($dsname, $reverse = false) { $newDsName = str_replace( - array("slash_", "bslash_", "pct_", "'", "\\"), + array("slash_", "bslash_", "pct_", "'", "\\"), array("/", "\\", "%", " ", "\\\\"), $dsname ); @@ -377,11 +378,10 @@ public function init() } } if ((isset($this->templateInformations["lower_limit"]) && - $this->templateInformations["lower_limit"] != null) || - (isset( - $this->templateInformations["upper_limit"] - ) && $this->templateInformations["upper_limit"] != null) - ) { + $this->templateInformations["lower_limit"] != null) || + (isset($this->templateInformations["upper_limit"]) && + $this->templateInformations["upper_limit"] != null) + ) { $this->setRRDOption("rigid"); $this->setRRDOption("alt-autoscale-max"); } @@ -402,7 +402,7 @@ public function init() */ private static function quote($elem) { - return "'".$elem."'"; + return "'" . $elem . "'"; } /** @@ -412,7 +412,7 @@ private static function quote($elem) */ private static function vquote($elem) { - return "'".substr($elem, 1, strlen($elem)-1)."'"; + return "'" . substr($elem, 1, strlen($elem) - 1) . "'"; } @@ -446,18 +446,20 @@ public function initCurveList() } /* Create selector for reals metrics */ if (count($l_rmEnabled)) { - $l_rselector = "metric_id IN (" . implode( - ",", - array_map(array("CentreonGraph", "quote"), $l_rmEnabled) - ) . ")"; + $l_rselector = + "metric_id IN (" . implode( + ",", + array_map(array("CentreonGraph", "quote"), $l_rmEnabled) + ) . ")"; $this->log("initCurveList with selector [real]= " . $l_rselector); } if (count($l_vmEnabled)) { - $l_vselector = "vmetric_id IN (" . implode( - ",", - array_map(array("CentreonGraph", "vquote"), $l_vmEnabled) - ) . ")"; - $this->log("initCurveList with selector [virtual]= ". $l_vselector); + $l_vselector = + "vmetric_id IN (" . implode( + ",", + array_map(array("CentreonGraph", "vquote"), $l_vmEnabled) + ) . ")"; + $this->log("initCurveList with selector [virtual]= " . $l_vselector); } } else { /* Full Image */ @@ -508,7 +510,7 @@ public function initCurveList() */ if ($this->CheckDBAvailability($metric["metric_id"])) { - $this->log("found metric ".$metric["metric_id"]); + $this->log("found metric " . $metric["metric_id"]); /* * List of id metrics for rrdcached @@ -517,11 +519,12 @@ public function initCurveList() if (isset($this->metricsEnabled) && count($this->metricsEnabled) && - !in_array($metric["metric_id"], $this->metricsEnabled)) { + !in_array($metric["metric_id"], $this->metricsEnabled) + ) { if (isset($metric["need"])) { $metric["need"] = 1; /* Hidden Metric */ } else { - $this->log("metric disabled ".$metric["metric_id"]); + $this->log("metric disabled " . $metric["metric_id"]); continue; } } @@ -546,20 +549,22 @@ public function initCurveList() $ds_data_regular = null; foreach ($components_ds_cache as $ds_val) { /* Prepare pattern for metrics */ - $metricPattern = '/^' . preg_quote($ds_val['ds_name'], '/') . '$/i'; + $metricPattern = '/^' . preg_quote($ds_val['ds_name'], '/') . '$/i'; $metricPattern = str_replace('\\*', '.*', $metricPattern); # Check associated if (($ds_val['host_id'] == $metric['host_id'] || $ds_val['host_id'] == '') && ($ds_val['service_id'] == $metric['service_id'] || $ds_val['service_id'] == '') && - preg_match($metricPattern, $metric['metric_name'])) { + preg_match($metricPattern, $metric['metric_name']) + ) { $ds_data_associated = $ds_val; break; } /* Check regular */ if (is_null($ds_data_regular) && - preg_match('/^' . preg_quote($ds_val['ds_name'], '/') . '$/i', $metric["metric_name"])) { + preg_match('/^' . preg_quote($ds_val['ds_name'], '/') . '$/i', $metric["metric_name"]) + ) { $ds_data_regular = $ds_val; } } @@ -574,8 +579,8 @@ public function initCurveList() if (!isset($ds_data) && !$ds_data) { /** ******************************************* - * Get default info in default template - */ + * Get default info in default template + */ $DBRESULT3 = $this->DB->query( "SELECT ds_min, ds_max, ds_minmax_int, ds_last, ds_average, ds_total, ds_tickness, ds_color_line_mode, ds_color_line @@ -601,7 +606,7 @@ public function initCurveList() */ foreach ($ds_data as $key => $ds_d) { if ($key == "ds_transparency") { - $transparency = dechex(255-($ds_d*255)/100); + $transparency = dechex(255 - ($ds_d * 255) / 100); if (strlen($transparency) == 1) { $transparency = "0" . $transparency; } @@ -630,7 +635,7 @@ public function initCurveList() ); } else { $this->metrics[$metric["metric_id"]]["legend"] = ( - isset($ds_data["ds_name"]) ? $ds_data["ds_name"] : "" + isset($ds_data["ds_name"]) ? $ds_data["ds_name"] : "" ); } $this->metrics[$metric["metric_id"]]["legend"] = str_replace( @@ -643,7 +648,7 @@ public function initCurveList() } if ($metric["unit_name"] != "") { - $this->metrics[$metric["metric_id"]]["legend"] .= " (".$metric["unit_name"].")"; + $this->metrics[$metric["metric_id"]]["legend"] .= " (" . $metric["unit_name"] . ")"; } /* Checks whether or not string must be decoded */ @@ -652,24 +657,28 @@ public function initCurveList() $this->metrics[$metric["metric_id"]]["legend"] = utf8_decode($lgd); } - $this->metrics[$metric["metric_id"]]["legend_len"] = mb_strlen( - $this->metrics[$metric["metric_id"]]["legend"], - 'UTF-8' - ) - $escaped_chars_nb; + $this->metrics[$metric["metric_id"]]["legend_len"] = + mb_strlen($this->metrics[$metric["metric_id"]]["legend"], 'UTF-8') - $escaped_chars_nb; $this->metrics[$metric["metric_id"]]["stack"] = ( - isset($ds_data["ds_stack"]) && $ds_data["ds_stack"] ? $ds_data["ds_stack"] : 0 + isset($ds_data["ds_stack"]) && $ds_data["ds_stack"] ? $ds_data["ds_stack"] : 0 ); if ($this->onecurve) { - if (isset($metric["warn"]) && $metric["warn"] != 0 && - $metric["warn"] != self::ENGINE_LOW_INFINITE && $metric["warn"] != self::ENGINE_HIGH_INFINITE) { + if (isset($metric["warn"]) && + $metric["warn"] != 0 && + $metric["warn"] != self::ENGINE_LOW_INFINITE && + $metric["warn"] != self::ENGINE_HIGH_INFINITE + ) { $this->metrics[$metric["metric_id"]]["warn"] = $metric["warn"]; if (!isset($ds_data["ds_color_area_warn"]) || empty($ds_data["ds_color_area_warn"])) { $this->metrics[$metric["metric_id"]]["ds_color_area_warn"] = $this->generalOpt["color_warning"]; } } - if (isset($metric["crit"]) && $metric["crit"] != 0 && - $metric["crit"] != self::ENGINE_LOW_INFINITE && $metric["crit"] != self::ENGINE_HIGH_INFINITE) { + if (isset($metric["crit"]) && + $metric["crit"] != 0 && + $metric["crit"] != self::ENGINE_LOW_INFINITE && + $metric["crit"] != self::ENGINE_HIGH_INFINITE + ) { $this->metrics[$metric["metric_id"]]["crit"] = $metric["crit"]; if (!isset($ds_data["ds_color_area_crit"]) || empty($ds_data["ds_color_area_crit"])) { $this->metrics[$metric["metric_id"]]["ds_color_area_crit"] = @@ -682,7 +691,7 @@ public function initCurveList() $this->metrics[$metric["metric_id"]]["need"] = $metric["need"]; } else { $this->metrics[$metric["metric_id"]]["ds_order"] = ( - isset($ds_data["ds_order"]) && $ds_data["ds_order"] ? $ds_data["ds_order"] : 0 + isset($ds_data["ds_order"]) && $ds_data["ds_order"] ? $ds_data["ds_order"] : 0 ); } } else { @@ -736,7 +745,8 @@ public function initCurveList() isset($this->RRDoptions["lower-limit"]) && $this->RRDoptions["lower-limit"] && isset($this->RRDoptions["upper-limit"]) && - $this->RRDoptions["upper-limit"]) { + $this->RRDoptions["upper-limit"] + ) { $this->switchRRDLimitOption( $this->RRDoptions["lower-limit"], $this->RRDoptions["upper-limit"] @@ -756,7 +766,8 @@ public function initCurveList() $this->addArgument("DEF:v" . $cpt . "=" . $this->dbPath . $key . ".rrd:value:AVERAGE"); } if ($this->onecurve && isset($tm["warn"]) && $tm["warn"] != 0 && - isset($tm["crit"]) && $tm["crit"] != 0) { + isset($tm["crit"]) && $tm["crit"] != 0 + ) { $l_CMP = "," . $this->getCmpOperator($tm) . ","; $this->addArgument( "CDEF:ok" . $cpt . "=v" . $cpt . "," . $tm["warn"] . $l_CMP . $tm["warn"] . ",v" . @@ -772,7 +783,7 @@ public function initCurveList() ); $this->areaNb = $cpt; } - $this->vname[$tm["metric"]] = "v".$cpt; + $this->vname[$tm["metric"]] = "v" . $cpt; $cpt++; } if (!isset($tm["virtual"])) { @@ -788,7 +799,7 @@ public function initCurveList() $rpn = $this->subsRPN($tm["rpn_function"], $this->vname); $arg = $deftype[$tm["def_type"]] . ":" . $this->vname[$tm["metric"]] . "=" . $rpn; if (isset($tm["ds_invert"]) && $tm["ds_invert"]) { - $this->addArgument($arg.",-1,*"); + $this->addArgument($arg . ",-1,*"); /* Switching RRD options lower-limit & upper-limit */ if ($this->onecurve) { $this->switchRRDLimitOption($this->RRDoptions["lower-limit"], $this->RRDoptions["upper-limit"]); @@ -804,7 +815,7 @@ public function initCurveList() } if ($this->onecurve && isset($tm["warn"]) && $tm["warn"] != 0 && isset($tm["crit"]) && $tm["crit"] != 0) { $l_CMP = "," . $this->getCmpOperator($tm) . ","; - $nb=substr($this->vname[$tm["metric"]], 2, strlen($this->vname[$tm["metric"]])-2); + $nb = substr($this->vname[$tm["metric"]], 2, strlen($this->vname[$tm["metric"]]) - 2); $this->addArgument( "CDEF:ok" . $nb . "=" . $this->vname[$tm["metric"]] . "," . $tm["warn"] . $l_CMP . $tm["warn"] . "," . $this->vname[$tm["metric"]] . ",IF" @@ -827,14 +838,26 @@ public function initCurveList() */ public function createLegend() { - $currentColors = array("Min"=>"#19EE11", "Max"=>"#F91E05", "Average"=>"#2AD1D4", - "Last_Min"=>"#2AD1D4", "Last_5_Min"=>"#13EB3A", "Last_15_Min"=>"#F8C706", - "Last_Hour"=>"#F91D05", "Up"=>"#19EE11", "Down"=>"#F91E05", - "Unreach"=>"#2AD1D4", "Ok"=>"#13EB3A", "Warn"=>"#F8C706", - "Crit"=>"#F91D05", "Unk"=>"#2AD1D4", "In_Use"=>"#13EB3A", - "Max_Used"=>"#F91D05", "Total_Available"=>"#2AD1D4" - ); - + $currentColors = array( + "Min" => "#19EE11", + "Max" => "#F91E05", + "Average" => "#2AD1D4", + "Last_Min" => "#2AD1D4", + "Last_5_Min" => "#13EB3A", + "Last_15_Min" => "#F8C706", + "Last_Hour" => "#F91D05", + "Up" => "#19EE11", + "Down" => "#F91E05", + "Unreach" => "#2AD1D4", + "Ok" => "#13EB3A", + "Warn" => "#F8C706", + "Crit" => "#F91D05", + "Unk" => "#2AD1D4", + "In_Use" => "#13EB3A", + "Max_Used" => "#F91D05", + "Total_Available" => "#2AD1D4" + ); + $cpt = 0; $rpn_values = ""; $rpn_expr = ""; @@ -842,7 +865,7 @@ public function createLegend() if (in_array($tm['metric'], $currentColors)) { $tm["ds_color_line"] = $currentColors[$tm['metric']]; } - + if (isset($tm["need"]) && $tm["need"] == 1) { continue; } @@ -851,10 +874,11 @@ public function createLegend() } else { if ((isset($tm["ds_filled"]) && $tm["ds_filled"]) || (isset($tm["ds_stack"]) && $tm["ds_stack"])) { if ($this->onecurve && isset($tm["warn"]) && - $tm["warn"] != 0 && isset($tm["crit"]) && $tm["crit"] != 0) { - $nb=$cpt; + $tm["warn"] != 0 && isset($tm["crit"]) && $tm["crit"] != 0 + ) { + $nb = $cpt; if (isset($tm["virtual"])) { - $nb=substr($this->vname[$tm["metric"]], 2, strlen($this->vname[$tm["metric"]]) - 2); + $nb = substr($this->vname[$tm["metric"]], 2, strlen($this->vname[$tm["metric"]]) - 2); } if (isset($this->areaNb)) { $nb = $this->areaNb; @@ -869,19 +893,20 @@ public function createLegend() $arg .= "00"; } if ($cpt != 0 && $tm["ds_stack"]) { - $arg .= "::STACK CDEF:vc" . $cpt . "=" . $rpn_values.$this->vname[$tm["metric"]] . $rpn_expr; + $arg .= "::STACK CDEF:vc" . $cpt . "=" . $rpn_values . $this->vname[$tm["metric"]] . $rpn_expr; } $rpn_values .= $this->vname[$tm["metric"]] . ",UN,0," . $this->vname[$tm["metric"]] . ",IF,"; $rpn_expr .= ",+"; $this->addArgument($arg); if ($this->onecurve && isset($tm["warn"]) && - $tm["warn"] != 0 && isset($tm["crit"]) && $tm["crit"] != 0) { + $tm["warn"] != 0 && isset($tm["crit"]) && $tm["crit"] != 0 + ) { $this->addArgument("AREA:ow" . $nb . $tm["ds_color_area_warn"] . "CF::STACK"); $this->addArgument("AREA:oc" . $nb . $tm["ds_color_area_crit"] . "CF::STACK"); } } - + if (!isset($tm["ds_stack"]) || !$tm["ds_stack"] || $cpt == 0) { $arg = "LINE" . $tm["ds_tickness"] . ":" . $this->vname[$tm["metric"]]; } else { @@ -904,10 +929,15 @@ public function createLegend() $vdefs = ""; $prints = ""; - - - foreach (array("last" => "LAST", "min" => "MINIMUM", "max" => "MAXIMUM", - "average" => "AVERAGE", "total" => "TOTAL") as $name => $cf) { + + + foreach (array( + "last" => "LAST", + "min" => "MINIMUM", + "max" => "MAXIMUM", + "average" => "AVERAGE", + "total" => "TOTAL" + ) as $name => $cf) { if (!$tm["ds_" . $name]) { continue; } @@ -915,12 +945,13 @@ public function createLegend() $vdefs .= "VDEF:" . $this->vname[$tm["metric"]] . $dispname . "=" . $this->vname[$tm["metric"]] . "," . $cf . " "; if (($name == "min" || $name == "max") && - (isset($tm['ds_minmax_int']) && $tm['ds_minmax_int'])) { + (isset($tm['ds_minmax_int']) && $tm['ds_minmax_int']) + ) { $displayformat = "%7.0lf"; } else { $displayformat = "%7.2lf"; } - $prints .= "GPRINT:" . $this->vname[$tm["metric"]] . $dispname.":\"" . + $prints .= "GPRINT:" . $this->vname[$tm["metric"]] . $dispname . ":\"" . $dispname . "\:" . $displayformat . ($this->gprintScaleOption) . "\" "; } $this->addArgument($vdefs); @@ -975,39 +1006,39 @@ private function humanReadable($l_value = null, $l_unit = null) } else { $l_base = 1000; } - + $l_px = array( "8" => array( "1000" => "Y", - "1024" =>"Yi" + "1024" => "Yi" ), "7" => array( "1000" => "Z", - "1024" =>"Zi" + "1024" => "Zi" ), "6" => array( "1000" => "E", - "1024" =>"Ei" + "1024" => "Ei" ), "5" => array( "1000" => "P", - "1024" =>"Pi" + "1024" => "Pi" ), "4" => array( "1000" => "T", - "1024" =>"Ti" + "1024" => "Ti" ), "3" => array( "1000" => "G", - "1024" =>"Gi" + "1024" => "Gi" ), "2" => array( "1000" => "M", - "1024" =>"Mi" + "1024" => "Mi" ), "1" => array( "1000" => "K", - "1024" =>"Ki" + "1024" => "Ki" ) ); $l_sign = ""; @@ -1021,7 +1052,7 @@ private function humanReadable($l_value = null, $l_unit = null) $l_cpx++; } $l_upx = $l_px[$l_cpx][$l_base]; - return $l_sign.sprintf("%.2f", $l_value).$l_upx.$l_unit; + return $l_sign . sprintf("%.2f", $l_value) . $l_upx . $l_unit; } return sprintf("%.2f", $l_value) . $l_unit; @@ -1039,7 +1070,7 @@ private function getDefaultGraphTemplate() return; } else { $command_id = getMyServiceField($this->indexData["service_id"], "command_command_id"); - $DBRESULT = $this->DB->query("SELECT graph_id FROM command WHERE `command_id` = '".$command_id."'"); + $DBRESULT = $this->DB->query("SELECT graph_id FROM command WHERE `command_id` = '" . $command_id . "'"); if ($DBRESULT->rowCount()) { $data = $DBRESULT->fetchRow(); if ($data["graph_id"] != 0) { @@ -1072,7 +1103,7 @@ public function setTemplate($template_id = null) $template_id = htmlentities($template_id, ENT_QUOTES, "UTF-8"); } - if (!isset($template_id)|| !$template_id) { + if (!isset($template_id) || !$template_id) { if ($this->indexData["host_name"] != "_Module_Meta") { /* * graph is based on real host/service @@ -1149,7 +1180,7 @@ private function getIndexData() $svc_instance = $this->index; } - $this->log("index_data for ".$svc_instance); + $this->log("index_data for " . $svc_instance); $DBRESULT = $this->DBC->query("SELECT * FROM index_data WHERE id = '" . $svc_instance . "' LIMIT 1"); if (!$DBRESULT->rowCount()) { $this->indexData = 0; @@ -1171,7 +1202,7 @@ private function getIndexData() $DBRESULT->closeCursor(); if (isset($this->metricsEnabled)) { - $metrictitle = " metric ".$this->metrics[$this->metricsEnabled]["metric_name"]; + $metrictitle = " metric " . $this->metrics[$this->metricsEnabled]["metric_name"]; } else { $metrictitle = ""; } @@ -1185,9 +1216,9 @@ private function getIndexData() if (!mb_detect_encoding($hname, 'UTF-8', true)) { $hname = utf8_encode($hname); } - $this->setRRDOption("title", _("Graph") . " " . $hname . '/' . $sdesc . $metrictitle); + $this->setRRDOption("title", _("Graph") . " " . $hname . '/' . $sdesc . $metrictitle); } else { - $this->setRRDOption("title", _("Graph")." ".$this->indexData["service_description"].$metrictitle); + $this->setRRDOption("title", _("Graph") . " " . $this->indexData["service_description"] . $metrictitle); } } @@ -1206,8 +1237,8 @@ public function addArgument($arg) */ public static function displayError() { - $image = imagecreate(250, 100); - $fond = imagecolorallocate($image, 0xEF, 0xF2, 0xFB); + $image = imagecreate(250, 100); + $fond = imagecolorallocate($image, 0xEF, 0xF2, 0xFB); $textcolor = imagecolorallocate($image, 0, 0, 255); // imagestring($image, 5, 0, 0, "Session: ".$_GET['session_id']."svc_id: ".$_GET["index"], $textcolor); @@ -1250,8 +1281,8 @@ public function setColor($name, $value) */ public function setRRDOption($name, $value = null) { - if (strpos($value, " ")!==false) { - $value = "'".$value."'"; + if (strpos($value, " ") !== false) { + $value = "'" . $value . "'"; } $this->RRDoptions[$name] = $value; } @@ -1321,10 +1352,10 @@ public function setHeaders($encoding, $content_length = false) { header("Content-Type: image/png"); header("Content-Transfer-Encoding: binary"); - header("Content-Disposition: attachment; filename=\"".$this->filename.".png\";"); + header("Content-Disposition: attachment; filename=\"" . $this->filename . ".png\";"); if ($this->compress && $encoding) { - header('Content-Encoding: '.$encoding); + header('Content-Encoding: ' . $encoding); } if ($content_length != false) { header("Content-Length: " . $content_length); @@ -1349,8 +1380,9 @@ public function displayImageFlow() if (isset($this->RRDoptions["end"]) && isset($this->RRDoptions["start"])) { if ($this->RRDoptions["end"] - $this->RRDoptions["start"] > 2160000 - && $this->RRDoptions["end"] - $this->RRDoptions["start"] < 12960000) { - if ($this->RRDoptions["end"] - $this->RRDoptions["start"] < 10368000 - (86400*7)) { + && $this->RRDoptions["end"] - $this->RRDoptions["start"] < 12960000 + ) { + if ($this->RRDoptions["end"] - $this->RRDoptions["start"] < 10368000 - (86400 * 7)) { $this->setRRDOption("x-grid", "DAY:1:DAY:7:DAY:7:0:%d/%m"); } else { $this->setRRDOption("x-grid", "DAY:7:DAY:7:DAY:14:0:%d/%m"); @@ -1359,37 +1391,37 @@ public function displayImageFlow() } foreach ($this->RRDoptions as $key => $value) { - $commandLine .= "--".$key; + $commandLine .= "--" . $key; if (isset($value)) { - $commandLine .= "=".$value; + $commandLine .= "=" . $value; } $commandLine .= " "; } foreach ($this->colors as $key => $value) { - $commandLine .= "--color ".$key.$value." "; + $commandLine .= "--color " . $key . $value . " "; } foreach ($this->fonts as $key => $value) { - $commandLine .= "--font ".$key.$value." "; + $commandLine .= "--font " . $key . $value . " "; } /* * ... order does matter! */ if (isset($this->options["comment_time"]) && $this->options["comment_time"] == true) { - $rrd_time = addslashes($this->GMT->getDate("Y\/m\/d G:i", $this->RRDoptions["start"])); + $rrd_time = addslashes($this->GMT->getDate("Y\/m\/d G:i", $this->RRDoptions["start"])); $rrd_time = str_replace(":", "\:", $rrd_time); - $rrd_time2 = addslashes($this->GMT->getDate("Y\/m\/d G:i", $this->RRDoptions["end"])) ; + $rrd_time2 = addslashes($this->GMT->getDate("Y\/m\/d G:i", $this->RRDoptions["end"])); $rrd_time2 = str_replace(":", "\:", $rrd_time2); $commandLine .= " COMMENT:\" From $rrd_time to $rrd_time2 \\c\" "; } foreach ($this->arguments as $arg) { - $commandLine .= " ".$arg." "; + $commandLine .= " " . $arg . " "; } $gmt_export = ""; $commandLine = preg_replace("/(\\\$|`)/", "", $commandLine); $timezone = $this->GMT->getMyTimezone(); if (!empty($timezone)) { - $gmt_export = "export TZ='".$timezone."'; " ; + $gmt_export = "export TZ='" . $timezone . "'; "; } $this->log($commandLine); /* @@ -1397,15 +1429,15 @@ public function displayImageFlow() */ if (!$this->checkcurve) { if (is_writable($this->generalOpt['debug_path'])) { - $stderr = array('file', $this->generalOpt['debug_path'].'/rrdtool.log', 'a'); + $stderr = array('file', $this->generalOpt['debug_path'] . '/rrdtool.log', 'a'); } else { $stderr = array('pipe', 'a'); } $descriptorspec = array( - 0 => array("pipe", "r"), // stdin est un pipe processus va lire - 1 => array("pipe", "w"), // stdout est un pipe processus va ecrire - 2 => $stderr // stderr est un fichier - ); + 0 => array("pipe", "r"), // stdin est un pipe processus va lire + 1 => array("pipe", "w"), // stdout est un pipe processus va ecrire + 2 => $stderr // stderr est un fichier + ); $process = proc_open( $gmt_export . $this->generalOpt["rrdtool_path_bin"] . " - ", @@ -1467,13 +1499,14 @@ public function getOVDColor($l_mid) $DBRESULT->closeCursor(); if (isset($l_ovd["rnd_color"]) && !empty($l_ovd["rnd_color"]) && - preg_match("/^\#[a-f0-9]{6,6}/i", $l_ovd["rnd_color"])) { + preg_match("/^\#[a-f0-9]{6,6}/i", $l_ovd["rnd_color"]) + ) { return $l_ovd["rnd_color"]; } $l_rndcolor = $this->getRandomWebColor(); // Update ods_view_details $DBRESULT = $this->DB->query( - "UPDATE `ods_view_details` SET `rnd_color` = '".$l_rndcolor."' + "UPDATE `ods_view_details` SET `rnd_color` = '" . $l_rndcolor . "' WHERE `index_id` = '" . $this->index . "' AND `metric_id` = '" . $l_mid . "' AND `contact_id` = '" . $this->user_id . "';" @@ -1490,43 +1523,218 @@ public function getOVDColor($l_mid) */ public function getRandomWebColor() { - $web_safe_colors = array('#000033', '#000066', '#000099', '#0000cc', - '#0000ff', '#003300', '#003333', '#003366', '#003399', '#0033cc', - '#0033ff', '#006600', '#006633', '#006666', '#006699', '#0066cc', - '#0066ff', '#009900', '#009933', '#009966', '#009999', '#0099cc', - '#0099ff', '#00cc00', '#00cc33', '#00cc66', '#00cc99', '#00cccc', - '#00ccff', '#00ff00', '#00ff33', '#00ff66', '#00ff99', '#00ffcc', - '#00ffff', '#330000', '#330033', '#330066', '#330099', '#3300cc', - '#3300ff', '#333300', '#333333', '#333366', '#333399', '#3333cc', - '#3333ff', '#336600', '#336633', '#336666', '#336699', '#3366cc', - '#3366ff', '#339900', '#339933', '#339966', '#339999', '#3399cc', - '#3399ff', '#33cc00', '#33cc33', '#33cc66', '#33cc99', '#33cccc', - '#33ccff', '#33ff00', '#33ff33', '#33ff66', '#33ff99', '#33ffcc', - '#33ffff', '#660000', '#660033', '#660066', '#660099', '#6600cc', - '#6600ff', '#663300', '#663333', '#663366', '#663399', '#6633cc', - '#6633ff', '#666600', '#666633', '#666666', '#666699', '#6666cc', - '#6666ff', '#669900', '#669933', '#669966', '#669999', '#6699cc', - '#6699ff', '#66cc00', '#66cc33', '#66cc66', '#66cc99', '#66cccc', - '#66ccff', '#66ff00', '#66ff33', '#66ff66', '#66ff99', '#66ffcc', - '#66ffff', '#990000', '#990033', '#990066', '#990099', '#9900cc', - '#9900ff', '#993300', '#993333', '#993366', '#993399', '#9933cc', - '#9933ff', '#996600', '#996633', '#996666', '#996699', '#9966cc', - '#9966ff', '#999900', '#999933', '#999966', '#999999', '#9999cc', - '#9999ff', '#99cc00', '#99cc33', '#99cc66', '#99cc99', '#99cccc', - '#99ccff', '#99ff00', '#99ff33', '#99ff66', '#99ff99', '#99ffcc', - '#99ffff', '#cc0000', '#cc0033', '#cc0066', '#cc0099', '#cc00cc', - '#cc00ff', '#cc3300', '#cc3333', '#cc3366', '#cc3399', '#cc33cc', - '#cc33ff', '#cc6600', '#cc6633', '#cc6666', '#cc6699', '#cc66cc', - '#cc66ff', '#cc9900', '#cc9933', '#cc9966', '#cc9999', '#cc99cc', - '#cc99ff', '#cccc00', '#cccc33', '#cccc66', '#cccc99', '#cccccc', - '#ccccff', '#ccff00', '#ccff33', '#ccff66', '#ccff99', '#ccffcc', - '#ccffff', '#ff0000', '#ff0033', '#ff0066', '#ff0099', '#ff00cc', - '#ff00ff', '#ff3300', '#ff3333', '#ff3366', '#ff3399', '#ff33cc', - '#ff33ff', '#ff6600', '#ff6633', '#ff6666', '#ff6699', '#ff66cc', - '#ff66ff', '#ff9900', '#ff9933', '#ff9966', '#ff9999', '#ff99cc', - '#ff99ff', '#ffcc00', '#ffcc33', '#ffcc66', '#ffcc99', '#ffcccc', - '#ffccff'); - return $web_safe_colors[rand(0, sizeof($web_safe_colors)-1)]; + $web_safe_colors = array( + '#000033', + '#000066', + '#000099', + '#0000cc', + '#0000ff', + '#003300', + '#003333', + '#003366', + '#003399', + '#0033cc', + '#0033ff', + '#006600', + '#006633', + '#006666', + '#006699', + '#0066cc', + '#0066ff', + '#009900', + '#009933', + '#009966', + '#009999', + '#0099cc', + '#0099ff', + '#00cc00', + '#00cc33', + '#00cc66', + '#00cc99', + '#00cccc', + '#00ccff', + '#00ff00', + '#00ff33', + '#00ff66', + '#00ff99', + '#00ffcc', + '#00ffff', + '#330000', + '#330033', + '#330066', + '#330099', + '#3300cc', + '#3300ff', + '#333300', + '#333333', + '#333366', + '#333399', + '#3333cc', + '#3333ff', + '#336600', + '#336633', + '#336666', + '#336699', + '#3366cc', + '#3366ff', + '#339900', + '#339933', + '#339966', + '#339999', + '#3399cc', + '#3399ff', + '#33cc00', + '#33cc33', + '#33cc66', + '#33cc99', + '#33cccc', + '#33ccff', + '#33ff00', + '#33ff33', + '#33ff66', + '#33ff99', + '#33ffcc', + '#33ffff', + '#660000', + '#660033', + '#660066', + '#660099', + '#6600cc', + '#6600ff', + '#663300', + '#663333', + '#663366', + '#663399', + '#6633cc', + '#6633ff', + '#666600', + '#666633', + '#666666', + '#666699', + '#6666cc', + '#6666ff', + '#669900', + '#669933', + '#669966', + '#669999', + '#6699cc', + '#6699ff', + '#66cc00', + '#66cc33', + '#66cc66', + '#66cc99', + '#66cccc', + '#66ccff', + '#66ff00', + '#66ff33', + '#66ff66', + '#66ff99', + '#66ffcc', + '#66ffff', + '#990000', + '#990033', + '#990066', + '#990099', + '#9900cc', + '#9900ff', + '#993300', + '#993333', + '#993366', + '#993399', + '#9933cc', + '#9933ff', + '#996600', + '#996633', + '#996666', + '#996699', + '#9966cc', + '#9966ff', + '#999900', + '#999933', + '#999966', + '#999999', + '#9999cc', + '#9999ff', + '#99cc00', + '#99cc33', + '#99cc66', + '#99cc99', + '#99cccc', + '#99ccff', + '#99ff00', + '#99ff33', + '#99ff66', + '#99ff99', + '#99ffcc', + '#99ffff', + '#cc0000', + '#cc0033', + '#cc0066', + '#cc0099', + '#cc00cc', + '#cc00ff', + '#cc3300', + '#cc3333', + '#cc3366', + '#cc3399', + '#cc33cc', + '#cc33ff', + '#cc6600', + '#cc6633', + '#cc6666', + '#cc6699', + '#cc66cc', + '#cc66ff', + '#cc9900', + '#cc9933', + '#cc9966', + '#cc9999', + '#cc99cc', + '#cc99ff', + '#cccc00', + '#cccc33', + '#cccc66', + '#cccc99', + '#cccccc', + '#ccccff', + '#ccff00', + '#ccff33', + '#ccff66', + '#ccff99', + '#ccffcc', + '#ccffff', + '#ff0000', + '#ff0033', + '#ff0066', + '#ff0099', + '#ff00cc', + '#ff00ff', + '#ff3300', + '#ff3333', + '#ff3366', + '#ff3399', + '#ff33cc', + '#ff33ff', + '#ff6600', + '#ff6633', + '#ff6666', + '#ff6699', + '#ff66cc', + '#ff66ff', + '#ff9900', + '#ff9933', + '#ff9966', + '#ff9999', + '#ff99cc', + '#ff99ff', + '#ffcc00', + '#ffcc33', + '#ffcc66', + '#ffcc99', + '#ffcccc', + '#ffccff' + ); + return $web_safe_colors[rand(0, sizeof($web_safe_colors) - 1)]; } /** @@ -1538,9 +1746,9 @@ public function getRandomWebColor() private function cmpmultiple($a, $b) { if (isset($a["ds_order"]) && isset($b["ds_order"])) { - if ($a["ds_order"]<$b["ds_order"]) { + if ($a["ds_order"] < $b["ds_order"]) { return -1; - } elseif ($a["ds_order"]>$b["ds_order"]) { + } elseif ($a["ds_order"] > $b["ds_order"]) { return 1; } } @@ -1561,7 +1769,7 @@ private function cmpcdeforder($a, $b) if ($a["cdef_order"] == $b["cdef_order"]) { return 0; } - return ( $a["cdef_order"] < $b["cdef_order"] ) ? -1 : 1; + return ($a["cdef_order"] < $b["cdef_order"]) ? -1 : 1; } /** @@ -1579,14 +1787,14 @@ protected function subsRPN($rpn, $vname, $suffix = null) if (isset($vname[$l_m])) { if ($suffix == null) { $l_rpn .= $vname[$l_m]; - } elseif (isset($vname[$l_m.$suffix])) { - $l_rpn .= $vname[$l_m.$suffix]; + } elseif (isset($vname[$l_m . $suffix])) { + $l_rpn .= $vname[$l_m . $suffix]; } else { return "No_RPN_Found"; } $l_rpn .= ","; } else { - $l_rpn .= $l_m.","; + $l_rpn .= $l_m . ","; } } return substr($l_rpn, 0, strlen($l_rpn) - 1); @@ -1629,7 +1837,7 @@ private function manageVMetric($vId, $vName, $indexId) if ($lPqy->rowCount() == 1) { $lVmetric = $lPqy->fetchRow(); $lPqy->closeCursor(); - if (!isset($this->mlist["v".$lVmetric["metric_id"]])) { + if (!isset($this->mlist["v" . $lVmetric["metric_id"]])) { if (is_null($vId)) { $lVmetric["need"] = 1; /* 1 : Need this virtual metric : Hidden */ } @@ -1671,14 +1879,14 @@ private function manageVMetric($vId, $vName, $indexId) } } } elseif ($l_poqy->rowCount() == 0) { - /* key : id or vname and iid */ - $l_poqy->closeCursor(); - $this->manageVMetric(null, $l_mnane, $lVmetric["index_id"]); + /* key : id or vname and iid */ + $l_poqy->closeCursor(); + $this->manageVMetric(null, $l_mnane, $lVmetric["index_id"]); } else { $l_poqy->closeCursor(); } } - $lVmetric["metric_id"] = "v".$lVmetric["metric_id"]; + $lVmetric["metric_id"] = "v" . $lVmetric["metric_id"]; $lVmetric["host_id"] = $l_indd["host_id"]; $lVmetric["service_id"] = $l_indd["service_id"]; $lVmetric["virtual"] = 1; @@ -1713,9 +1921,9 @@ private function log($message) { if ($this->generalOpt['debug_rrdtool'] && is_writable($this->generalOpt['debug_path'])) { error_log( - "[" . date("d/m/Y H:i") ."] RDDTOOL : ".$message." \n", + "[" . date("d/m/Y H:i") . "] RDDTOOL : " . $message . " \n", 3, - $this->generalOpt["debug_path"]."rrdtool.log" + $this->generalOpt["debug_path"] . "rrdtool.log" ); } } @@ -1727,7 +1935,7 @@ private function log($message) */ private function checkDBAvailability($metric_id) { - if (!file_exists($this->dbPath.$metric_id.".rrd") && !preg_match("/^v/", $metric_id)) { + if (!file_exists($this->dbPath . $metric_id . ".rrd") && !preg_match("/^v/", $metric_id)) { return 0; } return 1; @@ -1742,7 +1950,8 @@ private function checkDBAvailability($metric_id) protected function flushRrdcached($metricsId) { if (!isset($this->generalOpt['rrdcached_enable']) - || $this->generalOpt['rrdcached_enable'] == 0) { + || $this->generalOpt['rrdcached_enable'] == 0 + ) { return true; } @@ -1752,13 +1961,15 @@ protected function flushRrdcached($metricsId) $errno = 0; $errstr = ''; if (isset($this->generalOpt['rrdcached_port']) - && trim($this->generalOpt['rrdcached_port']) != '') { + && trim($this->generalOpt['rrdcached_port']) != '' + ) { $sock = @fsockopen('127.0.0.1', trim($this->generalOpt['rrdcached_port']), $errno, $errstr); if ($sock === false) { return false; } } elseif (isset($this->generalOpt['rrdcached_unix_path']) - && trim($this->generalOpt['rrdcached_unix_path']) != '') { + && trim($this->generalOpt['rrdcached_unix_path']) != '' + ) { $sock = @fsockopen('unix://' . trim($this->generalOpt['rrdcached_unix_path']), $errno, $errstr); } else { return false; @@ -1807,7 +2018,7 @@ protected function flushRrdcached($metricsId) @fclose($sock); return true; } - + /** * Returns index data id * @@ -1827,7 +2038,7 @@ public function getIndexDataId($hostId, $serviceId) } return 0; } - + /** * Returns true if status graph exists * @@ -1838,7 +2049,7 @@ public function getIndexDataId($hostId, $serviceId) public function statusGraphExists($hostId, $serviceId) { $id = $this->getIndexDataId($hostId, $serviceId); - if (is_file($this->dbStatusPath."/".$id.".rrd")) { + if (is_file($this->dbStatusPath . "/" . $id . ".rrd")) { return true; } return false; diff --git a/www/class/centreonGraphPoller.class.php b/www/class/centreonGraphPoller.class.php index f9ca50e8fea..832da2a9090 100644 --- a/www/class/centreonGraphPoller.class.php +++ b/www/class/centreonGraphPoller.class.php @@ -265,7 +265,7 @@ public function buildCommandLine($rows) throw new RuntimeException(); } $this->commandLine .= " DEF:v" . $i . "=" . $path . ":$metric:AVERAGE"; - $this->commandLine .= " GPRINT:v". ($i) .":LAST:\"\:%7.2lf%s\l\""; + $this->commandLine .= " GPRINT:v" . ($i) . ":LAST:\"\:%7.2lf%s\l\""; $this->commandLine .= " XPORT:v" . $i . ":v" . $i; $info = array( @@ -281,8 +281,9 @@ public function buildCommandLine($rows) ); if (isset($metric['ds_color_area']) && - isset($metric['ds_filled']) && - $metric['ds_filled'] === '1') { + isset($metric['ds_filled']) && + $metric['ds_filled'] === '1' + ) { $info['graph_type'] = "area"; } if (isset($metric['ds_invert']) && $metric['ds_invert'] == 1) { diff --git a/www/class/centreonLDAP.class.php b/www/class/centreonLDAP.class.php index 7fabe64dc37..e5cc8513564 100644 --- a/www/class/centreonLDAP.class.php +++ b/www/class/centreonLDAP.class.php @@ -107,7 +107,7 @@ public function __construct($pearDB, $CentreonLog = null, $arId = null) if ($this->debugPath == '') { $this->debugImport = false; } - + $searchTimeout = 5; $tempSearchTimeout = $this->getLdapHostParameters($arId, 'ldap_search_timeout'); if (count($tempSearchTimeout) > 0) { @@ -162,10 +162,10 @@ public function __construct($pearDB, $CentreonLog = null, $arId = null) $dbresult->closeCursor(); } } - + /** * - * @param int $arId + * @param int $arId * @param string $filter * @return array */ @@ -173,19 +173,19 @@ public function getLdapHostParameters($arId, $filter = '') { // ldap_search_timeout $queryLdapHostParemeters = "SELECT * FROM auth_ressource_info WHERE ar_id = " . $this->db->escape($arId); - + if (!empty($filter)) { $queryLdapHostParemeters .= " AND `ari_name` = '$filter'"; } - + $resLdapHostParameters = $this->db->query($queryLdapHostParemeters); - + $finalLdapHostParameters = array(); - + while ($rowLdapHostParameters = $resLdapHostParameters->fetchRow()) { $finalLdapHostParameters = $rowLdapHostParameters; } - + return $finalLdapHostParameters; } @@ -279,8 +279,8 @@ public function getDs() { return $this->ds; } - - /** + + /** * Transform user, group name for filter * * @param string $name the atrribute @@ -392,8 +392,8 @@ public function listOfUsers($pattern = '*') /** * Get a LDAP entry * - * @param string $dn The DN - * @param array $attr The list of attribute + * @param string $dn The DN + * @param array $attr The list of attribute * @return array|bool The list of information, or false in error */ public function getEntry($dn, $attr = array()) @@ -512,10 +512,10 @@ public function getAttrName($type, $info) /** * Search function * - * @param string $filter The filter string, null for use default - * @param string $basedn The basedn, null for use default - * @param int $searchLimit The search limit, null for all - * @param int $searchTimeout The search timeout, null for default + * @param string $filter The filter string, null for use default + * @param string $basedn The basedn, null for use default + * @param int $searchLimit The search limit, null for all + * @param int $searchTimeout The search timeout, null for default * @return array The search result */ public function search($filter, $basedn, $searchLimit, $searchTimeout) @@ -566,24 +566,24 @@ public function search($filter, $basedn, $searchLimit, $searchTimeout) $result = array(); $result['dn'] = (isset($info[$i]['dn']) ? $info[$i]['dn'] : ""); $result['alias'] = ( - isset($info[$i][$this->userSearchInfo['alias']][0]) ?$info[$i][$this->userSearchInfo['alias']][0] : "" + isset($info[$i][$this->userSearchInfo['alias']][0]) ? $info[$i][$this->userSearchInfo['alias']][0] : "" ); $result['name'] = ( - isset($info[$i][$this->userSearchInfo['name']][0]) ? $info[$i][$this->userSearchInfo['name']][0] : "" + isset($info[$i][$this->userSearchInfo['name']][0]) ? $info[$i][$this->userSearchInfo['name']][0] : "" ); $result['email'] = ( - isset($info[$i][$this->userSearchInfo['email']][0]) ? $info[$i][$this->userSearchInfo['email']][0] : "" + isset($info[$i][$this->userSearchInfo['email']][0]) ? $info[$i][$this->userSearchInfo['email']][0] : "" ); $result['pager'] = ( - isset($info[$i][$this->userSearchInfo['pager']][0]) ? $info[$i][$this->userSearchInfo['pager']][0] : "" + isset($info[$i][$this->userSearchInfo['pager']][0]) ? $info[$i][$this->userSearchInfo['pager']][0] : "" ); $result['firstname'] = ( - isset($info[$i][$this->userSearchInfo['firstname']][0]) ? - $info[$i][$this->userSearchInfo['firstname']][0] : "" + isset($info[$i][$this->userSearchInfo['firstname']][0]) ? + $info[$i][$this->userSearchInfo['firstname']][0] : "" ); $result['lastname'] = ( - isset($info[$i][$this->userSearchInfo['lastname']][0]) ? - $info[$i][$this->userSearchInfo['lastname']][0] : "" + isset($info[$i][$this->userSearchInfo['lastname']][0]) ? + $info[$i][$this->userSearchInfo['lastname']][0] : "" ); $results[] = $result; } @@ -799,13 +799,34 @@ public function __construct($pearDB) */ public function getLdapParameters() { - $tab = array('ldap_store_password', 'ldap_auto_import', 'ldap_search_limit', - 'ldap_search_timeout', 'ldap_contact_tmpl', 'ldap_srv_dns', - 'ldap_dns_use_ssl', 'ldap_dns_use_tls', 'ldap_dns_use_domain', - 'bind_dn', 'bind_pass', 'protocol_version', 'ldap_template', 'user_base_search', - 'group_base_search', 'user_filter', 'alias', 'user_group', 'user_name', - 'user_firstname', 'user_lastname', 'user_email', 'user_pager', 'group_filter', - 'group_name', 'group_member'); + $tab = array( + 'ldap_store_password', + 'ldap_auto_import', + 'ldap_search_limit', + 'ldap_search_timeout', + 'ldap_contact_tmpl', + 'ldap_srv_dns', + 'ldap_dns_use_ssl', + 'ldap_dns_use_tls', + 'ldap_dns_use_domain', + 'bind_dn', + 'bind_pass', + 'protocol_version', + 'ldap_template', + 'user_base_search', + 'group_base_search', + 'user_filter', + 'alias', + 'user_group', + 'user_name', + 'user_firstname', + 'user_lastname', + 'user_email', + 'user_pager', + 'group_filter', + 'group_name', + 'group_member' + ); return $tab; } @@ -832,9 +853,9 @@ protected function updateLdapServers($arId) $insertStr .= ", "; } $insertStr .= "($arId, '" . $this->db->escape($addr) . "', '" . - $this->db->escape($portList[$key]) . "', " . - $this->db->escape($sslList[$key] ? 1 : 0) . ", " . - $this->db->escape($tlsList[$key] ? 1 : 0) . ", $i)"; + $this->db->escape($portList[$key]) . "', " . + $this->db->escape($sslList[$key] ? 1 : 0) . ", " . + $this->db->escape($tlsList[$key] ? 1 : 0) . ", $i)"; $i++; } if ($insertStr) { @@ -846,14 +867,14 @@ protected function updateLdapServers($arId) } } } - + /** * Set ldap options * * 'ldap_auth_enable', 'ldap_auto_import', 'ldap_srv_dns', 'ldap_search_limit', 'ldap_search_timeout' * and 'ldap_dns_use_ssl', 'ldap_dns_use_tls', 'ldap_dns_use_domain' if ldap_srv_dns = 1 * - * @param int $arId + * @param int $arId * @param array $options The list of options * @return int | auth ressource id */ @@ -932,7 +953,7 @@ public function getGeneralOptions($arId) /** * Add a Ldap server * - * @param int $arId + * @param int $arId * @param array $params * @return void */ @@ -953,7 +974,7 @@ public function addServer($arId, $params = array()) /** * Modify a Ldap server * - * @param int $arId + * @param int $arId * @param array $params * @return void */ @@ -1015,7 +1036,7 @@ public function addTemplate($options = array()) * Modify a template * * @param int The id of the template - * @param array $options A hash table with options for connections and search in ldap + * @param array $options A hash table with options for connections and search in ldap * @return bool */ public function modifyTemplate($id, $options = array()) @@ -1131,7 +1152,7 @@ public function getTemplateLdap() * * @param string $search * @param string $offset - * @param int $limit + * @param int $limit * @return array */ public function getLdapConfigurationList($search = "", $offset = null, $limit = null) @@ -1172,7 +1193,7 @@ public function deleteConfiguration($configList = array()) /** * Enable/Disable ldap configuration * - * @param int $status + * @param int $status * @param array $configList * @return void */ diff --git a/www/class/centreonMetrics.class.php b/www/class/centreonMetrics.class.php index 42de02e3138..5f85b19e0c5 100644 --- a/www/class/centreonMetrics.class.php +++ b/www/class/centreonMetrics.class.php @@ -51,14 +51,15 @@ public function getObjectForSelect2($values = array()) $filters = 'm.metric_id IN (' . join(', ', $values) . ') AND'; } - $queryService = "SELECT SQL_CALC_FOUND_ROWS m.metric_id, CONCAT(h.name,' - ', s.description, ' - ', m.metric_name) AS fullname " - ."FROM metrics m, hosts h, services s, index_data i " - ."WHERE " + $queryService = "SELECT SQL_CALC_FOUND_ROWS m.metric_id, CONCAT(h.name,' - ', s.description," + . "' - ', m.metric_name) AS fullname " + . "FROM metrics m, hosts h, services s, index_data i " + . "WHERE " . $filters . " " . "i.id = m.index_id AND " - ."h.host_id = i.host_id " - ."AND s.service_id = i.service_id " - ."ORDER BY fullname COLLATE utf8_general_ci"; + . "h.host_id = i.host_id " + . "AND s.service_id = i.service_id " + . "ORDER BY fullname COLLATE utf8_general_ci"; try { $res = $this->dbo->query($queryService); } catch (\PDOException $e) { diff --git a/www/class/centreonPurgeEngine.class.php b/www/class/centreonPurgeEngine.class.php index 07cd72288b2..081025ca2ff 100644 --- a/www/class/centreonPurgeEngine.class.php +++ b/www/class/centreonPurgeEngine.class.php @@ -74,13 +74,15 @@ class CentreonPurgeEngine 'retention_field' => 'len_storage_comments', 'retention' => 0, 'is_partitioned' => false, - 'custom_query' => 'DELETE FROM comments WHERE (deletion_time is not null and deletion_time < __RETENTION__) OR (expire_time < __RETENTION__ AND expire_time <> 0)' + 'custom_query' => 'DELETE FROM comments WHERE (deletion_time is not null and deletion_time ' . + '< __RETENTION__) OR (expire_time < __RETENTION__ AND expire_time <> 0)' ), 'downtimes' => array( 'retention_field' => 'len_storage_downtimes', 'retention' => 0, 'is_partitioned' => false, - 'custom_query' => 'DELETE FROM downtimes WHERE (actual_end_time is not null and actual_end_time < __RETENTION__) OR (deletion_time is not null and deletion_time < __RETENTION__)' + 'custom_query' => 'DELETE FROM downtimes WHERE (actual_end_time is not null and actual_end_time ' . + '< __RETENTION__) OR (deletion_time is not null and deletion_time < __RETENTION__)' ), ); @@ -96,12 +98,11 @@ public function __construct() $this->isPartitioned(); } - + private function readConfig() { - $query = 'SELECT len_storage_mysql,archive_retention,reporting_retention, len_storage_downtimes, len_storage_comments ' - . 'FROM config'; - + $query = 'SELECT len_storage_mysql,archive_retention,reporting_retention, ' . + 'len_storage_downtimes, len_storage_comments FROM config'; try { $DBRESULT = $this->dbCentstorage->query($query); } catch (\PDOException $e) { @@ -111,8 +112,18 @@ private function readConfig() $ltime = localtime(); $row = $DBRESULT->fetchRow(); foreach ($this->tablesToPurge as &$table) { - if (isset($row[$table['retention_field']]) && !is_null($row[$table['retention_field']]) && $row[$table['retention_field']] > 0) { - $table['retention'] = mktime(0, 0, 0, $ltime[4]+1, $ltime[3]-$row[$table['retention_field']], $ltime[5]+1900); + if (isset($row[$table['retention_field']]) && + !is_null($row[$table['retention_field']]) && + $row[$table['retention_field']] > 0 + ) { + $table['retention'] = mktime( + 0, + 0, + 0, + $ltime[4] + 1, + $ltime[3] - $row[$table['retention_field']], + $ltime[5] + 1900 + ); } } } @@ -166,7 +177,8 @@ private function purgeParts($table) $request .= "WHERE TABLE_NAME='" . $table . "' "; $request .= "AND TABLE_SCHEMA='" . dbcstg . "' "; $request .= "AND CONVERT(PARTITION_DESCRIPTION, SIGNED INTEGER) IS NOT NULL "; - $request .= "AND CONVERT(PARTITION_DESCRIPTION, SIGNED INTEGER) < " . $this->tablesToPurge[$table]['retention'] . " "; + $request .= "AND CONVERT(PARTITION_DESCRIPTION, SIGNED INTEGER) < " . + $this->tablesToPurge[$table]['retention'] . " "; $request .= "AND CONVERT(PARTITION_DESCRIPTION, SIGNED INTEGER) NOT LIKE 'pmax' "; try { @@ -175,7 +187,7 @@ private function purgeParts($table) throw new Exception("Error : Cannot get partitions to purge for table " . $table . ", " . $e->getMessage() . "\n"); } - + while ($row = $DBRESULT->fetchRow()) { $request = "ALTER TABLE " . $table . " DROP PARTITION `" . $row["PARTITION_NAME"] . "`;"; try { @@ -191,10 +203,15 @@ private function purgeParts($table) private function purgeOldData($table) { if (isset($this->tablesToPurge[$table]['custom_query'])) { - $request = str_replace('__RETENTION__', $this->tablesToPurge[$table]['retention'], $this->tablesToPurge[$table]['custom_query']); + $request = str_replace( + '__RETENTION__', + $this->tablesToPurge[$table]['retention'], + $this->tablesToPurge[$table]['custom_query'] + ); } else { $request = "DELETE FROM " . $table . " "; - $request .= "WHERE " . $this->tablesToPurge[$table]['ctime_field'] . " < " . $this->tablesToPurge[$table]['retention']; + $request .= "WHERE " . $this->tablesToPurge[$table]['ctime_field'] . " < " . + $this->tablesToPurge[$table]['retention']; } try { @@ -214,8 +231,8 @@ private function purgeIndexData() $request .= "AND hsr.service_service_id = index_data.service_id LIMIT 1)) "; // Delete index_data entries for service by host - $request .= "AND ISNULL((SELECT 1 FROM " . db . ".host_service_relation hsr "; - $request .= "WHERE hsr.host_host_id = index_data.host_id AND hsr.service_service_id = index_data.service_id LIMIT 1)) "; + $request .= "AND ISNULL((SELECT 1 FROM " . db . ".host_service_relation hsr " . + "WHERE hsr.host_host_id = index_data.host_id AND hsr.service_service_id = index_data.service_id LIMIT 1)) "; try { $DBRESULT = $this->dbCentstorage->query($request); diff --git a/www/class/centreonService.class.php b/www/class/centreonService.class.php index 9535b6bae0b..0baf01a3e71 100644 --- a/www/class/centreonService.class.php +++ b/www/class/centreonService.class.php @@ -64,7 +64,7 @@ class CentreonService /** * Constructor * - * @param CentreonDB $db + * @param CentreonDB $db */ public function __construct($db, $dbMon = null) { @@ -83,8 +83,8 @@ public function __construct($db, $dbMon = null) /** * Method that returns service description from service_id * - * @param int $svc_id - * @return string + * @param int $svc_id + * @return string */ public function getServiceDesc($svc_id) { @@ -133,9 +133,9 @@ public function getServiceTemplateId($templateName = null) /** * Method that returns the id of a service * - * @param string $svc_desc - * @param string $host_name - * @return int + * @param string $svc_desc + * @param string $host_name + * @return int */ public function getServiceId($svc_desc = null, $host_name = null) { @@ -143,19 +143,19 @@ public function getServiceId($svc_desc = null, $host_name = null) if (!isset($hostSvcTab[$host_name])) { $rq = "SELECT s.service_id, s.service_description " . - " FROM service s" . - " JOIN (SELECT hsr.service_service_id FROM host_service_relation hsr" . - " JOIN host h" . - " ON hsr.host_host_id = h.host_id" . - " WHERE h.host_name = '" . $this->db->escape($host_name) . "'" . - " UNION" . - " SELECT hsr.service_service_id FROM hostgroup_relation hgr" . - " JOIN host h" . - " ON hgr.host_host_id = h.host_id" . - " JOIN host_service_relation hsr" . - " ON hgr.hostgroup_hg_id = hsr.hostgroup_hg_id" . - " WHERE h.host_name = '" . $this->db->escape($host_name) . "' ) ghsrv" . - " ON s.service_id = ghsrv.service_service_id"; + " FROM service s" . + " JOIN (SELECT hsr.service_service_id FROM host_service_relation hsr" . + " JOIN host h" . + " ON hsr.host_host_id = h.host_id" . + " WHERE h.host_name = '" . $this->db->escape($host_name) . "'" . + " UNION" . + " SELECT hsr.service_service_id FROM hostgroup_relation hgr" . + " JOIN host h" . + " ON hgr.host_host_id = h.host_id" . + " JOIN host_service_relation hsr" . + " ON hgr.hostgroup_hg_id = hsr.hostgroup_hg_id" . + " WHERE h.host_name = '" . $this->db->escape($host_name) . "' ) ghsrv" . + " ON s.service_id = ghsrv.service_service_id"; $DBRES = $this->db->query($rq); $hostSvcTab[$host_name] = array(); while ($row = $DBRES->fetchRow()) { @@ -245,8 +245,8 @@ public function getServicesDescr($sid = array()) } else { $where .= " AND ( "; } - $where .= " (h.host_id = ".$this->db->escape($tmp[0]); - $where .= " AND s.service_id = ".$this->db->escape($tmp[1])." ) "; + $where .= " (h.host_id = " . $this->db->escape($tmp[0]); + $where .= " AND s.service_id = " . $this->db->escape($tmp[1]) . " ) "; } } if ($where !== "") { @@ -255,14 +255,15 @@ public function getServicesDescr($sid = array()) FROM service s INNER JOIN host_service_relation hsr ON hsr.service_service_id = s.service_id INNER JOIN host h ON hsr.host_host_id = h.host_id - WHERE 1 = 1 ".$where; + WHERE 1 = 1 " . $where; $res = $this->db->query($query); while ($row = $res->fetchRow()) { - $arrayReturn[] = array("service_id" => $row['service_id'], - "description" => $row['service_description'], - "host_name" => $row['host_name'], - "host_id" => $row['host_id'] - ); + $arrayReturn[] = array( + "service_id" => $row['service_id'], + "description" => $row['service_description'], + "host_name" => $row['host_name'], + "host_id" => $row['host_id'] + ); } } } @@ -270,8 +271,6 @@ public function getServicesDescr($sid = array()) } - - /** * Check illegal char defined into nagios.cfg file * @@ -294,11 +293,11 @@ public function checkIllegalChar($name) /** * Returns a string that replaces on demand macros by their values * - * @param int $svc_id - * @param string $string - * @param int $antiLoop - * @param int $instanceId - * @return string + * @param int $svc_id + * @param string $string + * @param int $antiLoop + * @param int $instanceId + * @return string */ public function replaceMacroInString($svc_id, $string, $antiLoop = null, $instanceId = null) { @@ -429,18 +428,19 @@ public function insertMacro( ); foreach ($macros as $key => $value) { if ($value != "" && - !isset($stored[strtolower($value)])) { + !isset($stored[strtolower($value)]) + ) { $this->db->query( "INSERT INTO on_demand_macro_service (`svc_macro_name`, `svc_macro_value`, `is_password`, `description`, `svc_svc_id`, `macro_order`) VALUES ('\$_SERVICE" . strtoupper($this->db->escape($value)) . "\$', '" . - $this->db->escape($macrovalues[$key]) . "', " . (isset($macroPassword[$key]) ? 1 : 'NULL') . - ", '" . $this->db->escape($macroDescription[$key]) . "', " . $this->db->escape($serviceId) . - ", " . $cnt . " )" + $this->db->escape($macrovalues[$key]) . "', " . (isset($macroPassword[$key]) ? 1 : 'NULL') . + ", '" . $this->db->escape($macroDescription[$key]) . "', " . $this->db->escape($serviceId) . + ", " . $cnt . " )" ); $stored[strtolower($value)] = true; - $cnt ++; + $cnt++; } } } @@ -459,7 +459,7 @@ public function getCustomMacroInDb($serviceId = null, $template = null) $res = $this->db->query("SELECT svc_macro_name, svc_macro_value, is_password, description FROM on_demand_macro_service WHERE svc_svc_id = " . - $this->db->escape($serviceId) . " + $this->db->escape($serviceId) . " ORDER BY macro_order ASC"); while ($row = $res->fetchRow()) { if (preg_match('/\$_SERVICE(.*)\$$/', $row['svc_macro_name'], $matches)) { @@ -479,7 +479,7 @@ public function getCustomMacroInDb($serviceId = null, $template = null) $arr[$i]['macroDescription_#index#'] = $row['description']; $arr[$i]['macroDescription'] = $row['description']; if (!is_null($template)) { - $arr[$i]['macroTpl_#index#'] = "Service template : ".$template['service_description']; + $arr[$i]['macroTpl_#index#'] = "Service template : " . $template['service_description']; } $i++; } @@ -503,7 +503,7 @@ public function getCustomMacro($serviceId = null, $realKeys = false) $res = $this->db->query("SELECT svc_macro_name, svc_macro_value, is_password, description FROM on_demand_macro_service WHERE svc_svc_id = " . - $this->db->escape($serviceId) . " + $this->db->escape($serviceId) . " ORDER BY macro_order ASC"); while ($row = $res->fetchRow()) { if (preg_match('/\$_SERVICE(.*)\$$/', $row['svc_macro_name'], $matches)) { @@ -615,10 +615,10 @@ public function serviceHasContact($service, $type = 0, $cgSCache = array(), $cct static $serviceTemplateHasContact = array(); if ($type == 0) { - $staticArr = & $serviceTemplateHasContact; + $staticArr = &$serviceTemplateHasContact; $cache = $cctSCache; } else { - $staticArr = & $serviceTemplateHasContactGroup; + $staticArr = &$serviceTemplateHasContactGroup; $cache = $cgSCache; } @@ -668,7 +668,8 @@ public function hasMacroFromServiceChanged( # Don't override macros on massive change if there is not direct inheritance if (($input == $macro['macroInput_#index#'] && $macroValue[$ind] == $macro["macroValue_#index#"]) || ($isMassiveChange && $input == $macro['macroInput_#index#'] && - isset($macroFrom[$ind]) && $macroFrom[$ind] != 'direct')) { + isset($macroFrom[$ind]) && $macroFrom[$ind] != 'direct') + ) { unset($macroInput[$ind]); unset($macroValue[$ind]); } @@ -731,7 +732,7 @@ public function getMacros($iServiceId, $aListTemplate, $iIdCommande, $form = arr foreach ($aListTemplate as $template) { if (!empty($template['command_command_id'])) { $iIdCommande = $template['command_command_id']; - $templateName = "Service template : ".$template['service_description']." | "; + $templateName = "Service template : " . $template['service_description'] . " | "; } } } @@ -742,7 +743,7 @@ public function getMacros($iServiceId, $aListTemplate, $iIdCommande, $form = arr $oCommand = new CentreonCommand($this->db); $macroTmp = $oCommand->getMacroByIdAndType($iIdCommande, 'service'); foreach ($macroTmp as $tmpmacro) { - $tmpmacro['macroTpl_#index#'] = $templateName.' Commande : '.$tmpmacro['macroCommandFrom']; + $tmpmacro['macroTpl_#index#'] = $templateName . ' Commande : ' . $tmpmacro['macroCommandFrom']; $aMacroInService[] = $tmpmacro; } } @@ -790,7 +791,7 @@ public function ajaxMacroControl($form) $this->purgeOldMacroToForm($macroArray, $form, 'fromTpl'); $aListTemplate = array(); if (isset($form['service_template_model_stm_id']) && !empty($form['service_template_model_stm_id'])) { - $aListTemplate = getListTemplates($this->db, $form['service_template_model_stm_id']); + $aListTemplate = getListTemplates($this->db, $form['service_template_model_stm_id']); } //Get macro attached to the template $aMacroTemplate = array(); @@ -808,7 +809,7 @@ public function ajaxMacroControl($form) foreach ($aListTemplate as $template) { if (!empty($template['command_command_id'])) { $iIdCommande = $template['command_command_id']; - $templateName = "Service template : ".$template['service_description']." | "; + $templateName = "Service template : " . $template['service_description'] . " | "; } } } @@ -819,7 +820,7 @@ public function ajaxMacroControl($form) $macroTmp = $oCommand->getMacroByIdAndType($iIdCommande, 'service'); foreach ($macroTmp as $tmpmacro) { - $tmpmacro['macroTpl_#index#'] = $templateName.' Commande : '.$tmpmacro['macroCommandFrom']; + $tmpmacro['macroTpl_#index#'] = $templateName . ' Commande : ' . $tmpmacro['macroCommandFrom']; $aMacroInService[] = $tmpmacro; } } @@ -876,8 +877,6 @@ public function purgeOldMacroToForm(&$macroArray, &$form, $fromKey, $macrosArray } - - foreach ($macroArray as $key => $macro) { if ($macro["macroInput_#index#"] == "") { unset($macroArray[$key]); @@ -908,7 +907,6 @@ public function purgeOldMacroToForm(&$macroArray, &$form, $fromKey, $macrosArray } - /** * * @param integer $field @@ -1128,11 +1126,10 @@ public function getObjectForSelect2($values = array(), $options = array(), $regi } - private function comparaPriority($macroA, $macroB, $getFirst = true) { - $arrayPrio = array('direct' => 3,'fromTpl' => 2,'fromService' => 1); + $arrayPrio = array('direct' => 3, 'fromTpl' => 2, 'fromService' => 1); if ($getFirst) { if ($arrayPrio[$macroA['source']] > $arrayPrio[$macroB['source']]) { return $macroA; @@ -1290,7 +1287,7 @@ public function insert($ret) isset($ret["service_template_model_stm_id"]) && $ret["service_template_model_stm_id"] != null ? $rq .= (int)$ret["service_template_model_stm_id"] . ", " : $rq .= "NULL, "; isset($ret["command_command_id"]) && $ret["command_command_id"] != null ? - $rq .= (int)$ret["command_command_id"] . ", " : $rq .= "NULL, "; + $rq .= (int)$ret["command_command_id"] . ", " : $rq .= "NULL, "; isset($ret["timeperiod_tp_id"]) && $ret["timeperiod_tp_id"] != null ? $rq .= (int)$ret["timeperiod_tp_id"] . ", " : $rq .= "NULL, "; isset($ret["command_command_id2"]) && $ret["command_command_id2"] != null ? @@ -1310,23 +1307,23 @@ public function insert($ret) isset($ret["service_retry_check_interval"]) && $ret["service_retry_check_interval"] != null ? $rq .= (int)$ret["service_retry_check_interval"] . ", " : $rq .= "NULL, "; isset($ret["service_active_checks_enabled"]["service_active_checks_enabled"]) && - $ret["service_active_checks_enabled"]["service_active_checks_enabled"] != 2 ? + $ret["service_active_checks_enabled"]["service_active_checks_enabled"] != 2 ? $rq .= "'" . $ret["service_active_checks_enabled"]["service_active_checks_enabled"] . "', " : $rq .= "'2', "; isset($ret["service_passive_checks_enabled"]["service_passive_checks_enabled"]) && - $ret["service_passive_checks_enabled"]["service_passive_checks_enabled"] != 2 ? + $ret["service_passive_checks_enabled"]["service_passive_checks_enabled"] != 2 ? $rq .= "'" . $ret["service_passive_checks_enabled"]["service_passive_checks_enabled"] . "', " : $rq .= "'2', "; isset($ret["service_obsess_over_service"]["service_obsess_over_service"]) && - $ret["service_obsess_over_service"]["service_obsess_over_service"] != 2 ? + $ret["service_obsess_over_service"]["service_obsess_over_service"] != 2 ? $rq .= "'" . $ret["service_obsess_over_service"]["service_obsess_over_service"] . "', " : $rq .= "'2', "; isset($ret["service_check_freshness"]["service_check_freshness"]) && - $ret["service_check_freshness"]["service_check_freshness"] != 2 ? + $ret["service_check_freshness"]["service_check_freshness"] != 2 ? $rq .= "'" . $ret["service_check_freshness"]["service_check_freshness"] . "', " : $rq .= "'2', "; isset($ret["service_freshness_threshold"]) && $ret["service_freshness_threshold"] != null ? - $rq .= (int)$ret["service_freshness_threshold"] . ", ": $rq .= "NULL, "; + $rq .= (int)$ret["service_freshness_threshold"] . ", " : $rq .= "NULL, "; isset($ret["service_event_handler_enabled"]["service_event_handler_enabled"]) && - $ret["service_event_handler_enabled"]["service_event_handler_enabled"] != 2 ? + $ret["service_event_handler_enabled"]["service_event_handler_enabled"] != 2 ? $rq .= "'" . $ret["service_event_handler_enabled"]["service_event_handler_enabled"] . "', " : $rq .= "'2', "; isset($ret["service_low_flap_threshold"]) && $ret["service_low_flap_threshold"] != null ? @@ -1334,18 +1331,18 @@ public function insert($ret) isset($ret["service_high_flap_threshold"]) && $ret["service_high_flap_threshold"] != null ? $rq .= (int)$ret["service_high_flap_threshold"] . ", " : $rq .= "NULL, "; isset($ret["service_flap_detection_enabled"]["service_flap_detection_enabled"]) && - $ret["service_flap_detection_enabled"]["service_flap_detection_enabled"] != 2 ? + $ret["service_flap_detection_enabled"]["service_flap_detection_enabled"] != 2 ? $rq .= "'" . $ret["service_flap_detection_enabled"]["service_flap_detection_enabled"] . "', " : $rq .= "'2', "; isset($ret["service_process_perf_data"]["service_process_perf_data"]) && - $ret["service_process_perf_data"]["service_process_perf_data"] != 2 ? + $ret["service_process_perf_data"]["service_process_perf_data"] != 2 ? $rq .= "'" . $ret["service_process_perf_data"]["service_process_perf_data"] . "', " : $rq .= "'2', "; isset($ret["service_retain_status_information"]["service_retain_status_information"]) && - $ret["service_retain_status_information"]["service_retain_status_information"] != 2 ? + $ret["service_retain_status_information"]["service_retain_status_information"] != 2 ? $rq .= "'" . $ret["service_retain_status_information"]["service_retain_status_information"] . "', " : $rq .= "'2', "; isset($ret["service_retain_nonstatus_information"]["service_retain_nonstatus_information"]) && - $ret["service_retain_nonstatus_information"]["service_retain_nonstatus_information"] != 2 ? + $ret["service_retain_nonstatus_information"]["service_retain_nonstatus_information"] != 2 ? $rq .= "'" . $ret["service_retain_nonstatus_information"]["service_retain_nonstatus_information"] . "', " : $rq .= "'2', "; isset($ret["service_notification_interval"]) && $ret["service_notification_interval"] != null ? @@ -1353,17 +1350,17 @@ public function insert($ret) isset($ret["service_notifOpts"]) && $ret["service_notifOpts"] != null ? $rq .= "'" . implode(",", array_keys($ret["service_notifOpts"])) . "', " : $rq .= "NULL, "; isset($ret["service_notifications_enabled"]["service_notifications_enabled"]) && - $ret["service_notifications_enabled"]["service_notifications_enabled"] != 2 ? + $ret["service_notifications_enabled"]["service_notifications_enabled"] != 2 ? $rq .= "'" . $ret["service_notifications_enabled"]["service_notifications_enabled"] . "', " : $rq .= "'2', "; $rq .= (isset($ret["contact_additive_inheritance"]) ? 1 : 0) . ', '; $rq .= (isset($ret["cg_additive_inheritance"]) ? 1 : 0) . ', '; isset($ret["service_use_only_contacts_from_host"]["service_use_only_contacts_from_host"]) && - $ret["service_use_only_contacts_from_host"]["service_use_only_contacts_from_host"] != null ? + $ret["service_use_only_contacts_from_host"]["service_use_only_contacts_from_host"] != null ? $rq .= "'" . $ret["service_use_only_contacts_from_host"]["service_use_only_contacts_from_host"] . "', " : $rq .= "NULL, "; isset($ret["service_stalOpts"]) && $ret["service_stalOpts"] != null ? - $rq .= "'".implode(",", array_keys($ret["service_stalOpts"]))."', " : $rq .= "NULL, "; + $rq .= "'" . implode(",", array_keys($ret["service_stalOpts"])) . "', " : $rq .= "NULL, "; isset($ret["service_first_notification_delay"]) && $ret["service_first_notification_delay"] != null ? $rq .= (int)$ret["service_first_notification_delay"] . ", " : $rq .= "NULL, "; isset($ret["service_comment"]) && $ret["service_comment"] != null ? @@ -1374,16 +1371,16 @@ public function insert($ret) isset($ret["command_command_id_arg2"]) && $ret["command_command_id_arg2"] != null ? $rq .= "'" . CentreonDB::escape($ret["command_command_id_arg2"]) . "', " : $rq .= "NULL, "; isset($ret["service_register"]) && $ret["service_register"] != null ? - $rq .= "'".$ret["service_register"]."', " : $rq .= "NULL, "; + $rq .= "'" . $ret["service_register"] . "', " : $rq .= "NULL, "; isset($ret["service_locked"]) && $ret["service_locked"] != null ? - $rq .= (int)$ret["service_locked"].", " : $rq .= "0, "; + $rq .= (int)$ret["service_locked"] . ", " : $rq .= "0, "; isset($ret["service_activate"]["service_activate"]) && $ret["service_activate"]["service_activate"] != null ? - $rq .= "'".$ret["service_activate"]["service_activate"]."'" : $rq .= "'1'"; + $rq .= "'" . $ret["service_activate"]["service_activate"] . "'" : $rq .= "'1'"; $rq .= ")"; $this->db->query($rq); - $DBRESULT = $this->db->query("SELECT MAX(service_id) as service_id FROM service"); + $DBRESULT = $this->db->query("SELECT MAX(service_id) as service_id FROM service"); $service_id = $DBRESULT->fetchRow(); $ret['service_service_id'] = $service_id['service_id']; @@ -1407,16 +1404,16 @@ public function insertExtendInfo($aDatas) $rq .= "(service_service_id, esi_notes, esi_notes_url, esi_action_url, esi_icon_image, esi_icon_image_alt, graph_id) "; $rq .= "VALUES "; - $rq .= "('".$aDatas['service_service_id']."', "; - isset($aDatas["esi_notes"]) ? $rq .= "'" .CentreonDB::escape($aDatas["esi_notes"])."'," : $rq .="NULL, "; + $rq .= "('" . $aDatas['service_service_id'] . "', "; + isset($aDatas["esi_notes"]) ? $rq .= "'" . CentreonDB::escape($aDatas["esi_notes"]) . "'," : $rq .= "NULL, "; isset($aDatas["esi_notes_url"]) ? - $rq .= "'" .CentreonDB::escape($aDatas["esi_notes_url"])."'," : $rq .= "NULL, "; + $rq .= "'" . CentreonDB::escape($aDatas["esi_notes_url"]) . "'," : $rq .= "NULL, "; isset($aDatas["esi_action_url"]) ? - $rq .= "'" .CentreonDB::escape($aDatas["esi_action_url"])."'," : $rq .= "NULL, "; + $rq .= "'" . CentreonDB::escape($aDatas["esi_action_url"]) . "'," : $rq .= "NULL, "; isset($aDatas["esi_icon_image"]) ? - $rq .= "'" .CentreonDB::escape($aDatas["esi_icon_image"])."'," : $rq .= "NULL, "; + $rq .= "'" . CentreonDB::escape($aDatas["esi_icon_image"]) . "'," : $rq .= "NULL, "; isset($aDatas["esi_icon_image_alt"]) ? - $rq .= "'" .CentreonDB::escape($aDatas["esi_icon_image_alt"])."'," : $rq .= "NULL, "; + $rq .= "'" . CentreonDB::escape($aDatas["esi_icon_image_alt"]) . "'," : $rq .= "NULL, "; isset($aDatas["graph_id"]) ? $rq .= CentreonDB::escape($aDatas["graph_id"]) : $rq .= "NULL "; $rq .= ")"; @@ -1429,130 +1426,135 @@ public function insertExtendInfo($aDatas) */ public function update($service_id, $ret) { - $rq = "UPDATE service SET " ; + $rq = "UPDATE service SET "; $rq .= "service_template_model_stm_id = "; isset($ret["service_template_model_stm_id"]) && $ret["service_template_model_stm_id"] != null ? - $rq .= "'".$ret["service_template_model_stm_id"]."', ": $rq .= "NULL, "; + $rq .= "'" . $ret["service_template_model_stm_id"] . "', " : $rq .= "NULL, "; $rq .= "command_command_id = "; isset($ret["command_command_id"]) && $ret["command_command_id"] != null ? - $rq .= "'".$ret["command_command_id"]."', ": $rq .= "NULL, "; + $rq .= "'" . $ret["command_command_id"] . "', " : $rq .= "NULL, "; $rq .= "timeperiod_tp_id = "; isset($ret["timeperiod_tp_id"]) && $ret["timeperiod_tp_id"] != null ? - $rq .= "'".$ret["timeperiod_tp_id"]."', ": $rq .= "NULL, "; + $rq .= "'" . $ret["timeperiod_tp_id"] . "', " : $rq .= "NULL, "; $rq .= "command_command_id2 = "; isset($ret["command_command_id2"]) && $ret["command_command_id2"] != null ? - $rq .= "'".$ret["command_command_id2"]."', ": $rq .= "NULL, "; + $rq .= "'" . $ret["command_command_id2"] . "', " : $rq .= "NULL, "; $rq .= "service_description = "; isset($ret["service_description"]) && $ret["service_description"] != null ? - $rq .= "'".CentreonDB::escape($ret["service_description"])."', ": $rq .= "NULL, "; + $rq .= "'" . CentreonDB::escape($ret["service_description"]) . "', " : $rq .= "NULL, "; $rq .= "service_alias = "; isset($ret["service_alias"]) && $ret["service_alias"] != null ? - $rq .= "'" . CentreonDB::escape($ret["service_alias"]) . "', ": $rq .= "NULL, "; + $rq .= "'" . CentreonDB::escape($ret["service_alias"]) . "', " : $rq .= "NULL, "; $rq .= "service_acknowledgement_timeout = "; isset($ret["service_acknowledgement_timeout"]) && - $ret["service_acknowledgement_timeout"] != null ? - $rq .= "'".$ret["service_acknowledgement_timeout"]."', ": $rq .= "NULL, "; + $ret["service_acknowledgement_timeout"] != null ? + $rq .= "'" . $ret["service_acknowledgement_timeout"] . "', " : $rq .= "NULL, "; $rq .= "service_is_volatile = "; isset($ret["service_is_volatile"]["service_is_volatile"]) && - $ret["service_is_volatile"]["service_is_volatile"] != 2 ? - $rq .= "'".$ret["service_is_volatile"]["service_is_volatile"]."', ": $rq .= "'2', "; + $ret["service_is_volatile"]["service_is_volatile"] != 2 ? + $rq .= "'" . $ret["service_is_volatile"]["service_is_volatile"] . "', " : $rq .= "'2', "; $rq .= "service_max_check_attempts = "; isset($ret["service_max_check_attempts"]) && $ret["service_max_check_attempts"] != null ? - $rq .= "'".$ret["service_max_check_attempts"]."', " : $rq .= "NULL, "; + $rq .= "'" . $ret["service_max_check_attempts"] . "', " : $rq .= "NULL, "; $rq .= "service_normal_check_interval = "; isset($ret["service_normal_check_interval"]) && $ret["service_normal_check_interval"] != null ? - $rq .= "'".$ret["service_normal_check_interval"]."', ": $rq .= "NULL, "; + $rq .= "'" . $ret["service_normal_check_interval"] . "', " : $rq .= "NULL, "; $rq .= "service_retry_check_interval = "; isset($ret["service_retry_check_interval"]) && $ret["service_retry_check_interval"] != null ? - $rq .= "'".$ret["service_retry_check_interval"]."', ": $rq .= "NULL, "; + $rq .= "'" . $ret["service_retry_check_interval"] . "', " : $rq .= "NULL, "; $rq .= "service_active_checks_enabled = "; isset($ret["service_active_checks_enabled"]["service_active_checks_enabled"]) && - $ret["service_active_checks_enabled"]["service_active_checks_enabled"] != 2 ? - $rq .= "'".$ret["service_active_checks_enabled"]["service_active_checks_enabled"]."', ": $rq .= "'2', "; + $ret["service_active_checks_enabled"]["service_active_checks_enabled"] != 2 + ? $rq .= "'" . $ret["service_active_checks_enabled"]["service_active_checks_enabled"] . "', " + : $rq .= "'2', "; $rq .= "service_passive_checks_enabled = "; isset($ret["service_passive_checks_enabled"]["service_passive_checks_enabled"]) && - $ret["service_passive_checks_enabled"]["service_passive_checks_enabled"] != 2 ? - $rq .= "'".$ret["service_passive_checks_enabled"]["service_passive_checks_enabled"]."', ": $rq .= "'2', "; + $ret["service_passive_checks_enabled"]["service_passive_checks_enabled"] != 2 + ? $rq .= "'" . $ret["service_passive_checks_enabled"]["service_passive_checks_enabled"] . "', " + : $rq .= "'2', "; $rq .= "service_obsess_over_service = "; isset($ret["service_obsess_over_service"]["service_obsess_over_service"]) && - $ret["service_obsess_over_service"]["service_obsess_over_service"] != 2 ? - $rq .= "'".$ret["service_obsess_over_service"]["service_obsess_over_service"]."', ": $rq .= "'2', "; + $ret["service_obsess_over_service"]["service_obsess_over_service"] != 2 ? + $rq .= "'" . $ret["service_obsess_over_service"]["service_obsess_over_service"] . "', " : $rq .= "'2', "; $rq .= "service_check_freshness = "; isset($ret["service_check_freshness"]["service_check_freshness"]) && - $ret["service_check_freshness"]["service_check_freshness"] != 2 ? - $rq .= "'".$ret["service_check_freshness"]["service_check_freshness"]."', ": $rq .= "'2', "; + $ret["service_check_freshness"]["service_check_freshness"] != 2 ? + $rq .= "'" . $ret["service_check_freshness"]["service_check_freshness"] . "', " : $rq .= "'2', "; $rq .= "service_freshness_threshold = "; isset($ret["service_freshness_threshold"]) && $ret["service_freshness_threshold"] != null ? - $rq .= "'".$ret["service_freshness_threshold"]."', ": $rq .= "NULL, "; + $rq .= "'" . $ret["service_freshness_threshold"] . "', " : $rq .= "NULL, "; $rq .= "service_event_handler_enabled = "; isset($ret["service_event_handler_enabled"]["service_event_handler_enabled"]) && - $ret["service_event_handler_enabled"]["service_event_handler_enabled"] != 2 ? - $rq .= "'".$ret["service_event_handler_enabled"]["service_event_handler_enabled"]."', ": $rq .= "'2', "; + $ret["service_event_handler_enabled"]["service_event_handler_enabled"] != 2 + ? $rq .= "'" . $ret["service_event_handler_enabled"]["service_event_handler_enabled"] . "', " + : $rq .= "'2', "; $rq .= "service_low_flap_threshold = "; isset($ret["service_low_flap_threshold"]) && $ret["service_low_flap_threshold"] != null ? - $rq .= "'".$ret["service_low_flap_threshold"]."', " : $rq .= "NULL, "; + $rq .= "'" . $ret["service_low_flap_threshold"] . "', " : $rq .= "NULL, "; $rq .= "service_high_flap_threshold = "; isset($ret["service_high_flap_threshold"]) && $ret["service_high_flap_threshold"] != null ? - $rq .= "'".$ret["service_high_flap_threshold"]."', " : $rq .= "NULL, "; + $rq .= "'" . $ret["service_high_flap_threshold"] . "', " : $rq .= "NULL, "; $rq .= "service_flap_detection_enabled = "; isset($ret["service_flap_detection_enabled"]["service_flap_detection_enabled"]) && - $ret["service_flap_detection_enabled"]["service_flap_detection_enabled"] != 2 ? - $rq .= "'".$ret["service_flap_detection_enabled"]["service_flap_detection_enabled"]."', " : $rq .= "'2', "; + $ret["service_flap_detection_enabled"]["service_flap_detection_enabled"] != 2 + ? $rq .= "'" . $ret["service_flap_detection_enabled"]["service_flap_detection_enabled"] . "', " + : $rq .= "'2', "; $rq .= "service_process_perf_data = "; isset($ret["service_process_perf_data"]["service_process_perf_data"]) && - $ret["service_process_perf_data"]["service_process_perf_data"] != 2 ? - $rq .= "'".$ret["service_process_perf_data"]["service_process_perf_data"]."', " : $rq .= "'2', "; + $ret["service_process_perf_data"]["service_process_perf_data"] != 2 ? + $rq .= "'" . $ret["service_process_perf_data"]["service_process_perf_data"] . "', " : $rq .= "'2', "; $rq .= "service_retain_status_information = "; isset($ret["service_retain_status_information"]["service_retain_status_information"]) && - $ret["service_retain_status_information"]["service_retain_status_information"] != 2 ? - $rq .= "'".$ret["service_retain_status_information"]["service_retain_status_information"]."', " : + $ret["service_retain_status_information"]["service_retain_status_information"] != 2 ? + $rq .= "'" . $ret["service_retain_status_information"]["service_retain_status_information"] . "', " : $rq .= "'2', "; $rq .= "service_retain_nonstatus_information = "; isset($ret["service_retain_nonstatus_information"]["service_retain_nonstatus_information"]) && - $ret["service_retain_nonstatus_information"]["service_retain_nonstatus_information"] != 2 ? - $rq .= "'".$ret["service_retain_nonstatus_information"]["service_retain_nonstatus_information"]."', " : + $ret["service_retain_nonstatus_information"]["service_retain_nonstatus_information"] != 2 ? + $rq .= "'" . $ret["service_retain_nonstatus_information"]["service_retain_nonstatus_information"] . "', " : $rq .= "'2', "; $rq .= "service_notifications_enabled = "; isset($ret["service_notifications_enabled"]["service_notifications_enabled"]) && - $ret["service_notifications_enabled"]["service_notifications_enabled"] != 2 ? - $rq .= "'".$ret["service_notifications_enabled"]["service_notifications_enabled"]."', " : $rq .= "'2', "; + $ret["service_notifications_enabled"]["service_notifications_enabled"] != 2 + ? $rq .= "'" . $ret["service_notifications_enabled"]["service_notifications_enabled"] . "', " + : $rq .= "'2', "; $rq .= "service_use_only_contacts_from_host = "; isset($ret["service_use_only_contacts_from_host"]["service_use_only_contacts_from_host"]) && - $ret["service_use_only_contacts_from_host"]["service_use_only_contacts_from_host"] != null ? - $rq .= "'".$ret["service_use_only_contacts_from_host"]["service_use_only_contacts_from_host"]."', " : + $ret["service_use_only_contacts_from_host"]["service_use_only_contacts_from_host"] != null ? + $rq .= "'" . $ret["service_use_only_contacts_from_host"]["service_use_only_contacts_from_host"] . "', " : $rq .= "NULL, "; - $rq.= "contact_additive_inheritance = "; + $rq .= "contact_additive_inheritance = "; $rq .= (isset($ret['contact_additive_inheritance']) ? 1 : 0) . ', '; - $rq.= "cg_additive_inheritance = "; + $rq .= "cg_additive_inheritance = "; $rq .= (isset($ret['cg_additive_inheritance']) ? 1 : 0) . ', '; $rq .= "service_stalking_options = "; isset($ret["service_stalOpts"]) && $ret["service_stalOpts"] != null ? - $rq .= "'".implode(",", array_keys($ret["service_stalOpts"]))."', " : $rq .= "NULL, "; + $rq .= "'" . implode(",", array_keys($ret["service_stalOpts"])) . "', " : $rq .= "NULL, "; $rq .= "service_comment = "; isset($ret["service_comment"]) && $ret["service_comment"] != null ? - $rq .= "'".CentreonDB::escape($ret["service_comment"])."', " : $rq .= "NULL, "; + $rq .= "'" . CentreonDB::escape($ret["service_comment"]) . "', " : $rq .= "NULL, "; $ret["command_command_id_arg"] = $this->getCommandArgs($ret, $ret); $rq .= "command_command_id_arg = "; isset($ret["command_command_id_arg"]) && $ret["command_command_id_arg"] != null ? - $rq .= "'".CentreonDB::escape($ret["command_command_id_arg"])."', " : $rq .= "NULL, "; + $rq .= "'" . CentreonDB::escape($ret["command_command_id_arg"]) . "', " : $rq .= "NULL, "; $rq .= "command_command_id_arg2 = "; isset($ret["command_command_id_arg2"]) && $ret["command_command_id_arg2"] != null ? - $rq .= "'".CentreonDB::escape($ret["command_command_id_arg2"])."', " : $rq .= "NULL, "; + $rq .= "'" . CentreonDB::escape($ret["command_command_id_arg2"]) . "', " : $rq .= "NULL, "; $rq .= "service_register = "; isset($ret["service_register"]) && $ret["service_register"] != null ? - $rq .= "'".$ret["service_register"]."', " : $rq .= "NULL, "; + $rq .= "'" . $ret["service_register"] . "', " : $rq .= "NULL, "; $rq .= "service_activate = "; isset($ret["service_activate"]["service_activate"]) && $ret["service_activate"]["service_activate"] != null ? - $rq .= "'".$ret["service_activate"]["service_activate"]."' " : $rq .= "NULL "; - $rq .= "WHERE service_id = '".$service_id."'"; + $rq .= "'" . $ret["service_activate"]["service_activate"] . "' " : $rq .= "NULL "; + $rq .= "WHERE service_id = '" . $service_id . "'"; $DBRESULT = $this->db->query($rq); @@ -1595,11 +1597,11 @@ public function updateExtendedInfos($service_id, $ret) } /** - * Returns the formatted string for command arguments - * - * @param $argArray - * @return string - */ + * Returns the formatted string for command arguments + * + * @param $argArray + * @return string + */ public function getCommandArgs($argArray = array(), $conf = array()) { if (isset($conf['command_command_id_arg'])) { @@ -1628,7 +1630,7 @@ public function getCommandArgs($argArray = array(), $conf = array()) } - /** + /** * Returns service details * * @param int $id @@ -1655,7 +1657,8 @@ public function getParameters($id, $parameters = array(), $monitoringDB = false) $res = $db->query( "SELECT " . $sElement . " " . "FROM " . $table . " " - . "WHERE service_id = " . $db->escape($id)); + . "WHERE service_id = " . $db->escape($id) + ); if ($res->rowCount()) { $arr = $res->fetchRow(); @@ -1679,7 +1682,7 @@ public function getTemplatesChain($svcId, $alreadyProcessed = array()) $alreadyProcessed[] = $svcId; $res = $this->db->query( - "SELECT service_template_model_stm_id FROM service WHERE service_id = ".$this->db->escape($svcId) + "SELECT service_template_model_stm_id FROM service WHERE service_id = " . $this->db->escape($svcId) ); if ($res->rowCount()) { @@ -1724,7 +1727,7 @@ public function deleteServiceByDescription($service_description) public function setServiceDescription($serviceId, $serviceDescription) { $query = 'UPDATE service ' - . 'SET service_description = "' . $this->db->escape($serviceDescription) . '" ' + . 'SET service_description = "' . $this->db->escape($serviceDescription) . '" ' . 'WHERE service_id = ' . $this->db->escape($serviceId) . ' '; try { @@ -1744,7 +1747,7 @@ public function setServiceDescription($serviceId, $serviceDescription) public function setServiceAlias($serviceId, $serviceAlias) { $query = 'UPDATE service ' - . 'SET service_alias = "' . $this->db->escape($serviceAlias) . '" ' + . 'SET service_alias = "' . $this->db->escape($serviceAlias) . '" ' . 'WHERE service_id = ' . $this->db->escape($serviceId) . ' '; try { diff --git a/www/class/centreonSession.class.php b/www/class/centreonSession.class.php index 7046d8add3b..5ce8b84c6a6 100644 --- a/www/class/centreonSession.class.php +++ b/www/class/centreonSession.class.php @@ -1,4 +1,5 @@ query( "SELECT user_id FROM session - WHERE `session_id` = '".htmlentities(trim($sessionId), ENT_QUOTES, "UTF-8")."'" + WHERE `session_id` = '" . htmlentities(trim($sessionId), ENT_QUOTES, "UTF-8") . "'" ); $row = $DBRESULT->fetchRow(); if (!$row) { From 134503f348e0cfab4502eb971f4848d44888bb5b Mon Sep 17 00:00:00 2001 From: loiclau Date: Wed, 19 Jul 2017 16:26:01 +0200 Subject: [PATCH 046/207] * fix style widget params --- www/class/centreonWidget/Params.class.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/www/class/centreonWidget/Params.class.php b/www/class/centreonWidget/Params.class.php index 9fff3fbdca2..7bb2de9c8cb 100644 --- a/www/class/centreonWidget/Params.class.php +++ b/www/class/centreonWidget/Params.class.php @@ -35,7 +35,9 @@ require_once __DIR__ . "/Params/Interface.class.php"; -class CentreonWidgetParamsException extends Exception {} +class CentreonWidgetParamsException extends Exception +{ +} abstract class CentreonWidgetParams implements CentreonWidgetParamsInterface { @@ -88,17 +90,17 @@ protected function getUserPreferences($params) { $query = "SELECT preference_value FROM widget_preferences wp, widget_views wv, custom_view_user_relation cvur - WHERE wp.parameter_id = " .$this->db->escape($params['parameter_id']) . " + WHERE wp.parameter_id = " . $this->db->escape($params['parameter_id']) . " AND wp.widget_view_id = wv.widget_view_id - AND wv.widget_id = ".$this->db->escape($params['widget_id'])." + AND wv.widget_id = " . $this->db->escape($params['widget_id']) . " AND wv.custom_view_id = cvur.custom_view_id - AND wp.user_id = ".$this->db->escape($this->userId) . " + AND wp.user_id = " . $this->db->escape($this->userId) . " AND (cvur.user_id = wp.user_id"; if (count($this->userGroups)) { $cglist = implode(",", $this->userGroups); $query .= " OR cvur.usergroup_id IN ($cglist) "; } - $query .= ") AND cvur.custom_view_id = ". $this->db->escape($params['custom_view_id']) . " + $query .= ") AND cvur.custom_view_id = " . $this->db->escape($params['custom_view_id']) . " LIMIT 1"; $res = $this->db->query($query); if ($res->rowCount()) { @@ -158,13 +160,13 @@ public function setValue($params) } /** - * Get Element - * - * @return HTML_Quickform - */ + * Get Element + * + * @return HTML_Quickform + */ public function getElement() { - return $this->element; + return $this->element; } /** From ed97d794c6c8e86d17c8296a756de64c0763cb4c Mon Sep 17 00:00:00 2001 From: loiclau Date: Wed, 19 Jul 2017 17:54:01 +0200 Subject: [PATCH 047/207] * fix service dependency --- .../service_dependency/DB-Func.php | 130 +++++-- .../formServiceDependency.php | 330 +++++++++++------- .../configObject/service_dependency/help.php | 94 ++++- .../listServiceDependency.php | 118 ++++--- 4 files changed, 454 insertions(+), 218 deletions(-) diff --git a/www/include/configuration/configObject/service_dependency/DB-Func.php b/www/include/configuration/configObject/service_dependency/DB-Func.php index 2abdcb00404..d979b319934 100644 --- a/www/include/configuration/configObject/service_dependency/DB-Func.php +++ b/www/include/configuration/configObject/service_dependency/DB-Func.php @@ -51,7 +51,9 @@ function testServiceDependencyExistence($name = null) if (isset($form)) { $id = $form->getSubmitValue('dep_id'); } - $DBRESULT = $pearDB->query("SELECT dep_name, dep_id FROM dependency WHERE dep_name = '".htmlentities($name, ENT_QUOTES, "UTF-8")."'"); + $query = "SELECT dep_name, dep_id FROM dependency WHERE dep_name = '" . + htmlentities($name, ENT_QUOTES, "UTF-8") . "'"; + $DBRESULT = $pearDB->query($query); $dep = $DBRESULT->fetchRow(); #Modif case if ($DBRESULT->rowCount() >= 1 && $dep["dep_id"] == $id) { @@ -87,10 +89,10 @@ function deleteServiceDependencyInDB($dependencies = array()) { global $pearDB, $oreon; foreach ($dependencies as $key => $value) { - $DBRESULT2 = $pearDB->query("SELECT dep_name FROM `dependency` WHERE `dep_id` = '".$key."' LIMIT 1"); + $DBRESULT2 = $pearDB->query("SELECT dep_name FROM `dependency` WHERE `dep_id` = '" . $key . "' LIMIT 1"); $row = $DBRESULT2->fetchRow(); - $DBRESULT = $pearDB->query("DELETE FROM dependency WHERE dep_id = '".$key."'"); + $DBRESULT = $pearDB->query("DELETE FROM dependency WHERE dep_id = '" . $key . "'"); $oreon->CentreonLogAction->insertLog("service dependency", $key, $row['dep_name'], "d"); } } @@ -99,14 +101,16 @@ function multipleServiceDependencyInDB($dependencies = array(), $nbrDup = array( { foreach ($dependencies as $key => $value) { global $pearDB, $oreon; - $DBRESULT = $pearDB->query("SELECT * FROM dependency WHERE dep_id = '".$key."' LIMIT 1"); + $DBRESULT = $pearDB->query("SELECT * FROM dependency WHERE dep_id = '" . $key . "' LIMIT 1"); $row = $DBRESULT->fetchRow(); $row["dep_id"] = ''; for ($i = 1; $i <= $nbrDup[$key]; $i++) { $val = null; foreach ($row as $key2 => $value2) { - $key2 == "dep_name" ? ($dep_name = $value2 = $value2."_".$i) : null; - $val ? $val .= ($value2!=null?(", '".$value2."'"):", NULL") : $val .= ($value2!=null?("'".$value2."'"):"NULL"); + $key2 == "dep_name" ? ($dep_name = $value2 = $value2 . "_" . $i) : null; + $val + ? $val .= ($value2 != null ? (", '" . $value2 . "'") : ", NULL") + : $val .= ($value2 != null ? ("'" . $value2 . "'") : "NULL"); if ($key2 != "dep_id") { $fields[$key2] = $value2; } @@ -115,26 +119,39 @@ function multipleServiceDependencyInDB($dependencies = array(), $nbrDup = array( } } if (isset($dep_name) && testServiceDependencyExistence($dep_name)) { - $val ? $rq = "INSERT INTO dependency VALUES (".$val.")" : $rq = null; + $val ? $rq = "INSERT INTO dependency VALUES (" . $val . ")" : $rq = null; $pearDB->query($rq); $DBRESULT = $pearDB->query("SELECT MAX(dep_id) FROM dependency"); $maxId = $DBRESULT->fetchRow(); if (isset($maxId["MAX(dep_id)"])) { - $DBRESULT = $pearDB->query("SELECT * FROM dependency_serviceParent_relation WHERE dependency_dep_id = '".$key."'"); + $query = "SELECT * FROM dependency_serviceParent_relation WHERE dependency_dep_id = '" . $key . "'"; + $DBRESULT = $pearDB->query($query); $fields["dep_hSvPar"] = ""; while ($service = $DBRESULT->fetchRow()) { - $DBRESULT2 = $pearDB->query("INSERT INTO dependency_serviceParent_relation VALUES ('', '".$maxId["MAX(dep_id)"]."', '".$service["service_service_id"]."', '".$service["host_host_id"]."')"); + $query = "INSERT INTO dependency_serviceParent_relation VALUES ('', '" . + $maxId["MAX(dep_id)"] . "', '" . $service["service_service_id"] . "', '" . + $service["host_host_id"] . "')"; + $pearDB->query($query); $fields["dep_hSvPar"] .= $service["service_service_id"] . ","; } $fields["dep_hSvPar"] = trim($fields["dep_hSvPar"], ","); - $DBRESULT = $pearDB->query("SELECT * FROM dependency_serviceChild_relation WHERE dependency_dep_id = '".$key."'"); + $query = "SELECT * FROM dependency_serviceChild_relation WHERE dependency_dep_id = '" . $key . "'"; + $DBRESULT = $pearDB->query($query); $fields["dep_hSvChi"] = ""; while ($service = $DBRESULT->fetchRow()) { - $DBRESULT2 = $pearDB->query("INSERT INTO dependency_serviceChild_relation VALUES ('', '".$maxId["MAX(dep_id)"]."', '".$service["service_service_id"]."', '".$service["host_host_id"]."')"); + $query = "INSERT INTO dependency_serviceChild_relation VALUES ('', '" . $maxId["MAX(dep_id)"] . + "', '" . $service["service_service_id"] . "', '" . $service["host_host_id"] . "')"; + $pearDB->query($query); $fields["dep_hSvChi"] .= $service["service_service_id"] . ","; } $fields["dep_hSvChi"] = trim($fields["dep_hSvChi"], ","); - $oreon->CentreonLogAction->insertLog("service dependency", $maxId["MAX(dep_id)"], $dep_name, "a", $fields); + $oreon->CentreonLogAction->insertLog( + "service dependency", + $maxId["MAX(dep_id)"], + $dep_name, + "a", + $fields + ); } } } @@ -169,14 +186,27 @@ function insertServiceDependency($ret = array()) $ret = $form->getSubmitValues(); } $rq = "INSERT INTO dependency "; - $rq .= "(dep_name, dep_description, inherits_parent, execution_failure_criteria, notification_failure_criteria, dep_comment) "; + $rq .= "(dep_name, dep_description, inherits_parent, execution_failure_criteria, " . + "notification_failure_criteria, dep_comment) "; $rq .= "VALUES ("; - isset($ret["dep_name"]) && $ret["dep_name"] != null ? $rq .= "'".htmlentities($ret["dep_name"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; - isset($ret["dep_description"]) && $ret["dep_description"] != null ? $rq .= "'".htmlentities($ret["dep_description"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; - isset($ret["inherits_parent"]["inherits_parent"]) && $ret["inherits_parent"]["inherits_parent"] != null ? $rq .= "'".$ret["inherits_parent"]["inherits_parent"]."', " : $rq .= "NULL, "; - isset($ret["execution_failure_criteria"]) && $ret["execution_failure_criteria"] != null ? $rq .= "'".implode(",", array_keys($ret["execution_failure_criteria"]))."', " : $rq .= "NULL, "; - isset($ret["notification_failure_criteria"]) && $ret["notification_failure_criteria"] != null ? $rq .= "'".implode(",", array_keys($ret["notification_failure_criteria"]))."', " : $rq .= "NULL, "; - isset($ret["dep_comment"]) && $ret["dep_comment"] != null ? $rq .= "'".htmlentities($ret["dep_comment"], ENT_QUOTES, "UTF-8")."' " : $rq .= "NULL "; + isset($ret["dep_name"]) && $ret["dep_name"] != null + ? $rq .= "'" . htmlentities($ret["dep_name"], ENT_QUOTES, "UTF-8") . "', " + : $rq .= "NULL, "; + isset($ret["dep_description"]) && $ret["dep_description"] != null + ? $rq .= "'" . htmlentities($ret["dep_description"], ENT_QUOTES, "UTF-8") . "', " + : $rq .= "NULL, "; + isset($ret["inherits_parent"]["inherits_parent"]) && $ret["inherits_parent"]["inherits_parent"] != null + ? $rq .= "'" . $ret["inherits_parent"]["inherits_parent"] . "', " + : $rq .= "NULL, "; + isset($ret["execution_failure_criteria"]) && $ret["execution_failure_criteria"] != null + ? $rq .= "'" . implode(",", array_keys($ret["execution_failure_criteria"])) . "', " + : $rq .= "NULL, "; + isset($ret["notification_failure_criteria"]) && $ret["notification_failure_criteria"] != null + ? $rq .= "'" . implode(",", array_keys($ret["notification_failure_criteria"])) . "', " + : $rq .= "NULL, "; + isset($ret["dep_comment"]) && $ret["dep_comment"] != null + ? $rq .= "'" . htmlentities($ret["dep_comment"], ENT_QUOTES, "UTF-8") . "' " + : $rq .= "NULL "; $rq .= ")"; $DBRESULT = $pearDB->query($rq); $DBRESULT = $pearDB->query("SELECT MAX(dep_id) FROM dependency"); @@ -202,7 +232,13 @@ function insertServiceDependency($ret = array()) if (isset($ret["dep_hSvChi"])) { $fields["dep_hSvChi"] = implode(",", $ret["dep_hSvChi"]); } - $oreon->CentreonLogAction->insertLog("service dependency", $dep_id["MAX(dep_id)"], htmlentities($ret["dep_name"], ENT_QUOTES, "UTF-8"), "a", $fields); + $oreon->CentreonLogAction->insertLog( + "service dependency", + $dep_id["MAX(dep_id)"], + htmlentities($ret["dep_name"], ENT_QUOTES, "UTF-8"), + "a", + $fields + ); return ($dep_id["MAX(dep_id)"]); } @@ -217,19 +253,31 @@ function updateServiceDependency($dep_id = null) $ret = $form->getSubmitValues(); $rq = "UPDATE dependency SET "; $rq .= "dep_name = "; - isset($ret["dep_name"]) && $ret["dep_name"] != null ? $rq .= "'".htmlentities($ret["dep_name"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + isset($ret["dep_name"]) && $ret["dep_name"] != null + ? $rq .= "'" . htmlentities($ret["dep_name"], ENT_QUOTES, "UTF-8") . "', " + : $rq .= "NULL, "; $rq .= "dep_description = "; - isset($ret["dep_description"]) && $ret["dep_description"] != null ? $rq .= "'".htmlentities($ret["dep_description"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + isset($ret["dep_description"]) && $ret["dep_description"] != null + ? $rq .= "'" . htmlentities($ret["dep_description"], ENT_QUOTES, "UTF-8") . "', " + : $rq .= "NULL, "; $rq .= "inherits_parent = "; - isset($ret["inherits_parent"]["inherits_parent"]) && $ret["inherits_parent"]["inherits_parent"] != null ? $rq .= "'".$ret["inherits_parent"]["inherits_parent"]."', " : $rq .= "NULL, "; + isset($ret["inherits_parent"]["inherits_parent"]) && $ret["inherits_parent"]["inherits_parent"] != null + ? $rq .= "'" . $ret["inherits_parent"]["inherits_parent"] . "', " + : $rq .= "NULL, "; $rq .= "execution_failure_criteria = "; - isset($ret["execution_failure_criteria"]) && $ret["execution_failure_criteria"] != null ? $rq .= "'".implode(",", array_keys($ret["execution_failure_criteria"]))."', " : $rq .= "NULL, "; + isset($ret["execution_failure_criteria"]) && $ret["execution_failure_criteria"] != null + ? $rq .= "'" . implode(",", array_keys($ret["execution_failure_criteria"])) . "', " + : $rq .= "NULL, "; $rq .= "notification_failure_criteria = "; - isset($ret["notification_failure_criteria"]) && $ret["notification_failure_criteria"] != null ? $rq .= "'".implode(",", array_keys($ret["notification_failure_criteria"]))."', " : $rq .= "NULL, "; + isset($ret["notification_failure_criteria"]) && $ret["notification_failure_criteria"] != null + ? $rq .= "'" . implode(",", array_keys($ret["notification_failure_criteria"])) . "', " + : $rq .= "NULL, "; $rq .= "dep_comment = "; - isset($ret["dep_comment"]) && $ret["dep_comment"] != null ? $rq .= "'".htmlentities($ret["dep_comment"], ENT_QUOTES, "UTF-8")."' " : $rq .= "NULL "; - $rq .= "WHERE dep_id = '".$dep_id."'"; - $DBRESULT = $pearDB->query($rq); + isset($ret["dep_comment"]) && $ret["dep_comment"] != null + ? $rq .= "'" . htmlentities($ret["dep_comment"], ENT_QUOTES, "UTF-8") . "' " + : $rq .= "NULL "; + $rq .= "WHERE dep_id = '" . $dep_id . "'"; + $pearDB->query($rq); $fields["dep_name"] = htmlentities($ret["dep_name"], ENT_QUOTES, "UTF-8"); $fields["dep_description"] = htmlentities($ret["dep_description"], ENT_QUOTES, "UTF-8"); @@ -249,7 +297,13 @@ function updateServiceDependency($dep_id = null) if (isset($ret["dep_hSvChi"])) { $fields["dep_hSvChi"] = implode(",", $ret["dep_hSvChi"]); } - $oreon->CentreonLogAction->insertLog("service dependency", $dep_id, htmlentities($ret["dep_name"], ENT_QUOTES, "UTF-8"), "c", $fields); + $oreon->CentreonLogAction->insertLog( + "service dependency", + $dep_id, + htmlentities($ret["dep_name"], ENT_QUOTES, "UTF-8"), + "c", + $fields + ); } function updateServiceDependencyServiceParents($dep_id = null, $ret = array()) @@ -260,7 +314,7 @@ function updateServiceDependencyServiceParents($dep_id = null, $ret = array()) global $form; global $pearDB; $rq = "DELETE FROM dependency_serviceParent_relation "; - $rq .= "WHERE dependency_dep_id = '".$dep_id."'"; + $rq .= "WHERE dependency_dep_id = '" . $dep_id . "'"; $DBRESULT = $pearDB->query($rq); if (isset($ret["dep_hSvPar"])) { $ret1 = $ret["dep_hSvPar"]; @@ -273,7 +327,7 @@ function updateServiceDependencyServiceParents($dep_id = null, $ret = array()) $rq = "INSERT INTO dependency_serviceParent_relation "; $rq .= "(dependency_dep_id, service_service_id, host_host_id) "; $rq .= "VALUES "; - $rq .= "('".$dep_id."', '".$exp[1]."', '".$exp[0]."')"; + $rq .= "('" . $dep_id . "', '" . $exp[1] . "', '" . $exp[0] . "')"; $DBRESULT = $pearDB->query($rq); } } @@ -287,7 +341,7 @@ function updateServiceDependencyServiceChilds($dep_id = null, $ret = array()) global $form; global $pearDB; $rq = "DELETE FROM dependency_serviceChild_relation "; - $rq .= "WHERE dependency_dep_id = '".$dep_id."'"; + $rq .= "WHERE dependency_dep_id = '" . $dep_id . "'"; $DBRESULT = $pearDB->query($rq); if (isset($ret["dep_hSvChi"])) { $ret1 = $ret["dep_hSvChi"]; @@ -300,15 +354,15 @@ function updateServiceDependencyServiceChilds($dep_id = null, $ret = array()) $rq = "INSERT INTO dependency_serviceChild_relation "; $rq .= "(dependency_dep_id, service_service_id, host_host_id) "; $rq .= "VALUES "; - $rq .= "('".$dep_id."', '".$exp[1]."', '".$exp[0]."')"; + $rq .= "('" . $dep_id . "', '" . $exp[1] . "', '" . $exp[0] . "')"; $DBRESULT = $pearDB->query($rq); } } } - /** - * Update Service Dependency Host Children - */ +/** + * Update Service Dependency Host Children + */ function updateServiceDependencyHostChildren($dep_id = null, $ret = array()) { if (!$dep_id) { @@ -317,7 +371,7 @@ function updateServiceDependencyHostChildren($dep_id = null, $ret = array()) global $form; global $pearDB; $rq = "DELETE FROM dependency_hostChild_relation "; - $rq .= "WHERE dependency_dep_id = '".$dep_id."'"; + $rq .= "WHERE dependency_dep_id = '" . $dep_id . "'"; $DBRESULT = $pearDB->query($rq); if (isset($ret["dep_hHostChi"])) { $ret1 = $ret["dep_hHostChi"]; @@ -328,7 +382,7 @@ function updateServiceDependencyHostChildren($dep_id = null, $ret = array()) $rq = "INSERT INTO dependency_hostChild_relation "; $rq .= "(dependency_dep_id, host_host_id) "; $rq .= "VALUES "; - $rq .= "('".$dep_id."', '".$ret1[$i]."')"; + $rq .= "('" . $dep_id . "', '" . $ret1[$i] . "')"; $DBRESULT = $pearDB->query($rq); } } diff --git a/www/include/configuration/configObject/service_dependency/formServiceDependency.php b/www/include/configuration/configObject/service_dependency/formServiceDependency.php index 8f8c6293f4e..66fd48ab852 100644 --- a/www/include/configuration/configObject/service_dependency/formServiceDependency.php +++ b/www/include/configuration/configObject/service_dependency/formServiceDependency.php @@ -41,7 +41,7 @@ $initialValues = array(); if (($o == "c" || $o == "w") && $dep_id) { - $DBRESULT = $pearDB->query("SELECT * FROM dependency WHERE dep_id = '".$dep_id."' LIMIT 1"); + $DBRESULT = $pearDB->query("SELECT * FROM dependency WHERE dep_id = '" . $dep_id . "' LIMIT 1"); // Set base value $dep = array_map("myDecode", $DBRESULT->fetchRow()); @@ -58,30 +58,35 @@ $dep["execution_failure_criteria"][trim($value)] = 1; } - $DBRESULT->closeCursor(); + $DBRESULT->closeCursor(); } # Var information to format the element -$attrsText = array("size"=>"30"); -$attrsText2 = array("size"=>"10"); +$attrsText = array("size" => "30"); +$attrsText2 = array("size" => "10"); $attrsAdvSelect = array("style" => "width: 400px; height: 200px;"); -$attrsTextarea = array("rows"=>"3", "cols"=>"30"); -$eTemplate = '
{label_2}
{unselected}
{add}


{remove}
{label_3}
{selected}
'; +$attrsTextarea = array("rows" => "3", "cols" => "30"); +$eTemplate = '
{label_2}
{unselected}
{add}
' . + '

{remove}
{label_3}
{selected}
'; + +$route = './include/common/webServices/rest/internal.php?object=centreon_configuration_host&action=list'; $attrHosts = array( 'datasourceOrigin' => 'ajax', - 'availableDatasetRoute' => './include/common/webServices/rest/internal.php?object=centreon_configuration_host&action=list', + 'availableDatasetRoute' => $route, 'multiple' => true, 'linkedObject' => 'centreonHost' ); + +$route = './include/common/webServices/rest/internal.php?object=centreon_configuration_service&action=list'; $attrServices = array( 'datasourceOrigin' => 'ajax', - 'availableDatasetRoute' => './include/common/webServices/rest/internal.php?object=centreon_configuration_service&action=list', + 'availableDatasetRoute' => $route, 'multiple' => true, 'linkedObject' => 'centreonService' ); # Form begin -$form = new HTML_QuickForm('Form', 'post', "?p=".$p); +$form = new HTML_QuickForm('Form', 'post', "?p=" . $p); if ($o == "a") { $form->addElement('header', 'title', _("Add a Dependency")); } elseif ($o == "c") { @@ -99,43 +104,121 @@ $tab[] = HTML_QuickForm::createElement('radio', 'inherits_parent', null, _("Yes"), '1'); $tab[] = HTML_QuickForm::createElement('radio', 'inherits_parent', null, _("No"), '0'); $form->addGroup($tab, 'inherits_parent', _("Parent relationship"), ' '); -$form->setDefaults(array('inherits_parent'=>'1')); +$form->setDefaults(array('inherits_parent' => '1')); $tab = array(); -$tab[] = HTML_QuickForm::createElement('checkbox', 'o', ' ', _("Ok"), array('id' => 'sOk', 'onClick' => 'uncheckAllS(this);')); -$tab[] = HTML_QuickForm::createElement('checkbox', 'w', ' ', _("Warning"), array('id' => 'sWarning', 'onClick' => 'uncheckAllS(this);')); -$tab[] = HTML_QuickForm::createElement('checkbox', 'u', ' ', _("Unknown"), array('id' => 'sUnknown', 'onClick' => 'uncheckAllS(this);')); -$tab[] = HTML_QuickForm::createElement('checkbox', 'c', ' ', _("Critical"), array('id' => 'sCritical', 'onClick' => 'uncheckAllS(this);')); -$tab[] = HTML_QuickForm::createElement('checkbox', 'p', ' ', _("Pending"), array('id' => 'sPending', 'onClick' => 'uncheckAllS(this);')); -$tab[] = HTML_QuickForm::createElement('checkbox', 'n', ' ', _("None"), array('id' => 'sNone', 'onClick' => 'uncheckAllS(this);')); +$tab[] = HTML_QuickForm::createElement( + 'checkbox', + 'o', + ' ', + _("Ok"), + array('id' => 'sOk', 'onClick' => 'uncheckAllS(this);') +); +$tab[] = HTML_QuickForm::createElement( + 'checkbox', + 'w', + ' ', + _("Warning"), + array('id' => 'sWarning', 'onClick' => 'uncheckAllS(this);') +); +$tab[] = HTML_QuickForm::createElement( + 'checkbox', + 'u', + ' ', + _("Unknown"), + array('id' => 'sUnknown', 'onClick' => 'uncheckAllS(this);') +); +$tab[] = HTML_QuickForm::createElement( + 'checkbox', + 'c', + ' ', + _("Critical"), + array('id' => 'sCritical', 'onClick' => 'uncheckAllS(this);') +); +$tab[] = HTML_QuickForm::createElement( + 'checkbox', + 'p', + ' ', + _("Pending"), + array('id' => 'sPending', 'onClick' => 'uncheckAllS(this);') +); +$tab[] = HTML_QuickForm::createElement( + 'checkbox', + 'n', + ' ', + _("None"), + array('id' => 'sNone', 'onClick' => 'uncheckAllS(this);') +); $form->addGroup($tab, 'notification_failure_criteria', _("Notification Failure Criteria"), '  '); $tab = array(); -$tab[] = HTML_QuickForm::createElement('checkbox', 'o', ' ', _("Ok"), array('id' => 'sOk2', 'onClick' => 'uncheckAllS2(this);')); -$tab[] = HTML_QuickForm::createElement('checkbox', 'w', ' ', _("Warning"), array('id' => 'sWarning2', 'onClick' => 'uncheckAllS2(this);')); -$tab[] = HTML_QuickForm::createElement('checkbox', 'u', ' ', _("Unknown"), array('id' => 'sUnknown2', 'onClick' => 'uncheckAllS2(this);')); -$tab[] = HTML_QuickForm::createElement('checkbox', 'c', ' ', _("Critical"), array('id' => 'sCritical2', 'onClick' => 'uncheckAllS2(this);')); -$tab[] = HTML_QuickForm::createElement('checkbox', 'p', ' ', _("Pending"), array('id' => 'sPending2', 'onClick' => 'uncheckAllS2(this);')); -$tab[] = HTML_QuickForm::createElement('checkbox', 'n', ' ', _("None"), array('id' => 'sNone2', 'onClick' => 'uncheckAllS2(this);')); +$tab[] = HTML_QuickForm::createElement( + 'checkbox', + 'o', + ' ', + _("Ok"), + array('id' => 'sOk2', 'onClick' => 'uncheckAllS2(this);') +); +$tab[] = HTML_QuickForm::createElement( + 'checkbox', + 'w', + ' ', + _("Warning"), + array('id' => 'sWarning2', 'onClick' => 'uncheckAllS2(this);') +); +$tab[] = HTML_QuickForm::createElement( + 'checkbox', + 'u', + ' ', + _("Unknown"), + array('id' => 'sUnknown2', 'onClick' => 'uncheckAllS2(this);') +); +$tab[] = HTML_QuickForm::createElement( + 'checkbox', + 'c', + ' ', + _("Critical"), + array('id' => 'sCritical2', 'onClick' => 'uncheckAllS2(this);') +); +$tab[] = HTML_QuickForm::createElement( + 'checkbox', + 'p', + ' ', + _("Pending"), + array('id' => 'sPending2', 'onClick' => 'uncheckAllS2(this);') +); +$tab[] = HTML_QuickForm::createElement( + 'checkbox', + 'n', + ' ', + _("None"), + array('id' => 'sNone2', 'onClick' => 'uncheckAllS2(this);') +); $form->addGroup($tab, 'execution_failure_criteria', _("Execution Failure Criteria"), '  '); $form->addElement('textarea', 'dep_comment', _("Comments"), $attrsTextarea); +$route = './include/common/webServices/rest/internal.php?object=centreon_configuration_service&' . + 'action=defaultValues&target=dependency&field=dep_hSvPar&id=' . $dep_id; $attrService1 = array_merge( $attrServices, - array('defaultDatasetRoute' => './include/common/webServices/rest/internal.php?object=centreon_configuration_service&action=defaultValues&target=dependency&field=dep_hSvPar&id=' . $dep_id) + array('defaultDatasetRoute' => $route) ); $form->addElement('select2', 'dep_hSvPar', _("Services"), array(), $attrService1); +$route = './include/common/webServices/rest/internal.php?object=centreon_configuration_service&action=defaultValues' . + '&target=dependency&field=dep_hSvChi&id=' . $dep_id; $attrService2 = array_merge( $attrServices, - array('defaultDatasetRoute' => './include/common/webServices/rest/internal.php?object=centreon_configuration_service&action=defaultValues&target=dependency&field=dep_hSvChi&id=' . $dep_id) + array('defaultDatasetRoute' => $route) ); $form->addElement('select2', 'dep_hSvChi', _("Dependent Services"), array(), $attrService2); +$route = './include/common/webServices/rest/internal.php?object=centreon_configuration_host&' . + 'action=defaultValues&target=dependency&field=dep_hHostChi&id=' . $dep_id; $attrHost2 = array_merge( $attrHosts, - array('defaultDatasetRoute' => './include/common/webServices/rest/internal.php?object=centreon_configuration_host&action=defaultValues&target=dependency&field=dep_hHostChi&id=' . $dep_id) + array('defaultDatasetRoute' => $route) ); $form->addElement('select2', 'dep_hHostChi', _("Dependent Hosts"), array(), $attrHost2); @@ -154,7 +237,7 @@ $form->addRule('dep_hSvChi', _("Circular Definition"), 'cycleH'); $form->registerRule('exist', 'callback', 'testServiceDependencyExistence'); $form->addRule('dep_name', _("Name is already in use"), 'exist'); -$form->setRequiredNote("* ". _("Required fields")); +$form->setRequiredNote("* " . _("Required fields")); /* @@ -166,20 +249,30 @@ $tpl->assign("sort1", _("Information")); $tpl->assign("sort2", _("Service Description")); -$tpl->assign("helpattr", 'TITLE, "'._("Help").'", CLOSEBTN, true, FIX, [this, 0, 5], BGCOLOR, "#ffff99", BORDERCOLOR, "orange", TITLEFONTCOLOR, "black", TITLEBGCOLOR, "orange", CLOSEBTNCOLORS, ["","black", "white", "red"], WIDTH, -300, SHADOW, true, TEXTALIGN, "justify"'); +$tpl->assign( + "helpattr", + 'TITLE, "' . _("Help") . '", CLOSEBTN, true, FIX, [this, 0, 5], BGCOLOR, "#ffff99", BORDERCOLOR, ' . + '"orange", TITLEFONTCOLOR, "black", TITLEBGCOLOR, "orange", CLOSEBTNCOLORS, ["","black", "white", "red"], ' . + 'WIDTH, -300, SHADOW, true, TEXTALIGN, "justify"' +); // prepare help texts $helptext = ""; include_once("help.php"); foreach ($help as $key => $text) { - $helptext .= ''."\n"; + $helptext .= '' . "\n"; } $tpl->assign("helptext", $helptext); // Just watch a Dependency information if ($o == "w") { if ($centreon->user->access->page($p) != 2) { - $form->addElement("button", "change", _("Modify"), array("onClick"=>"javascript:window.location.href='?p=".$p."&o=c&dep_id=".$dep_id."'")); + $form->addElement( + "button", + "change", + _("Modify"), + array("onClick" => "javascript:window.location.href='?p=" . $p . "&o=c&dep_id=" . $dep_id . "'") + ); } $form->setDefaults($dep); $form->freeze(); @@ -222,113 +315,110 @@ } ?> diff --git a/www/include/configuration/configObject/service_dependency/help.php b/www/include/configuration/configObject/service_dependency/help.php index 598c84ce1f9..92fd07055fa 100644 --- a/www/include/configuration/configObject/service_dependency/help.php +++ b/www/include/configuration/configObject/service_dependency/help.php @@ -2,40 +2,104 @@ $help = array(); $help["name"] = dgettext("help", "Define a short name for this dependency."); -$help["description"] = dgettext("help", "Define a description for this dependency for easier identification and differentiation."); +$help["description"] = dgettext( + "help", + "Define a description for this dependency for easier identification and differentiation." +); $help["inherits_parent"] = sprintf( "%s
%s", - dgettext("help", "This directive indicates whether or not the dependency inherits dependencies of the host that is being depended upon (also referred to as the master host). In other words, if the master host is dependent upon other hosts and any one of those dependencies fail, this dependency will also fail."), + dgettext( + "help", + "This directive indicates whether or not the dependency inherits dependencies of the host that is " . + "being depended upon (also referred to as the master host). In other words, if the master host is " . + "dependent upon other hosts and any one of those dependencies fail, this dependency will also fail." + ), dgettext("help", "Ignored by Centreon Engine.") ); -$help["execution_failure_criteria"] = dgettext("help", "This directive is used to specify the criteria that determine when the dependent host should not be actively checked. If the master host is in one of the failure states we specify, the dependent host will not be actively checked. If you specify None as an option, the execution dependency will never fail and the dependent host will always be actively checked (if other conditions allow for it to be)."); -$help["notification_failure_criteria"] = dgettext("help", "This directive is used to define the criteria that determine when notifications for the dependent host should not be sent out. If the master host is in one of the failure states we specify, notifications for the dependent host will not be sent to contacts. If you specify None as an option, the notification dependency will never fail and notifications for the dependent host will always be sent out."); +$help["execution_failure_criteria"] = dgettext( + "help", + "This directive is used to specify the criteria that determine when the dependent host should not be " . + "actively checked. If the master host is in one of the failure states we specify, the dependent host will " . + "not be actively checked. If you specify None as an option, the execution dependency will never fail and " . + "the dependent host will always be actively checked (if other conditions allow for it to be)." +); +$help["notification_failure_criteria"] = dgettext( + "help", + "This directive is used to define the criteria that determine when notifications for the dependent host " . + "should not be sent out. If the master host is in one of the failure states we specify, notifications " . + "for the dependent host will not be sent to contacts. If you specify None as an option, the notification " . + "dependency will never fail and notifications for the dependent host will always be sent out." +); /* * Host service description */ -$help["host_name"] = dgettext("help", "This directive is used to identify the host(s) that the service that is being depended upon (also referred to as the master service) \"runs\" on or is associated with."); -$help["service_description"] = dgettext("help", "This directive is used to identify the description of the service that is being depended upon (also referred to as the master service)."); -$help["dependent_host_name"] = dgettext("help", "This directive is used to identify the host(s) that the dependent service \"runs\" on or is associated with. Leaving this directive blank can be used to create \"same host\" dependencies."); -$help["dependent_service_description"] = dgettext("help", "This directive is used to identify the description of the dependent service."); +$help["host_name"] = dgettext( + "help", + "This directive is used to identify the host(s) that the service that is being depended upon " . + "(also referred to as the master service) \"runs\" on or is associated with." +); +$help["service_description"] = dgettext( + "help", + "This directive is used to identify the description of the service that is being depended upon " . + "(also referred to as the master service)." +); +$help["dependent_host_name"] = dgettext( + "help", + "This directive is used to identify the host(s) that the dependent service \"runs\" on or is " . + "associated with. Leaving this directive blank can be used to create \"same host\" dependencies." +); +$help["dependent_service_description"] = dgettext( + "help", + "This directive is used to identify the description of the dependent service." +); -$help["hostgroup_name"] = dgettext("help", "This directive is used to identify the short name(s) of the hostgroup(s) that the service that is being depended upon (also referred to as the master service) \"runs\" on or is associated with. Multiple hostgroups should be separated by commas. The hostgroup_name may be used instead of, or in addition to, the host_name directive."); -$help["dependent_hostgroup_name"] = dgettext("help", "This directive is used to specify the short name (s) of the hostgroup(s) that the dependent service \"runs\" on or is associated with. The dependent_hostgroup may be used instead of, or in addition to, the dependent_host directive."); +$help["hostgroup_name"] = dgettext( + "help", + "This directive is used to identify the short name(s) of the hostgroup(s) that the service that is being " . + "depended upon (also referred to as the master service) \"runs\" on or is associated with. " . + "Multiple hostgroups should be separated by commas. The hostgroup_name may be used instead of, or " . + "in addition to, the host_name directive." +); +$help["dependent_hostgroup_name"] = dgettext( + "help", + "This directive is used to specify the short name (s) of the hostgroup(s) that the dependent service \"runs\" on " . + "or is associated with. The dependent_hostgroup may be used instead of, or in addition to, " . + "the dependent_host directive." +); -$help["servicegroup_name"] = dgettext("help", "This directive is used to identify the description of the service group that is being depended upon (also referred to as the master service group)."); -$help["dependent_servicegroup_name"] = dgettext("help", "This directive is used to identify the description of the dependent service group."); +$help["servicegroup_name"] = dgettext( + "help", + "This directive is used to identify the description of the service group that is being depended upon " . + "(also referred to as the master service group)." +); +$help["dependent_servicegroup_name"] = dgettext( + "help", + "This directive is used to identify the description of the dependent service group." +); -$help["metaservice_name"] = dgettext("help", "This directive is used to identify the description of the meta service that is being depended upon (also referred to as the master meta service)."); -$help["dependent_metaservice_name"] = dgettext("help", "This directive is used to identify the description of the dependent meta service."); +$help["metaservice_name"] = dgettext( + "help", + "This directive is used to identify the description of the meta service that is being depended upon " . + "(also referred to as the master meta service)." +); +$help["dependent_metaservice_name"] = dgettext( + "help", + "This directive is used to identify the description of the dependent meta service." +); /* * unsupported in centreon */ -$help["dependency_period"] = dgettext("help", "This directive is used to specify the short name of the time period during which this dependency is valid. If this directive is not specified, the dependency is considered to be valid during all times."); +$help["dependency_period"] = dgettext( + "help", + "This directive is used to specify the short name of the time period during which this dependency is valid. " . + "If this directive is not specified, the dependency is considered to be valid during all times." +); $help["dep_hHostChi"] = sprintf( "%s
%s", diff --git a/www/include/configuration/configObject/service_dependency/listServiceDependency.php b/www/include/configuration/configObject/service_dependency/listServiceDependency.php index 8b18f6dad0e..09ea62bea09 100644 --- a/www/include/configuration/configObject/service_dependency/listServiceDependency.php +++ b/www/include/configuration/configObject/service_dependency/listServiceDependency.php @@ -38,7 +38,7 @@ } include_once("./class/centreonUtils.class.php"); - + include("./include/common/autoNumLimit.php"); isset($_GET["list"]) ? $list = $_GET["list"] : $list = null; @@ -49,9 +49,9 @@ $aclFrom = ", $dbmon.centreon_acl acl "; $aclCond = " AND dspr.host_host_id = acl.host_id AND acl.service_id = dspr.service_service_id - AND acl.group_id IN (".$acl->getAccessGroupsString().") "; + AND acl.group_id IN (" . $acl->getAccessGroupsString() . ") "; } - + $rq = "SELECT COUNT(DISTINCT dep.dep_id) as count_dep " . "FROM dependency dep, dependency_serviceParent_relation dspr " . $aclFrom . " " . "WHERE dspr.dependency_dep_id = dep.dep_id " . $aclCond . " " @@ -60,7 +60,8 @@ $search = ''; if (isset($_POST['searchSD']) && $_POST['searchSD']) { $search = $_POST['searchSD']; - $rq .= " AND (dep_name LIKE '%".htmlentities($search, ENT_QUOTES, "UTF-8")."%' OR dep_description LIKE '%".htmlentities($search, ENT_QUOTES, "UTF-8")."%')"; + $rq .= " AND (dep_name LIKE '%" . htmlentities($search, ENT_QUOTES, "UTF-8") . + "%' OR dep_description LIKE '%" . htmlentities($search, ENT_QUOTES, "UTF-8") . "%')"; } $DBRESULT = $pearDB->query($rq); @@ -91,14 +92,15 @@ . "AND dspr.host_host_id NOT IN (SELECT host_id FROM host WHERE host_register = '2') "; if ($search) { - $rq .= " AND (dep_name LIKE '%".htmlentities($search, ENT_QUOTES, "UTF-8")."%' OR dep_description LIKE '%".htmlentities($search, ENT_QUOTES, "UTF-8")."%')"; + $rq .= " AND (dep_name LIKE '%" . htmlentities($search, ENT_QUOTES, "UTF-8") . + "%' OR dep_description LIKE '%" . htmlentities($search, ENT_QUOTES, "UTF-8") . "%')"; } -$rq .= " ORDER BY dep_name, dep_description LIMIT ".$num * $limit.", ".$limit; +$rq .= " ORDER BY dep_name, dep_description LIMIT " . $num * $limit . ", " . $limit; $DBRESULT = $pearDB->query($rq); $search = tidySearchKey($search, $advanced_search); -$form = new HTML_QuickForm('select_form', 'POST', "?p=".$p); +$form = new HTML_QuickForm('select_form', 'POST', "?p=" . $p); # Different style between each lines $style = "one"; @@ -107,14 +109,19 @@ $elemArr = array(); for ($i = 0; $dep = $DBRESULT->fetchRow(); $i++) { $moptions = ""; - $selectedElements = $form->addElement('checkbox', "select[".$dep['dep_id']."]"); - $moptions .= "  31 && (event.keyCode < 45 || event.keyCode > 57)) event.returnValue = false; if(event.which > 31 && (event.which < 45 || event.which > 57)) return false;\" maxlength=\"3\" size=\"3\" value='1' style=\"margin-bottom:0px;\" name='dupNbr[".$dep['dep_id']."]'>"; - $elemArr[$i] = array("MenuClass"=>"list_".$style, - "RowMenu_select"=>$selectedElements->toHtml(), - "RowMenu_name"=>CentreonUtils::escapeSecure(myDecode($dep["dep_name"])), - "RowMenu_link"=>"?p=".$p."&o=c&dep_id=".$dep['dep_id'], - "RowMenu_description"=>CentreonUtils::escapeSecure(myDecode($dep["dep_description"])), - "RowMenu_options"=>$moptions); + $selectedElements = $form->addElement('checkbox', "select[" . $dep['dep_id'] . "]"); + $moptions .= "  31 && (event.keyCode < 45 || event.keyCode > 57)) " . + "event.returnValue = false; if(event.which > 31 && (event.which < 45 || event.which > 57)) " . + "return false;\" maxlength=\"3\" size=\"3\" value='1' style=\"margin-bottom:0px;\" " . + "name='dupNbr[" . $dep['dep_id'] . "]' />"; + $elemArr[$i] = array( + "MenuClass" => "list_" . $style, + "RowMenu_select" => $selectedElements->toHtml(), + "RowMenu_name" => CentreonUtils::escapeSecure(myDecode($dep["dep_name"])), + "RowMenu_link" => "?p=" . $p . "&o=c&dep_id=" . $dep['dep_id'], + "RowMenu_description" => CentreonUtils::escapeSecure(myDecode($dep["dep_description"])), + "RowMenu_options" => $moptions + ); $style != "two" ? $style = "two" : $style = "one"; } $tpl->assign("elemArr", $elemArr); @@ -122,46 +129,67 @@ /* * Different messages we put in the template */ -$tpl->assign('msg', array ("addL"=>"?p=".$p."&o=a", "addT"=>_("Add"), "delConfirm"=>_("Do you confirm the deletion ?"))); +$tpl->assign( + 'msg', + array("addL" => "?p=" . $p . "&o=a", "addT" => _("Add"), "delConfirm" => _("Do you confirm the deletion ?")) +); /* * Toolbar select */ ?> - + "javascript: " . - " var bChecked = isChecked(); ". - " if (this.form.elements['o1'].selectedIndex != 0 && !bChecked) {". - " alert('"._("Please select one or more items")."'); return false;} " . - "if (this.form.elements['o1'].selectedIndex == 1 && confirm('"._("Do you confirm the duplication ?")."')) {" . - " setO(this.form.elements['o1'].value); submit();} " . - "else if (this.form.elements['o1'].selectedIndex == 2 && confirm('"._("Do you confirm the deletion ?")."')) {" . - " setO(this.form.elements['o1'].value); submit();} " . - "else if (this.form.elements['o1'].selectedIndex == 3) {" . - " setO(this.form.elements['o1'].value); submit();} " . - ""); -$form->addElement('select', 'o1', null, array(null=>_("More actions..."), "m"=>_("Duplicate"), "d"=>_("Delete")), $attrs1); + 'onchange' => "javascript: " . + " var bChecked = isChecked(); " . + " if (this.form.elements['o1'].selectedIndex != 0 && !bChecked) {" . + " alert('" . _("Please select one or more items") . "'); return false;} " . + "if (this.form.elements['o1'].selectedIndex == 1 && confirm('" . + _("Do you confirm the duplication ?") . "')) {" . + " setO(this.form.elements['o1'].value); submit();} " . + "else if (this.form.elements['o1'].selectedIndex == 2 && confirm('" . + _("Do you confirm the deletion ?") . "')) {" . + " setO(this.form.elements['o1'].value); submit();} " . + "else if (this.form.elements['o1'].selectedIndex == 3) {" . + " setO(this.form.elements['o1'].value); submit();} " . + "" +); +$form->addElement( + 'select', + 'o1', + null, + array(null => _("More actions..."), "m" => _("Duplicate"), "d" => _("Delete")), + $attrs1 +); $form->setDefaults(array('o1' => null)); $attrs2 = array( - 'onchange'=>"javascript: " . - " var bChecked = isChecked(); ". - " if (this.form.elements['o2'].selectedIndex != 0 && !bChecked) {". - " alert('"._("Please select one or more items")."'); return false;} " . - "if (this.form.elements['o2'].selectedIndex == 1 && confirm('"._("Do you confirm the duplication ?")."')) {" . - " setO(this.form.elements['o2'].value); submit();} " . - "else if (this.form.elements['o2'].selectedIndex == 2 && confirm('"._("Do you confirm the deletion ?")."')) {" . - " setO(this.form.elements['o2'].value); submit();} " . - "else if (this.form.elements['o2'].selectedIndex == 3) {" . - " setO(this.form.elements['o2'].value); submit();} " . - ""); -$form->addElement('select', 'o2', null, array(null=>_("More actions..."), "m"=>_("Duplicate"), "d"=>_("Delete")), $attrs2); + 'onchange' => "javascript: " . + " var bChecked = isChecked(); " . + " if (this.form.elements['o2'].selectedIndex != 0 && !bChecked) {" . + " alert('" . _("Please select one or more items") . "'); return false;} " . + "if (this.form.elements['o2'].selectedIndex == 1 && confirm('" . + _("Do you confirm the duplication ?") . "')) {" . + " setO(this.form.elements['o2'].value); submit();} " . + "else if (this.form.elements['o2'].selectedIndex == 2 && confirm('" . + _("Do you confirm the deletion ?") . "')) {" . + " setO(this.form.elements['o2'].value); submit();} " . + "else if (this.form.elements['o2'].selectedIndex == 3) {" . + " setO(this.form.elements['o2'].value); submit();} " . + "" +); +$form->addElement( + 'select', + 'o2', + null, + array(null => _("More actions..."), "m" => _("Duplicate"), "d" => _("Delete")), + $attrs2 +); $form->setDefaults(array('o2' => null)); $o1 = $form->getElement('o1'); From 62c60b4913bd01863a02c533f103620e3ccee40b Mon Sep 17 00:00:00 2001 From: loiclau Date: Wed, 19 Jul 2017 18:07:13 +0200 Subject: [PATCH 048/207] * fix style action acl --- .../accessLists/actionsACL/DB-Func.php | 71 +++++----- .../actionsACL/formActionsAccess.php | 35 +++-- .../options/accessLists/actionsACL/help.php | 115 ++++++++++++---- .../actionsACL/listsActionsAccess.php | 124 +++++++++++------- 4 files changed, 234 insertions(+), 111 deletions(-) diff --git a/www/include/options/accessLists/actionsACL/DB-Func.php b/www/include/options/accessLists/actionsACL/DB-Func.php index 73c868ddcda..16100a66dc8 100644 --- a/www/include/options/accessLists/actionsACL/DB-Func.php +++ b/www/include/options/accessLists/actionsACL/DB-Func.php @@ -38,9 +38,8 @@ } /** - * - * is this action rules already existing - * @param $name + * @param null $name + * @return bool */ function testActionExistence($name = null) { @@ -50,7 +49,9 @@ function testActionExistence($name = null) if (isset($form)) { $id = $form->getSubmitValue('acl_action_id'); } - $DBRESULT = $pearDB->query("SELECT acl_action_id, acl_action_name FROM acl_actions WHERE acl_action_name = '".htmlentities($name, ENT_QUOTES, "UTF-8")."'"); + $query = "SELECT acl_action_id, acl_action_name FROM acl_actions " . + "WHERE acl_action_name = '" . htmlentities($name, ENT_QUOTES, "UTF-8") . "'"; + $DBRESULT = $pearDB->query($query); $cg = $DBRESULT->fetchRow(); #Modif case if ($DBRESULT->rowCount() >= 1 && $cg["acl_action_id"] == $id) { @@ -74,7 +75,7 @@ function enableActionInDB($acl_action_id = null) return; } global $pearDB; - $DBRESULT = $pearDB->query("UPDATE acl_actions SET acl_action_activate = '1' WHERE acl_action_id = '".$acl_action_id."'"); + $pearDB->query("UPDATE acl_actions SET acl_action_activate = '1' WHERE acl_action_id = '" . $acl_action_id . "'"); } /** @@ -88,7 +89,7 @@ function disableActionInDB($acl_action_id = null) return; } global $pearDB; - $DBRESULT = $pearDB->query("UPDATE acl_actions SET acl_action_activate = '0' WHERE acl_action_id = '".$acl_action_id."'"); + $pearDB->query("UPDATE acl_actions SET acl_action_activate = '0' WHERE acl_action_id = '" . $acl_action_id . "'"); } /** @@ -100,9 +101,9 @@ function deleteActionInDB($Actions = array()) { global $pearDB; foreach ($Actions as $key => $value) { - $DBRESULT = $pearDB->query("DELETE FROM acl_actions WHERE acl_action_id = '".$key."'"); - $DBRESULT = $pearDB->query("DELETE FROM acl_actions_rules WHERE acl_action_rule_id = '".$key."'"); - $DBRESULT = $pearDB->query("DELETE FROM acl_group_actions_relations WHERE acl_action_id = '".$key."'"); + $pearDB->query("DELETE FROM acl_actions WHERE acl_action_id = '" . $key . "'"); + $pearDB->query("DELETE FROM acl_actions_rules WHERE acl_action_rule_id = '" . $key . "'"); + $pearDB->query("DELETE FROM acl_group_actions_relations WHERE acl_action_id = '" . $key . "'"); } } @@ -116,31 +117,39 @@ function multipleActionInDB($Actions = array(), $nbrDup = array()) { foreach ($Actions as $key => $value) { global $pearDB; - $DBRESULT = $pearDB->query("SELECT * FROM acl_actions WHERE acl_action_id = '".$key."' LIMIT 1"); + $DBRESULT = $pearDB->query("SELECT * FROM acl_actions WHERE acl_action_id = '" . $key . "' LIMIT 1"); $row = $DBRESULT->fetchRow(); $row["acl_action_id"] = ''; for ($i = 1; $i <= $nbrDup[$key]; $i++) { $val = null; foreach ($row as $key2 => $value2) { - $key2 == "acl_action_name" ? ($acl_action_name = $value2 = $value2."_".$i) : null; - $val ? $val .= ", '".$value2."'" : $val .= "'".$value2."'"; + $key2 == "acl_action_name" ? ($acl_action_name = $value2 = $value2 . "_" . $i) : null; + $val ? $val .= ", '" . $value2 . "'" : $val .= "'" . $value2 . "'"; } if (testActionExistence($acl_action_name)) { - $val ? $rq = "INSERT INTO acl_actions VALUES (".$val.")" : $rq = null; + $val ? $rq = "INSERT INTO acl_actions VALUES (" . $val . ")" : $rq = null; $DBRESULT = $pearDB->query($rq); $DBRESULT = $pearDB->query("SELECT MAX(acl_action_id) FROM acl_actions"); $maxId = $DBRESULT->fetchRow(); $DBRESULT->closeCursor(); if (isset($maxId["MAX(acl_action_id)"])) { - $DBRESULT = $pearDB->query("SELECT DISTINCT acl_group_id,acl_action_id FROM acl_group_actions_relations WHERE acl_action_id = '".$key."'"); + $query = "SELECT DISTINCT acl_group_id,acl_action_id FROM acl_group_actions_relations " . + "WHERE acl_action_id = '" . $key . "'"; + $DBRESULT = $pearDB->query($query); while ($cct = $DBRESULT->fetchRow()) { - $DBRESULT2 = $pearDB->query("INSERT INTO acl_group_actions_relations VALUES ('', '".$maxId["MAX(acl_action_id)"]."', '".$cct["acl_group_id"]."')"); + $query = "INSERT INTO acl_group_actions_relations VALUES ('', '" . + $maxId["MAX(acl_action_id)"] . "', '" . $cct["acl_group_id"] . "')"; + $pearDB->query($query); } # Duplicate Actions - $DBRESULT = $pearDB->query("SELECT acl_action_rule_id,acl_action_name FROM acl_actions_rules WHERE acl_action_rule_id = '".$key."'"); + $query = "SELECT acl_action_rule_id,acl_action_name FROM acl_actions_rules " . + "WHERE acl_action_rule_id = '" . $key . "'"; + $DBRESULT = $pearDB->query($query); while ($acl = $DBRESULT->fetchRow()) { - $DBRESULT2 = $pearDB->query("INSERT INTO acl_actions_rules VALUES ('', '".$maxId["MAX(acl_action_id)"]."', '".$acl["acl_action_name"]."')"); + $query = "INSERT INTO acl_actions_rules VALUES ('', '" . $maxId["MAX(acl_action_id)"] . + "', '" . $acl["acl_action_name"] . "')"; + $pearDB->query($query); } $DBRESULT->closeCursor(); @@ -175,11 +184,13 @@ function insertAction($ret) $ret = $form->getSubmitValues(); } - $rq = "INSERT INTO acl_actions "; + $rq = "INSERT INTO acl_actions "; $rq .= "(acl_action_name, acl_action_description, acl_action_activate) "; $rq .= "VALUES "; - $rq .= "('".htmlentities($ret["acl_action_name"], ENT_QUOTES, "UTF-8")."', '".htmlentities($ret["acl_action_description"], ENT_QUOTES, "UTF-8")."', '".htmlentities($ret["acl_action_activate"]["acl_action_activate"], ENT_QUOTES, "UTF-8")."')"; - $DBRESULT = $pearDB->query($rq); + $rq .= "('" . htmlentities($ret["acl_action_name"], ENT_QUOTES, "UTF-8") . "', '" . + htmlentities($ret["acl_action_description"], ENT_QUOTES, "UTF-8") . "', '" . + htmlentities($ret["acl_action_activate"]["acl_action_activate"], ENT_QUOTES, "UTF-8") . "')"; + $pearDB->query($rq); $DBRESULT = $pearDB->query("SELECT MAX(acl_action_id) FROM acl_actions"); $cg_id = $DBRESULT->fetchRow(); return ($cg_id["MAX(acl_action_id)"]); @@ -211,14 +222,14 @@ function updateAction($acl_action_id = null) } global $form, $pearDB; - $ret = array(); $ret = $form->getSubmitValues(); $rq = "UPDATE acl_actions "; - $rq .= "SET acl_action_name = '".htmlentities($ret["acl_action_name"], ENT_QUOTES, "UTF-8")."', " . - "acl_action_description = '".htmlentities($ret["acl_action_description"], ENT_QUOTES, "UTF-8")."', " . - "acl_action_activate = '".htmlentities($ret["acl_action_activate"]["acl_action_activate"], ENT_QUOTES, "UTF-8")."' " . - "WHERE acl_action_id = '".$acl_action_id."'"; - $DBRESULT = $pearDB->query($rq); + $rq .= "SET acl_action_name = '" . htmlentities($ret["acl_action_name"], ENT_QUOTES, "UTF-8") . "', " . + "acl_action_description = '" . htmlentities($ret["acl_action_description"], ENT_QUOTES, "UTF-8") . "', " . + "acl_action_activate = '" . + htmlentities($ret["acl_action_activate"]["acl_action_activate"], ENT_QUOTES, "UTF-8") . "' " . + "WHERE acl_action_id = '" . $acl_action_id . "'"; + $pearDB->query($rq); } /** @@ -234,14 +245,14 @@ function updateGroupActions($acl_action_id, $ret = array()) } global $form, $pearDB; - $rq = "DELETE FROM acl_group_actions_relations WHERE acl_action_id = '".$acl_action_id."'"; + $rq = "DELETE FROM acl_group_actions_relations WHERE acl_action_id = '" . $acl_action_id . "'"; $DBRESULT = $pearDB->query($rq); if (isset($_POST["acl_groups"])) { foreach ($_POST["acl_groups"] as $id) { $rq = "INSERT INTO acl_group_actions_relations "; $rq .= "(acl_group_id, acl_action_id) "; $rq .= "VALUES "; - $rq .= "('".$id."', '".$acl_action_id."')"; + $rq .= "('" . $id . "', '" . $acl_action_id . "')"; $DBRESULT = $pearDB->query($rq); } } @@ -261,7 +272,7 @@ function updateRulesActions($acl_action_id, $ret = array()) return; } - $rq = "DELETE FROM acl_actions_rules WHERE acl_action_rule_id = '".$acl_action_id."'"; + $rq = "DELETE FROM acl_actions_rules WHERE acl_action_rule_id = '" . $acl_action_id . "'"; $DBRESULT = $pearDB->query($rq); $actions = array(); @@ -272,7 +283,7 @@ function updateRulesActions($acl_action_id, $ret = array()) $rq = "INSERT INTO acl_actions_rules "; $rq .= "(acl_action_rule_id, acl_action_name) "; $rq .= "VALUES "; - $rq .= "('".$acl_action_id."', '".$action."')"; + $rq .= "('" . $acl_action_id . "', '" . $action . "')"; $DBRESULT = $pearDB->query($rq); } } diff --git a/www/include/options/accessLists/actionsACL/formActionsAccess.php b/www/include/options/accessLists/actionsACL/formActionsAccess.php index c677697e37d..7d623783509 100644 --- a/www/include/options/accessLists/actionsACL/formActionsAccess.php +++ b/www/include/options/accessLists/actionsACL/formActionsAccess.php @@ -42,12 +42,14 @@ */ if (($o == "c") && $acl_action_id) { // 1. Get "Actions Rule" id selected by user - $DBRESULT = $pearDB->query("SELECT * FROM acl_actions WHERE acl_action_id = '".$acl_action_id."' LIMIT 1"); + $DBRESULT = $pearDB->query("SELECT * FROM acl_actions WHERE acl_action_id = '" . $acl_action_id . "' LIMIT 1"); $action_infos = array(); $action_infos = array_map("myDecode", $DBRESULT->fetchRow()); // 2. Get "Groups" id linked with the selected Rule in order to initialize the form - $DBRESULT = $pearDB->query("SELECT DISTINCT acl_group_id FROM acl_group_actions_relations WHERE acl_action_id = '".$acl_action_id."'"); + $query = "SELECT DISTINCT acl_group_id FROM acl_group_actions_relations " . + "WHERE acl_action_id = '" . $acl_action_id . "'"; + $DBRESULT = $pearDB->query($query); $selected = array(); for ($i = 0; $contacts = $DBRESULT->fetchRow(); $i++) { @@ -56,7 +58,8 @@ $action_infos["acl_groups"] = $selected; // 3. Range in a table variable, all Groups used in this "Actions Access" - $DBRESULT = $pearDB->query("SELECT acl_action_name FROM `acl_actions_rules` WHERE `acl_action_rule_id` = $acl_action_id"); + $query = "SELECT acl_action_name FROM `acl_actions_rules` WHERE `acl_action_rule_id` = $acl_action_id"; + $DBRESULT = $pearDB->query($query); $selected_actions = array(); for ($i = 0; $act = $DBRESULT->fetchRow(); $i++) { @@ -77,13 +80,14 @@ $DBRESULT->closeCursor(); // Var information to format the element -$attrsText = array("size"=>"30"); +$attrsText = array("size" => "30"); $attrsAdvSelect = array("style" => "width: 300px; height: 220px;"); -$attrsTextarea = array("rows"=>"5", "cols"=>"60"); -$eTemplate = "
{unselected}{add}


{remove}
{selected}
"; +$attrsTextarea = array("rows" => "5", "cols" => "60"); +$eTemplate = "
{unselected}{add}


" . + "{remove}
{selected}
"; // Form begin -$form = new HTML_QuickForm('Form', 'post', "?p=".$p); +$form = new HTML_QuickForm('Form', 'post', "?p=" . $p); if ($o == "a") { $form->addElement('header', 'title', _("Add an Action")); } elseif ($o == "c") { @@ -155,7 +159,7 @@ $form->addElement('checkbox', 'all_engine', ""); -$form->setDefaults(array("hostComment" => 1 )); +$form->setDefaults(array("hostComment" => 1)); // Contacts Selection $form->addElement('header', 'notification', _("Relations")); @@ -165,7 +169,7 @@ $form->addElement('header', 'global_access', _("Global Functionalities Access")); $ams1 = $form->addElement('advmultiselect', 'acl_groups', _("Linked Groups"), $groups, $attrsAdvSelect, SORT_ASC); -$ams1->setButtonAttributes('add', array('value' => _("Add"), "class" => "btc bt_success")); +$ams1->setButtonAttributes('add', array('value' => _("Add"), "class" => "btc bt_success")); $ams1->setButtonAttributes('remove', array('value' => _("Remove"), "class" => "btc bt_danger")); $ams1->setElementTemplate($eTemplate); echo $ams1->getElementJs(false); @@ -197,7 +201,7 @@ function myReplace() $form->addRule('acl_groups', _("Compulsory Groups"), 'required'); $form->registerRule('exist', 'callback', 'testActionExistence'); $form->addRule('acl_action_name', _("Name is already in use"), 'exist'); -$form->setRequiredNote("* ". _("Required fields")); +$form->setRequiredNote("* " . _("Required fields")); // End of form definition @@ -229,7 +233,12 @@ function myReplace() updateRulesActions($groupObj->getValue()); } $o = null; - $form->addElement("button", "change", _("Modify"), array("onClick"=>"javascript:window.location.href='?p=".$p."&o=c&c_id=".$groupObj->getValue()."'")); + $form->addElement( + "button", + "change", + _("Modify"), + array("onClick" => "javascript:window.location.href='?p=" . $p . "&o=c&c_id=" . $groupObj->getValue() . "'") + ); $form->freeze(); $valid = true; } @@ -238,13 +247,13 @@ function myReplace() $helptext = ""; include_once("help.php"); foreach ($help as $key => $text) { - $helptext .= ''."\n"; + $helptext .= '' . "\n"; } $tpl->assign("helptext", $helptext); $action = $form->getSubmitValue("action"); if ($valid) { - require_once($path."listsActionsAccess.php"); + require_once($path . "listsActionsAccess.php"); } else { // Apply a template definition $renderer = new HTML_QuickForm_Renderer_ArraySmarty($tpl); diff --git a/www/include/options/accessLists/actionsACL/help.php b/www/include/options/accessLists/actionsACL/help.php index 0f9ef946e5b..adc5ec7c194 100644 --- a/www/include/options/accessLists/actionsACL/help.php +++ b/www/include/options/accessLists/actionsACL/help.php @@ -18,15 +18,30 @@ * Global Functionalities Access */ -$help['tip_display_top_counter'] = dgettext('help', 'The monitoring overview will be displayed at the top of all pages.'); -$help['tip_display_top_counter_pollers_statistics'] = dgettext('help', 'The monitoring poller status overview will be displayed at the top of all pages.'); -$help['tip_display_poller_listing'] = dgettext('help', 'The poller filter will be available to users in the monitoring consoles.'); +$help['tip_display_top_counter'] = dgettext( + 'help', + 'The monitoring overview will be displayed at the top of all pages.' +); +$help['tip_display_top_counter_pollers_statistics'] = dgettext( + 'help', + 'The monitoring poller status overview will be displayed at the top of all pages.' +); +$help['tip_display_poller_listing'] = dgettext( + 'help', + 'The poller filter will be available to users in the monitoring consoles.' +); /** * Generation of files */ -$help['tip_display_generate_cfg'] = dgettext('help', 'Allows user to generate and export configuration, and restart poller.'); -$help['tip_display_generate_trap'] = dgettext('help', 'Allows user to generate and export configuration, and restart centreontrapd process.'); +$help['tip_display_generate_cfg'] = dgettext( + 'help', + 'Allows user to generate and export configuration, and restart poller.' +); +$help['tip_display_generate_trap'] = dgettext( + 'help', + 'Allows user to generate and export configuration, and restart centreontrapd process.' +); /** * Global Nagios Actions (External Process Commands) @@ -36,30 +51,66 @@ $help['tip_restart_nagios'] = dgettext('help', 'Allows users to restart the monitoring systems.'); $help['tip_enable_disable_notifications'] = dgettext('help', 'Allows users to enable or disable notifications.'); $help['tip_enable_service_checks'] = dgettext('help', 'Allows users to enable or disable service checks.'); -$help['tip_enable_passive_service_checks'] = dgettext('help', 'Allows users to enable or disable passive service checks.'); +$help['tip_enable_passive_service_checks'] = dgettext( + 'help', + 'Allows users to enable or disable passive service checks.' +); $help['tip_enable_host_checks'] = dgettext('help', 'Allows users to enable or disable host checks.'); $help['tip_enable_passive_host_checks'] = dgettext('help', 'Allows users to enable or disable passive host checks.'); $help['tip_enable_event_handlers'] = dgettext('help', 'Allows users to enable or disable event handlers.'); $help['tip_enable_flap_detection'] = dgettext('help', 'Allows users to enable or disable flap detection.'); -$help['tip_enable_obsessive_service_checks'] = dgettext('help', 'Allows users to enable or disable obsessive service checks.'); -$help['tip_enable_obsessive_host_checks'] = dgettext('help', 'Allows users to enable or disable obsessive host checks.'); -$help['tip_enable_performance_data'] = dgettext('help', 'Allows users to enable or disable performance data processing.'); +$help['tip_enable_obsessive_service_checks'] = dgettext( + 'help', + 'Allows users to enable or disable obsessive service checks.' +); +$help['tip_enable_obsessive_host_checks'] = dgettext( + 'help', + 'Allows users to enable or disable obsessive host checks.' +); +$help['tip_enable_performance_data'] = dgettext( + 'help', + 'Allows users to enable or disable performance data processing.' +); /** * Services Actions Access */ -$help['tip_enable_disable_checks_for_a_service'] = dgettext('help', 'Allows users to enable or disable checks of a service.'); -$help['tip_enable_disable_notifications_for_a_service'] = dgettext('help', 'Allows users to enable or disable notifications of a service.'); +$help['tip_enable_disable_checks_for_a_service'] = dgettext( + 'help', + 'Allows users to enable or disable checks of a service.' +); +$help['tip_enable_disable_notifications_for_a_service'] = dgettext( + 'help', + 'Allows users to enable or disable notifications of a service.' +); $help['tip_acknowledge_a_service'] = dgettext('help', 'Allows users to acknowledge a service.'); $help['tip_disacknowledge_a_service'] = dgettext('help', 'Allows users to remove an acknowledgement from a service.'); -$help['tip_re_schedule_the_next_check_for_a_service'] = dgettext('help', 'Allows users to re-schedule next check of a service.'); -$help['tip_re_schedule_the_next_check_for_a_service_forced'] = dgettext('help', 'Allows users to re-schedule next check of a service by placing its priority to the top.'); +$help['tip_re_schedule_the_next_check_for_a_service'] = dgettext( + 'help', + 'Allows users to re-schedule next check of a service.' +); +$help['tip_re_schedule_the_next_check_for_a_service_forced'] = dgettext( + 'help', + 'Allows users to re-schedule next check of a service by placing its priority to the top.' +); $help['tip_schedule_downtime_for_a_service'] = dgettext('help', 'Allows users to schedule downtime on a service.'); -$help['tip_add_delete_a_comment_for_a_service'] = dgettext('help', 'Allows users to add or delete a comment of a service.'); -$help['tip_enable_disable_event_handler_for_a_service'] = dgettext('help', 'Allows users to enable or disable the event handler processing of a service.'); -$help['tip_enable_disable_flap_detection_of_a_service'] = dgettext('help', 'Allows users to enable or disable flap detection of a service.'); -$help['tip_enable_disable_passive_checks_of_a_service'] = dgettext('help', 'Allows users to enable or disable passive checks of a service.'); +$help['tip_add_delete_a_comment_for_a_service'] = dgettext( + 'help', + 'Allows users to add or delete a comment of a service.' +); +$help['tip_enable_disable_event_handler_for_a_service'] = dgettext( + 'help', + 'Allows users to enable or disable the event handler processing of a service.' +); +$help['tip_enable_disable_flap_detection_of_a_service'] = dgettext( + 'help', + 'Allows users to enable or disable flap detection of a service.' +); +$help['tip_enable_disable_passive_checks_of_a_service'] = dgettext( + 'help', + 'Allows users to enable or disable passive checks of a service.' +); $help['tip_submit_result_for_a_service'] = dgettext('help', 'Allows users to submit result to a service.'); /** @@ -67,17 +118,35 @@ */ $help['tip_enable_disable_checks_for_a_host'] = dgettext('help', 'Allows users to enable or disable checks of a host.'); -$help['tip_enable_disable_notifications_for_a_host'] = dgettext('help', 'Allows users to enable or disable notifications of a host.'); +$help['tip_enable_disable_notifications_for_a_host'] = dgettext( + 'help', + 'Allows users to enable or disable notifications of a host.' +); $help['tip_acknowledge_a_host'] = dgettext('help', 'Allows users to acknowledge a host.'); $help['tip_disacknowledge_a_host'] = dgettext('help', 'Allows users to remove an acknowledgement from a host.'); $help['tip_schedule_the_check_for_a_host'] = dgettext('help', 'Allows users to re-schedule next check of a host.'); -$help['tip_schedule_the_check_for_a_host_forced'] = dgettext('help', 'Allows users to re-schedule next check of a host by placing its priority to the top.'); +$help['tip_schedule_the_check_for_a_host_forced'] = dgettext( + 'help', + 'Allows users to re-schedule next check of a host by placing its priority to the top.' +); $help['tip_schedule_downtime_for_a_host'] = dgettext('help', 'Allows users to schedule downtime on a host.'); $help['tip_add_delete_a_comment_for_a_host'] = dgettext('help', 'Allows users to add or delete a comment of a host.'); -$help['tip_enable_disable_event_handler_for_a_host'] = dgettext('help', 'Allows users to enable or disable the event handler processing of a host.'); -$help['tip_enable_disable_flap_detection_for_a_host'] = dgettext('help', 'Allows users to enable or disable flap detection of a host.'); -$help['tip_enable_disable_checks_services_of_a_host'] = dgettext('help', 'Allows users to enable or disable all service checks of a host.'); -$help['tip_enable_disable_notifications_services_of_a_host'] = dgettext('help', 'Allows users to enable or disable service notifications of a host.'); +$help['tip_enable_disable_event_handler_for_a_host'] = dgettext( + 'help', + 'Allows users to enable or disable the event handler processing of a host.' +); +$help['tip_enable_disable_flap_detection_for_a_host'] = dgettext( + 'help', + 'Allows users to enable or disable flap detection of a host.' +); +$help['tip_enable_disable_checks_services_of_a_host'] = dgettext( + 'help', + 'Allows users to enable or disable all service checks of a host.' +); +$help['tip_enable_disable_notifications_services_of_a_host'] = dgettext( + 'help', + 'Allows users to enable or disable service notifications of a host.' +); $help['tip_submit_result_for_a_host'] = dgettext('help', 'Allows users to submit result to a host.'); /** diff --git a/www/include/options/accessLists/actionsACL/listsActionsAccess.php b/www/include/options/accessLists/actionsACL/listsActionsAccess.php index e568598c0c1..de28d4768a9 100644 --- a/www/include/options/accessLists/actionsACL/listsActionsAccess.php +++ b/www/include/options/accessLists/actionsACL/listsActionsAccess.php @@ -36,7 +36,7 @@ if (!isset($centreon)) { exit(); } - + include("./include/common/autoNumLimit.php"); # QuickSearch @@ -44,10 +44,11 @@ $search = ''; if (isset($_POST['searchACLA']) && $_POST['searchACLA']) { $search = $_POST['searchACLA']; - $SearchStr = " WHERE (acl_action_name LIKE '%".htmlentities($search, ENT_QUOTES, "UTF-8")."%' OR acl_action_description LIKE '".htmlentities($search, ENT_QUOTES, "UTF-8")."')"; + $SearchStr = " WHERE (acl_action_name LIKE '%" . htmlentities($search, ENT_QUOTES, "UTF-8") . + "%' OR acl_action_description LIKE '" . htmlentities($search, ENT_QUOTES, "UTF-8") . "')"; } $DBRESULT = $pearDB->query("SELECT COUNT(*) FROM acl_actions" . $SearchStr); - + $tmp = $DBRESULT->fetchRow(); $rows = $tmp["COUNT(*)"]; @@ -65,80 +66,113 @@ $SearchStr = ""; if ($search) { - $SearchStr = "WHERE (acl_action_name LIKE '%".htmlentities($search, ENT_QUOTES, "UTF-8")."%' OR acl_action_description LIKE '%".htmlentities($search, ENT_QUOTES, "UTF-8")."%')"; + $SearchStr = "WHERE (acl_action_name LIKE '%" . htmlentities($search, ENT_QUOTES, "UTF-8") . + "%' OR acl_action_description LIKE '%" . htmlentities($search, ENT_QUOTES, "UTF-8") . "%')"; } -$rq = "SELECT acl_action_id, acl_action_name, acl_action_description, acl_action_activate FROM acl_actions $SearchStr ORDER BY acl_action_name LIMIT ".$num * $limit.", ".$limit; +$rq = "SELECT acl_action_id, acl_action_name, acl_action_description, acl_action_activate " . + "FROM acl_actions $SearchStr ORDER BY acl_action_name LIMIT " . $num * $limit . ", " . $limit; $DBRESULT = $pearDB->query($rq); $search = tidySearchKey($search, $advanced_search); -$form = new HTML_QuickForm('select_form', 'POST', "?p=".$p); +$form = new HTML_QuickForm('select_form', 'POST', "?p=" . $p); #Different style between each lines $style = "one"; #Fill a tab with a mutlidimensionnal Array we put in $tpl $elemArr = array(); for ($i = 0; $topo = $DBRESULT->fetchRow(); $i++) { - $selectedElements = $form->addElement('checkbox', "select[".$topo['acl_action_id']."]"); + $selectedElements = $form->addElement('checkbox', "select[" . $topo['acl_action_id'] . "]"); if ($topo["acl_action_activate"]) { - $moptions = ""._("Disabled")."  "; + $moptions = "" . _("Disabled") . "  "; } else { - $moptions = ""._("Enabled")."  "; + $moptions = "" . _("Enabled") . "  "; } $moptions .= " "; - $moptions .= " 31 && (event.keyCode < 45 || event.keyCode > 57)) event.returnValue = false; if(event.which > 31 && (event.which < 45 || event.which > 57)) return false;\" maxlength=\"3\" size=\"3\" value='1' style=\"margin-bottom:0px;\" name='dupNbr[".$topo['acl_action_id']."]'>"; + $moptions .= " 31 && (event.keyCode < 45 || event.keyCode > 57)) " . + "event.returnValue = false; if(event.which > 31 && (event.which < 45 || event.which > 57)) " . + "return false;\" maxlength=\"3\" size=\"3\" value='1' style=\"margin-bottom:0px;\" name='dupNbr[" . + $topo['acl_action_id'] . "]' />"; /* Contacts */ $ctNbr = array(); - $rq = "SELECT COUNT(*) AS nbr FROM acl_group_actions_relations WHERE acl_action_id = '".$topo['acl_action_id']."'"; + $rq = "SELECT COUNT(*) AS nbr FROM acl_group_actions_relations " . + "WHERE acl_action_id = '" . $topo['acl_action_id'] . "'"; $DBRESULT2 = $pearDB->query($rq); $ctNbr = $DBRESULT2->fetchRow(); - $elemArr[$i] = array("MenuClass"=>"list_".$style, - "RowMenu_select"=>$selectedElements->toHtml(), - "RowMenu_name"=>$topo["acl_action_name"], - "RowMenu_link"=>"?p=".$p."&o=c&acl_action_id=".$topo['acl_action_id'], - "RowMenu_alias"=>myDecode($topo["acl_action_description"]), - "RowMenu_status"=>$topo["acl_action_activate"] ? _("Enabled") : _("Disabled"), - "RowMenu_badge" => $topo["acl_action_activate"] ? "service_ok" : "service_critical", - "RowMenu_options"=>$moptions); - + $elemArr[$i] = array( + "MenuClass" => "list_" . $style, + "RowMenu_select" => $selectedElements->toHtml(), + "RowMenu_name" => $topo["acl_action_name"], + "RowMenu_link" => "?p=" . $p . "&o=c&acl_action_id=" . $topo['acl_action_id'], + "RowMenu_alias" => myDecode($topo["acl_action_description"]), + "RowMenu_status" => $topo["acl_action_activate"] ? _("Enabled") : _("Disabled"), + "RowMenu_badge" => $topo["acl_action_activate"] ? "service_ok" : "service_critical", + "RowMenu_options" => $moptions + ); + $style != "two" ? $style = "two" : $style = "one"; } $tpl->assign("elemArr", $elemArr); #Different messages we put in the template -$tpl->assign('msg', array ("addL"=>"?p=".$p."&o=a", "addT"=>_("Add"), "delConfirm"=>_("Do you confirm the deletion ?"))); +$tpl->assign( + 'msg', + array("addL" => "?p=" . $p . "&o=a", "addT" => _("Add"), "delConfirm" => _("Do you confirm the deletion ?")) +); # ##Toolbar select # ?> - + "javascript: " . - "if (this.form.elements['o1'].selectedIndex == 1 && confirm('"._("Do you confirm the duplication ?")."')) {" . - " setO(this.form.elements['o1'].value); submit();} " . - "else if (this.form.elements['o1'].selectedIndex == 2 && confirm('"._("Do you confirm the deletion ?")."')) {" . - " setO(this.form.elements['o1'].value); submit();} " . - "else if (this.form.elements['o1'].selectedIndex == 3) {" . - " setO(this.form.elements['o1'].value); submit();} " . - ""); -$form->addElement('select', 'o1', null, array(null=>_("More actions..."), "m"=>_("Duplicate"), "d"=>_("Delete")), $attrs1); + 'onchange' => "javascript: " . + "if (this.form.elements['o1'].selectedIndex == 1 && confirm('" . + _("Do you confirm the duplication ?") . "')) {" . + " setO(this.form.elements['o1'].value); submit();} " . + "else if (this.form.elements['o1'].selectedIndex == 2 && confirm('" . + _("Do you confirm the deletion ?") . "')) {" . + " setO(this.form.elements['o1'].value); submit();} " . + "else if (this.form.elements['o1'].selectedIndex == 3) {" . + " setO(this.form.elements['o1'].value); submit();} " . + "" +); +$form->addElement( + 'select', + 'o1', + null, + array(null => _("More actions..."), "m" => _("Duplicate"), "d" => _("Delete")), + $attrs1 +); $form->setDefaults(array('o1' => null)); - + $attrs2 = array( - 'onchange'=>"javascript: " . - "if (this.form.elements['o2'].selectedIndex == 1 && confirm('"._("Do you confirm the duplication ?")."')) {" . - " setO(this.form.elements['o2'].value); submit();} " . - "else if (this.form.elements['o2'].selectedIndex == 2 && confirm('"._("Do you confirm the deletion ?")."')) {" . - " setO(this.form.elements['o2'].value); submit();} " . - "else if (this.form.elements['o2'].selectedIndex == 3) {" . - " setO(this.form.elements['o2'].value); submit();} " . - ""); -$form->addElement('select', 'o2', null, array(null=>_("More actions..."), "m"=>_("Duplicate"), "d"=>_("Delete")), $attrs2); + 'onchange' => "javascript: " . + "if (this.form.elements['o2'].selectedIndex == 1 && confirm('" . + _("Do you confirm the duplication ?") . "')) {" . + " setO(this.form.elements['o2'].value); submit();} " . + "else if (this.form.elements['o2'].selectedIndex == 2 && confirm('" . + _("Do you confirm the deletion ?") . "')) {" . + " setO(this.form.elements['o2'].value); submit();} " . + "else if (this.form.elements['o2'].selectedIndex == 3) {" . + " setO(this.form.elements['o2'].value); submit();} " . + "" +); +$form->addElement( + 'select', + 'o2', + null, + array(null => _("More actions..."), "m" => _("Duplicate"), "d" => _("Delete")), + $attrs2 +); $form->setDefaults(array('o2' => null)); $o1 = $form->getElement('o1'); From c98a415d914c29e85f883323048f7a542d8668c4 Mon Sep 17 00:00:00 2001 From: loiclau Date: Wed, 19 Jul 2017 18:11:16 +0200 Subject: [PATCH 049/207] * fix style group acl --- .../options/accessLists/groupsACL/DB-Func.php | 42 +++--- .../accessLists/groupsACL/formGroupConfig.php | 44 +++--- .../accessLists/groupsACL/groupsConfig.php | 18 +-- .../accessLists/groupsACL/listGroupConfig.php | 133 +++++++++++------- 4 files changed, 136 insertions(+), 101 deletions(-) diff --git a/www/include/options/accessLists/groupsACL/DB-Func.php b/www/include/options/accessLists/groupsACL/DB-Func.php index 846203f4f84..5c2142e5933 100644 --- a/www/include/options/accessLists/groupsACL/DB-Func.php +++ b/www/include/options/accessLists/groupsACL/DB-Func.php @@ -68,7 +68,7 @@ function testGroupExistence($name = null) } $query = "SELECT acl_group_id, acl_group_name " . "FROM acl_groups " - . "WHERE acl_group_name = '" . htmlentities($name, ENT_QUOTES, "UTF-8")."' "; + . "WHERE acl_group_name = '" . htmlentities($name, ENT_QUOTES, "UTF-8") . "' "; $DBRESULT = $pearDB->query($query); $cg = $DBRESULT->fetchRow(); if ($DBRESULT->rowCount() >= 1 && $cg["acl_group_id"] == $id) { @@ -93,7 +93,7 @@ function enableGroupInDB($acl_group_id = null) if (!$acl_group_id) { return; } - $pearDB->query("UPDATE acl_groups SET acl_group_activate = '1' WHERE acl_group_id = '".$acl_group_id."'"); + $pearDB->query("UPDATE acl_groups SET acl_group_activate = '1' WHERE acl_group_id = '" . $acl_group_id . "'"); } /** @@ -108,7 +108,7 @@ function disableGroupInDB($acl_group_id = null) if (!$acl_group_id) { return; } - $pearDB->query("UPDATE acl_groups SET acl_group_activate = '0' WHERE acl_group_id = '".$acl_group_id."'"); + $pearDB->query("UPDATE acl_groups SET acl_group_activate = '0' WHERE acl_group_id = '" . $acl_group_id . "'"); } /** @@ -121,7 +121,7 @@ function deleteGroupInDB($Groups = array()) global $pearDB; foreach ($Groups as $key => $value) { - $pearDB->query("DELETE FROM acl_groups WHERE acl_group_id = '".$key."'"); + $pearDB->query("DELETE FROM acl_groups WHERE acl_group_id = '" . $key . "'"); } } @@ -136,19 +136,19 @@ function multipleGroupInDB($Groups = array(), $nbrDup = array()) global $pearDB; foreach ($Groups as $key => $value) { - $DBRESULT = $pearDB->query("SELECT * FROM acl_groups WHERE acl_group_id = '".$key."' LIMIT 1"); + $DBRESULT = $pearDB->query("SELECT * FROM acl_groups WHERE acl_group_id = '" . $key . "' LIMIT 1"); $row = $DBRESULT->fetchRow(); $row["acl_group_id"] = ''; for ($i = 1; $i <= $nbrDup[$key]; $i++) { $val = null; foreach ($row as $key2 => $value2) { - $key2 == "acl_group_name" ? ($acl_group_name = $value2 = $value2."_".$i) : null; - $val ? $val .= ", '".$value2."'" : $val .= "'".$value2."'"; + $key2 == "acl_group_name" ? ($acl_group_name = $value2 = $value2 . "_" . $i) : null; + $val ? $val .= ", '" . $value2 . "'" : $val .= "'" . $value2 . "'"; } if (testGroupExistence($acl_group_name)) { - $val ? $rq = "INSERT INTO acl_groups VALUES (".$val.")" : $rq = null; + $val ? $rq = "INSERT INTO acl_groups VALUES (" . $val . ")" : $rq = null; $DBRESULT = $pearDB->query($rq); $DBRESULT = $pearDB->query("SELECT MAX(acl_group_id) FROM acl_groups"); $maxId = $DBRESULT->fetchRow(); @@ -199,7 +199,7 @@ function insertGroup($ret) $rq = "INSERT INTO acl_groups " . "(acl_group_name, acl_group_alias, acl_group_activate) " . "VALUES " - . "('".htmlentities($ret["acl_group_name"], ENT_QUOTES, "UTF-8")."', " + . "('" . htmlentities($ret["acl_group_name"], ENT_QUOTES, "UTF-8") . "', " . "'" . htmlentities($ret["acl_group_alias"], ENT_QUOTES, "UTF-8") . "', " . "'" . htmlentities($ret["acl_group_activate"]["acl_group_activate"], ENT_QUOTES, "UTF-8") . "') "; $pearDB->query($rq); @@ -244,10 +244,10 @@ function updateGroup($acl_group_id = null) $ret = $form->getSubmitValues(); $rq = "UPDATE acl_groups "; $rq .= "SET acl_group_name = '" . htmlentities($ret["acl_group_name"], ENT_QUOTES, "UTF-8") . "', " - . "acl_group_alias = '".htmlentities($ret["acl_group_alias"], ENT_QUOTES, "UTF-8")."', " + . "acl_group_alias = '" . htmlentities($ret["acl_group_alias"], ENT_QUOTES, "UTF-8") . "', " . "acl_group_activate = '" - . htmlentities($ret["acl_group_activate"]["acl_group_activate"], ENT_QUOTES, "UTF-8")."' " - . "WHERE acl_group_id = '".$acl_group_id."'"; + . htmlentities($ret["acl_group_activate"]["acl_group_activate"], ENT_QUOTES, "UTF-8") . "' " + . "WHERE acl_group_id = '" . $acl_group_id . "'"; $pearDB->query($rq); setAclGroupChanged($pearDB, $acl_group_id); } @@ -266,14 +266,14 @@ function updateGroupContacts($acl_group_id, $ret = array()) return; } - $rq = "DELETE FROM acl_group_contacts_relations WHERE acl_group_id = '".$acl_group_id."'"; + $rq = "DELETE FROM acl_group_contacts_relations WHERE acl_group_id = '" . $acl_group_id . "'"; $DBRESULT = $pearDB->query($rq); if (isset($_POST["cg_contacts"])) { foreach ($_POST["cg_contacts"] as $id) { $rq = "INSERT INTO acl_group_contacts_relations "; $rq .= "(contact_contact_id, acl_group_id) "; $rq .= "VALUES "; - $rq .= "('".$id."', '".$acl_group_id."')"; + $rq .= "('" . $id . "', '" . $acl_group_id . "')"; $DBRESULT = $pearDB->query($rq); } } @@ -293,7 +293,7 @@ function updateGroupContactGroups($acl_group_id, $ret = array()) return; } - $rq = "DELETE FROM acl_group_contactgroups_relations WHERE acl_group_id = '".$acl_group_id."'"; + $rq = "DELETE FROM acl_group_contactgroups_relations WHERE acl_group_id = '" . $acl_group_id . "'"; $DBRESULT = $pearDB->query($rq); if (isset($_POST["cg_contactGroups"])) { $cg = new CentreonContactgroup($pearDB); @@ -309,7 +309,7 @@ function updateGroupContactGroups($acl_group_id, $ret = array()) $rq = "INSERT INTO acl_group_contactgroups_relations "; $rq .= "(cg_cg_id, acl_group_id) "; $rq .= "VALUES "; - $rq .= "('".$id."', '".$acl_group_id."')"; + $rq .= "('" . $id . "', '" . $acl_group_id . "')"; $DBRESULT = $pearDB->query($rq); } } @@ -329,14 +329,14 @@ function updateGroupActions($acl_group_id, $ret = array()) return; } - $rq = "DELETE FROM acl_group_actions_relations WHERE acl_group_id = '".$acl_group_id."'"; + $rq = "DELETE FROM acl_group_actions_relations WHERE acl_group_id = '" . $acl_group_id . "'"; $DBRESULT = $pearDB->query($rq); if (isset($_POST["actionAccess"])) { foreach ($_POST["actionAccess"] as $id) { $rq = "INSERT INTO acl_group_actions_relations "; $rq .= "(acl_action_id, acl_group_id) "; $rq .= "VALUES "; - $rq .= "('".$id."', '".$acl_group_id."')"; + $rq .= "('" . $id . "', '" . $acl_group_id . "')"; $DBRESULT = $pearDB->query($rq); } } @@ -356,14 +356,14 @@ function updateGroupMenus($acl_group_id, $ret = array()) return; } - $rq = "DELETE FROM acl_group_topology_relations WHERE acl_group_id = '".$acl_group_id."'"; + $rq = "DELETE FROM acl_group_topology_relations WHERE acl_group_id = '" . $acl_group_id . "'"; $DBRESULT = $pearDB->query($rq); if (isset($_POST["menuAccess"])) { foreach ($_POST["menuAccess"] as $id) { $rq = "INSERT INTO acl_group_topology_relations "; $rq .= "(acl_topology_id, acl_group_id) "; $rq .= "VALUES "; - $rq .= "('".$id."', '".$acl_group_id."')"; + $rq .= "('" . $id . "', '" . $acl_group_id . "')"; $DBRESULT = $pearDB->query($rq); } } @@ -394,7 +394,7 @@ function updateGroupResources($acl_group_id, $ret = array()) $rq = "INSERT INTO acl_res_group_relations "; $rq .= "(acl_res_id, acl_group_id) "; $rq .= "VALUES "; - $rq .= "('".$id."', '".$acl_group_id."')"; + $rq .= "('" . $id . "', '" . $acl_group_id . "')"; $pearDB->query($rq); } } diff --git a/www/include/options/accessLists/groupsACL/formGroupConfig.php b/www/include/options/accessLists/groupsACL/formGroupConfig.php index b211eec52fe..63ecca975ef 100644 --- a/www/include/options/accessLists/groupsACL/formGroupConfig.php +++ b/www/include/options/accessLists/groupsACL/formGroupConfig.php @@ -45,12 +45,12 @@ */ $group = array(); if (($o == "c" || $o == "w") && $acl_group_id) { - $DBRESULT = $pearDB->query("SELECT * FROM acl_groups WHERE acl_group_id = '".$acl_group_id."' LIMIT 1"); + $DBRESULT = $pearDB->query("SELECT * FROM acl_groups WHERE acl_group_id = '" . $acl_group_id . "' LIMIT 1"); /* * Set base value */ $group = array_map("myDecode", $DBRESULT->fetchRow()); - + /* * Set Contact Childs */ @@ -64,7 +64,7 @@ $group["cg_contacts"][$i] = $contacts["contact_contact_id"]; } $DBRESULT->closeCursor(); - + /* * Set ContactGroup Childs */ @@ -76,7 +76,7 @@ $group["cg_contactGroups"][$i] = $contactgroups["cg_cg_id"]; } $DBRESULT->closeCursor(); - + /* * Set Menu link List */ @@ -88,7 +88,7 @@ $group["menuAccess"][$i] = $data["acl_topology_id"]; } $DBRESULT->closeCursor(); - + /* * Set resources List */ @@ -103,7 +103,7 @@ } $DBRESULT->closeCursor(); - + /* * Set Action List */ @@ -170,16 +170,16 @@ ########################################################## # Var information to format the element # -$attrsText = array("size"=>"30"); +$attrsText = array("size" => "30"); $attrsAdvSelect = array("style" => "width: 300px; height: 130px;"); -$attrsTextarea = array("rows"=>"6", "cols"=>"150"); -$eTemplate = '' +$attrsTextarea = array("rows" => "6", "cols" => "150"); +$eTemplate = '
' . '' . '' . '' . '
{label_2}
{unselected}
{add}


{remove}
{label_3}
{selected}
'; -$form = new HTML_QuickForm('Form', 'post', "?p=".$p); +$form = new HTML_QuickForm('Form', 'post', "?p=" . $p); if ($o == "a") { $form->addElement('header', 'title', _("Add a Group")); } elseif ($o == "c") { @@ -215,7 +215,7 @@ $attrsAdvSelect, SORT_ASC ); -$ams1->setButtonAttributes('add', array('value' => _("Add"), "class" => "btc bt_success")); +$ams1->setButtonAttributes('add', array('value' => _("Add"), "class" => "btc bt_success")); $ams1->setButtonAttributes('remove', array('value' => _("Remove"), "class" => "btc bt_danger")); $ams1->setElementTemplate($eTemplate); echo $ams1->getElementJs(false); @@ -232,7 +232,7 @@ $attrsAdvSelect, SORT_ASC ); -$ams1->setButtonAttributes('add', array('value' => _("Add"), "class" => "btc bt_success")); +$ams1->setButtonAttributes('add', array('value' => _("Add"), "class" => "btc bt_success")); $ams1->setButtonAttributes('remove', array('value' => _("Remove"), "class" => "btc bt_danger")); $ams1->setElementTemplate($eTemplate); echo $ams1->getElementJs(false); @@ -249,7 +249,7 @@ $attrsAdvSelect, SORT_ASC ); -$ams1->setButtonAttributes('add', array('value' => _("Add"), "class" => "btc bt_success")); +$ams1->setButtonAttributes('add', array('value' => _("Add"), "class" => "btc bt_success")); $ams1->setButtonAttributes('remove', array('value' => _("Remove"), "class" => "btc bt_danger")); $ams1->setElementTemplate($eTemplate); echo $ams1->getElementJs(false); @@ -266,7 +266,7 @@ $attrsAdvSelect, SORT_ASC ); -$ams1->setButtonAttributes('add', array('value' => _("Add"), "class" => "btc bt_success")); +$ams1->setButtonAttributes('add', array('value' => _("Add"), "class" => "btc bt_success")); $ams1->setButtonAttributes('remove', array('value' => _("Remove"), "class" => "btc bt_danger")); $ams1->setElementTemplate($eTemplate); echo $ams1->getElementJs(false); @@ -283,7 +283,7 @@ $attrsAdvSelect, SORT_ASC ); -$ams1->setButtonAttributes('add', array('value' => _("Add"), "class" => "btc bt_success")); +$ams1->setButtonAttributes('add', array('value' => _("Add"), "class" => "btc bt_success")); $ams1->setButtonAttributes('remove', array('value' => _("Remove"), "class" => "btc bt_danger")); $ams1->setElementTemplate($eTemplate); echo $ams1->getElementJs(false); @@ -324,7 +324,7 @@ function myReplace() $form->addRule('acl_group_alias', _("Compulsory Alias"), 'required'); $form->registerRule('exist', 'callback', 'testGroupExistence'); $form->addRule('acl_group_name', _("Name is already in use"), 'exist'); -$form->setRequiredNote("* ". _("Required fields")); +$form->setRequiredNote("* " . _("Required fields")); $form->registerRule('cg_group_exists', 'callback', 'testCg'); $form->addRule( 'cg_contactGroups', @@ -351,7 +351,7 @@ function myReplace() $helptext = ""; include_once("help.php"); foreach ($help as $key => $text) { - $helptext .= ''."\n"; + $helptext .= '' . "\n"; } $tpl->assign("helptext", $helptext); @@ -364,7 +364,7 @@ function myReplace() "change", _("Modify"), array( - "onClick" => "javascript:window.location.href='?p=".$p."&o=c&cg_id=".$group_id."'" + "onClick" => "javascript:window.location.href='?p=" . $p . "&o=c&cg_id=" . $group_id . "'" ) ); $form->setDefaults($group); @@ -397,11 +397,11 @@ function myReplace() $action = $form->getSubmitValue("action"); if ($valid) { - require_once($path."listGroupConfig.php"); + require_once($path . "listGroupConfig.php"); } else { - /* - * Apply a template definition - */ + /* + * Apply a template definition + */ $renderer = new HTML_QuickForm_Renderer_ArraySmarty($tpl, true); $renderer->setRequiredTemplate('{$label} *'); $renderer->setErrorTemplate('{$error}
{$html}'); diff --git a/www/include/options/accessLists/groupsACL/groupsConfig.php b/www/include/options/accessLists/groupsACL/groupsConfig.php index 769569a576e..68d3ac1cd0d 100644 --- a/www/include/options/accessLists/groupsACL/groupsConfig.php +++ b/www/include/options/accessLists/groupsACL/groupsConfig.php @@ -65,35 +65,35 @@ /* * PHP functions */ -require_once $path."DB-Func.php"; +require_once $path . "DB-Func.php"; require_once "./include/common/common-Func.php"; switch ($o) { case "a": - require_once($path."formGroupConfig.php"); + require_once($path . "formGroupConfig.php"); break; #Add a contactgroup case "w": - require_once($path."formGroupConfig.php"); + require_once($path . "formGroupConfig.php"); break; #Watch a contactgroup case "c": - require_once($path."formGroupConfig.php"); + require_once($path . "formGroupConfig.php"); break; #Modify a contactgroup case "s": enableGroupInDB($acl_group_id); - require_once($path."listGroupConfig.php"); + require_once($path . "listGroupConfig.php"); break; #Activate a contactgroup case "u": disableGroupInDB($acl_group_id); - require_once($path."listGroupConfig.php"); + require_once($path . "listGroupConfig.php"); break; #Desactivate a contactgroup case "m": multipleGroupInDB(isset($select) ? $select : array(), $dupNbr); - require_once($path."listGroupConfig.php"); + require_once($path . "listGroupConfig.php"); break; #Duplicate n contact grou case "d": deleteGroupInDB(isset($select) ? $select : array()); - require_once($path."listGroupConfig.php"); + require_once($path . "listGroupConfig.php"); break; #Delete n contact group default: - require_once($path."listGroupConfig.php"); + require_once($path . "listGroupConfig.php"); break; } diff --git a/www/include/options/accessLists/groupsACL/listGroupConfig.php b/www/include/options/accessLists/groupsACL/listGroupConfig.php index ccd76f01c26..00ded0d1a3a 100644 --- a/www/include/options/accessLists/groupsACL/listGroupConfig.php +++ b/www/include/options/accessLists/groupsACL/listGroupConfig.php @@ -43,7 +43,8 @@ $search = ''; if (isset($_POST['searchACLG']) && $_POST['searchACLG']) { $search = $_POST['searchACLG']; - $SearchStr = "WHERE (acl_group_name LIKE '%".htmlentities($search, ENT_QUOTES, "UTF-8")."%' OR acl_group_alias LIKE '%".htmlentities($search, ENT_QUOTES, "UTF-8")."%')"; + $SearchStr = "WHERE (acl_group_name LIKE '%" . htmlentities($search, ENT_QUOTES, "UTF-8") . + "%' OR acl_group_alias LIKE '%" . htmlentities($search, ENT_QUOTES, "UTF-8") . "%')"; } $rq = "SELECT COUNT(*) FROM acl_groups $SearchStr ORDER BY acl_group_name"; $DBRESULT = $pearDB->query($rq); @@ -68,14 +69,16 @@ $SearchStr = ""; if (isset($search) && $search) { - $SearchStr = "WHERE (acl_group_name LIKE '%".htmlentities($search, ENT_QUOTES, "UTF-8")."%' OR acl_group_alias LIKE '%".htmlentities($search, ENT_QUOTES, "UTF-8")."%')"; + $SearchStr = "WHERE (acl_group_name LIKE '%" . htmlentities($search, ENT_QUOTES, "UTF-8") . + "%' OR acl_group_alias LIKE '%" . htmlentities($search, ENT_QUOTES, "UTF-8") . "%')"; } -$rq = "SELECT acl_group_id, acl_group_name, acl_group_alias, acl_group_activate FROM acl_groups $SearchStr ORDER BY acl_group_name LIMIT ".$num * $limit.", ".$limit; +$rq = "SELECT acl_group_id, acl_group_name, acl_group_alias, acl_group_activate FROM acl_groups $SearchStr " . + "ORDER BY acl_group_name LIMIT " . $num * $limit . ", " . $limit; $DBRESULT = $pearDB->query($rq); $search = tidySearchKey($search, $advanced_search); -$form = new HTML_QuickForm('select_form', 'POST', "?p=".$p); +$form = new HTML_QuickForm('select_form', 'POST', "?p=" . $p); /* * Different style between each lines @@ -87,40 +90,51 @@ */ $elemArr = array(); for ($i = 0; $group = $DBRESULT->fetchRow(); $i++) { - $selectedElements = $form->addElement('checkbox', "select[".$group['acl_group_id']."]"); - + $selectedElements = $form->addElement('checkbox', "select[" . $group['acl_group_id'] . "]"); + if ($group["acl_group_activate"]) { - $moptions = ""._("Disabled")."  "; + $moptions = "" . _("Disabled") . "  "; } else { - $moptions = ""._("Enabled")."  "; + $moptions = "" . _("Enabled") . "  "; } - + $moptions .= "     "; - $moptions .= " 31 && (event.keyCode < 45 || event.keyCode > 57)) event.returnValue = false; if(event.which > 31 && (event.which < 45 || event.which > 57)) return false;\" maxlength=\"3\" size=\"3\" value='1' style=\"margin-bottom:0px;\" name='dupNbr[".$group['acl_group_id']."]'>"; - + $moptions .= " 31 && (event.keyCode < 45 || event.keyCode > 57)) " . + "event.returnValue = false; if(event.which > 31 && (event.which < 45 || event.which > 57)) " . + "return false;\" maxlength=\"3\" size=\"3\" value='1' style=\"margin-bottom:0px;\" name='dupNbr[" . + $group['acl_group_id'] . "]' />"; + /* Contacts */ $ctNbr = array(); - $rq = "SELECT COUNT(*) AS nbr FROM acl_group_contacts_relations WHERE acl_group_id = '".$group['acl_group_id']."'"; + $rq = "SELECT COUNT(*) AS nbr FROM acl_group_contacts_relations " . + "WHERE acl_group_id = '" . $group['acl_group_id'] . "'"; $DBRESULT2 = $pearDB->query($rq); $ctNbr = $DBRESULT2->fetchRow(); $DBRESULT2->closeCursor(); - + $cgNbr = array(); - $rq = "SELECT COUNT(*) AS nbr FROM acl_group_contactgroups_relations WHERE acl_group_id = '".$group['acl_group_id']."'"; + $rq = "SELECT COUNT(*) AS nbr FROM acl_group_contactgroups_relations " . + "WHERE acl_group_id = '" . $group['acl_group_id'] . "'"; $DBRESULT2 = $pearDB->query($rq); $cgNbr = $DBRESULT2->fetchRow(); $DBRESULT2->closeCursor(); - - $elemArr[$i] = array("MenuClass" => "list_".$style, - "RowMenu_select" => $selectedElements->toHtml(), - "RowMenu_name" => $group["acl_group_name"], - "RowMenu_link" => "?p=".$p."&o=c&acl_group_id=".$group['acl_group_id'], - "RowMenu_desc" => myDecode($group["acl_group_alias"]), - "RowMenu_contacts" => $ctNbr["nbr"], - "RowMenu_contactgroups" => $cgNbr["nbr"], - "RowMenu_status" => $group["acl_group_activate"] ? _("Enabled") : _("Disabled"), - "RowMenu_badge" => $group["acl_group_activate"] ? "service_ok" : "service_critical", - "RowMenu_options" => $moptions); + + $elemArr[$i] = array( + "MenuClass" => "list_" . $style, + "RowMenu_select" => $selectedElements->toHtml(), + "RowMenu_name" => $group["acl_group_name"], + "RowMenu_link" => "?p=" . $p . "&o=c&acl_group_id=" . $group['acl_group_id'], + "RowMenu_desc" => myDecode($group["acl_group_alias"]), + "RowMenu_contacts" => $ctNbr["nbr"], + "RowMenu_contactgroups" => $cgNbr["nbr"], + "RowMenu_status" => $group["acl_group_activate"] ? _("Enabled") : _("Disabled"), + "RowMenu_badge" => $group["acl_group_activate"] ? "service_ok" : "service_critical", + "RowMenu_options" => $moptions + ); $style != "two" ? $style = "two" : $style = "one"; } @@ -129,40 +143,61 @@ /* * Different messages we put in the template */ -$tpl->assign('msg', array ("addL"=>"?p=".$p."&o=a", "addT"=>_("Add"), "delConfirm"=>_("Do you confirm the deletion ?"))); +$tpl->assign( + 'msg', + array("addL" => "?p=" . $p . "&o=a", "addT" => _("Add"), "delConfirm" => _("Do you confirm the deletion ?")) +); /* * Toolbar select lgd_more_actions */ ?> - + "javascript: " . - "if (this.form.elements['o1'].selectedIndex == 1 && confirm('"._("Do you confirm the duplication ?")."')) {" . - " setO(this.form.elements['o1'].value); submit();} " . - "else if (this.form.elements['o1'].selectedIndex == 2 && confirm('"._("Do you confirm the deletion ?")."')) {" . - " setO(this.form.elements['o1'].value); submit();} " . - "else if (this.form.elements['o1'].selectedIndex == 3) {" . - " setO(this.form.elements['o1'].value); submit();} " . - ""); -$form->addElement('select', 'o1', null, array(null=>_("More actions..."), "m"=>_("Duplicate"), "d"=>_("Delete")), $attrs1); + 'onchange' => "javascript: " . + "if (this.form.elements['o1'].selectedIndex == 1 && confirm('" . + _("Do you confirm the duplication ?") . "')) {" . + " setO(this.form.elements['o1'].value); submit();} " . + "else if (this.form.elements['o1'].selectedIndex == 2 && confirm('" . + _("Do you confirm the deletion ?") . "')) {" . + " setO(this.form.elements['o1'].value); submit();} " . + "else if (this.form.elements['o1'].selectedIndex == 3) {" . + " setO(this.form.elements['o1'].value); submit();} " . + "" +); +$form->addElement( + 'select', + 'o1', + null, + array(null => _("More actions..."), "m" => _("Duplicate"), "d" => _("Delete")), + $attrs1 +); $form->setDefaults(array('o1' => null)); $attrs2 = array( - 'onchange'=>"javascript: " . - "if (this.form.elements['o2'].selectedIndex == 1 && confirm('"._("Do you confirm the duplication ?")."')) {" . - " setO(this.form.elements['o2'].value); submit();} " . - "else if (this.form.elements['o2'].selectedIndex == 2 && confirm('"._("Do you confirm the deletion ?")."')) {" . - " setO(this.form.elements['o2'].value); submit();} " . - "else if (this.form.elements['o2'].selectedIndex == 3) {" . - " setO(this.form.elements['o2'].value); submit();} " . - ""); -$form->addElement('select', 'o2', null, array(null=>_("More actions..."), "m"=>_("Duplicate"), "d"=>_("Delete")), $attrs2); + 'onchange' => "javascript: " . + "if (this.form.elements['o2'].selectedIndex == 1 && confirm('" . + _("Do you confirm the duplication ?") . "')) {" . + " setO(this.form.elements['o2'].value); submit();} " . + "else if (this.form.elements['o2'].selectedIndex == 2 && confirm('" . + _("Do you confirm the deletion ?") . "')) {" . + " setO(this.form.elements['o2'].value); submit();} " . + "else if (this.form.elements['o2'].selectedIndex == 3) {" . + " setO(this.form.elements['o2'].value); submit();} " . + "" +); +$form->addElement( + 'select', + 'o2', + null, + array(null => _("More actions..."), "m" => _("Duplicate"), "d" => _("Delete")), + $attrs2 +); $form->setDefaults(array('o2' => null)); $o1 = $form->getElement('o1'); From 8ba559f1d7f3ed79ae1ac47f1743077f5615d10d Mon Sep 17 00:00:00 2001 From: loiclau Date: Wed, 19 Jul 2017 18:26:27 +0200 Subject: [PATCH 050/207] * fix style acl menu --- .../options/accessLists/menusACL/DB-Func.php | 68 ++++--- .../accessLists/menusACL/formMenusAccess.php | 169 ++++++++++++------ .../accessLists/menusACL/listsMenusAccess.php | 100 +++++++---- 3 files changed, 218 insertions(+), 119 deletions(-) diff --git a/www/include/options/accessLists/menusACL/DB-Func.php b/www/include/options/accessLists/menusACL/DB-Func.php index 8360c8f42c3..1cae24ab385 100644 --- a/www/include/options/accessLists/menusACL/DB-Func.php +++ b/www/include/options/accessLists/menusACL/DB-Func.php @@ -43,7 +43,8 @@ function testExistence($name = null) if (isset($form)) { $id = $form->getSubmitValue('lca_id'); } - $DBRESULT = $pearDB->query("SELECT acl_topo_name, acl_topo_id FROM `acl_topology` WHERE acl_topo_name = '".$name."'"); + $query = "SELECT acl_topo_name, acl_topo_id FROM `acl_topology` WHERE acl_topo_name = '" . $name . "'"; + $DBRESULT = $pearDB->query($query); $lca = $DBRESULT->fetchRow(); #Modif case if ($DBRESULT->rowCount() >= 1 && $lca["acl_topo_id"] == $id) { @@ -62,7 +63,7 @@ function enableLCAInDB($acl_id = null) if (!$acl_id) { return; } - $DBRESULT = $pearDB->query("UPDATE `acl_topology` SET acl_topo_activate = '1' WHERE `acl_topo_id` = '".$acl_id."'"); + $pearDB->query("UPDATE `acl_topology` SET acl_topo_activate = '1' WHERE `acl_topo_id` = '" . $acl_id . "'"); } function disableLCAInDB($acl_id = null) @@ -71,14 +72,14 @@ function disableLCAInDB($acl_id = null) if (!$acl_id) { return; } - $DBRESULT = $pearDB->query("UPDATE `acl_topology` SET acl_topo_activate = '0' WHERE `acl_topo_id` = '".$acl_id."'"); + $pearDB->query("UPDATE `acl_topology` SET acl_topo_activate = '0' WHERE `acl_topo_id` = '" . $acl_id . "'"); } function deleteLCAInDB($acls = array()) { global $pearDB; foreach ($acls as $key => $value) { - $DBRESULT = $pearDB->query("DELETE FROM `acl_topology` WHERE acl_topo_id = '".$key."'"); + $pearDB->query("DELETE FROM `acl_topology` WHERE acl_topo_id = '" . $key . "'"); } } @@ -86,27 +87,35 @@ function multipleLCAInDB($lcas = array(), $nbrDup = array()) { global $pearDB; foreach ($lcas as $key => $value) { - $DBRESULT = $pearDB->query("SELECT * FROM `acl_topology` WHERE acl_topo_id = '".$key."' LIMIT 1"); + $DBRESULT = $pearDB->query("SELECT * FROM `acl_topology` WHERE acl_topo_id = '" . $key . "' LIMIT 1"); $row = $DBRESULT->fetchRow(); $row["acl_topo_id"] = ''; for ($i = 1; $i <= $nbrDup[$key]; $i++) { $val = null; foreach ($row as $key2 => $value2) { - $key2 == "acl_topo_name" ? ($acl_name = $value2 = $value2."_".$i) : null; - $val ? $val .= ($value2!=null?(", '".$value2."'"):", NULL") : $val .= ($value2!=null?("'".$value2."'"):"NULL"); + $key2 == "acl_topo_name" ? ($acl_name = $value2 = $value2 . "_" . $i) : null; + $val + ? $val .= ($value2 != null ? (", '" . $value2 . "'") : ", NULL") + : $val .= ($value2 != null ? ("'" . $value2 . "'") : "NULL"); } if (testExistence($acl_name)) { - $val ? $rq = "INSERT INTO acl_topology VALUES (".$val.")" : $rq = null; + $val ? $rq = "INSERT INTO acl_topology VALUES (" . $val . ")" : $rq = null; $pearDB->query($rq); $DBRESULT = $pearDB->query("SELECT MAX(acl_topo_id) FROM acl_topology"); $maxId = $DBRESULT->fetchRow(); $DBRESULT->closeCursor(); if (isset($maxId["MAX(acl_topo_id)"])) { $maxTopoId = $maxId['MAX(acl_topo_id)']; - $pearDB->query("INSERT INTO acl_topology_relations (acl_topo_id, topology_topology_id, access_right) - (SELECT $maxTopoId, topology_topology_id, access_right FROM acl_topology_relations WHERE acl_topo_id = ".$pearDB->escape($key).")"); - $pearDB->query("INSERT INTO acl_group_topology_relations (acl_topology_id, acl_group_id) - (SELECT $maxTopoId, acl_group_id FROM acl_group_topology_relations WHERE acl_topology_id = ".$pearDB->escape($key).")"); + + $query = "INSERT INTO acl_topology_relations (acl_topo_id, topology_topology_id, access_right) " . + "(SELECT $maxTopoId, topology_topology_id, access_right FROM acl_topology_relations " . + "WHERE acl_topo_id = " . $pearDB->escape($key) . ")"; + $pearDB->query($query); + + $query = "INSERT INTO acl_group_topology_relations (acl_topology_id, acl_group_id) " . + "(SELECT $maxTopoId, acl_group_id FROM acl_group_topology_relations WHERE acl_topology_id = " . + $pearDB->escape($key) . ")"; + $pearDB->query($query); } } } @@ -136,9 +145,12 @@ function insertLCA() global $form, $pearDB; $ret = array(); $ret = $form->getSubmitValues(); - $rq = "INSERT INTO `acl_topology` (acl_topo_name, acl_topo_alias, acl_topo_activate, acl_comments) "; - $rq .= "VALUES ('".$pearDB->escape($ret["acl_topo_name"])."', '".$pearDB->escape($ret["acl_topo_alias"])."', '".$pearDB->escape($ret["acl_topo_activate"]["acl_topo_activate"])."', '".$pearDB->escape($ret['acl_comments'])."')"; - $DBRESULT = $pearDB->query($rq); + $rq = "INSERT INTO `acl_topology` (acl_topo_name, acl_topo_alias, acl_topo_activate, acl_comments) "; + $rq .= "VALUES ('" . $pearDB->escape($ret["acl_topo_name"]) . "', '" . + $pearDB->escape($ret["acl_topo_alias"]) . "', '" . + $pearDB->escape($ret["acl_topo_activate"]["acl_topo_activate"]) . "', '" . + $pearDB->escape($ret['acl_comments']) . "')"; + $pearDB->query($rq); $DBRESULT = $pearDB->query("SELECT MAX(acl_topo_id) FROM `acl_topology`"); $acl = $DBRESULT->fetchRow(); return ($acl["MAX(acl_topo_id)"]); @@ -153,12 +165,12 @@ function updateLCA($acl_id = null) $ret = array(); $ret = $form->getSubmitValues(); $rq = "UPDATE `acl_topology` - SET acl_topo_name = '".$pearDB->escape($ret["acl_topo_name"])."', - acl_topo_alias = '".$pearDB->escape($ret["acl_topo_alias"])."', - acl_topo_activate = '".$pearDB->escape($ret["acl_topo_activate"]["acl_topo_activate"])."', - acl_comments = '".$pearDB->escape($ret['acl_comments'])."' - WHERE acl_topo_id = '".$acl_id."'"; - $DBRESULT = $pearDB->query($rq); + SET acl_topo_name = '" . $pearDB->escape($ret["acl_topo_name"]) . "', + acl_topo_alias = '" . $pearDB->escape($ret["acl_topo_alias"]) . "', + acl_topo_activate = '" . $pearDB->escape($ret["acl_topo_activate"]["acl_topo_activate"]) . "', + acl_comments = '" . $pearDB->escape($ret['acl_comments']) . "' + WHERE acl_topo_id = '" . $acl_id . "'"; + $pearDB->query($rq); } function updateLCATopology($acl_id = null) @@ -167,12 +179,13 @@ function updateLCATopology($acl_id = null) if (!$acl_id) { return; } - $DBRESULT = $pearDB->query("DELETE FROM acl_topology_relations WHERE acl_topo_id = '".$acl_id."'"); - $ret = array(); + $pearDB->query("DELETE FROM acl_topology_relations WHERE acl_topo_id = '" . $acl_id . "'"); $ret = $form->getSubmitValue("acl_r_topos"); foreach ($ret as $key => $value) { if (isset($ret) && $key != 0) { - $DBRESULT = $pearDB->query("INSERT INTO acl_topology_relations (acl_topo_id, topology_topology_id, access_right) VALUES ('".$acl_id."', '".$key."', " . $value . ")"); + $query = "INSERT INTO acl_topology_relations (acl_topo_id, topology_topology_id, access_right) " . + "VALUES ('" . $acl_id . "', '" . $key . "', " . $value . ")"; + $pearDB->query($query); } } } @@ -183,13 +196,14 @@ function updateGroups($acl_id = null) if (!$acl_id) { return; } - $DBRESULT = $pearDB->query("DELETE FROM acl_group_topology_relations WHERE acl_topology_id = '".$acl_id."'"); - $ret = array(); + $pearDB->query("DELETE FROM acl_group_topology_relations WHERE acl_topology_id = '" . $acl_id . "'"); $ret = $form->getSubmitValue("acl_groups"); if (isset($ret)) { foreach ($ret as $key => $value) { if (isset($value)) { - $DBRESULT = $pearDB->query("INSERT INTO acl_group_topology_relations (acl_topology_id, acl_group_id) VALUES ('".$acl_id."', '".$value."')"); + $query = "INSERT INTO acl_group_topology_relations (acl_topology_id, acl_group_id) " . + "VALUES ('" . $acl_id . "', '" . $value . "')"; + $pearDB->query($query); } } } diff --git a/www/include/options/accessLists/menusACL/formMenusAccess.php b/www/include/options/accessLists/menusACL/formMenusAccess.php index 8dac1420dba..9c45cc3e630 100644 --- a/www/include/options/accessLists/menusACL/formMenusAccess.php +++ b/www/include/options/accessLists/menusACL/formMenusAccess.php @@ -41,20 +41,23 @@ * Database retrieve information for LCA */ if ($o == "c" || $o == "w") { - $DBRESULT = $pearDB->query("SELECT * FROM acl_topology WHERE acl_topo_id = '".$acl_id."' LIMIT 1"); + $DBRESULT = $pearDB->query("SELECT * FROM acl_topology WHERE acl_topo_id = '" . $acl_id . "' LIMIT 1"); // Set base value $acl = array_map("myDecode", $DBRESULT->fetchRow()); // Set Topology relations - $DBRESULT = $pearDB->query("SELECT topology_topology_id, access_right FROM acl_topology_relations WHERE acl_topo_id = '".$acl_id."'"); + $query = "SELECT topology_topology_id, access_right FROM acl_topology_relations " . + "WHERE acl_topo_id = '" . $acl_id . "'"; + $DBRESULT = $pearDB->query($query); for ($i = 0; $topo = $DBRESULT->fetchRow(); $i++) { $acl["acl_topos"][$topo["topology_topology_id"]] = $topo["access_right"]; } $DBRESULT->closeCursor(); // Set Contact Groups relations - $DBRESULT = $pearDB->query("SELECT DISTINCT acl_group_id FROM acl_group_topology_relations WHERE acl_topology_id = '".$acl_id."'"); + $query = "SELECT DISTINCT acl_group_id FROM acl_group_topology_relations WHERE acl_topology_id = '" . $acl_id . "'"; + $DBRESULT = $pearDB->query($query); for ($i = 0; $groups = $DBRESULT->fetchRow(); $i++) { $acl["acl_groups"][$i] = $groups["acl_group_id"]; } @@ -76,16 +79,17 @@ * Var information to format the element */ -$attrsText = array("size"=>"30"); +$attrsText = array("size" => "30"); $attrsAdvSelect = array("style" => "width: 300px; height: 180px;"); -$attrsTextarea = array("rows"=>"5", "cols"=>"80"); -$eTemplate = '
{label_2}
{unselected}
{add}


{remove}
{label_3}
{selected}
'; +$attrsTextarea = array("rows" => "5", "cols" => "80"); +$eTemplate = '
{label_2}
{unselected}
{add}

' . + '
{remove}
{label_3}
{selected}
'; /* * Form begin */ -$form = new HTML_QuickForm('Form', 'post', "?p=".$p); +$form = new HTML_QuickForm('Form', 'post', "?p=" . $p); if ($o == "a") { $form->addElement('header', 'title', _("Add an ACL")); } elseif ($o == "c") { @@ -101,8 +105,19 @@ $form->addElement('text', 'acl_topo_name', _("ACL Definition"), $attrsText); $form->addElement('text', 'acl_topo_alias', _("Alias"), $attrsText); -$ams1 = $form->addElement('advmultiselect', 'acl_groups', array(_("Linked Groups"), _("Available"), _("Selected")), $groups, $attrsAdvSelect, SORT_ASC); -$ams1->setButtonAttributes('add', array('value' => _("Add"), "class" => "btc bt_success")); +$ams1 = $form->addElement( + 'advmultiselect', + 'acl_groups', + array( + _("Linked Groups"), + _("Available"), + _("Selected") + ), + $groups, + $attrsAdvSelect, + SORT_ASC +); +$ams1->setButtonAttributes('add', array('value' => _("Add"), "class" => "btc bt_success")); $ams1->setButtonAttributes('remove', array('value' => _("Remove"), "class" => "btc bt_danger")); $ams1->setElementTemplate($eTemplate); echo $ams1->getElementJs(false); @@ -123,7 +138,9 @@ * Create buffer group list for Foorth level. */ -$DBRESULT = $pearDB->query("SELECT topology_group, topology_name, topology_parent FROM `topology` WHERE topology_page IS NULL ORDER BY topology_group, topology_page"); +$query = "SELECT topology_group, topology_name, topology_parent FROM `topology` " . + "WHERE topology_page IS NULL ORDER BY topology_group, topology_page"; +$DBRESULT = $pearDB->query($query); while ($group = $DBRESULT->fetchRow()) { if (!isset($groupMenus[$group["topology_group"]])) { $groupMenus[$group["topology_group"]] = array(); @@ -137,76 +154,113 @@ * Topology concerned */ $form->addElement('header', 'pages', _("Accessible Pages")); -$DBRESULT1 = $pearDB->query("SELECT topology_id, topology_page, topology_name, topology_parent, readonly FROM topology WHERE topology_parent IS NULL ORDER BY topology_order, topology_group"); +$query = "SELECT topology_id, topology_page, topology_name, topology_parent, readonly FROM topology " . + "WHERE topology_parent IS NULL ORDER BY topology_order, topology_group"; +$DBRESULT1 = $pearDB->query($query); -$acl_topos = array(); +$acl_topos = array(); $acl_topos2 = array(); $a = 0; while ($topo1 = $DBRESULT1->fetchRow()) { - $acl_topos2[$a] = array(); - $acl_topos2[$a]["name"] = _($topo1["topology_name"]); - $acl_topos2[$a]["id"] = $topo1["topology_id"]; - $acl_topos2[$a]["access"] = isset($acl["acl_topos"][$topo1["topology_id"]]) ? $acl["acl_topos"][$topo1["topology_id"]] : 0; - $acl_topos2[$a]["c_id"] = $a; - $acl_topos2[$a]['readonly'] = $topo1['readonly']; - $acl_topos2[$a]["childs"] = array(); - - $acl_topos[] = HTML_QuickForm::createElement('checkbox', $topo1["topology_id"], null, _($topo1["topology_name"]), array("style"=>"margin-top: 5px;", "id"=>$topo1["topology_id"])); - - $b = 0; - $DBRESULT2 = $pearDB->query("SELECT topology_id, topology_page, topology_name, topology_parent, readonly FROM topology WHERE topology_parent = '".$topo1["topology_page"]."' ORDER BY topology_order"); + $acl_topos2[$a] = array(); + $acl_topos2[$a]["name"] = _($topo1["topology_name"]); + $acl_topos2[$a]["id"] = $topo1["topology_id"]; + $acl_topos2[$a]["access"] = isset($acl["acl_topos"][$topo1["topology_id"]]) + ? $acl["acl_topos"][$topo1["topology_id"]] + : 0; + $acl_topos2[$a]["c_id"] = $a; + $acl_topos2[$a]['readonly'] = $topo1['readonly']; + $acl_topos2[$a]["childs"] = array(); + + $acl_topos[] = HTML_QuickForm::createElement( + 'checkbox', + $topo1["topology_id"], + null, + _($topo1["topology_name"]), + array("style" => "margin-top: 5px;", "id" => $topo1["topology_id"]) + ); + + $b = 0; + $query = "SELECT topology_id, topology_page, topology_name, topology_parent, readonly FROM topology " . + "WHERE topology_parent = '" . $topo1["topology_page"] . "' ORDER BY topology_order"; + $DBRESULT2 = $pearDB->query($query); while ($topo2 = $DBRESULT2->fetchRow()) { $acl_topos2[$a]["childs"][$b] = array(); $acl_topos2[$a]["childs"][$b]["name"] = _($topo2["topology_name"]); $acl_topos2[$a]["childs"][$b]["id"] = $topo2["topology_id"]; - $acl_topos2[$a]["childs"][$b]["access"] = isset($acl["acl_topos"][$topo2["topology_id"]]) ? $acl["acl_topos"][$topo2["topology_id"]] : 0; - $acl_topos2[$a]["childs"][$b]["c_id"] = $a."_".$b; + $acl_topos2[$a]["childs"][$b]["access"] = + isset($acl["acl_topos"][$topo2["topology_id"]]) ? $acl["acl_topos"][$topo2["topology_id"]] : 0; + $acl_topos2[$a]["childs"][$b]["c_id"] = $a . "_" . $b; $acl_topos2[$a]["childs"][$b]['readonly'] = $topo2['readonly']; $acl_topos2[$a]["childs"][$b]["childs"] = array(); - $acl_topos[] = HTML_QuickForm::createElement('checkbox', $topo2["topology_id"], null, _($topo2["topology_name"])."
", array("style"=>"margin-top: 5px; margin-left: 20px;")); + $acl_topos[] = HTML_QuickForm::createElement( + 'checkbox', + $topo2["topology_id"], + null, + _($topo2["topology_name"]) . "
", + array("style" => "margin-top: 5px; margin-left: 20px;") + ); $c = 0; - $DBRESULT3 = $pearDB->query("SELECT topology_id, topology_name, topology_parent, topology_page, topology_group, readonly FROM topology WHERE topology_parent = '".$topo2["topology_page"]."' AND topology_page IS NOT NULL ORDER BY topology_group, topology_order"); + $query = "SELECT topology_id, topology_name, topology_parent, topology_page, topology_group, readonly " . + "FROM topology WHERE topology_parent = '" . $topo2["topology_page"] . + "' AND topology_page IS NOT NULL ORDER BY topology_group, topology_order"; + $DBRESULT3 = $pearDB->query($query); while ($topo3 = $DBRESULT3->fetchRow()) { $acl_topos2[$a]["childs"][$b]["childs"][$c] = array(); $acl_topos2[$a]["childs"][$b]["childs"][$c]["name"] = _($topo3["topology_name"]); - if (isset($groupMenus[$topo3["topology_group"]]) && isset($groupMenus[$topo3["topology_group"]][$topo3["topology_parent"]])) { - $acl_topos2[$a]["childs"][$b]["childs"][$c]["group"] = $groupMenus[$topo3["topology_group"]][$topo3["topology_parent"]]; + if (isset($groupMenus[$topo3["topology_group"]]) && + isset($groupMenus[$topo3["topology_group"]][$topo3["topology_parent"]]) + ) { + $acl_topos2[$a]["childs"][$b]["childs"][$c]["group"] = + $groupMenus[$topo3["topology_group"]][$topo3["topology_parent"]]; } else { $acl_topos2[$a]["childs"][$b]["childs"][$c]["group"] = _("Main Menu"); } $acl_topos2[$a]["childs"][$b]["childs"][$c]["id"] = $topo3["topology_id"]; - $acl_topos2[$a]["childs"][$b]["childs"][$c]["access"] = isset($acl["acl_topos"][$topo3["topology_id"]]) ? $acl["acl_topos"][$topo3["topology_id"]] : 0; - $acl_topos2[$a]["childs"][$b]["childs"][$c]["c_id"] = $a."_".$b."_".$c; + $acl_topos2[$a]["childs"][$b]["childs"][$c]["access"] = + isset($acl["acl_topos"][$topo3["topology_id"]]) ? $acl["acl_topos"][$topo3["topology_id"]] : 0; + $acl_topos2[$a]["childs"][$b]["childs"][$c]["c_id"] = $a . "_" . $b . "_" . $c; $acl_topos2[$a]["childs"][$b]["childs"][$c]['readonly'] = $topo3['readonly']; $acl_topos2[$a]["childs"][$b]["childs"][$c]["childs"] = array(); - - $acl_topos[] = HTML_QuickForm::createElement('checkbox', $topo3["topology_id"], null, _($topo3["topology_name"])."
", array("style"=>"margin-top: 5px; margin-left: 40px;")); + + $acl_topos[] = HTML_QuickForm::createElement( + 'checkbox', + $topo3["topology_id"], + null, + _($topo3["topology_name"]) . "
", + array("style" => "margin-top: 5px; margin-left: 40px;") + ); $d = 0; - $DBRESULT4 = $pearDB->query("SELECT topology_id, topology_name, topology_parent, readonly FROM topology WHERE topology_parent = '".$topo3["topology_page"]."' AND topology_page IS NOT NULL ORDER BY topology_order"); + $query = "SELECT topology_id, topology_name, topology_parent, readonly FROM topology " . + "WHERE topology_parent = '" . $topo3["topology_page"] . + "' AND topology_page IS NOT NULL ORDER BY topology_order"; + $DBRESULT4 = $pearDB->query($query); while ($topo4 = $DBRESULT4->fetchRow()) { $acl_topos2[$a]["childs"][$b]["childs"][$c]["childs"][$d] = array(); $acl_topos2[$a]["childs"][$b]["childs"][$c]["childs"][$d]["name"] = _($topo4["topology_name"]); $acl_topos2[$a]["childs"][$b]["childs"][$c]["childs"][$d]["id"] = $topo4["topology_id"]; - $acl_topos2[$a]["childs"][$b]["childs"][$c]["childs"][$d]["access"] = isset($acl["acl_topos"][$topo4["topology_id"]]) ? $acl["acl_topos"][$topo4["topology_id"]] : 0; - $acl_topos2[$a]["childs"][$b]["childs"][$c]["childs"][$d]["c_id"] = $a."_".$b."_".$c."_".$d; + $acl_topos2[$a]["childs"][$b]["childs"][$c]["childs"][$d]["access"] = + isset($acl["acl_topos"][$topo4["topology_id"]]) ? $acl["acl_topos"][$topo4["topology_id"]] : 0; + $acl_topos2[$a]["childs"][$b]["childs"][$c]["childs"][$d]["c_id"] = $a . "_" . $b . "_" . $c . "_" . $d; $acl_topos2[$a]["childs"][$b]["childs"][$c]["childs"][$d]['readonly'] = $topo4['readonly']; $acl_topos2[$a]["childs"][$b]["childs"][$c]["childs"][$d]["childs"] = array(); $d++; } - $acl_topos2[$a]["childs"][$b]["childs"][$c]["childNumber"] = count($acl_topos2[$a]["childs"][$b]["childs"][$c]["childs"]); + $acl_topos2[$a]["childs"][$b]["childs"][$c]["childNumber"] = + count($acl_topos2[$a]["childs"][$b]["childs"][$c]["childs"]); $c++; } $acl_topos2[$a]["childs"][$b]["childNumber"] = count($acl_topos2[$a]["childs"][$b]["childs"]); $b++; } - $acl_topos2[$a]["childNumber"] = count($acl_topos2[$a]["childs"]); - $a++; + $acl_topos2[$a]["childNumber"] = count($acl_topos2[$a]["childs"]); + $a++; } $form->addGroup($acl_topos, 'acl_topos', _("Visible page"), '  '); @@ -222,7 +276,7 @@ $form->addRule('acl_topo_name', _("Required"), 'required'); $form->registerRule('exist', 'callback', 'testExistence'); if ($o == "a") { - $form->addRule('acl_topo_name', _("Already exists"), 'exist'); + $form->addRule('acl_topo_name', _("Already exists"), 'exist'); } $form->setRequiredNote(_("Required field")); @@ -236,18 +290,21 @@ * Just watch a LCA information */ if ($o == "w") { - $form->addElement("button", "change", _("Modify"), array("onClick"=>"javascript:window.location.href='?p=".$p."&o=c&acl_id=".$acl_id."'", "class" => "btc bt_success")); - $form->setDefaults($acl); - $form->freeze(); + $form->addElement("button", "change", _("Modify"), array( + "onClick" => "javascript:window.location.href='?p=" . $p . "&o=c&acl_id=" . $acl_id . "'", + "class" => "btc bt_success" + )); + $form->setDefaults($acl); + $form->freeze(); } elseif ($o == "c") { # Modify a LCA information - $subC = $form->addElement('submit', 'submitC', _("Save"), array("class" => "btc bt_success")); - $res = $form->addElement('reset', 'reset', _("Delete"), array("class" => "btc bt_danger")); - $form->setDefaults($acl); + $subC = $form->addElement('submit', 'submitC', _("Save"), array("class" => "btc bt_success")); + $res = $form->addElement('reset', 'reset', _("Delete"), array("class" => "btc bt_danger")); + $form->setDefaults($acl); } elseif ($o == "a") { # Add a LCA information - $subA = $form->addElement('submit', 'submitA', _("Save"), array("class" => "btc bt_success")); - $res = $form->addElement('reset', 'reset', _("Delete"), array("class" => "btc bt_danger")); + $subA = $form->addElement('submit', 'submitA', _("Save"), array("class" => "btc bt_success")); + $res = $form->addElement('reset', 'reset', _("Delete"), array("class" => "btc bt_danger")); } -$tpl->assign('msg', array ("changeL"=>"?p=".$p."&o=c&lca_id=".$acl_id, "changeT"=>_("Modify"))); +$tpl->assign('msg', array("changeL" => "?p=" . $p . "&o=c&lca_id=" . $acl_id, "changeT" => _("Modify"))); $tpl->assign("lca_topos2", $acl_topos2); $tpl->assign("sort1", _("General Information")); @@ -262,21 +319,21 @@ $helptext = ""; include_once("help.php"); foreach ($help as $key => $text) { - $helptext .= ''."\n"; + $helptext .= '' . "\n"; } $tpl->assign("helptext", $helptext); $valid = false; if ($form->validate()) { - $aclObj = $form->getElement('acl_topo_id'); + $aclObj = $form->getElement('acl_topo_id'); if ($form->getSubmitValue("submitA")) { - $aclObj->setValue(insertLCAInDB()); + $aclObj->setValue(insertLCAInDB()); } elseif ($form->getSubmitValue("submitC")) { - updateLCAInDB($aclObj->getValue()); + updateLCAInDB($aclObj->getValue()); } - require_once("listsMenusAccess.php"); + require_once("listsMenusAccess.php"); } else { - $action = $form->getSubmitValue("action"); + $action = $form->getSubmitValue("action"); if ($valid && $action["action"]) { require_once("listsMenusAccess.php"); } else { diff --git a/www/include/options/accessLists/menusACL/listsMenusAccess.php b/www/include/options/accessLists/menusACL/listsMenusAccess.php index 8f5cda80ff3..aaf75c0ef58 100644 --- a/www/include/options/accessLists/menusACL/listsMenusAccess.php +++ b/www/include/options/accessLists/menusACL/listsMenusAccess.php @@ -36,7 +36,7 @@ if (!isset($oreon)) { exit(); } - + include("./include/common/autoNumLimit.php"); $SearchStr = ""; @@ -44,9 +44,10 @@ if (isset($_POST['searchACLM']) && $_POST['searchACLM']) { $search = $_POST['searchACLM']; } -$SearchStr = " WHERE (acl_topo_name LIKE '%".htmlentities($search, ENT_QUOTES, "UTF-8")."%' OR acl_topo_alias LIKE '".htmlentities($search, ENT_QUOTES, "UTF-8")."')"; +$SearchStr = " WHERE (acl_topo_name LIKE '%" . htmlentities($search, ENT_QUOTES, "UTF-8") . + "%' OR acl_topo_alias LIKE '" . htmlentities($search, ENT_QUOTES, "UTF-8") . "')"; $DBRESULT = $pearDB->query("SELECT COUNT(*) FROM acl_topology" . $SearchStr); - + $tmp = $DBRESULT->fetchRow(); $rows = $tmp["COUNT(*)"]; @@ -69,14 +70,16 @@ $SearchStr = ""; if (isset($search) && $search) { - $SearchStr = "WHERE (acl_topo_name LIKE '%".htmlentities($search, ENT_QUOTES, "UTF-8")."%' OR acl_topo_alias LIKE '%".htmlentities($search, ENT_QUOTES, "UTF-8")."%')"; + $SearchStr = "WHERE (acl_topo_name LIKE '%" . htmlentities($search, ENT_QUOTES, "UTF-8") . + "%' OR acl_topo_alias LIKE '%" . htmlentities($search, ENT_QUOTES, "UTF-8") . "%')"; } -$rq = "SELECT acl_topo_id, acl_topo_name, acl_topo_alias, acl_topo_activate FROM acl_topology $SearchStr ORDER BY acl_topo_name LIMIT ".$num * $limit.", ".$limit; +$rq = "SELECT acl_topo_id, acl_topo_name, acl_topo_alias, acl_topo_activate " . + "FROM acl_topology $SearchStr ORDER BY acl_topo_name LIMIT " . $num * $limit . ", " . $limit; $DBRESULT = $pearDB->query($rq); $search = tidySearchKey($search, $advanced_search); -$form = new HTML_QuickForm('select_form', 'POST', "?p=".$p); +$form = new HTML_QuickForm('select_form', 'POST', "?p=" . $p); /* * Different style between each lines @@ -88,28 +91,37 @@ */ $elemArr = array(); for ($i = 0; $topo = $DBRESULT->fetchRow(); $i++) { - $selectedElements = $form->addElement('checkbox', "select[".$topo['acl_topo_id']."]"); + $selectedElements = $form->addElement('checkbox', "select[" . $topo['acl_topo_id'] . "]"); if ($topo["acl_topo_activate"]) { - $moptions = ""._("Disabled")."  "; + $moptions = "" . _("Disabled") . "  "; } else { - $moptions = ""._("Enabled")."  "; + $moptions = "" . _("Enabled") . "  "; } $moptions .= " "; - $moptions .= " 31 && (event.keyCode < 45 || event.keyCode > 57)) event.returnValue = false; if(event.which > 31 && (event.which < 45 || event.which > 57)) return false;\" maxlength=\"3\" size=\"3\" value='1' style=\"margin-bottom:0px;\" name='dupNbr[".$topo['acl_topo_id']."]'>"; + $moptions .= " 31 && (event.keyCode < 45 || event.keyCode > 57)) " . + "event.returnValue = false; if(event.which > 31 && (event.which < 45 || event.which > 57)) " . + "return false;\" maxlength=\"3\" size=\"3\" value='1' style=\"margin-bottom:0px;\" name='dupNbr[" . + $topo['acl_topo_id'] . "]' />"; /* Contacts */ $ctNbr = array(); - $rq = "SELECT COUNT(*) AS nbr FROM acl_topology_relations WHERE acl_topo_id = '".$topo['acl_topo_id']."'"; + $rq = "SELECT COUNT(*) AS nbr FROM acl_topology_relations WHERE acl_topo_id = '" . $topo['acl_topo_id'] . "'"; $DBRESULT2 = $pearDB->query($rq); $ctNbr = $DBRESULT2->fetchRow(); - $elemArr[$i] = array("MenuClass"=>"list_".$style, - "RowMenu_select"=>$selectedElements->toHtml(), - "RowMenu_name"=>$topo["acl_topo_name"], - "RowMenu_link"=>"?p=".$p."&o=c&acl_topo_id=".$topo['acl_topo_id'], - "RowMenu_alias"=>myDecode($topo["acl_topo_alias"]), - "RowMenu_status"=>$topo["acl_topo_activate"] ? _("Enabled") : _("Disabled"), - "RowMenu_badge" => $topo["acl_topo_activate"] ? "service_ok" : "service_critical", - "RowMenu_options"=>$moptions); - + $elemArr[$i] = array( + "MenuClass" => "list_" . $style, + "RowMenu_select" => $selectedElements->toHtml(), + "RowMenu_name" => $topo["acl_topo_name"], + "RowMenu_link" => "?p=" . $p . "&o=c&acl_topo_id=" . $topo['acl_topo_id'], + "RowMenu_alias" => myDecode($topo["acl_topo_alias"]), + "RowMenu_status" => $topo["acl_topo_activate"] ? _("Enabled") : _("Disabled"), + "RowMenu_badge" => $topo["acl_topo_activate"] ? "service_ok" : "service_critical", + "RowMenu_options" => $moptions + ); + $style != "two" ? $style = "two" : $style = "one"; } $tpl->assign("elemArr", $elemArr); @@ -117,32 +129,48 @@ /* * Different messages we put in the template */ -$tpl->assign('msg', array ("addL"=>"?p=".$p."&o=a", "addT"=>_("Add"), "delConfirm"=>_("Do you confirm the deletion ?"))); +$tpl->assign( + 'msg', + array("addL" => "?p=" . $p . "&o=a", "addT" => _("Add"), "delConfirm" => _("Do you confirm the deletion ?")) +); ?> - + "javascript: " . - "if (this.form.elements['".$option."'].selectedIndex == 1 && confirm('"._("Do you confirm the duplication ?")."')) {" . - " setO(this.form.elements['".$option."'].value); submit();} " . - "else if (this.form.elements['".$option."'].selectedIndex == 2 && confirm('"._("Do you confirm the deletion ?")."')) {" . - " setO(this.form.elements['".$option."'].value); submit();} " . - "else if (this.form.elements['".$option."'].selectedIndex == 3) {" . - " setO(this.form.elements['".$option."'].value); submit();} " . - ""); - $form->addElement('select', $option, null, array(null=>_("More actions..."), "m"=>_("Duplicate"), "d"=>_("Delete")), $attrs1); + 'onchange' => "javascript: " . + "if (this.form.elements['" . $option . "'].selectedIndex == 1 && confirm('" . + _("Do you confirm the duplication ?") . "')) {" . + " setO(this.form.elements['" . $option . "'].value); submit();} " . + "else if (this.form.elements['" . $option . "'].selectedIndex == 2 && confirm('" . + _("Do you confirm the deletion ?") . "')) {" . + " setO(this.form.elements['" . $option . "'].value); submit();} " . + "else if (this.form.elements['" . $option . "'].selectedIndex == 3) {" . + " setO(this.form.elements['" . $option . "'].value); submit();} " . + "" + ); + $form->addElement( + 'select', + $option, + null, + array( + null => _("More actions..."), + "m" => _("Duplicate"), + "d" => _("Delete") + ), + $attrs1 + ); $form->setDefaults(array($option => null)); $o1 = $form->getElement($option); $o1->setValue(null); $o1->setSelected(null); } - + $tpl->assign('limit', $limit); $tpl->assign('searchACLM', $search); From 3df6795446082e90fdda49a3ab555748248f32b0 Mon Sep 17 00:00:00 2001 From: mariegallardo Date: Thu, 20 Jul 2017 09:10:12 +0200 Subject: [PATCH 051/207] TrapSnmpConfigurationTestCreated (#5398) * TrapSnmpConfigurationTestCreated * behat file changed * File updated * * fix style * * fix duplicate rules --- behat.yml | 5 + features/TrapsSNMPConfiguration.feature | 23 + .../TrapsSNMPConfigurationContext.php | 413 ++++++++++++++++++ www/class/centreonTraps.class.php | 12 + 4 files changed, 453 insertions(+) create mode 100644 features/TrapsSNMPConfiguration.feature create mode 100644 features/bootstrap/TrapsSNMPConfigurationContext.php diff --git a/behat.yml b/behat.yml index d4d8542fe7c..26c7efe9e43 100644 --- a/behat.yml +++ b/behat.yml @@ -209,6 +209,11 @@ default: contexts: - LdapConfigurationContext + traps_snmp_configuration: + paths: [ %paths.base%/features/TrapsSNMPConfiguration.feature ] + contexts: + - TrapsSNMPConfigurationContext + ldap_manual_import: paths: [ %paths.base%/features/LdapManualImport.feature ] contexts: diff --git a/features/TrapsSNMPConfiguration.feature b/features/TrapsSNMPConfiguration.feature new file mode 100644 index 00000000000..54c38b53cf6 --- /dev/null +++ b/features/TrapsSNMPConfiguration.feature @@ -0,0 +1,23 @@ +Feature: TrapsSNMPConfiguration + As an IT supervisor + I want to configure SNMP traps + To monitore a router + + Background: + Given I am logged in a Centreon server + + Scenario: Creating SNMP trap with advanced matching rule + When I add a new SNMP trap definition with an advanced matching rule + Then the trap definition is saved with its properties, especially the content of Regexp field + + Scenario: Modify SNMP trap definition + When I modify some properties of an existing SNMP trap definition + Then all changes are saved + + Scenario: Duplicate SNMP trap definition + When I have duplicated one existing SNMP trap definition + Then all SNMP trap properties are updated + + Scenario: Delete SNMP trap definition + When I have deleted one existing SNMP trap definition + Then this definition disappears from the SNMP trap list diff --git a/features/bootstrap/TrapsSNMPConfigurationContext.php b/features/bootstrap/TrapsSNMPConfigurationContext.php new file mode 100644 index 00000000000..199a253ee86 --- /dev/null +++ b/features/bootstrap/TrapsSNMPConfigurationContext.php @@ -0,0 +1,413 @@ + 'atrapName', + 'oid' => '1.2.3', + 'vendor' => 'Cisco', + 'output' => 'trapOutputMessage' + )); + + protected $updatedProperties = (array( + 'name' => 'atrapNameChanged', + 'oid' => '.1.2.3.4', + 'vendor' => 'HP', + 'output' => 'trapOutputMessagechanged', + 'status' => 'Critical', + 'severity' => 'serviceCategoryName (3)', + 'mode' => 1, + 'behavior' => 'If match, disable submit', + 'rule' => array( + array( + 'string' => '@trapRule@', + 'regexp' => '/ruleRegexp/', + 'status' => 'Critical', + 'severity' => 'serviceCategoryName (3)' + ) + ), + 'submit' => 0, + 'reschedule' => 1, + 'execute_command' => 1, + 'special_command' => 'trapCommand', + 'comments' => 'trapComments', + 'services' => 'hostName - serviceName', + 'service_templates' => 'serviceTemplateName', + 'routing' => 1, + 'routing_definition' => 'trapRouteDefinition', + 'filter_services' => 'trapFilterServices', + 'preexec' => array('trapPreexec'), + 'insert_information' => 1, + 'timeout' => '66', + 'execution_interval' => '44', + 'execution_type' => 2, + 'execution_method' => 0, + 'check_downtime' => 2, + 'output_transform' => 'trapOutputTransform', + 'custom_code' => 'trapCustomCode' + )); + + protected $duplicatedProperties = (array( + 'name' => 'atrapNameChanged_1', + 'oid' => '.1.2.3.4', + 'vendor' => 'HP', + 'output' => 'trapOutputMessagechanged', + 'status' => 'Critical', + 'severity' => 'serviceCategoryName (3)', + 'mode' => 1, + 'behavior' => 'If match, disable submit', + 'rule' => array( + array( + 'string' => '@trapRule@', + 'regexp' => '/ruleRegexp/', + 'status' => 'Critical', + 'severity' => 'serviceCategoryName (3)' + ) + ), + 'submit' => 0, + 'reschedule' => 1, + 'execute_command' => 1, + 'special_command' => 'trapCommand', + 'comments' => 'trapComments', + 'services' => 'hostName - serviceName', + 'service_templates' => 'serviceTemplateName', + 'routing' => 1, + 'routing_definition' => 'trapRouteDefinition', + 'filter_services' => 'trapFilterServices', + 'preexec' => array('trapPreexec'), + 'insert_information' => 1, + 'timeout' => '66', + 'execution_interval' => '44', + 'execution_type' => 2, + 'execution_method' => 0, + 'check_downtime' => 2, + 'output_transform' => 'trapOutputTransform', + 'custom_code' => 'trapCustomCode' + )); + + /** + * @When I add a new SNMP trap definition with an advanced matching rule + */ + public function iAddANewSNMPTrapDefinitionWithAnAdvancedMatchingRule() + { + $this->currentPage = new HostConfigurationPage($this); + $this->currentPage->setProperties(array( + 'name' => 'hostName', + 'alias' => 'hostName', + 'address' => 'host@localhost' + )); + $this->currentPage->save(); + $this->currentPage = new CommandConfigurationPage($this); + $this->currentPage->setProperties(array( + 'command_name' => 'commandName', + 'command_line' => 'commandLine' + )); + $this->currentPage->save(); + $this->currentPage = new ServiceConfigurationPage($this); + $this->currentPage->setProperties(array( + 'description' => 'serviceName', + 'hosts' => 'hostName', + 'check_command' => 'commandName' + )); + $this->currentPage->save(); + $this->currentPage = new ServiceTemplateConfigurationPage($this); + $this->currentPage->setProperties(array( + 'description' => $this->updatedProperties['service_templates'], + 'alias' => $this->updatedProperties['service_templates'] + )); + $this->currentPage->save(); + $this->currentPage = new ServiceCategoryConfigurationPage($this); + $this->currentPage->setProperties(array( + 'name' => 'serviceCategoryName', + 'description' => 'severityDescription', + 'severity' => 1, + 'level' => '3', + 'icon' => ' centreon (png)' + )); + $this->currentPage->save(); + $this->currentPage = new SnmpTrapsConfigurationPage($this); + $this->currentPage->setProperties($this->updatedProperties); + $this->currentPage->save(); + } + + /** + * @Then the trap definition is saved with its properties, especially the content of Regexp field + */ + public function theTrapDefinitionIsSavedWithItsPropertiesEspeciallyTheContentOfRegexpField() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new SnmpTrapsConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->updatedProperties['name']); + $object = $this->currentPage->getProperties(); + foreach ($this->updatedProperties as $key => $value) { + if ($key != 'rule' && $value != $object[$key]) { + $this->tableau[] = $key; + } + } + $i = 0; + $countObject = count($object['rule']); + foreach ($this->updatedProperties['rule'] as $value) { + if ($i >= $countObject || $value['string'] != $object['rule'][$i]['string']) { + $this->tableau[] = 'rule_string'; + } + if ($i >= $countObject || $value['regexp'] != $object['rule'][$i]['regexp']) { + $this->tableau[] = 'rule_regexp'; + } + if ($i >= $countObject || $value['status'] != $object['rule'][$i]['status']) { + $this->tableau[] = 'rule_status'; + } + if ($i >= $countObject || $value['severity'] != $object['rule'][$i]['severity']) { + $this->tableau[] = 'rule_severity'; + } + ++$i; + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I modify some properties of an existing SNMP trap definition + */ + public function iModifySomePropertiesOfAnExistingSNMPTrapDefinition() + { + $this->currentPage = new SnmpTrapsConfigurationPage($this); + $this->currentPage->setProperties($this->initialProperties); + $this->currentPage->save(); + $this->currentPage = new HostConfigurationPage($this); + $this->currentPage->setProperties(array( + 'name' => 'hostName', + 'alias' => 'hostName', + 'address' => 'host@localhost' + )); + $this->currentPage->save(); + $this->currentPage = new CommandConfigurationPage($this); + $this->currentPage->setProperties(array( + 'command_name' => 'commandName', + 'command_line' => 'commandLine' + )); + $this->currentPage->save(); + $this->currentPage = new ServiceConfigurationPage($this); + $this->currentPage->setProperties(array( + 'description' => 'serviceName', + 'hosts' => 'hostName', + 'check_command' => 'commandName' + )); + $this->currentPage->save(); + $this->currentPage = new ServiceTemplateConfigurationPage($this); + $this->currentPage->setProperties(array( + 'description' => $this->updatedProperties['service_templates'], + 'alias' => $this->updatedProperties['service_templates'] + )); + $this->currentPage->save(); + $this->currentPage = new ServiceCategoryConfigurationPage($this); + $this->currentPage->setProperties(array( + 'name' => 'serviceCategoryName', + 'description' => 'severityDescription', + 'severity' => 1, + 'level' => '3', + 'icon' => ' centreon (png)' + )); + $this->currentPage->save(); + $this->currentPage = new SnmpTrapsConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['name']); + $this->currentPage->setProperties($this->updatedProperties); + $this->currentPage->save(); + } + + /** + * @Then all changes are saved + */ + public function allChangesAreSaved() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new SnmpTrapsConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->updatedProperties['name']); + $object = $this->currentPage->getProperties(); + foreach ($this->updatedProperties as $key => $value) { + if ($key != 'rule' && $value != $object[$key]) { + $this->tableau[] = $key; + } + } + $i = 0; + $countObject = count($object['rule']); + foreach ($this->updatedProperties['rule'] as $value) { + if ($i >= $countObject || $value['string'] != $object['rule'][$i]['string']) { + $this->tableau[] = 'rule_string'; + } + if ($i >= $countObject || $value['regexp'] != $object['rule'][$i]['regexp']) { + $this->tableau[] = 'rule_regexp'; + } + if ($i >= $countObject || $value['status'] != $object['rule'][$i]['status']) { + $this->tableau[] = 'rule_status'; + } + if ($i >= $countObject || $value['severity'] != $object['rule'][$i]['severity']) { + $this->tableau[] = 'rule_severity'; + } + ++$i; + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I have duplicated one existing SNMP trap definition + */ + public function iHaveDuplicatedOneExistingSNMPTrapDefinition() + { + $this->currentPage = new HostConfigurationPage($this); + $this->currentPage->setProperties(array( + 'name' => 'hostName', + 'alias' => 'hostName', + 'address' => 'host@localhost' + )); + $this->currentPage->save(); + $this->currentPage = new CommandConfigurationPage($this); + $this->currentPage->setProperties(array( + 'command_name' => 'commandName', + 'command_line' => 'commandLine' + )); + $this->currentPage->save(); + $this->currentPage = new ServiceConfigurationPage($this); + $this->currentPage->setProperties(array( + 'description' => 'serviceName', + 'hosts' => 'hostName', + 'check_command' => 'commandName' + )); + $this->currentPage->save(); + $this->currentPage = new ServiceTemplateConfigurationPage($this); + $this->currentPage->setProperties(array( + 'description' => $this->updatedProperties['service_templates'], + 'alias' => $this->updatedProperties['service_templates'] + )); + $this->currentPage->save(); + $this->currentPage = new ServiceCategoryConfigurationPage($this); + $this->currentPage->setProperties(array( + 'name' => 'serviceCategoryName', + 'description' => 'severityDescription', + 'severity' => 1, + 'level' => '3', + 'icon' => ' centreon (png)' + )); + $this->currentPage->save(); + $this->currentPage = new SnmpTrapsConfigurationPage($this); + $this->currentPage->setProperties($this->updatedProperties); + $this->currentPage->save(); + $this->currentPage = new SnmpTrapsConfigurationListingPage($this); + $object = $this->currentPage->getEntry($this->updatedProperties['name']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Duplicate'); + } + + /** + * @Then all SNMP trap properties are updated + */ + public function allSNMPTrapPropertiesAreUpdated() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new SnmpTrapsConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->duplicatedProperties['name']); + $object = $this->currentPage->getProperties(); + foreach ($this->duplicatedProperties as $key => $value) { + if ($key != 'rule' && $value != $object[$key]) { + $this->tableau[] = $key; + } + } + $i = 0; + $countObject = count($object['rule']); + foreach ($this->duplicatedProperties['rule'] as $value) { + if ($i >= $countObject || $value['string'] != $object['rule'][$i]['string']) { + $this->tableau[] = 'rule_string'; + } + if ($i >= $countObject || $value['regexp'] != $object['rule'][$i]['regexp']) { + $this->tableau[] = 'rule_regexp'; + } + if ($i >= $countObject || $value['status'] != $object['rule'][$i]['status']) { + $this->tableau[] = 'rule_status'; + } + if ($i >= $countObject || $value['severity'] != $object['rule'][$i]['severity']) { + $this->tableau[] = 'rule_severity'; + } + ++$i; + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I have deleted one existing SNMP trap definition + */ + public function iHaveDeletedOneExistingSNMPTrapDefinition() + { + $this->currentPage = new SnmpTrapsConfigurationPage($this); + $this->currentPage->setProperties($this->initialProperties); + $this->currentPage->save(); + $this->currentPage = new SnmpTrapsConfigurationListingPage($this); + $object = $this->currentPage->getEntry($this->initialProperties['name']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Delete'); + } + + /** + * @Then this definition disappears from the SNMP trap list + */ + public function thisDefinitionDisappearsFromTheSNMPTrapList() + { + $this->spin( + function ($context) { + $this->currentPage = new SnmpTrapsConfigurationListingPage($this); + $object = $this->currentPage->getEntries(); + $bool = true; + foreach ($object as $value) { + $bool = $bool && $value['name'] != $this->initialProperties['name']; + } + return $bool; + }, + "The contact group was not deleted.", + 5 + ); + } +} diff --git a/www/class/centreonTraps.class.php b/www/class/centreonTraps.class.php index d2c60191345..60ffc31e7af 100644 --- a/www/class/centreonTraps.class.php +++ b/www/class/centreonTraps.class.php @@ -188,6 +188,18 @@ public function duplicate($traps = array(), $nbrDup = array()) (SELECT ".$maxId['MAX(traps_id)'].", tpe_string, tpe_order FROM traps_preexec WHERE trap_id = ".$this->db->escape($key).")"); + + $query = "SELECT * FROM traps_matching_properties WHERE trap_id = " . (int)$key; + $dbResult = $this->db->query($query); + while ($row = $dbResult->fetchRow()) { + $query = "INSERT INTO traps_matching_properties " . + "(`trap_id`,`tmo_order`,`tmo_regexp`,`tmo_string`,`tmo_status`,`severity_id`) " . + "VALUES (" . $maxId['MAX(traps_id)'] . "," . $row['tmo_order'] . + ",'" . $row['tmo_regexp'] . "','" . $row['tmo_string'] . "'," . $row['tmo_status'] . "," . + $row['severity_id'] . ")"; + $this->db->query($query); + } + $this->centreon->CentreonLogAction->insertLog( "traps", $maxId["MAX(traps_id)"], From 86753dea67eccfbd43b0c71057c0d37ca1186b2b Mon Sep 17 00:00:00 2001 From: Kevin Duret Date: Thu, 20 Jul 2017 09:13:47 +0200 Subject: [PATCH 052/207] avoid external command shell injection in comment --- www/class/centreonExternalCommand.class.php | 158 +++++++++++++----- .../external_cmd/functionsPopup.php | 158 ++++++++++-------- 2 files changed, 203 insertions(+), 113 deletions(-) diff --git a/www/class/centreonExternalCommand.class.php b/www/class/centreonExternalCommand.class.php index 5f2698c16ff..46627841d2f 100644 --- a/www/class/centreonExternalCommand.class.php +++ b/www/class/centreonExternalCommand.class.php @@ -45,7 +45,7 @@ class CentreonExternalCommand { protected $DB; protected $DBC; - protected $cmdTab; + protected $cmdTab = array(); protected $pollerTab; public $localhostTab = array(); protected $actions = array(); @@ -88,46 +88,33 @@ public function write() $varlib = _CENTREON_VARLIB_; } - $str_local = ""; $str_remote = ""; - $return_local = 0; $return_remote = 0; - if (count($this->cmdTab)) { - foreach ($this->cmdTab as $key => $cmd) { - $cmd = str_replace("\"", "", $cmd); - $cmd = str_replace("\n", "
", $cmd); - if (isset($this->localhostTab[$this->pollerTab[$key]])) { - $str_local .= "\"[" . time() . "] " . $cmd . "\n\""; - } else { - $str_remote .= "\"EXTERNALCMD:" . $this->pollerTab[$key] . ":[" . time() . "] " . $cmd . "\n\""; - } - } + foreach ($this->cmdTab as $key => $cmd) { + $cmd = str_replace("\"", "", $cmd); + $cmd = str_replace("\n", "
", $cmd); + $cmd = "[" . time() . "] " . $cmd . "\n"; + $str_remote .= "EXTERNALCMD:" . $this->pollerTab[$key] . ":" . $cmd; } - if ($str_local != "") { - $str_local = "echo " . $str_local . " >> " . $centreon->Nagioscfg["command_file"]; - if ($this->debug) { - print "COMMAND BEFORE SEND: $str_local"; - } - passthru(trim($str_local), $return_local); - } if ($str_remote != "") { - $str_remote = "echo " . $str_remote . " >> $varlib/centcore.cmd"; if ($this->debug) { print "COMMAND BEFORE SEND: $str_remote"; } - passthru($str_remote, $return_remote); + $result = file_put_contents($varlib . '/centcore.cmd', $str_remote, FILE_APPEND); + $return_remote = ($result !== false) ? 0 : 1; } + $this->cmdTab = array(); $this->pollerTab = array(); - return ($return_local + $return_remote); + + return $return_remote; } /* * set basic process commands */ - public function setProcessCommand($command, $poller) { if ($this->debug) { @@ -252,8 +239,10 @@ private function setExternalCommandList() /** * * Get poller id where the host is hosted - * @param $pearDB - * @param $host_name + * @param null $host + * @return int + * @internal param $pearDB + * @internal param $host_name */ public function getPollerID($host = null) { @@ -289,9 +278,105 @@ public function getExternalCommandList() return $this->actions; } - /** * **************************************************** - * Downtime + /**************** + * Schedule check + ***************/ + + /** + * @param $hostName */ + public function scheduleForcedCheckHost($hostName) + { + $pollerId = $this->getPollerID($hostName); + + $this->setProcessCommand( + "SCHEDULE_FORCED_HOST_CHECK;" . $hostName . ";" . time(), + $pollerId + ); + + $this->write(); + } + + /** + * @param $hostName + * @param $serviceDescription + */ + public function scheduleForcedCheckService($hostName, $serviceDescription) + { + $pollerId = $this->getPollerID($hostName); + + $this->setProcessCommand( + "SCHEDULE_FORCED_SVC_CHECK;" . $hostName . ";" . $serviceDescription . ";" . time(), + $pollerId + ); + + $this->write(); + } + + /***************** + * Acknowledgement + ****************/ + + /** + * @param $hostName + * @param $serviceDescription + * @param $sticky + * @param $notify + * @param $persistent + * @param $author + * @param $comment + */ + public function acknowledgeHost( + $hostName, + $sticky, + $notify, + $persistent, + $author, + $comment + ) { + $pollerId = $this->getPollerID($hostName); + + $this->setProcessCommand( + "ACKNOWLEDGE_HOST_PROBLEM;" . $hostName . ";" . + $sticky . ";" . $notify . ";" . $persistent . ";" . $author . ";" . $comment, + $pollerId + ); + + $this->write(); + } + + /** + * @param $hostName + * @param $serviceDescription + * @param $sticky + * @param $notify + * @param $persistent + * @param $author + * @param $comment + */ + public function acknowledgeService( + $hostName, + $serviceDescription, + $sticky, + $notify, + $persistent, + $author, + $comment + ) { + $pollerId = $this->getPollerID($hostName); + + $this->setProcessCommand( + "ACKNOWLEDGE_SVC_PROBLEM;" . $hostName . ";" . $serviceDescription . ";" . + $sticky . ";" . $notify . ";" . $persistent . ";" . $author . ";" . $comment, + $pollerId + ); + + $this->write(); + } + + /************ + * Downtime + ***********/ /** * @@ -309,23 +394,6 @@ public function deleteDowntime($type, $hosts = array()) $this->write(); } - /** - * - * Get date from string - * - * date format: m/d/Y H:i - * @param string $string - */ - private function getDate($string) - { - $res = preg_split("/ /", $string); - $res3 = preg_split("/\//", $res[0]); - $res4 = preg_split("/:/", $res[1]); - $end_time = mktime($res4[0], $res4[1], "0", $res3[0], $res3[1], $res3[2]); - unset($res); - return $end_time; - } - /** * * Add a host downtime diff --git a/www/include/monitoring/external_cmd/functionsPopup.php b/www/include/monitoring/external_cmd/functionsPopup.php index 73bef140f97..354577a5843 100644 --- a/www/include/monitoring/external_cmd/functionsPopup.php +++ b/www/include/monitoring/external_cmd/functionsPopup.php @@ -37,73 +37,84 @@ exit(); } -/** - * - * Write command in nagios pipe or in centcore pipe. - * @param $cmd - * @param $poller - */ -function write_command($cmd, $poller) +function sanitizeShellString($string) { - global $centreon, $key, $pearDB; - $str = null; + $string = str_replace('\'', ' ', trim(urldecode($string))); + $string = str_replace('`', ' ', $string); + $string = str_replace('$(', '(', $string); - $informations = preg_split("/\;/", $key); - - /* Replace forbidden charaters in external command*/ - $cmd = str_replace("`", "`", $cmd); - $cmd = str_replace("\n", "
", $cmd); - - setlocale(LC_CTYPE, 'en_US.UTF-8'); - $str = "echo ". escapeshellarg("EXTERNALCMD:$poller:[" . time() . "]" . $cmd . "\n") . " >> " . _CENTREON_VARLIB_."/centcore.cmd"; - return passthru($str); + return $string; } /** * * Ack hosts massively * @param $key + * @return string */ function massiveHostAck($key) { global $pearDB, $is_admin, $centreon; static $processedHosts = array(); - $actions = false; $actions = $centreon->user->access->checkAction("host_acknowledgement"); $key = urldecode($key); $tmp = preg_split("/\;/", $key); - $host_name = $tmp[0]; - if (isset($processedHosts[$host_name])) { + $hostName = $tmp[0]; + if (isset($processedHosts[$hostName])) { return null; } - $processedHosts[$host_name] = true; + $processedHosts[$hostName] = true; - isset($_GET['persistent']) && $_GET['persistent'] == "true" ? $persistent = "1" : $persistent = "0"; - isset($_GET['notify']) && $_GET['notify'] == "true" ? $notify = "1" : $notify = "0"; - isset($_GET['sticky']) && $_GET['sticky'] == "true" ? $sticky = "2" : $sticky = "1"; - isset($_GET['force_check']) && $_GET['force_check'] == "true" ? $force_check = "1" : $force_check = "0"; + $persistent = isset($_GET['persistent']) && $_GET['persistent'] == "true" ? "1" : "0"; + $notify = isset($_GET['notify']) && $_GET['notify'] == "true" ? "1" :"0"; + $sticky = isset($_GET['sticky']) && $_GET['sticky'] == "true" ? "2" : "1"; + $force_check = isset($_GET['force_check']) && $_GET['force_check'] == "true" ? "1" : "0"; + + $_GET["comment"] = sanitizeShellString($_GET["comment"]); + + $extCmdObj = new CentreonExternalCommand($centreon); if ($actions == true || $is_admin) { - $host_poller = GetMyHostPoller($pearDB, $host_name); - $flg = write_command(" ACKNOWLEDGE_HOST_PROBLEM;".$host_name.";".$sticky.";".$notify.";".$persistent.";".$_GET["author"].";".trim(urldecode($_GET["comment"])), $host_poller); + $extCmdObj->acknowledgeHost( + $hostName, + $sticky, + $notify, + $persistent, + $_GET["author"], + $_GET["comment"] + ); + if ($force_check == 1) { - write_command(" SCHEDULE_FORCED_HOST_CHECK;".$host_name.";".time(), $host_poller); + $extCmdObj->scheduleForcedCheckHost( + $hostName + ); } } $actions = $centreon->user->access->checkAction("service_acknowledgement"); if (($actions == true || $is_admin) && isset($_GET['ackhostservice']) && $_GET['ackhostservice'] == "true") { - $DBRES = $pearDB->query("SELECT host_id FROM `host` WHERE host_name = '".$host_name."' LIMIT 1"); + $DBRES = $pearDB->query("SELECT host_id FROM `host` WHERE host_name = '".$hostName."' LIMIT 1"); $row = $DBRES->fetchRow(); - $svc_tab = array(); $svc_tab = getMyHostServices($row['host_id']); if (count($svc_tab)) { foreach ($svc_tab as $key2 => $value) { - write_command(" ACKNOWLEDGE_SVC_PROBLEM;".$host_name.";".$value.";".$sticky.";".$notify.";".$persistent.";".$_GET["author"].";".trim(urldecode($_GET["comment"])), $host_poller); - if ($force_check == 1 && $centreon->user->access->checkAction("service_schedule_forced_check") == true) { - write_command(" SCHEDULE_FORCED_SVC_CHECK;".$host_name.";".$value.";".time(), $host_poller); + $extCmdObj->acknowledgeService( + $hostName, + $value, + $sticky, + $notify, + $persistent, + $_GET["author"], + $_GET["comment"] + ); + if ($force_check == 1 && + $centreon->user->access->checkAction("service_schedule_forced_check") == true) { + $extCmdObj->scheduleForcedCheckService( + $hostName, + $value + ); } } } @@ -124,12 +135,13 @@ function massiveHostAck($key) * * Ack services massively * @param $key + * @return null|string + * @throws Exception */ function massiveServiceAck($key) { global $pearDB, $is_admin, $centreon; - $actions = false; $actions = $centreon->user->access->checkAction("service_acknowledgement"); $key = urldecode($key); @@ -139,29 +151,38 @@ function massiveServiceAck($key) if (!isset($tmp[0])) { throw new Exception('No host found'); } - $host_name = $tmp[0]; + $hostName = $tmp[0]; if (!isset($tmp[1])) { throw new Exception('No service found'); } else { - $svc_description = $tmp[1]; + $serviceDescription = $tmp[1]; } - isset($_GET['persistent']) && $_GET['persistent'] == "true" ? $persistent = "1" : $persistent = "0"; - isset($_GET['notify']) && $_GET['notify'] == "true" ? $notify = "1" : $notify = "0"; - isset($_GET['sticky']) && $_GET['sticky'] == "true" ? $sticky = "2" : $sticky = "1"; - isset($_GET['force_check']) && $_GET['force_check'] == "true" ? $force_check = "1" : $force_check = "0"; - - $host_poller = GetMyHostPoller($pearDB, $host_name); + isset($_GET['persistent']) && $_GET['persistent'] == "true" ? $persistent = "1" : $persistent = "0"; + isset($_GET['notify']) && $_GET['notify'] == "true" ? $notify = "1" : $notify = "0"; + isset($_GET['sticky']) && $_GET['sticky'] == "true" ? $sticky = "2" : $sticky = "1"; + isset($_GET['force_check']) && $_GET['force_check'] == "true" ? $force_check = "1" : $force_check = "0"; if ($actions == true || $is_admin) { - $_GET["comment"] = $_GET["comment"]; - $_GET["comment"] = str_replace('\'', ' ', trim(urldecode($_GET["comment"]))); + $_GET["comment"] = sanitizeShellString($_GET["comment"]); - $flg = write_command(" ACKNOWLEDGE_SVC_PROBLEM;".$host_name.";".$svc_description.";".$sticky.";".$notify.";".$persistent.";".$_GET["author"].";".$_GET["comment"], $host_poller); + $extCmdObj = new CentreonExternalCommand($centreon); + $extCmdObj->acknowledgeService( + $hostName, + $serviceDescription, + $sticky, + $notify, + $persistent, + $_GET["author"], + $_GET["comment"] + ); if ($force_check == 1 && $centreon->user->access->checkAction("service_schedule_forced_check") == true) { - write_command(" SCHEDULE_FORCED_SVC_CHECK;".$host_name.";".$svc_description.";".time(), $host_poller); + $extCmdObj->scheduleForcedCheckService( + $hostName, + $serviceDescription + ); } set_user_param($centreon->user->user_id, $pearDB, "ack_sticky", $sticky); set_user_param($centreon->user->user_id, $pearDB, "ack_notify", $notify); @@ -178,13 +199,14 @@ function massiveServiceAck($key) * * Sets host downtime massively * @param $key + * @return null + * @throws Exception */ function massiveHostDowntime($key) { - global $pearDB, $is_admin, $centreon, $centreonGMT; + global $is_admin, $centreon; static $processedHosts = array(); - - $actions = false; + $actions = $centreon->user->access->checkAction("host_schedule_downtime"); if ($actions == true || $is_admin) { @@ -201,13 +223,13 @@ function massiveHostDowntime($key) } $processedHosts[$host_name] = true; - isset($_GET['start']) && $_GET['start'] ? $start = $_GET['start'] : $start = time(); - isset($_GET['end']) && $_GET['end'] ? $end = $_GET['end'] : $end = time(); - isset($_GET['comment']) && $_GET['comment'] ? $comment = str_replace('\'', ' ', trim(urldecode($_GET["comment"]))) : $comment = ""; - isset($_GET['fixed']) && $_GET['fixed'] == "true" ? $fixed = 1 : $fixed = 0; - isset($_GET['duration']) && $_GET['duration'] && is_numeric($_GET['duration']) ? $duration = $_GET['duration'] : $duration = 0; - isset($_GET['duration_scale']) && $_GET['duration_scale'] ? $duration_scale = $_GET['duration_scale'] : $duration_scale = "s"; - isset($_GET['host_or_centreon_time']) && $_GET['host_or_centreon_time'] == "true" ? $host_or_centreon_time = "1" : $host_or_centreon_time = "0"; + $start = isset($_GET['start']) && $_GET['start'] ? $_GET['start'] : time(); + $end = isset($_GET['end']) && $_GET['end'] ? $_GET['end'] : time(); + $comment = isset($_GET['comment']) && $_GET['comment'] ? sanitizeShellString($_GET["comment"]) : ""; + $fixed = isset($_GET['fixed']) && $_GET['fixed'] == "true" ? $fixed = 1 : $fixed = 0; + $duration = isset($_GET['duration']) && $_GET['duration'] && is_numeric($_GET['duration']) ? $duration = $_GET['duration'] : $duration = 0; + $duration_scale = isset($_GET['duration_scale']) && $_GET['duration_scale'] ? $duration_scale = $_GET['duration_scale'] : $duration_scale = "s"; + $hostTime = isset($_GET['host_or_centreon_time']) && $_GET['host_or_centreon_time'] == "true" ? "1" : "0"; if ($duration > 0) { switch ($duration_scale) { @@ -236,7 +258,7 @@ function massiveHostDowntime($key) } $extCmdObj = new CentreonExternalCommand($centreon); - $extCmdObj->addHostDowntime($host, $comment, $start, $end, $fixed, $duration, $with_services, $host_or_centreon_time); + $extCmdObj->addHostDowntime($host, $comment, $start, $end, $fixed, $duration, $with_services, $hostTime); } return null; @@ -247,9 +269,8 @@ function massiveHostDowntime($key) */ function massiveServiceDowntime($key) { - global $pearDB, $is_admin, $centreon, $centreonGMT; + global $is_admin, $centreon; - $actions = false; $actions = $centreon->user->access->checkAction("service_schedule_downtime"); if ($actions == true || $is_admin) { @@ -267,13 +288,14 @@ function massiveServiceDowntime($key) $svc_description = $tmp[1]; } - isset($_GET['start']) && $_GET['start'] ? $start = $_GET['start'] : $start = time(); - isset($_GET['end']) && $_GET['end'] ? $end = $_GET['end'] : $end = time(); - isset($_GET['comment']) && $_GET['comment'] ? $comment = str_replace('\'', ' ', $_GET["comment"]) : $comment = ""; - isset($_GET['fixed']) && $_GET['fixed'] == "true" ? $fixed = 1 : $fixed = 0; - isset($_GET['duration']) && $_GET['duration'] && is_numeric($_GET['duration']) ? $duration = $_GET['duration'] : $duration = 0; - isset($_GET['duration_scale']) && $_GET['duration_scale'] ? $duration_scale = $_GET['duration_scale'] : $duration_scale = "s"; - isset($_GET['host_or_centreon_time']) && $_GET['host_or_centreon_time'] == "true" ? $host_or_centreon_time = "1" : $host_or_centreon_time = "0"; + $start = isset($_GET['start']) && $_GET['start'] ? $_GET['start'] : time(); + $end = isset($_GET['end']) && $_GET['end'] ? $_GET['end'] : time(); + $comment = isset($_GET['comment']) && $_GET['comment'] ? sanitizeShellString($_GET["comment"]) : ""; + $fixed = isset($_GET['fixed']) && $_GET['fixed'] == "true" ? 1 : 0; + $duration = isset($_GET['duration']) && $_GET['duration'] && is_numeric($_GET['duration']) ? + $_GET['duration'] : 0; + $duration_scale = isset($_GET['duration_scale']) && $_GET['duration_scale'] ? $_GET['duration_scale'] : "s"; + $hostTime = isset($_GET['host_or_centreon_time']) && $_GET['host_or_centreon_time'] == "true" ? "1" : "0"; if ($duration > 0) { switch ($duration_scale) { @@ -300,7 +322,7 @@ function massiveServiceDowntime($key) $service = getMyServiceID($svc_description, $host); $extCmdObj = new CentreonExternalCommand($centreon); - $extCmdObj->addSvcDowntime($host, $service, $comment, $start, $end, $fixed, $duration, $host_or_centreon_time); + $extCmdObj->addSvcDowntime($host, $service, $comment, $start, $end, $fixed, $duration, $hostTime); } return null; } From a2eb2bac5bdabb1991a6d7bdc64bb48693987c55 Mon Sep 17 00:00:00 2001 From: Kevin Duret Date: Thu, 20 Jul 2017 11:59:12 +0200 Subject: [PATCH 053/207] #5453 Fix hg setparam with geo coords --- www/class/centreon-clapi/centreonHostGroup.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/class/centreon-clapi/centreonHostGroup.class.php b/www/class/centreon-clapi/centreonHostGroup.class.php index 3c1d80728ae..980989980c7 100644 --- a/www/class/centreon-clapi/centreonHostGroup.class.php +++ b/www/class/centreon-clapi/centreonHostGroup.class.php @@ -152,7 +152,7 @@ public function setparam($parameters = null) throw new CentreonClapiException(self::MISSINGPARAMETER); } if (($objectId = $this->getObjectId($params[self::ORDER_UNIQUENAME])) != 0) { - if (!preg_match("/^hg_/", $params[1])) { + if (!preg_match("/^hg_/", $params[1]) && $params[1] != "geo_coords") { $params[1] = "hg_" . $params[1]; } $updateParams = array($params[1] => $params[2]); From ca02f15f7468601cb6d832a4ea1826d0b8d3e238 Mon Sep 17 00:00:00 2001 From: Matthieu Kermagoret Date: Thu, 20 Jul 2017 14:18:41 +0200 Subject: [PATCH 054/207] Add Debian 9 to unittest and package steps in Jenkinsfile. --- Jenkinsfile | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 27c46f4f5d8..1ac2c4f5eb6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -52,6 +52,20 @@ try { failedNewAll: '0' ]) } + }, + 'debian9': { + node { + sh 'cd /opt/centreon-build && git pull && cd -' + sh '/opt/centreon-build/jobs/web/3.5/mon-web-unittest.sh debian9' + step([ + $class: 'XUnitBuilder', + thresholds: [ + [$class: 'FailedThreshold', failureThreshold: '0'], + [$class: 'SkippedThreshold', failureThreshold: '0'] + ], + tools: [[$class: 'PHPUnitJunitHudsonTestType', pattern: 'ut.xml']] + ]) + } } if ((currentBuild.result ?: 'SUCCESS') != 'SUCCESS') { error('Unit tests stage failure.'); @@ -70,6 +84,12 @@ try { sh 'cd /opt/centreon-build && git pull && cd -' sh '/opt/centreon-build/jobs/web/3.5/mon-web-package.sh centos7' } + }, + 'debian9': { + node { + sh 'cd /opt/centreon-build && git pull && cd -' + sh '/opt/centreon-build/jobs/web/3.5/mon-web-package.sh debian9' + } } if ((currentBuild.result ?: 'SUCCESS') != 'SUCCESS') { error('Package stage failure.'); From b4018ab863c05ba6df7dfd71d17b645b56ec1fb0 Mon Sep 17 00:00:00 2001 From: Kevin Duret Date: Thu, 20 Jul 2017 15:02:18 +0200 Subject: [PATCH 055/207] fix clapi import of module objects --- .../centreon-clapi/centreonAPI.class.php | 27 +++++++------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/www/class/centreon-clapi/centreonAPI.class.php b/www/class/centreon-clapi/centreonAPI.class.php index 02544ab9646..be1865bce0f 100644 --- a/www/class/centreon-clapi/centreonAPI.class.php +++ b/www/class/centreon-clapi/centreonAPI.class.php @@ -760,27 +760,14 @@ public function launchActionForImport() * Check method availability before using it. */ if ($this->object) { - /** - * Require needed class - */ - $this->requireLibs($this->object); + $this->iniObject($this->object); /** * Check class declaration */ - if (isset($this->relationObject[$this->object]['class'])) { - $objName = "\CentreonClapi\centreon" . $this->relationObject[$this->object]['class']; - } else { - $objName = ""; - } - if (!isset($this->relationObject[$this->object]['class']) || !class_exists($objName)) { - print "Object $this->object not found in Centreon API.\n"; - return 1; - } - $obj = new $objName($this->DB, $this->object); + $obj = $this->objectTable[$this->object]; if (method_exists($obj, $action) || method_exists($obj, "__call")) { $this->return_code = $obj->$action($this->variables); - //print "TEST : ".$this->return_code."\n"; } else { print "Method not implemented into Centreon API.\n"; return 1; @@ -1065,9 +1052,13 @@ public function sortClassExport() $key = key($oObjet); if (isset($oObjet[$key]['class']) && $oObjet[$key]['export'] === true - && !in_array($key, $this->aExport) - ) { - $objName = "CentreonClapi\Centreon" . $oObjet[$key]['class']; + && !in_array($key, $this->aExport)) { + + $objName = ''; + if (isset($oObjet[$key]['namespace'])) { + $objName = '\\' . $oObjet[$key]['namespace']; + } + $objName .= '\CentreonClapi\Centreon' . $oObjet[$key]['class']; $objVars = get_class_vars($objName); if (isset($objVars['aDepends'])) { From 6039070ccf79b445eea27399496daafc6be01d67 Mon Sep 17 00:00:00 2001 From: loiclau Date: Thu, 20 Jul 2017 15:29:01 +0200 Subject: [PATCH 056/207] * check space --- www/include/common/common-Func.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/include/common/common-Func.php b/www/include/common/common-Func.php index 3790d32a2fc..313cf6736ee 100644 --- a/www/include/common/common-Func.php +++ b/www/include/common/common-Func.php @@ -2173,7 +2173,7 @@ function get_my_first_allowed_root_menu($lcaTStr) { global $pearDB; - if ($lcaTStr != "") { + if (trim($lcaTStr) != "") { $rq = " SELECT topology_parent,topology_name,topology_id,topology_url,topology_page,topology_url_opt FROM topology WHERE topology_page IN ($lcaTStr) From f30c6ff548d07248f1e824c171de879937f0f63f Mon Sep 17 00:00:00 2001 From: Kevin Duret Date: Thu, 20 Jul 2017 16:43:09 +0200 Subject: [PATCH 057/207] fix clapi export filter --- www/class/centreon-clapi/centreonAPI.class.php | 12 +++++++++++- www/class/centreon-clapi/centreonObject.class.php | 5 +++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/www/class/centreon-clapi/centreonAPI.class.php b/www/class/centreon-clapi/centreonAPI.class.php index be1865bce0f..bde994c6d0c 100644 --- a/www/class/centreon-clapi/centreonAPI.class.php +++ b/www/class/centreon-clapi/centreonAPI.class.php @@ -805,7 +805,17 @@ public function export_filter($action, $filter_id, $filter_name) return 0; } - $this->objectTable[$action]->export($filter_id, $filter_name); + $filters = array(); + if (!is_null($filter_id) && $filter_id !== 0) { + $primaryKey = $this->objectTable[$action]->getObject()->getPrimaryKey(); + $filters[$primaryKey] = $filter_id; + } + if (!is_null($filter_name)) { + $labelField = $this->objectTable[$action]->getObject()->getUniqueLabelField(); + $filters[$labelField] = $filter_name; + } + + $this->objectTable[$action]->export($filters); $exported->ariane_pop(); } diff --git a/www/class/centreon-clapi/centreonObject.class.php b/www/class/centreon-clapi/centreonObject.class.php index bbdba4855a0..8f527b2fff6 100644 --- a/www/class/centreon-clapi/centreonObject.class.php +++ b/www/class/centreon-clapi/centreonObject.class.php @@ -129,6 +129,11 @@ public function __construct() $this->api = CentreonAPI::getInstance(); } + public function getObject() + { + return $this->object; + } + /** * Get Centreon Version * From ea93324c0a447d44d7ba2e0ed50096803e0e2b0e Mon Sep 17 00:00:00 2001 From: Kevin Duret Date: Thu, 20 Jul 2017 17:18:14 +0200 Subject: [PATCH 058/207] fix clapi ldap contact import --- www/class/centreon-clapi/centreonContact.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/class/centreon-clapi/centreonContact.class.php b/www/class/centreon-clapi/centreonContact.class.php index 35ad40036b8..0ac500cf8f7 100644 --- a/www/class/centreon-clapi/centreonContact.class.php +++ b/www/class/centreon-clapi/centreonContact.class.php @@ -355,7 +355,7 @@ public function setparam($parameters) } } } - if ($params[1] != 'reach_api' && $params[1] != 'default_page') { + if ($params[1] != 'reach_api' && $params[1] != 'default_page' && $params[1] != 'ar_id') { $params[1] = "contact_" . $params[1]; } } From 094a7f141f4157b5bfb9a5c8ebab5a5bf5e0731f Mon Sep 17 00:00:00 2001 From: Laurent Pinsivy Date: Mon, 24 Jul 2017 09:29:39 +0100 Subject: [PATCH 059/207] Update release note Centreon web 2.8.10 --- .../centreon-2.8/centreon-2.8.10.rst | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/doc/fr/release_notes/centreon-2.8/centreon-2.8.10.rst b/doc/fr/release_notes/centreon-2.8/centreon-2.8.10.rst index c4d00e852ce..b48c94fd9a8 100644 --- a/doc/fr/release_notes/centreon-2.8/centreon-2.8.10.rst +++ b/doc/fr/release_notes/centreon-2.8/centreon-2.8.10.rst @@ -5,4 +5,28 @@ Centreon Web 2.8.10 Enhancements ============ -* Update engine reserved macros ($HOSTID$, $SERVICEID$, $HOSTTIMEZONE$) +* Proposal break Ajax #5256 +* Do not export empty Centreon Broker parameters with API #5284 +* Remove duplicate $_GET["autologin"] in test #5344 +* Documentation improvement #5063 +* Update engine reserved macros ($HOSTID$, $SERVICEID$, $HOSTTIMEZONE$) #5246 +* Config generation is too long #5388 +* Rename Centreon Broker Daemon option #5276 + +Bugfix +====== + +* Failure with special character in password for mysqldump #5173 +* Unable to select all services in escalation form #5326 #PR5325 +* Contacts/contactgroups inheritance #5396 PR #5400 +* Check if wiki is configured and extend error message #5278 PR #5269 +* Select All don't work on service categories PR #5389 +* Autologin + fullscreen options #5338 PR #5338 +* Directory "/var/spool/centreon" not created by Centreon-common.rpm #5405 +* "Fill in" option in graph doesn't work with "VDEF" DEF type #5354 +* Delete SNMP Traps #5282 +* Can't duplicate trap definition #5272 PR #5280 +* Virtual Metric problems with French language package #5355 +* Impossible to set manually a service to a meta service for non admin users #5358 PR #5391 +* Graph period displayed does not match selected zoom period #5334 +* Host configuration can not be saved or modified #5348 From 73420eea0c71ed63c99b5ff30396334f5acf8356 Mon Sep 17 00:00:00 2001 From: Laurent Pinsivy Date: Mon, 24 Jul 2017 09:31:26 +0100 Subject: [PATCH 060/207] Update release note Centreon web 2.8.10 --- .../centreon-2.8/centreon-2.8.10.rst | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/doc/en/release_notes/centreon-2.8/centreon-2.8.10.rst b/doc/en/release_notes/centreon-2.8/centreon-2.8.10.rst index c4d00e852ce..b48c94fd9a8 100644 --- a/doc/en/release_notes/centreon-2.8/centreon-2.8.10.rst +++ b/doc/en/release_notes/centreon-2.8/centreon-2.8.10.rst @@ -5,4 +5,28 @@ Centreon Web 2.8.10 Enhancements ============ -* Update engine reserved macros ($HOSTID$, $SERVICEID$, $HOSTTIMEZONE$) +* Proposal break Ajax #5256 +* Do not export empty Centreon Broker parameters with API #5284 +* Remove duplicate $_GET["autologin"] in test #5344 +* Documentation improvement #5063 +* Update engine reserved macros ($HOSTID$, $SERVICEID$, $HOSTTIMEZONE$) #5246 +* Config generation is too long #5388 +* Rename Centreon Broker Daemon option #5276 + +Bugfix +====== + +* Failure with special character in password for mysqldump #5173 +* Unable to select all services in escalation form #5326 #PR5325 +* Contacts/contactgroups inheritance #5396 PR #5400 +* Check if wiki is configured and extend error message #5278 PR #5269 +* Select All don't work on service categories PR #5389 +* Autologin + fullscreen options #5338 PR #5338 +* Directory "/var/spool/centreon" not created by Centreon-common.rpm #5405 +* "Fill in" option in graph doesn't work with "VDEF" DEF type #5354 +* Delete SNMP Traps #5282 +* Can't duplicate trap definition #5272 PR #5280 +* Virtual Metric problems with French language package #5355 +* Impossible to set manually a service to a meta service for non admin users #5358 PR #5391 +* Graph period displayed does not match selected zoom period #5334 +* Host configuration can not be saved or modified #5348 From 52267a3231d798af197f586dd61c511836cc766d Mon Sep 17 00:00:00 2001 From: Laurent Pinsivy Date: Mon, 24 Jul 2017 09:37:23 +0100 Subject: [PATCH 061/207] Update index to add 2.8.10 --- doc/en/release_notes/centreon-2.8/index.rst | 1 + doc/fr/release_notes/centreon-2.8/index.rst | 1 + 2 files changed, 2 insertions(+) diff --git a/doc/en/release_notes/centreon-2.8/index.rst b/doc/en/release_notes/centreon-2.8/index.rst index ecca4b2af78..d4a7e707cb2 100644 --- a/doc/en/release_notes/centreon-2.8/index.rst +++ b/doc/en/release_notes/centreon-2.8/index.rst @@ -16,3 +16,4 @@ Please find here the release notes dedicated to the last 2.8.x version of Centre centreon-2.8.7 centreon-2.8.8 centreon-2.8.9 + centreon-2.8.10 diff --git a/doc/fr/release_notes/centreon-2.8/index.rst b/doc/fr/release_notes/centreon-2.8/index.rst index ecca4b2af78..d4a7e707cb2 100644 --- a/doc/fr/release_notes/centreon-2.8/index.rst +++ b/doc/fr/release_notes/centreon-2.8/index.rst @@ -16,3 +16,4 @@ Please find here the release notes dedicated to the last 2.8.x version of Centre centreon-2.8.7 centreon-2.8.8 centreon-2.8.9 + centreon-2.8.10 From 024b1d383d7f532279e44c65bba60105da76568c Mon Sep 17 00:00:00 2001 From: Matthieu Kermagoret Date: Mon, 24 Jul 2017 14:21:09 +0200 Subject: [PATCH 062/207] Add 2.8.11 update script. --- www/install/sql/centreon/Update-DB-2.8.10_to_2.8.11.sql | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 www/install/sql/centreon/Update-DB-2.8.10_to_2.8.11.sql diff --git a/www/install/sql/centreon/Update-DB-2.8.10_to_2.8.11.sql b/www/install/sql/centreon/Update-DB-2.8.10_to_2.8.11.sql new file mode 100644 index 00000000000..f80239d9d7e --- /dev/null +++ b/www/install/sql/centreon/Update-DB-2.8.10_to_2.8.11.sql @@ -0,0 +1,2 @@ +-- Change version of Centreon +UPDATE `informations` SET `value` = '2.8.11' WHERE CONVERT( `informations`.`key` USING utf8 ) = 'version' AND CONVERT ( `informations`.`value` USING utf8 ) = '2.8.10' LIMIT 1; From e3b805d09df9fc7ee67f376737aa68a08471c49c Mon Sep 17 00:00:00 2001 From: Matthieu Kermagoret Date: Mon, 24 Jul 2017 14:32:14 +0200 Subject: [PATCH 063/207] Insert 2.8.11 in SQL update path. --- ...pdate-DB-2.8.10_to_2.9.0.sql => Update-DB-2.8.11_to_2.9.0.sql} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename www/install/sql/centreon/{Update-DB-2.8.10_to_2.9.0.sql => Update-DB-2.8.11_to_2.9.0.sql} (100%) diff --git a/www/install/sql/centreon/Update-DB-2.8.10_to_2.9.0.sql b/www/install/sql/centreon/Update-DB-2.8.11_to_2.9.0.sql similarity index 100% rename from www/install/sql/centreon/Update-DB-2.8.10_to_2.9.0.sql rename to www/install/sql/centreon/Update-DB-2.8.11_to_2.9.0.sql From 10ce6c2b39175ed1d509329db2a940a971ac201b Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Date: Mon, 24 Jul 2017 17:20:15 +0200 Subject: [PATCH 064/207] Enhancement for deletion status and adding servicegroups and hostgroups types (#5433) --- www/include/configuration/configServers/DB-Func.php | 12 +++++++++--- .../configuration/configServers/listServers.php | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/www/include/configuration/configServers/DB-Func.php b/www/include/configuration/configServers/DB-Func.php index 07f3e3e33fc..9cb0aa3faa0 100644 --- a/www/include/configuration/configServers/DB-Func.php +++ b/www/include/configuration/configServers/DB-Func.php @@ -470,11 +470,17 @@ function checkChangeState($poller_id, $last_restart) } $query = "SELECT * FROM log_action WHERE action_log_date > $last_restart " . - "AND ((object_type = 'host' AND (action_type = 'd' OR object_id IN (SELECT host_host_id FROM " . + "AND ((object_type = 'host' AND ((action_type = 'd' AND object_id IN (SELECT host_id FROM hosts)) OR object_id IN (SELECT host_host_id FROM " . $conf_centreon['db'] . ".ns_host_relation WHERE nagios_server_id = '$poller_id'))) " . - "OR (object_type = 'service' AND (action_type = 'd' OR object_id IN (SELECT service_service_id FROM " . + "OR (object_type = 'service' AND ((action_type = 'd' AND object_id IN (SELECT service_id FROM services)) OR object_id IN (SELECT service_service_id FROM " . $conf_centreon['db'] . ".ns_host_relation nhr, " . $conf_centreon['db'] . ".host_service_relation hsr " . - "WHERE nagios_server_id = '$poller_id' AND hsr.host_host_id = nhr.host_host_id))))"; + "WHERE nagios_server_id = '$poller_id' AND hsr.host_host_id = nhr.host_host_id)))" . + "OR (object_type = 'servicegroup' AND ((action_type = 'd' AND object_id IN (SELECT DISTINCT servicegroup_id FROM services_servicegroups)) OR object_id IN (SELECT DISTINCT servicegroup_sg_id FROM " . + $conf_centreon['db'] . ".servicegroup_relation sgr, " . $conf_centreon['db'] . ".ns_host_relation nhr " . + "WHERE sgr.host_host_id = nhr.host_host_id AND nhr.nagios_server_id = '$poller_id')))" . + "OR (object_type = 'hostgroup' AND ((action_type = 'd' AND object_id IN (SELECT DISTINCT hostgroup_id FROM hosts_hostgroups)) OR object_id IN (SELECT DISTINCT hr.hostgroup_hg_id FROM " . + $conf_centreon['db'] . ".hostgroup_relation hr, " . $conf_centreon['db'] . ".ns_host_relation nhr " . + "WHERE hr.host_host_id = nhr.host_host_id AND nhr.nagios_server_id = '$poller_id'))))"; $dbResult = $pearDBO->query($query); if ($dbResult->rowCount()) { return 1; diff --git a/www/include/configuration/configServers/listServers.php b/www/include/configuration/configServers/listServers.php index 26965703a2d..651e9dc7aae 100644 --- a/www/include/configuration/configServers/listServers.php +++ b/www/include/configuration/configServers/listServers.php @@ -251,7 +251,7 @@ $tpl->assign( "notice", - _("Only services and hosts are taken in account in order to calculate this status. " . + _("Only services, servicegroups, hosts and hostgroups are taken in account in order to calculate this status. " . "If you modify a template, it won't tell you the configuration had changed.") ); From 12a7cfb016e1185f01cbc95fd870b76798d366f2 Mon Sep 17 00:00:00 2001 From: mariegallardo Date: Mon, 24 Jul 2017 17:37:23 +0200 Subject: [PATCH 065/207] New Feature MassiveChangeHost (#5452) * Feature created * * fix style * Test completed * * add recovery notification delay in massive change #5451 * Delete vrml_image * * dont delete empty input * * fix style --- behat.yml | 5 + features/MassiveChangeHosts.feature | 12 + .../bootstrap/MassiveChangeHostsContext.php | 346 ++++++++++++++++++ .../configObject/host/DB-Func.php | 33 ++ 4 files changed, 396 insertions(+) create mode 100644 features/MassiveChangeHosts.feature create mode 100644 features/bootstrap/MassiveChangeHostsContext.php diff --git a/behat.yml b/behat.yml index 26c7efe9e43..4e757cee2e3 100644 --- a/behat.yml +++ b/behat.yml @@ -258,3 +258,8 @@ default: paths: [ %paths.base%/features/TimePeriodConfiguration.feature ] contexts: - TimePeriodConfigurationContext + + massive_change_hosts: + paths: [ %paths.base%/features/MassiveChangeHosts.feature ] + contexts: + - MassiveChangeHostsContext diff --git a/features/MassiveChangeHosts.feature b/features/MassiveChangeHosts.feature new file mode 100644 index 00000000000..145b385d4ae --- /dev/null +++ b/features/MassiveChangeHosts.feature @@ -0,0 +1,12 @@ +Feature: Massive Change on Hosts + As a Centreon administrator + I want to modify some properties of similar hosts + To configure quickly numerous hosts at the same time + + Background: + Given I am logged in a Centreon server + And several hosts have been created with mandatory properties + + Scenario: Configure by massive change several hosts with same properties + When I have applied Massive Change operation to several hosts + Then all selected hosts are updated with the same values diff --git a/features/bootstrap/MassiveChangeHostsContext.php b/features/bootstrap/MassiveChangeHostsContext.php new file mode 100644 index 00000000000..de2d96da3a8 --- /dev/null +++ b/features/bootstrap/MassiveChangeHostsContext.php @@ -0,0 +1,346 @@ + 'host1Name', + 'alias' => 'host1Alias', + 'address' => 'host1@localhost' + ); + + protected $host2 = array( + 'name' => 'host2Name', + 'alias' => 'host2Alias', + 'address' => 'host2@localhost' + ); + + protected $host3 = array( + 'name' => 'host3Name', + 'alias' => 'host3Alias', + 'address' => 'host3@localhost' + ); + + protected $hostGroup = array( + 'name' => 'hostGroupName', + 'alias' => 'hostGroupAlias' + ); + + protected $hostCategory1 = array( + 'name' => 'hostCategoryName1', + 'alias' => 'hostCategoryAlias1', + 'severity' => 1, + 'severity_level' => 2, + 'severity_icon' => ' centreon (png)' + ); + + protected $hostCategory2 = array( + 'name' => 'hostCategoryName2', + 'alias' => 'hostCategoryAlias2' + ); + + protected $updatedProperties = array( + 'snmp_community' => 'snmp', + 'snmp_version' => '2c', + 'monitored_from' => 'Central', + 'monitored_option' => 1, + 'location' => 'Europe/Paris', + 'update_mode_tplp' => 0, + 'templates' => array( + 'generic-host' + ), + 'service_linked_to_template' => 0, + 'command_arguments' => 'hostCommandArgument', + 'macros' => array( + 'HOSTMACRONAME' => '22' + ), + 'check_command' => 'check_http', + 'check_period' => 'workhours', + 'max_check_attempts' => 34, + 'normal_check_interval' => 5, + 'retry_check_interval' => 10, + 'active_checks_enabled' => 2, + 'passive_checks_enabled' => 0, + 'notifications_enabled' => 1, + 'contact_additive_inheritance' => 1, + 'contacts' => 'Guest', + 'contact_group_additive_inheritance' => 0, + 'contact_groups' => 'Supervisors', + 'update_mode_notifopts' => 1, + 'notify_on_down' => 1, + 'notify_on_unreachable' => 1, + 'notify_on_recovery' => 1, + 'notify_on_flapping' => 1, + 'notify_on_downtime_scheduled' => 1, + 'notify_on_none' => 0, + 'notification_interval' => 17, + 'update_mode_hcg' => 1, + 'update_mode_notif_interval' => 0, + 'update_mode_timeperiod' => 0, + 'notification_period' => 'none', + 'update_mode_first_notif_delay' => 1, + 'first_notification_delay' => 4, + 'recovery_notification_delay' => 3, + 'update_mode_hhg' => 0, + 'parent_host_groups' => 'hostGroupName', + 'update_mode_hhc' => 1, + 'parent_host_categories' => 'hostCategoryName2', + 'update_mode_hpar' => 1, + 'parent_hosts' => 'Centreon-Server', + 'update_mode_hch' => 0, + 'child_hosts' => 'host3Name', + 'obsess_over_host' => 2, + 'acknowledgement_timeout' => 2, + 'check_freshness' => 0, + 'freshness_threshold' => 34, + 'flap_detection_enabled' => 1, + 'low_flap_threshold' => 67, + 'high_flap_threshold' => 85, + 'retain_status_information' => 2, + 'retain_non_status_information' => 0, + 'stalking_option_on_up' => 1, + 'stalking_option_on_down' => 0, + 'stalking_option_on_unreachable' => 1, + 'event_handler_enabled' => 2, + 'event_handler' => 'check_https', + 'event_handler_arguments' => 'event_handler_arguments', + 'url' => 'hostMassiveChangeUrl', + 'notes' => 'hostMassiveChangeNotes', + 'action_url' => 'hostMassiveChangeActionUrl', + 'icon' => ' centreon (png)', + 'alt_icon' => 'hostMassiveChangeIcon', + 'status_map_image' => ' centreon (png)', + 'geo_coordinates' => 'Paris', + '2d_coords' => '15,84', + '3d_coords' => '15,84,76', + 'severity_level' => 'hostCategoryName1 (2)', + 'enabled' => 0, + 'comments' => 'hostMassiveChangeComments' + ); + + protected $updatedHost1 = array( + 'name' => 'host1Name', + 'alias' => 'host1Alias', + 'address' => 'host1@localhost', + 'snmp_community' => 'snmp', + 'snmp_version' => '2c', + 'monitored_from' => 'Central', + 'location' => 'Europe/Paris', + 'templates' => array( + 'generic-host' + ), + 'service_linked_to_template' => 0, + 'check_command' => 'check_http', + 'command_arguments' => 'hostCommandArgument', + 'macros' => array( + 'HOSTMACRONAME' => '22' + ), + 'check_period' => 'workhours', + 'max_check_attempts' => 34, + 'normal_check_interval' => 5, + 'retry_check_interval' => 10, + 'active_checks_enabled' => 2, + 'passive_checks_enabled' => 0, + 'notifications_enabled' => 1, + 'contact_additive_inheritance' => 1, + 'contacts' => 'Guest', + 'contact_group_additive_inheritance' => 0, + 'contact_groups' => 'Supervisors', + 'notify_on_down' => 1, + 'notify_on_unreachable' => 1, + 'notify_on_recovery' => 1, + 'notify_on_flapping' => 1, + 'notify_on_downtime_scheduled' => 1, + 'notify_on_none' => 1, + 'notification_interval' => 17, + 'notification_period' => 'none', + 'first_notification_delay' => 4, + 'recovery_notification_delay' => 3, + 'parent_host_groups' => 'hostGroupName', + 'parent_host_categories' => 'hostCategoryName2', + 'parent_hosts' => 'Centreon-Server', + 'child_hosts' => 'host3Name', + 'obsess_over_host' => 2, + 'acknowledgement_timeout' => 2, + 'check_freshness' => 0, + 'freshness_threshold' => 34, + 'flap_detection_enabled' => 1, + 'low_flap_threshold' => 67, + 'high_flap_threshold' => 85, + 'retain_status_information' => 2, + 'retain_non_status_information' => 0, + 'stalking_option_on_up' => 1, + 'stalking_option_on_down' => 0, + 'stalking_option_on_unreachable' => 1, + 'event_handler_enabled' => 2, + 'event_handler' => 'check_https', + 'event_handler_arguments' => 'event_handler_arguments', + 'url' => 'hostMassiveChangeUrl', + 'notes' => 'hostMassiveChangeNotes', + 'action_url' => 'hostMassiveChangeActionUrl', + 'icon' => ' centreon (png)', + 'alt_icon' => 'hostMassiveChangeIcon', + 'status_map_image' => ' centreon (png)', + 'geo_coordinates' => 'Paris', + '2d_coords' => '15,84', + '3d_coords' => '15,84,76', + 'severity_level' => 'hostCategoryName1 (2)', + 'enabled' => 0, + 'comments' => 'hostMassiveChangeComments' + ); + + protected $updatedHost2 = array( + 'name' => 'host2Name', + 'alias' => 'host2Alias', + 'address' => 'host2@localhost', + 'snmp_community' => 'snmp', + 'snmp_version' => '2c', + 'monitored_from' => 'Central', + 'location' => 'Europe/Paris', + 'templates' => array( + 'generic-host' + ), + 'service_linked_to_template' => 0, + 'check_command' => 'check_http', + 'command_arguments' => 'hostCommandArgument', + 'macros' => array( + 'HOSTMACRONAME' => '22' + ), + 'check_period' => 'workhours', + 'max_check_attempts' => 34, + 'normal_check_interval' => 5, + 'retry_check_interval' => 10, + 'active_checks_enabled' => 2, + 'passive_checks_enabled' => 0, + 'notifications_enabled' => 1, + 'contact_additive_inheritance' => 1, + 'contacts' => 'Guest', + 'contact_group_additive_inheritance' => 0, + 'contact_groups' => 'Supervisors', + 'notify_on_down' => 1, + 'notify_on_unreachable' => 1, + 'notify_on_recovery' => 1, + 'notify_on_flapping' => 1, + 'notify_on_downtime_scheduled' => 1, + 'notify_on_none' => 1, + 'notification_interval' => 17, + 'notification_period' => 'none', + 'first_notification_delay' => 4, + 'recovery_notification_delay' => 3, + 'parent_host_groups' => 'hostGroupName', + 'parent_host_categories' => 'hostCategoryName2', + 'parent_hosts' => 'Centreon-Server', + 'child_hosts' => 'host3Name', + 'obsess_over_host' => 2, + 'acknowledgement_timeout' => 2, + 'check_freshness' => 0, + 'freshness_threshold' => 34, + 'flap_detection_enabled' => 1, + 'low_flap_threshold' => 67, + 'high_flap_threshold' => 85, + 'retain_status_information' => 2, + 'retain_non_status_information' => 0, + 'stalking_option_on_up' => 1, + 'stalking_option_on_down' => 0, + 'stalking_option_on_unreachable' => 1, + 'event_handler_enabled' => 2, + 'event_handler' => 'check_https', + 'event_handler_arguments' => 'event_handler_arguments', + 'url' => 'hostMassiveChangeUrl', + 'notes' => 'hostMassiveChangeNotes', + 'action_url' => 'hostMassiveChangeActionUrl', + 'icon' => ' centreon (png)', + 'alt_icon' => 'hostMassiveChangeIcon', + 'status_map_image' => ' centreon (png)', + 'geo_coordinates' => 'Paris', + '2d_coords' => '15,84', + '3d_coords' => '15,84,76', + 'severity_level' => 'hostCategoryName1 (2)', + 'enabled' => 0, + 'comments' => 'hostMassiveChangeComments' + ); + + /** + * @Given several hosts have been created with mandatory properties + */ + public function severalHostsHaveBeenCreatedWithMandatoryProperties() + { + $this->currentPage = new HostConfigurationPage($this); + $this->currentPage->setProperties($this->host1); + $this->currentPage->save(); + $this->currentPage = new HostConfigurationPage($this); + $this->currentPage->setProperties($this->host2); + $this->currentPage->save(); + $this->currentPage = new HostConfigurationPage($this); + $this->currentPage->setProperties($this->host3); + $this->currentPage->save(); + $this->currentPage = new HostGroupConfigurationPage($this); + $this->currentPage->setProperties($this->hostGroup); + $this->currentPage->save(); + $this->currentPage = new HostCategoryConfigurationPage($this); + $this->currentPage->setProperties($this->hostCategory1); + $this->currentPage->save(); + $this->currentPage = new HostCategoryConfigurationPage($this); + $this->currentPage->setProperties($this->hostCategory2); + $this->currentPage->save(); + } + + /** + * @When I have applied Massive Change operation to several hosts + */ + public function iHaveAppliedMassiveChangeOperationToSeveralHosts() + { + $this->currentPage = new HostConfigurationListingPage($this); + $object = $this->currentPage->getEntry($this->host1['name']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $object = $this->currentPage->getEntry($this->host2['name']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->selectInList('select[name="o1"]', 'Massive Change'); + $this->currentPage = new MassiveChangeHostConfigurationPage($this, false); + $this->currentPage->setProperties($this->updatedProperties); + $this->currentPage->save(); + } + + /** + * @Then all selected hosts are updated with the same values + */ + public function allSelectedHostsAreUpdatedWithTheSameValues() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new HostConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->updatedHost1['name']); + $object = $this->currentPage->getProperties(); + foreach ($this->updatedHost1 as $key => $value) { + if ($value != $object[$key]) { + $this->tableau[] = $key . '1'; + } + } + $this->currentPage = new HostConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->updatedHost2['name']); + $object = $this->currentPage->getProperties(); + foreach ($this->updatedHost2 as $key => $value) { + if ($value != $object[$key]) { + $this->tableau[] = $key . '2'; + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } +} diff --git a/www/include/configuration/configObject/host/DB-Func.php b/www/include/configuration/configObject/host/DB-Func.php index 1381422a5c5..81b513dee13 100644 --- a/www/include/configuration/configObject/host/DB-Func.php +++ b/www/include/configuration/configObject/host/DB-Func.php @@ -662,6 +662,11 @@ function updateHostInDB($host_id = null, $from_MC = false, $cfg = null) } +# Function for updating first notification delay options + updateHostNotifOptionRecoveryNotificationDelay($host_id); + + + # Function for updating notification timeperiod options # 1 - MC with deletion of existing options (Replacement) # 2 - MC with addition of new options (incremental) @@ -2290,6 +2295,34 @@ function updateHostNotifOptionFirstNotificationDelay_MC($host_id = null) } } + +function updateHostNotifOptionRecoveryNotificationDelay($host_id = null, $ret = array()) +{ + if (!$host_id) { + return; + } + global $form; + global $pearDB; + + if (isset($ret["host_recovery_notification_delay"])) { + $ret = $ret["host_recovery_notification_delay"]; + } else { + $ret = $form->getSubmitValue("host_recovery_notification_delay"); + } + + if ($ret == '') { + return; + } + $rq = "UPDATE host SET "; + $rq .= "host_recovery_notification_delay = "; + isset($ret) && $ret != null ? $rq .= "'" . $ret . "' " : $rq .= "NULL "; + $rq .= "WHERE host_id = '" . $host_id . "'"; + $pearDB->query($rq); +} + + + + function updateHostHostGroup($host_id, $ret = array()) { global $form, $pearDB; From 30856f887d25b480179da04dd5569bfd016de987 Mon Sep 17 00:00:00 2001 From: Laurent Pinsivy Date: Mon, 24 Jul 2017 16:54:40 +0100 Subject: [PATCH 066/207] Add how to translate Centreon Web interface in documentation Conflicts: doc/en/developer/index.rst doc/fr/developper/index.rst --- doc/en/developer/index.rst | 2 +- doc/en/developer/translatecentreon.rst | 130 ++++++++++++++++++++ doc/en/images/developer/change_language.png | Bin 0 -> 73890 bytes doc/fr/developper/index.rst | 4 +- doc/fr/developper/translatecentreon.rst | 130 ++++++++++++++++++++ doc/fr/images/developer/change_language.png | Bin 0 -> 73890 bytes 6 files changed, 262 insertions(+), 4 deletions(-) create mode 100644 doc/en/developer/translatecentreon.rst create mode 100644 doc/en/images/developer/change_language.png create mode 100644 doc/fr/developper/translatecentreon.rst create mode 100644 doc/fr/images/developer/change_language.png diff --git a/doc/en/developer/index.rst b/doc/en/developer/index.rst index 9c988ad0ae0..00fa4f69c44 100644 --- a/doc/en/developer/index.rst +++ b/doc/en/developer/index.rst @@ -7,4 +7,4 @@ Developer writemodule writewidget - develop-a-plugin.rst + translatecentreon diff --git a/doc/en/developer/translatecentreon.rst b/doc/en/developer/translatecentreon.rst new file mode 100644 index 00000000000..3fdc9c0cf98 --- /dev/null +++ b/doc/en/developer/translatecentreon.rst @@ -0,0 +1,130 @@ +========================= +How to translate Centreon +========================= + +If you want to contribute to translate Centreon, this new tutorial is for you! +Discover how to translate Centreon web interface and how to help us to add new +language in Centreon. + +******************************* +Install translation environment +******************************* + +Download the following `archive `_ and copy it on a Linux server. + +Execute the following commands:: + + $ unzip centreon-translation.zip + $ cd centreon-translation + +Your environment to translate Centreon is now ready. + +**************** +First generation +**************** + +During the first generation, the script will clone Centreon sources from GitHub +on your server. + +Execute the following command:: + + $ bash make-translation.sh + +At the end of execution, two files are available: + +* messages.pot to translate Centreon web interface menu and forms +* help.pot to translate help tooltips in configuration forms + +Rename messages.pot to messages.po and help.po to help.po + +You can now start translation of Centreon by editing files with a PO file editor like poedit. + +.. note:: + Keep always your \*.po files for next translation. + +******************** +Use your translation +******************** + +On your Centreon server, install gettext:: + + $ sudo yum install gettext + +Create the locale directory for your Centreon:: + + $ sudo mkdir -p /usr/share/centreon/www/locale/`locale | grep LC_MESSAGES | cut -d \" -f 2`/LC_MESSAGES + +.. note:: + **/usr/share/centreon** is the Centreon installed directory. + +If you want to translate Centreon in other language than use by your Centreon +server, you have to define manually the locale. + +For example, for Brazilian users, execute the following command:: + + $ sudo mkdir -p /usr/share/centreon/www/locale/pt_BR/LC_MESSAGES + +Compile translated files:: + + $ msgfmt messages.po -o messages.mo + $ msgfmt help.pot -o help.mo + +Copy compiled translated files:: + + $ sudo cp *.mo /usr/share/centreon/www/locale/`locale | grep LC_MESSAGES | cut -d \" -f 2`/LC_MESSAGES + +Change rights on directory:: + + $ sudo chown -R apache.apache /usr/share/centreon/www/locale/`locale | grep LC_MESSAGES | cut -d \" -f 2` + +Restart Apache:: + + $ sudo service httpd restart + +Connect to your Centreon web interface, edit your profil and select new language: + +.. image:: /images/developer/change_language.png + :align: center + :scale: 65% + +Save the form and access to another menu, your interface will be translated. + +******************* +Upgrade translation +******************* + +Centreon developers released every month a new version of Centreon Web. +So translation could be modified with every new release. + +To maintain translation up-to-date follow this steps:: + + $ bash make-translation.sh + +At the end of execution, two files up-to-date are available: + +* messages.pot to translate Centreon Web interface menu and forms +* help.pot to translate help tooltips in configuration forms + +Merge this files with previous translation (messages.po and help.po):: + + $ msgmerge help.po help.pot -o new_help.po + $ msgmerge messages.po messages.pot -o new_messages.po + +Follow chapter “Use your translation” to upgrade translation for Centreon. + +******************************* +Participate to Centreon project +******************************* + +Once your translation is up-to-date, you can ask to the Centreon team to add +your translation to Centreon project. This will allow for all person using +Centreon to have access to your translation on their Centreon platform. + +* Create an account on GitHub +* Fork centreon/centreon project on GitHub +* Add your translated \*.mo and \*.po files to lang//LC_MESSAGES directory +* Commit your change on your project +* Create a pull request on centreon/centreon project +* We will add your translation to Centreon. + +Thank you for your help! diff --git a/doc/en/images/developer/change_language.png b/doc/en/images/developer/change_language.png new file mode 100644 index 0000000000000000000000000000000000000000..3f5ad2e4a53c2fa0fc49d8550d951900def09c36 GIT binary patch literal 73890 zcmeFYS5%YT);~%Sk**>j-GZPXMd>9}>Alwg(tA&U&;(Re1Vp5Fqy|EV(2EF23q91( z5eOx;5ITR}y}z?x_dCWpH|OG9obMvfSYu_?xn}vzIoJBArJ+bc%0P;Thex5T^hyU0 zj}VE6N5FpT=5x0;$<^oZUt$%OKW{Yp$u`qs~eB_LnNBh?}V zyF@=7#Md)34e&QZxe2I%At9VIobuflm%Dv*YLmR0Hi3gGQdBu`WW%Bm+ z*$tjZB`$}kYSjAqP|8gf(*Ia+P)2y5oGQIK*pf*1JY}3-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QcH)?4q>$wQx5;~ei?BOETf;i9 zDd+G*i-SXo3T!18EtamDGi}+l*5Y-kk3-d?OP9Dty_n>EgmwRxvr^rsRD3V54$+%7 zsTeet-`3htGGpypvHO}vC${9~e8{}-_^4XrR69%Q^E)d-uBql0NV{u453~Pl$TSg@ zu2eD%^&xgKC@)Y@U@N^;I5l&3L|qo!HP8TnOkP1If&aYu`rN*N}) zqBFKllhjF64vmjUO9R`_ and copy it on a Linux server. + +Execute the following commands:: + + $ unzip centreon-translation.zip + $ cd centreon-translation + +Your environment to translate Centreon is now ready. + +**************** +First generation +**************** + +During the first generation, the script will clone Centreon sources from GitHub +on your server. + +Execute the following command:: + + $ bash make-translation.sh + +At the end of execution, two files are available: + +* messages.pot to translate Centreon web interface menu and forms +* help.pot to translate help tooltips in configuration forms + +Rename messages.pot to messages.po and help.po to help.po + +You can now start translation of Centreon by editing files with a PO file editor like poedit. + +.. note:: + Keep always your \*.po files for next translation. + +******************** +Use your translation +******************** + +On your Centreon server, install gettext:: + + $ sudo yum install gettext + +Create the locale directory for your Centreon:: + + $ sudo mkdir -p /usr/share/centreon/www/locale/`locale | grep LC_MESSAGES | cut -d \" -f 2`/LC_MESSAGES + +.. note:: + **/usr/share/centreon** is the Centreon installed directory. + +If you want to translate Centreon in other language than use by your Centreon +server, you have to define manually the locale. + +For example, for Brazilian users, execute the following command:: + + $ sudo mkdir -p /usr/share/centreon/www/locale/pt_BR/LC_MESSAGES + +Compile translated files:: + + $ msgfmt messages.po -o messages.mo + $ msgfmt help.pot -o help.mo + +Copy compiled translated files:: + + $ sudo cp *.mo /usr/share/centreon/www/locale/`locale | grep LC_MESSAGES | cut -d \" -f 2`/LC_MESSAGES + +Change rights on directory:: + + $ sudo chown -R apache.apache /usr/share/centreon/www/locale/`locale | grep LC_MESSAGES | cut -d \" -f 2` + +Restart Apache:: + + $ sudo service httpd restart + +Connect to your Centreon web interface, edit your profil and select new language: + +.. image:: /images/developer/change_language.png + :align: center + :scale: 65% + +Save the form and access to another menu, your interface will be translated. + +******************* +Upgrade translation +******************* + +Centreon developers released every month a new version of Centreon Web. +So translation could be modified with every new release. + +To maintain translation up-to-date follow this steps:: + + $ bash make-translation.sh + +At the end of execution, two files up-to-date are available: + +* messages.pot to translate Centreon Web interface menu and forms +* help.pot to translate help tooltips in configuration forms + +Merge this files with previous translation (messages.po and help.po):: + + $ msgmerge help.po help.pot -o new_help.po + $ msgmerge messages.po messages.pot -o new_messages.po + +Follow chapter “Use your translation” to upgrade translation for Centreon. + +******************************* +Participate to Centreon project +******************************* + +Once your translation is up-to-date, you can ask to the Centreon team to add +your translation to Centreon project. This will allow for all person using +Centreon to have access to your translation on their Centreon platform. + +* Create an account on GitHub +* Fork centreon/centreon project on GitHub +* Add your translated \*.mo and \*.po files to lang//LC_MESSAGES directory +* Commit your change on your project +* Create a pull request on centreon/centreon project +* We will add your translation to Centreon. + +Thank you for your help! diff --git a/doc/fr/images/developer/change_language.png b/doc/fr/images/developer/change_language.png new file mode 100644 index 0000000000000000000000000000000000000000..3f5ad2e4a53c2fa0fc49d8550d951900def09c36 GIT binary patch literal 73890 zcmeFYS5%YT);~%Sk**>j-GZPXMd>9}>Alwg(tA&U&;(Re1Vp5Fqy|EV(2EF23q91( z5eOx;5ITR}y}z?x_dCWpH|OG9obMvfSYu_?xn}vzIoJBArJ+bc%0P;Thex5T^hyU0 zj}VE6N5FpT=5x0;$<^oZUt$%OKW{Yp$u`qs~eB_LnNBh?}V zyF@=7#Md)34e&QZxe2I%At9VIobuflm%Dv*YLmR0Hi3gGQdBu`WW%Bm+ z*$tjZB`$}kYSjAqP|8gf(*Ia+P)2y5oGQIK*pf*1JY}3-vHf(qZL#2;cXT&USdNK_ z1J1he;d~(l|0dqkh02SL2guN*hlo!HvDN{#T4=KE;akBnN+nDMq~70G_l9Leeq5~9!gU+yqIKj^&cpYwB9o6;;JhwjtqWzPb zw=X`n|CG+@yiY}GlTML(d-p1ehx|w)DgAAvr9g!H-YrcM)LX^3jBitPKwVyt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@N^;I5l&3L|qo!HP8TnOkP1If&aYu`rN*N}) zqBFKllhjF64vmjUO9R Date: Tue, 25 Jul 2017 10:41:01 +0200 Subject: [PATCH 067/207] * new clapi query set param img --- .../centreonHostGroup.class.php | 36 +++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/www/class/centreon-clapi/centreonHostGroup.class.php b/www/class/centreon-clapi/centreonHostGroup.class.php index 980989980c7..16521b72999 100644 --- a/www/class/centreon-clapi/centreonHostGroup.class.php +++ b/www/class/centreon-clapi/centreonHostGroup.class.php @@ -141,20 +141,25 @@ public function del($objectName) /** * Set params * - * @param string $parameters - * @return void - * @throws CenrtreonClapiException + * @param null $parameters + * @throws CentreonClapiException */ public function setparam($parameters = null) { $params = explode($this->delim, $parameters); + if (count($params) < self::NB_UPDATE_PARAMS) { throw new CentreonClapiException(self::MISSINGPARAMETER); } + if (($objectId = $this->getObjectId($params[self::ORDER_UNIQUENAME])) != 0) { + if (($params[1] == "icon_image" || $params[1] == "map_icon_image")) { + $params[2] = $this->getIdIcon($params[2]); + } if (!preg_match("/^hg_/", $params[1]) && $params[1] != "geo_coords") { $params[1] = "hg_" . $params[1]; } + $updateParams = array($params[1] => $params[2]); parent::setparam($objectId, $updateParams); } else { @@ -162,6 +167,31 @@ public function setparam($parameters = null) } } + /** + * @param $path + * @return mixed + */ + public function getIdIcon($path) + { + $iconData = explode('/', $path); + $query = 'SELECT dir_id FROM view_img_dir WHERE dir_name = "' . $iconData[0] . '"'; + $res = $this->db->query($query); + $row = $res->fetch(); + $dirId = $row['dir_id']; + + $query = 'SELECT img_id FROM view_img WHERE img_path = "' . $iconData[1] .'"'; + $res = $this->db->query($query); + $row = $res->fetch(); + $iconId = $row['img_id']; + + $query = 'SELECT vidr_id FROM view_img_dir_relation ' . + 'WHERE dir_dir_parent_id = ' . $dirId . ' AND img_img_id = ' . $iconId; + $res = $this->db->query($query); + $row = $res->fetch(); + return $row['vidr_id']; + } + + /** * Magic method * From 35c97ad00f4569b36024fce463564ff84797fcf9 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Date: Tue, 25 Jul 2017 11:29:48 +0200 Subject: [PATCH 068/207] CLAPI - Host - Save changes in logs (#5442) Save changes in logs (Set/Add/Del)... --- www/class/centreon-clapi/centreonHost.class.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/www/class/centreon-clapi/centreonHost.class.php b/www/class/centreon-clapi/centreonHost.class.php index e77266bdaf6..5c8da3986f5 100644 --- a/www/class/centreon-clapi/centreonHost.class.php +++ b/www/class/centreon-clapi/centreonHost.class.php @@ -875,6 +875,12 @@ public function __call($name, $arg) $aclObj = new CentreonACL(); $aclObj->reload(true); } + $this->addAuditLog( + 'c', + $hostId, + $args[0], + array($matches[2] => str_replace('|', ',', $args[1])) + ); } } else { throw new CentreonClapiException(self::UNKNOWN_METHOD); From d50629e6ee7ea0f0c7073575c01592a1fd0ea4f1 Mon Sep 17 00:00:00 2001 From: mariegallardo Date: Tue, 25 Jul 2017 16:19:55 +0200 Subject: [PATCH 069/207] New feature HostCategoryConfiguration (#5460) --- behat.yml | 5 + features/HostCategoryConfiguration.feature | 20 ++ .../HostCategoryConfigurationContext.php | 199 ++++++++++++++++++ 3 files changed, 224 insertions(+) create mode 100644 features/HostCategoryConfiguration.feature create mode 100644 features/bootstrap/HostCategoryConfigurationContext.php diff --git a/behat.yml b/behat.yml index 4e757cee2e3..1cbbd87008f 100644 --- a/behat.yml +++ b/behat.yml @@ -189,6 +189,11 @@ default: contexts: - HostConfigurationContext + host_category: + paths: [ %paths.base%/features/HostCategoryConfiguration.feature ] + contexts: + - HostCategoryConfigurationContext + contact_group_configuration: paths: [ %paths.base%/features/ContactGroupConfiguration.feature ] contexts: diff --git a/features/HostCategoryConfiguration.feature b/features/HostCategoryConfiguration.feature new file mode 100644 index 00000000000..d3aeb4a8e75 --- /dev/null +++ b/features/HostCategoryConfiguration.feature @@ -0,0 +1,20 @@ +Feature: HostCategoryConfiguration + As a Centreon admin + I want to manipulate an host + To see if all simples manipulations work + + Background: + Given I am logged in a Centreon server + And a host category is configured + + Scenario: + When I change the properties of a host category + Then the properties are updated + + Scenario: + When I duplicate a host category + Then the new host category has the same properties + + Scenario: + When I delete a host category + Then the deleted host is not displayed in the host list diff --git a/features/bootstrap/HostCategoryConfigurationContext.php b/features/bootstrap/HostCategoryConfigurationContext.php new file mode 100644 index 00000000000..7967306825d --- /dev/null +++ b/features/bootstrap/HostCategoryConfigurationContext.php @@ -0,0 +1,199 @@ + 'host1Name', + 'alias' => 'host1Alias', + 'address' => 'host1@localhost' + ); + + protected $host2 = array( + 'name' => 'host2Name', + 'alias' => 'host2Alias', + 'address' => 'host2@localhost' + ); + + protected $hostTemplate1 = array( + 'name' => 'hostTemplate1Name', + 'alias' => 'hostTemplate2Alias' + ); + + protected $hostTemplate2 = array( + 'name' => 'hostTemplate2Name', + 'alias' => 'hostTemplate2Alias' + ); + + protected $initialProperties = array( + 'name' => 'hostCategoryName', + 'alias' => 'hostCategoryAlias', + 'hosts' => 'host1Name', + 'host_templates' => 'hostTemplate1Name', + 'severity' => 0, + 'enabled' => 1, + 'comments' => 'hostCategoryComment' + ); + + protected $duplicatedProperties = array( + 'name' => 'hostCategoryName_1', + 'alias' => 'hostCategoryAlias', + 'hosts' => 'host1Name', + 'host_templates' => 'hostTemplate1Name', + 'severity' => 0, + 'enabled' => 1, + 'comments' => 'hostCategoryComment' + ); + + protected $updatedProperties = array( + 'name' => 'hostCategoryNameChanged', + 'alias' => 'hostCategoryAliasChanged', + 'hosts' => 'host2Name', + 'host_templates' => 'hostTemplate2Name', + 'severity' => 1, + 'severity_level' => 3, + 'severity_icon' => ' centreon (png)', + 'enabled' => 0, + 'comments' => 'hostCategoryCommentChanged' + ); + + /** + * @Given a host category is configured + */ + public function aHostCategoryIsConfigured() + { + $this->currentPage = new HostConfigurationPage($this); + $this->currentPage->setProperties($this->host1); + $this->currentPage->save(); + $this->currentPage = new HostConfigurationPage($this); + $this->currentPage->setProperties($this->host2); + $this->currentPage->save(); + $this->currentPage = new HostTemplateConfigurationPage($this); + $this->currentPage->setProperties($this->hostTemplate1); + $this->currentPage->save(); + $this->currentPage = new HostTemplateConfigurationPage($this); + $this->currentPage->setProperties($this->hostTemplate2); + $this->currentPage->save(); + $this->currentPage = new HostCategoryConfigurationPage($this); + $this->currentPage->setProperties($this->initialProperties); + $this->currentPage->save(); + } + + /** + * @When I change the properties of a host category + */ + public function iChangeThePropertiesOfAHostCategory() + { + $this->currentPage = new HostCategoryConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['name']); + $this->currentPage->setProperties($this->updatedProperties); + $this->currentPage->save(); + } + + /** + * @Then the properties are updated + */ + public function thePropertiesAreUpdated() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new HostCategoryConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->updatedProperties['name']); + $object = $this->currentPage->getProperties(); + foreach ($this->updatedProperties as $key => $value) { + if ($value != $object[$key]) { + $this->tableau[] = $key; + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I duplicate a host category + */ + public function iDuplicateAHostCategory() + { + $this->currentPage = new HostCategoryConfigurationListingPage($this); + $object = $this->currentPage->getEntry($this->initialProperties['name']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Duplicate'); + } + + /** + * @Then the new host category has the same properties + */ + public function theNewHostCategoryHasTheSameProperties() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new HostCategoryConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->duplicatedProperties['name']); + $object = $this->currentPage->getProperties(); + foreach ($this->duplicatedProperties as $key => $value) { + if ($value != $object[$key]) { + $this->tableau[] = $key; + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I delete a host category + */ + public function iDeleteAHostCategory() + { + $this->currentPage = new HostCategoryConfigurationListingPage($this); + $object = $this->currentPage->getEntry($this->initialProperties['name']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Delete'); + } + + /** + * @Then the deleted host is not displayed in the host list + */ + public function theDeletedHostIsNotDisplayedInTheHostList() + { + $this->spin( + function ($context) { + $this->currentPage = new HostCategoryConfigurationListingPage($this); + $object = $this->currentPage->getEntries(); + $bool = true; + foreach ($object as $value) { + $bool = $bool && $value['name'] != $this->initialProperties['name']; + } + return $bool; + }, + "The host category is not being deleted.", + 5 + ); + } +} From bed7d5e2e3c3df5705c9d7ee0a1a241702755d6b Mon Sep 17 00:00:00 2001 From: loiclau Date: Tue, 25 Jul 2017 16:31:17 +0200 Subject: [PATCH 070/207] * add clapi acl menu read only option / update grant option #5281 --- doc/en/api/clapi/objects/acl_menu.rst | 11 +++-- doc/fr/api/clapi/objects/acl_menu.rst | 10 +++-- .../centreon-clapi/centreonACLMenu.class.php | 45 ++++++++++++++++++- 3 files changed, 59 insertions(+), 7 deletions(-) diff --git a/doc/en/api/clapi/objects/acl_menu.rst b/doc/en/api/clapi/objects/acl_menu.rst index 1adbe76d76a..26631e07f71 100644 --- a/doc/en/api/clapi/objects/acl_menu.rst +++ b/doc/en/api/clapi/objects/acl_menu.rst @@ -117,18 +117,23 @@ Order Column description 1 Name of ACL menu rule ======= ======================= + Grant and Revoke ---------------- -If you want to grant or revoke menus in an ACL Menu rule definition, use the following actions: **GRANT**, **REVOKE** +If you want to grant in Read/Write, Read Only or revoke menus in an ACL Menu rule definition, use the following actions: **GRANTRW**, **GRANTRO**, **REVOKE** Let's assume that you would like to grant full access to the [Monitoring] menu in your ACL Menu rule::: - [root@centreon ~]# ./centreon -u admin -p centreon -o ACLMENU -a grant -v "ACL Menu test;Monitoring" + [root@centreon ~]# ./centreon -u admin -p centreon -o ACLMENU -a grantrw -v "ACL Menu test;Monitoring" Then, you would like to grant access to the [Home] > [Poller statistics] menu::: - [root@centreon ~]# ./centreon -u admin -p centreon -o ACLMENU -a grant -v "ACL Menu test;Home;Poller statistics" + [root@centreon ~]# ./centreon -u admin -p centreon -o ACLMENU -a grantrw -v "ACL Menu test;Home;Poller statistics" + +Then, you would like to grant access in read only to the [Configuration] > [Hosts] menu::: + + [root@centreon ~]# ./centreon -u admin -p centreon -o ACLMENU -a grantro -v "ACL Menu test;Configuration;Hosts" Then, you decide to revoke access from [Monitoring] > [Event Logs]::: diff --git a/doc/fr/api/clapi/objects/acl_menu.rst b/doc/fr/api/clapi/objects/acl_menu.rst index 1adbe76d76a..003855f2b46 100644 --- a/doc/fr/api/clapi/objects/acl_menu.rst +++ b/doc/fr/api/clapi/objects/acl_menu.rst @@ -120,15 +120,19 @@ Order Column description Grant and Revoke ---------------- -If you want to grant or revoke menus in an ACL Menu rule definition, use the following actions: **GRANT**, **REVOKE** +If you want to grant in Read/Write, Read Only or revoke menus in an ACL Menu rule definition, use the following actions: **GRANTRW**, **GRANTRO**, **REVOKE** Let's assume that you would like to grant full access to the [Monitoring] menu in your ACL Menu rule::: - [root@centreon ~]# ./centreon -u admin -p centreon -o ACLMENU -a grant -v "ACL Menu test;Monitoring" + [root@centreon ~]# ./centreon -u admin -p centreon -o ACLMENU -a grantrw -v "ACL Menu test;Monitoring" Then, you would like to grant access to the [Home] > [Poller statistics] menu::: - [root@centreon ~]# ./centreon -u admin -p centreon -o ACLMENU -a grant -v "ACL Menu test;Home;Poller statistics" + [root@centreon ~]# ./centreon -u admin -p centreon -o ACLMENU -a grantrw -v "ACL Menu test;Home;Poller statistics" + +Then, you would like to grant access in read only to the [Configuration] > [Hosts] menu::: + + [root@centreon ~]# ./centreon -u admin -p centreon -o ACLMENU -a grantro -v "ACL Menu test;Configuration;Hosts" Then, you decide to revoke access from [Monitoring] > [Event Logs]::: diff --git a/www/class/centreon-clapi/centreonACLMenu.class.php b/www/class/centreon-clapi/centreonACLMenu.class.php index 7763e4580aa..78d4e1c3f56 100644 --- a/www/class/centreon-clapi/centreonACLMenu.class.php +++ b/www/class/centreon-clapi/centreonACLMenu.class.php @@ -284,17 +284,34 @@ protected function processChildrenOf($action = "grant", $aclMenuId, $parentTopol array($aclMenuId, $row['topology_id']) ); } + if ($action == "grantro") { + $query = "INSERT INTO acl_topology_relations (acl_topo_id, topology_topology_id, access_right) " . + "VALUES (?, ?, 2)"; + $this->db->query($query, array($aclMenuId, $row['topology_id'])); + } $this->processChildrenOf($action, $aclMenuId, $row['topology_page']); } } + /** - * Grant menu + * old Grant menu * * @param string $parameters * @return void */ public function grant($parameters) + { + $this->grantRw($parameters); + } + + /** + * Grant menu + * + * @param string $parameters + * @return void + */ + public function grantRw($parameters) { list($aclMenuId, $menus, $topologies) = $this->splitParams($parameters); foreach ($menus as $level => $menuId) { @@ -312,6 +329,32 @@ public function grant($parameters) } } + + /** + * Grant menu + * + * @param string $parameters + * @return void + */ + public function grantRo($parameters) + { + list($aclMenuId, $menus, $topologies) = $this->splitParams($parameters); + foreach ($menus as $level => $menuId) { + $this->db->query( + "DELETE FROM acl_topology_relations WHERE acl_topo_id = ? AND topology_topology_id = ?", + array($aclMenuId, $menuId) + ); + $this->db->query( + "INSERT INTO acl_topology_relations (acl_topo_id, topology_topology_id, access_right) VALUES (?, ?, 2)", + array($aclMenuId, $menuId) + ); + if (!isset($menus[$level + 1]) && $level != self::LEVEL_4) { + $this->processChildrenOf("grantro", $aclMenuId, $topologies[$level]); + } + } + } + + /** * Revoke menu * From 33d6d0637d7cc6482cea0139d8eac9997876fffe Mon Sep 17 00:00:00 2001 From: loiclau Date: Tue, 25 Jul 2017 17:14:15 +0200 Subject: [PATCH 071/207] * fix bindParam not set --- www/api/class/centreon_administration_aclgroup.class.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/www/api/class/centreon_administration_aclgroup.class.php b/www/api/class/centreon_administration_aclgroup.class.php index a5d558702c9..62dd7436f38 100644 --- a/www/api/class/centreon_administration_aclgroup.class.php +++ b/www/api/class/centreon_administration_aclgroup.class.php @@ -66,8 +66,12 @@ public function getList() $filterAclgroup . "ORDER BY acl_group_name " . $range; + $stmt = $this->pearDB->prepare($query); - $stmt->bindParam(':aclGroup', $queryValues["aclGroup"], PDO::PARAM_STR); + + if (isset($queryValues['aclGroup'])) { + $stmt->bindParam(':aclGroup', $queryValues["aclGroup"], PDO::PARAM_STR); + } if (isset($queryValues["offset"])) { $stmt->bindParam(':offset', $queryValues["offset"], PDO::PARAM_INT); $stmt->bindParam(':limit', $queryValues["limit"], PDO::PARAM_INT); From 43411b06cd0ae73fbe5263b5c11c0049afaba9d3 Mon Sep 17 00:00:00 2001 From: loiclau Date: Tue, 25 Jul 2017 17:28:32 +0200 Subject: [PATCH 072/207] * fix style myAccount --- .../Administration/myAccount/DB-Func.php | 83 +++++++----- .../myAccount/formMyAccount.php | 119 ++++++++++++------ 2 files changed, 133 insertions(+), 69 deletions(-) diff --git a/www/include/Administration/myAccount/DB-Func.php b/www/include/Administration/myAccount/DB-Func.php index 6e098a0b4dc..be0744dfe7e 100644 --- a/www/include/Administration/myAccount/DB-Func.php +++ b/www/include/Administration/myAccount/DB-Func.php @@ -36,8 +36,10 @@ function testExistence($name = null) { global $pearDB, $form, $centreon; - - $DBRESULT = $pearDB->query("SELECT contact_name, contact_id FROM contact WHERE contact_name = '".htmlentities($name, ENT_QUOTES, "UTF-8")."'"); + + $query = "SELECT contact_name, contact_id FROM contact WHERE contact_name = '" . + htmlentities($name, ENT_QUOTES, "UTF-8") . "'"; + $DBRESULT = $pearDB->query($query); $contact = $DBRESULT->fetchRow(); /* * Modif case @@ -57,10 +59,12 @@ function testExistence($name = null) function testAliasExistence($alias = null) { global $pearDB, $form, $centreon; - - $DBRESULT = $pearDB->query("SELECT contact_alias, contact_id FROM contact WHERE contact_alias = '".htmlentities($alias, ENT_QUOTES, "UTF-8")."'"); + + $query = "SELECT contact_alias, contact_id FROM contact " . + "WHERE contact_alias = '" . htmlentities($alias, ENT_QUOTES, "UTF-8") . "'"; + $DBRESULT = $pearDB->query($query); $contact = $DBRESULT->fetchRow(); - + /* * Modif case */ @@ -81,14 +85,19 @@ function updateNotificationOptions($contact_id) global $form, $pearDB; $pearDB->query("DELETE FROM contact_param - WHERE cp_contact_id = ".$pearDB->escape($contact_id)." + WHERE cp_contact_id = " . $pearDB->escape($contact_id) . " AND cp_key LIKE 'monitoring%notification%'"); $data = $form->getSubmitValues(); foreach ($data as $k => $v) { if (preg_match("/^monitoring_(host|svc)_notification/", $k)) { - $pearDB->query("INSERT INTO contact_param (cp_key, cp_value, cp_contact_id) VALUES ('".$pearDB->escape($k)."', '1', ".$pearDB->escape($contact_id).")"); + $query = "INSERT INTO contact_param (cp_key, cp_value, cp_contact_id) " . + "VALUES ('" . $pearDB->escape($k) . "', '1', " . $pearDB->escape($contact_id) . ")"; + $pearDB->query($query); } elseif (preg_match("/^monitoring_sound/", $k)) { - $pearDB->query("INSERT INTO contact_param (cp_key, cp_value, cp_contact_id) VALUES ('".$pearDB->escape($k)."', '".$pearDB->escape($v)."', ".$pearDB->escape($contact_id).")"); + $query = "INSERT INTO contact_param (cp_key, cp_value, cp_contact_id) " . + "VALUES ('" . $pearDB->escape($k) . "', '" . $pearDB->escape($v) . "', " . + $pearDB->escape($contact_id) . ")"; + $pearDB->query($query); } } unset($_SESSION['centreon_notification_preferences']); @@ -106,46 +115,60 @@ function updateContactInDB($contact_id = null) function updateContact($contact_id = null) { global $form, $pearDB, $centreon, $encryptType; - + if (!$contact_id) { return; } - + $ret = array(); $ret = $form->getSubmitValues(); $rq = "UPDATE contact SET "; $rq .= "contact_name = "; - isset($ret["contact_name"]) && $ret["contact_name"] != null ? $rq .= "'".htmlentities($ret["contact_name"], ENT_QUOTES, "UTF-8")."', ": $rq .= "NULL, "; + isset($ret["contact_name"]) && $ret["contact_name"] != null + ? $rq .= "'" . htmlentities($ret["contact_name"], ENT_QUOTES, "UTF-8") . "', " + : $rq .= "NULL, "; $rq .= "contact_alias = "; - isset($ret["contact_alias"]) && $ret["contact_alias"] != null ? $rq .= "'".htmlentities($ret["contact_alias"], ENT_QUOTES, "UTF-8")."', ": $rq .= "NULL, "; - + isset($ret["contact_alias"]) && $ret["contact_alias"] != null + ? $rq .= "'" . htmlentities($ret["contact_alias"], ENT_QUOTES, "UTF-8") . "', " + : $rq .= "NULL, "; + if (isset($ret["contact_passwd"]) && $ret["contact_passwd"]) { if ($encryptType == 1) { - $rq .= "contact_passwd = '".md5($ret["contact_passwd"])."', "; + $rq .= "contact_passwd = '" . md5($ret["contact_passwd"]) . "', "; } elseif ($encryptType == 2) { - $rq .= "contact_passwd = '".sha1($ret["contact_passwd"])."', "; + $rq .= "contact_passwd = '" . sha1($ret["contact_passwd"]) . "', "; } else { - $rq .= "contact_passwd = '".md5($ret["contact_passwd"])."', "; + $rq .= "contact_passwd = '" . md5($ret["contact_passwd"]) . "', "; } } - - $rq .= "contact_location = "; - isset($ret["contact_location"]) && $ret["contact_location"] != null ? $rq .= "'".htmlentities($ret["contact_location"], ENT_QUOTES, "UTF-8")."', ": $rq .= "NULL, "; - $rq .= "contact_lang = "; - isset($ret["contact_lang"]) && $ret["contact_lang"] != null ? $rq .= "'".htmlentities($ret["contact_lang"], ENT_QUOTES, "UTF-8")."', ": $rq .= "NULL, "; + + $rq .= "contact_location = "; + isset($ret["contact_location"]) && $ret["contact_location"] != null + ? $rq .= "'" . htmlentities($ret["contact_location"], ENT_QUOTES, "UTF-8") . "', " + : $rq .= "NULL, "; + $rq .= "contact_lang = "; + isset($ret["contact_lang"]) && $ret["contact_lang"] != null + ? $rq .= "'" . htmlentities($ret["contact_lang"], ENT_QUOTES, "UTF-8") . "', " + : $rq .= "NULL, "; $rq .= "contact_email = "; - isset($ret["contact_email"]) && $ret["contact_email"] != null ? $rq .= "'".htmlentities($ret["contact_email"], ENT_QUOTES, "UTF-8")."', ": $rq .= "NULL, "; + isset($ret["contact_email"]) && $ret["contact_email"] != null + ? $rq .= "'" . htmlentities($ret["contact_email"], ENT_QUOTES, "UTF-8") . "', " + : $rq .= "NULL, "; $rq .= "contact_pager = "; - isset($ret["contact_pager"]) && $ret["contact_pager"] != null ? $rq .= "'".htmlentities($ret["contact_pager"], ENT_QUOTES, "UTF-8")."', ": $rq .= "NULL, "; - $rq .= "default_page = "; - isset($ret["default_page"]) && $ret["default_page"] != null ? $rq .= "'".htmlentities($ret["default_page"], ENT_QUOTES, "UTF-8")."', ": $rq .= "NULL, "; + isset($ret["contact_pager"]) && $ret["contact_pager"] != null + ? $rq .= "'" . htmlentities($ret["contact_pager"], ENT_QUOTES, "UTF-8") . "', " + : $rq .= "NULL, "; + $rq .= "default_page = "; + isset($ret["default_page"]) && $ret["default_page"] != null + ? $rq .= "'" . htmlentities($ret["default_page"], ENT_QUOTES, "UTF-8") . "', " + : $rq .= "NULL, "; $rq .= "contact_js_effects = "; - isset($ret["contact_js_effects"]) ? $rq .= "'1', ": $rq .= "'0', "; + isset($ret["contact_js_effects"]) ? $rq .= "'1', " : $rq .= "'0', "; $rq .= "contact_autologin_key = "; - $rq .= isset($ret["contact_autologin_key"]) ? "'".$pearDB->escape($ret['contact_autologin_key'])."'" : "''"; - $rq .= "WHERE contact_id = '".$contact_id."'"; - $DBRESULT = $pearDB->query($rq); - + $rq .= isset($ret["contact_autologin_key"]) ? "'" . $pearDB->escape($ret['contact_autologin_key']) . "'" : "''"; + $rq .= "WHERE contact_id = '" . $contact_id . "'"; + $pearDB->query($rq); + /* * Update user object.. */ diff --git a/www/include/Administration/myAccount/formMyAccount.php b/www/include/Administration/myAccount/formMyAccount.php index e3ab8fb6fa8..b1b44a4e566 100644 --- a/www/include/Administration/myAccount/formMyAccount.php +++ b/www/include/Administration/myAccount/formMyAccount.php @@ -44,34 +44,35 @@ require_once "./include/common/common-Func.php"; -$form = new HTML_QuickForm('Form', 'post', "?p=".$p); - +$form = new HTML_QuickForm('Form', 'post', "?p=" . $p); + /* * Path to the configuration dir */ $path = "./include/Administration/myAccount/"; // PHP Functions -require_once $path."DB-Func.php"; +require_once $path . "DB-Func.php"; /* * Database retrieve information for the User */ $cct = array(); if ($o == "c") { - $DBRESULT = $pearDB->query("SELECT contact_id, contact_name, contact_alias, contact_lang, contact_email, contact_pager, contact_js_effects, contact_autologin_key, default_page, contact_auth_type - FROM contact - WHERE contact_id = '".$centreon->user->get_id()."'"); + $query = "SELECT contact_id, contact_name, contact_alias, contact_lang, contact_email, contact_pager, " . + "contact_js_effects, contact_autologin_key, default_page, contact_auth_type " . + "FROM contact WHERE contact_id = '" . $centreon->user->get_id() . "'"; + $DBRESULT = $pearDB->query($query); // Set base value $cct = array_map("myDecode", $DBRESULT->fetchRow()); $res = $pearDB->query("SELECT cp_key, cp_value FROM contact_param - WHERE cp_contact_id = '".$pearDB->escape($centreon->user->get_id())."'"); + WHERE cp_contact_id = '" . $pearDB->escape($centreon->user->get_id()) . "'"); while ($row = $res->fetchRow()) { $cct[$row['cp_key']] = $row['cp_value']; } } - + /* * Database retrieve information for differents elements list we need on the page * @@ -79,9 +80,9 @@ */ $langs = array(); $langs = getLangs(); -$attrsText = array("size"=>"35"); +$attrsText = array("size" => "35"); -$form = new HTML_QuickForm('Form', 'post', "?p=".$p); +$form = new HTML_QuickForm('Form', 'post', "?p=" . $p); $form->addElement('header', 'title', _("Change my settings")); $form->addElement('header', 'information', _("General Information")); @@ -94,40 +95,70 @@ $form->addElement('text', 'contact_email', _("Email"), $attrsText); $form->addElement('text', 'contact_pager', _("Pager"), $attrsText); if ($cct["contact_auth_type"] != 'ldap') { - $form->addElement('password', 'contact_passwd', _("Password"), array("size"=>"30", "autocomplete"=>"off", "id"=>"passwd1", "onFocus" => "resetPwdType(this);")); - $form->addElement('password', 'contact_passwd2', _("Confirm Password"), array("size"=>"30", "autocomplete"=>"off", "id"=>"passwd2", "onFocus" => "resetPwdType(this);")); - $form->addElement('button', 'contact_gen_passwd', _("Generate"), array('onclick'=>'generatePassword("passwd");', 'class' => 'btc bt_info')); + $form->addElement( + 'password', + 'contact_passwd', + _("Password"), + array("size" => "30", "autocomplete" => "off", "id" => "passwd1", "onFocus" => "resetPwdType(this);") + ); + $form->addElement( + 'password', + 'contact_passwd2', + _("Confirm Password"), + array("size" => "30", "autocomplete" => "off", "id" => "passwd2", "onFocus" => "resetPwdType(this);") + ); + $form->addElement( + 'button', + 'contact_gen_passwd', + _("Generate"), + array('onclick' => 'generatePassword("passwd");', 'class' => 'btc bt_info') + ); } $form->addElement('text', 'contact_autologin_key', _("Autologin Key"), array("size" => "30", "id" => "aKey")); -$form->addElement('button', 'contact_gen_akey', _("Generate"), array( 'onclick' => 'generatePassword("aKey");', 'class' => 'btc bt_info')); +$form->addElement( + 'button', + 'contact_gen_akey', + _("Generate"), + array('onclick' => 'generatePassword("aKey");', 'class' => 'btc bt_info') +); $form->addElement('select', 'contact_lang', _("Language"), $langs); $form->addElement('checkbox', 'contact_js_effects', _("Animation effects"), null, $attrsText); /* ------------------------ Topoogy ---------------------------- */ $pages = array(); -$DBRESULT1 = $pearDB->query("SELECT topology_page, topology_name, topology_parent FROM topology WHERE topology_parent IS NULL AND topology_show = '1' ORDER BY topology_order, topology_group"); +$query = "SELECT topology_page, topology_name, topology_parent FROM topology " . + "WHERE topology_parent IS NULL AND topology_show = '1' ORDER BY topology_order, topology_group"; +$DBRESULT1 = $pearDB->query($query); while ($topo1 = $DBRESULT1->fetchRow()) { if ($centreon->user->access->page($topo1["topology_page"]) == 1) { $pages[$topo1["topology_page"]] = _($topo1["topology_name"]); } - - $DBRESULT2 = $pearDB->query("SELECT topology_page, topology_name, topology_parent FROM topology WHERE topology_parent = '".$topo1["topology_page"]."' AND topology_show = '1' ORDER BY topology_order"); + $query = "SELECT topology_page, topology_name, topology_parent FROM topology " . + "WHERE topology_parent = '" . $topo1["topology_page"] . "' AND topology_show = '1' ORDER BY topology_order"; + $DBRESULT2 = $pearDB->query($query); while ($topo2 = $DBRESULT2->fetchRow()) { if ($centreon->user->access->page($topo2["topology_page"]) == 1) { - $pages[$topo2["topology_page"]] = " "._($topo1["topology_name"]) . " > " . _($topo2["topology_name"]); + $pages[$topo2["topology_page"]] = " " . _($topo1["topology_name"]) . " > " . _($topo2["topology_name"]); } - - $DBRESULT3 = $pearDB->query("SELECT topology_name, topology_parent, topology_page FROM topology WHERE topology_parent = '".$topo2["topology_page"]."' AND topology_page IS NOT NULL AND topology_show = '1' ORDER BY topology_group, topology_order"); + $query = "SELECT topology_name, topology_parent, topology_page FROM topology " . + "WHERE topology_parent = '" . $topo2["topology_page"] . "' " . + "AND topology_page IS NOT NULL AND topology_show = '1' ORDER BY topology_group, topology_order"; + $DBRESULT3 = $pearDB->query($query); while ($topo3 = $DBRESULT3->fetchRow()) { if ($centreon->user->access->page($topo3["topology_page"]) == 1) { - $pages[$topo3["topology_page"]] = " "._($topo1["topology_name"]) . " > " . _($topo2["topology_name"]) . " > " . _($topo3["topology_name"]); + $pages[$topo3["topology_page"]] = " " . _($topo1["topology_name"]) . " > " . + _($topo2["topology_name"]) . " > " . _($topo3["topology_name"]); } - - $DBRESULT4 = $pearDB->query("SELECT topology_name, topology_parent FROM topology WHERE topology_parent = '".$topo3["topology_page"]."' AND topology_page IS NOT NULL AND topology_show = '1' ORDER BY topology_order"); + $query = "SELECT topology_name, topology_parent FROM topology " . + "WHERE topology_parent = '" . $topo3["topology_page"] . "' " . + "AND topology_page IS NOT NULL AND topology_show = '1' ORDER BY topology_order"; + $DBRESULT4 = $pearDB->query($query); while ($topo4 = $DBRESULT4->fetchRow()) { if ($centreon->user->access->page($topo4["topology_page"]) == 1) { - $pages[$topo4["topology_page"]] = " "._($topo1["topology_name"]) . " > " . _($topo2["topology_name"]) . " > " . _($topo3["topology_name"]) . " > ". _($topo4["topology_name"]); + $pages[$topo4["topology_page"]] = " " . _($topo1["topology_name"]) . " > " . + _($topo2["topology_name"]) . " > " . _($topo3["topology_name"]) . " > " . + _($topo4["topology_name"]); } } } @@ -143,14 +174,14 @@ $form->addElement('checkbox', 'monitoring_svc_notification_2', _('Show Critical status')); $form->addElement('checkbox', 'monitoring_svc_notification_3', _('Show Unknown status')); -$sound_files = scandir(_CENTREON_PATH_."www/sounds/"); +$sound_files = scandir(_CENTREON_PATH_ . "www/sounds/"); $sounds = array(null => null); foreach ($sound_files as $f) { if ($f == "." || $f == "..") { continue; } $info = pathinfo($f); - $fname = basename($f, ".".$info['extension']); + $fname = basename($f, "." . $info['extension']); $sounds[$fname] = $fname; } $form->addElement('select', 'monitoring_sound_host_notification_0', _("Sound for Up status"), $sounds); @@ -160,11 +191,15 @@ $form->addElement('select', 'monitoring_sound_svc_notification_1', _("Sound for Warning status"), $sounds); $form->addElement('select', 'monitoring_sound_svc_notification_2', _("Sound for Critical status"), $sounds); $form->addElement('select', 'monitoring_sound_svc_notification_3', _("Sound for Unknown status"), $sounds); - + + +$availableRoute = './include/common/webServices/rest/internal.php?object=centreon_configuration_timezone&action=list'; +$defaultRoute = './include/common/webServices/rest/internal.php?object=centreon_configuration_timezone' . + '&action=defaultValues&target=contact&field=contact_location&id=' . $centreon->user->get_id(); $attrTimezones = array( 'datasourceOrigin' => 'ajax', - 'availableDatasetRoute' => './include/common/webServices/rest/internal.php?object=centreon_configuration_timezone&action=list', - 'defaultDatasetRoute' => './include/common/webServices/rest/internal.php?object=centreon_configuration_timezone&action=defaultValues&target=contact&field=contact_location&id=' . $centreon->user->get_id(), + 'availableDatasetRoute' => $availableRoute, + 'defaultDatasetRoute' => $defaultRoute, 'multiple' => false, 'linkedObject' => 'centreonGMT' ); @@ -179,6 +214,7 @@ function myReplace() $ret = $form->getSubmitValues(); return (str_replace(" ", "_", $ret["contact_name"])); } + $form->applyFilter('__ALL__', 'myTrim'); $form->applyFilter('contact_name', 'myReplace'); $form->addRule('contact_name', _("Compulsory name"), 'required'); @@ -189,7 +225,7 @@ function myReplace() $form->addRule('contact_name', _("Name already in use"), 'exist'); $form->registerRule('existAlias', 'callback', 'testAliasExistence'); $form->addRule('contact_alias', _("Name already in use"), 'existAlias'); -$form->setRequiredNote("*"._("Required fields")); +$form->setRequiredNote("*" . _("Required fields")); // Smarty template Init $tpl = new Smarty(); @@ -208,7 +244,12 @@ function myReplace() $centreon->user->passwd = md5($form->getSubmitValue("contact_passwd")); } $o = null; - $form->addElement("button", "change", _("Modify"), array("onClick"=>"javascript:window.location.href='?p=".$p."&o=c'", 'class' => 'btc bt_info')); + $form->addElement( + "button", + "change", + _("Modify"), + array("onClick" => "javascript:window.location.href='?p=" . $p . "&o=c'", 'class' => 'btc bt_info') + ); $form->freeze(); } @@ -224,14 +265,14 @@ function myReplace() ?> From c28f0e18e26e605d3a10fe8b52f0b5bc9a382fc9 Mon Sep 17 00:00:00 2001 From: loiclau Date: Tue, 25 Jul 2017 17:43:15 +0200 Subject: [PATCH 073/207] * fix style contact template --- .../contact_template.php | 24 +-- .../formContactTemplateModel.php | 183 ++++++++++++++---- .../listContactTemplateModel.php | 108 ++++++++--- 3 files changed, 239 insertions(+), 76 deletions(-) diff --git a/www/include/configuration/configObject/contact_template_model/contact_template.php b/www/include/configuration/configObject/contact_template_model/contact_template.php index db8a21bad4e..d0175358a69 100644 --- a/www/include/configuration/configObject/contact_template_model/contact_template.php +++ b/www/include/configuration/configObject/contact_template_model/contact_template.php @@ -73,45 +73,45 @@ } $contactObj = new CentreonContact($pearDB); - + switch ($o) { case "mc": - require_once($path."formContactTemplateModel.php"); + require_once($path . "formContactTemplateModel.php"); break; // Massive Change case "a": - require_once($path."formContactTemplateModel.php"); + require_once($path . "formContactTemplateModel.php"); break; // Add a contact template case "w": - require_once($path."formContactTemplateModel.php"); + require_once($path . "formContactTemplateModel.php"); break; // Watch a contact template case "c": - require_once($path."formContactTemplateModel.php"); + require_once($path . "formContactTemplateModel.php"); break; // Modify a contact template case "s": enableContactInDB($contact_id); - require_once($path."listContactTemplateModel.php"); + require_once($path . "listContactTemplateModel.php"); break; // Activate a contact template case "ms": enableContactInDB(null, isset($select) ? $select : array()); - require_once($path."listContactTemplateModel.php"); + require_once($path . "listContactTemplateModel.php"); break; case "u": disableContactInDB($contact_id); - require_once($path."listContactTemplateModel.php"); + require_once($path . "listContactTemplateModel.php"); break; // Desactivate a contact case "mu": disableContactInDB(null, isset($select) ? $select : array()); - require_once($path."listContactTemplateModel.php"); + require_once($path . "listContactTemplateModel.php"); break; case "m": multipleContactInDB(isset($select) ? $select : array(), $dupNbr); - require_once($path."listContactTemplateModel.php"); + require_once($path . "listContactTemplateModel.php"); break; // Duplicate n contacts case "d": deleteContactInDB(isset($select) ? $select : array()); - require_once($path."listContactTemplateModel.php"); + require_once($path . "listContactTemplateModel.php"); break; // Delete n contacts default: - require_once($path."listContactTemplateModel.php"); + require_once($path . "listContactTemplateModel.php"); break; } diff --git a/www/include/configuration/configObject/contact_template_model/formContactTemplateModel.php b/www/include/configuration/configObject/contact_template_model/formContactTemplateModel.php index f40659b9b9b..7ecc64881c1 100644 --- a/www/include/configuration/configObject/contact_template_model/formContactTemplateModel.php +++ b/www/include/configuration/configObject/contact_template_model/formContactTemplateModel.php @@ -72,7 +72,9 @@ /** * Set Host Notification Commands */ - $DBRESULT = $pearDB->query("SELECT DISTINCT command_command_id FROM contact_hostcommands_relation WHERE contact_contact_id = '" . $contact_id . "'"); + $query = "SELECT DISTINCT command_command_id FROM contact_hostcommands_relation " . + "WHERE contact_contact_id = '" . $contact_id . "'"; + $DBRESULT = $pearDB->query($query); for ($i = 0; $notifCmd = $DBRESULT->fetchRow(); $i++) { $cct["contact_hostNotifCmds"][$i] = $notifCmd["command_command_id"]; } @@ -81,7 +83,9 @@ /** * Set Service Notification Commands */ - $DBRESULT = $pearDB->query("SELECT DISTINCT command_command_id FROM contact_servicecommands_relation WHERE contact_contact_id = '" . $contact_id . "'"); + $query = "SELECT DISTINCT command_command_id FROM contact_servicecommands_relation " . + "WHERE contact_contact_id = '" . $contact_id . "'"; + $DBRESULT = $pearDB->query($query); for ($i = 0; $notifCmd = $DBRESULT->fetchRow(); $i++) { $cct["contact_svNotifCmds"][$i] = $notifCmd["command_command_id"]; } @@ -112,7 +116,8 @@ * Notification commands comes from DB -> Store in $notifsCmds Array */ $notifCmds = array(); -$DBRESULT = $pearDB->query("SELECT command_id, command_name FROM command WHERE command_type = '1' ORDER BY command_name"); +$query = "SELECT command_id, command_name FROM command WHERE command_type = '1' ORDER BY command_name"; +$DBRESULT = $pearDB->query($query); while ($notifCmd = $DBRESULT->fetchRow()) { $notifCmds[$notifCmd["command_id"]] = $notifCmd["command_name"]; } @@ -128,7 +133,9 @@ } $contactTpl = array(null => ""); -$DBRESULT = $pearDB->query("SELECT contact_id, contact_name FROM contact WHERE contact_register = '0' $strRestrinction ORDER BY contact_name"); +$query = "SELECT contact_id, contact_name FROM contact " . + "WHERE contact_register = '0' $strRestrinction ORDER BY contact_name"; +$DBRESULT = $pearDB->query($query); while ($contacts = $DBRESULT->fetchRow()) { $contactTpl[$contacts["contact_id"]] = $contacts["contact_name"]; } @@ -143,10 +150,12 @@ $attrsTextMail = array("size" => "90"); $attrsAdvSelect = array("style" => "width: 300px; height: 100px;"); $attrsTextarea = array("rows" => "15", "cols" => "100"); -$eTemplate = '
{label_2}
{unselected}
{add}


{remove}
{label_3}
{selected}
'; +$eTemplate = '
{label_2}
{unselected}
{add}

' . + '
{remove}
{label_3}
{selected}
'; +$route = './include/common/webServices/rest/internal.php?object=centreon_configuration_timeperiod&action=list'; $attrTimeperiods = array( 'datasourceOrigin' => 'ajax', - 'availableDatasetRoute' => './include/common/webServices/rest/internal.php?object=centreon_configuration_timeperiod&action=list', + 'availableDatasetRoute' => $route, 'multiple' => false, 'linkedObject' => 'centreonTimeperiod' ); @@ -215,17 +224,55 @@ * Host notifications */ $form->addElement('header', 'hostNotification', _("Host")); -$hostNotifOpt[] = HTML_QuickForm::createElement('checkbox', 'd', ' ', _("Down"), array('id' => 'hDown', 'onClick' => 'uncheckAllH(this);')); -$hostNotifOpt[] = HTML_QuickForm::createElement('checkbox', 'u', ' ', _("Unreachable"), array('id' => 'hUnreachable', 'onClick' => 'uncheckAllH(this);')); -$hostNotifOpt[] = HTML_QuickForm::createElement('checkbox', 'r', ' ', _("Recovery"), array('id' => 'hRecovery', 'onClick' => 'uncheckAllH(this);')); -$hostNotifOpt[] = HTML_QuickForm::createElement('checkbox', 'f', ' ', _("Flapping"), array('id' => 'hFlapping', 'onClick' => 'uncheckAllH(this);')); -$hostNotifOpt[] = HTML_QuickForm::createElement('checkbox', 's', ' ', _("Downtime Scheduled"), array('id' => 'hScheduled', 'onClick' => 'uncheckAllH(this);')); -$hostNotifOpt[] = HTML_QuickForm::createElement('checkbox', 'n', ' ', _("None"), array('id' => 'hNone', 'onClick' => 'javascript:uncheckAllH(this);')); +$hostNotifOpt[] = HTML_QuickForm::createElement( + 'checkbox', + 'd', + ' ', + _("Down"), + array('id' => 'hDown', 'onClick' => 'uncheckAllH(this);') +); +$hostNotifOpt[] = HTML_QuickForm::createElement( + 'checkbox', + 'u', + ' ', + _("Unreachable"), + array('id' => 'hUnreachable', 'onClick' => 'uncheckAllH(this);') +); +$hostNotifOpt[] = HTML_QuickForm::createElement( + 'checkbox', + 'r', + ' ', + _("Recovery"), + array('id' => 'hRecovery', 'onClick' => 'uncheckAllH(this);') +); +$hostNotifOpt[] = HTML_QuickForm::createElement( + 'checkbox', + 'f', + ' ', + _("Flapping"), + array('id' => 'hFlapping', 'onClick' => 'uncheckAllH(this);') +); +$hostNotifOpt[] = HTML_QuickForm::createElement( + 'checkbox', + 's', + ' ', + _("Downtime Scheduled"), + array('id' => 'hScheduled', 'onClick' => 'uncheckAllH(this);') +); +$hostNotifOpt[] = HTML_QuickForm::createElement( + 'checkbox', + 'n', + ' ', + _("None"), + array('id' => 'hNone', 'onClick' => 'javascript:uncheckAllH(this);') +); $form->addGroup($hostNotifOpt, 'contact_hostNotifOpts', _("Host Notification Options"), '  '); +$route = './include/common/webServices/rest/internal.php?object=centreon_configuration_timeperiod' . + '&action=defaultValues&target=contact&field=timeperiod_tp_id&id=' . $contact_id; $attrTimeperiod1 = array_merge( $attrTimeperiods, - array('defaultDatasetRoute' => './include/common/webServices/rest/internal.php?object=centreon_configuration_timeperiod&action=defaultValues&target=contact&field=timeperiod_tp_id&id=' . $contact_id) + array('defaultDatasetRoute' => $route) ); $form->addElement('select2', 'timeperiod_tp_id', _("Host Notification Period"), array(), $attrTimeperiod1); @@ -239,11 +286,15 @@ $form->setDefaults(array('mc_mod_hcmds' => '0')); } +$defaultRoute = './include/common/webServices/rest/internal.php?object=centreon_configuration_command' . + '&action=defaultValues&target=contact&field=contact_hostNotifCmds&id=' . $contact_id; +$availableRoute = './include/common/webServices/rest/internal.php' . + '?object=centreon_configuration_command&action=list&t=1'; $attrCommand1 = array_merge( $attrCommands, array( - 'defaultDatasetRoute' => './include/common/webServices/rest/internal.php?object=centreon_configuration_command&action=defaultValues&target=contact&field=contact_hostNotifCmds&id=' . $contact_id, - 'availableDatasetRoute' => './include/common/webServices/rest/internal.php?object=centreon_configuration_command&action=list&t=1' + 'defaultDatasetRoute' => $defaultRoute, + 'availableDatasetRoute' => $availableRoute ) ); $form->addElement('select2', 'contact_hostNotifCmds', _("Host Notification Commands"), array(), $attrCommand1); @@ -252,18 +303,62 @@ * Service notifications */ $form->addElement('header', 'serviceNotification', _("Service")); -$svNotifOpt[] = HTML_QuickForm::createElement('checkbox', 'w', ' ', _("Warning"), array('id' => 'sWarning', 'onClick' => 'uncheckAllS(this);')); -$svNotifOpt[] = HTML_QuickForm::createElement('checkbox', 'u', ' ', _("Unknown"), array('id' => 'sUnknown', 'onClick' => 'uncheckAllS(this);')); -$svNotifOpt[] = HTML_QuickForm::createElement('checkbox', 'c', ' ', _("Critical"), array('id' => 'sCritical', 'onClick' => 'uncheckAllS(this);')); -$svNotifOpt[] = HTML_QuickForm::createElement('checkbox', 'r', ' ', _("Recovery"), array('id' => 'sRecovery', 'onClick' => 'uncheckAllS(this);')); -$svNotifOpt[] = HTML_QuickForm::createElement('checkbox', 'f', ' ', _("Flapping"), array('id' => 'sFlapping', 'onClick' => 'uncheckAllS(this);')); -$svNotifOpt[] = HTML_QuickForm::createElement('checkbox', 's', ' ', _("Downtime Scheduled"), array('id' => 'sScheduled', 'onClick' => 'uncheckAllS(this);')); -$svNotifOpt[] = HTML_QuickForm::createElement('checkbox', 'n', ' ', _("None"), array('id' => 'sNone', 'onClick' => 'uncheckAllS(this);')); +$svNotifOpt[] = HTML_QuickForm::createElement( + 'checkbox', + 'w', + ' ', + _("Warning"), + array('id' => 'sWarning', 'onClick' => 'uncheckAllS(this);') +); +$svNotifOpt[] = HTML_QuickForm::createElement( + 'checkbox', + 'u', + ' ', + _("Unknown"), + array('id' => 'sUnknown', 'onClick' => 'uncheckAllS(this);') +); +$svNotifOpt[] = HTML_QuickForm::createElement( + 'checkbox', + 'c', + ' ', + _("Critical"), + array('id' => 'sCritical', 'onClick' => 'uncheckAllS(this);') +); +$svNotifOpt[] = HTML_QuickForm::createElement( + 'checkbox', + 'r', + ' ', + _("Recovery"), + array('id' => 'sRecovery', 'onClick' => 'uncheckAllS(this);') +); +$svNotifOpt[] = HTML_QuickForm::createElement( + 'checkbox', + 'f', + ' ', + _("Flapping"), + array('id' => 'sFlapping', 'onClick' => 'uncheckAllS(this);') +); +$svNotifOpt[] = HTML_QuickForm::createElement( + 'checkbox', + 's', + ' ', + _("Downtime Scheduled"), + array('id' => 'sScheduled', 'onClick' => 'uncheckAllS(this);') +); +$svNotifOpt[] = HTML_QuickForm::createElement( + 'checkbox', + 'n', + ' ', + _("None"), + array('id' => 'sNone', 'onClick' => 'uncheckAllS(this);') +); $form->addGroup($svNotifOpt, 'contact_svNotifOpts', _("Service Notification Options"), '  '); +$route = './include/common/webServices/rest/internal.php?object=centreon_configuration_timeperiod' . + '&action=defaultValues&target=contact&field=timeperiod_tp_id2&id=' . $contact_id; $attrTimeperiod2 = array_merge( $attrTimeperiods, - array('defaultDatasetRoute' => './include/common/webServices/rest/internal.php?object=centreon_configuration_timeperiod&action=defaultValues&target=contact&field=timeperiod_tp_id2&id=' . $contact_id) + array('defaultDatasetRoute' => $route) ); $form->addElement('select2', 'timeperiod_tp_id2', _("Service Notification Period"), array(), $attrTimeperiod2); @@ -274,11 +369,17 @@ $form->addGroup($mc_mod_svcmds, 'mc_mod_svcmds', _("Update mode"), ' '); $form->setDefaults(array('mc_mod_svcmds' => '0')); } + +$defaultRoute = './include/common/webServices/rest/internal.php?object=centreon_configuration_command' . + '&action=defaultValues&target=contact&field=contact_svNotifCmds&id=' . $contact_id; +$availableRoute = './include/common/webServices/rest/internal.php' . + '?object=centreon_configuration_command&action=list&t=1'; + $attrCommand2 = array_merge( $attrCommands, array( - 'defaultDatasetRoute' => './include/common/webServices/rest/internal.php?object=centreon_configuration_command&action=defaultValues&target=contact&field=contact_svNotifCmds&id=' . $contact_id, - 'availableDatasetRoute' => './include/common/webServices/rest/internal.php?object=centreon_configuration_command&action=list&t=1' + 'defaultDatasetRoute' => $defaultRoute, + 'availableDatasetRoute' => $availableRoute ) ); $form->addElement('select2', 'contact_svNotifCmds', _("Service Notification Commands"), array(), $attrCommand2); @@ -331,7 +432,9 @@ function myReplace() $form->addRule('contact_name', _("Compulsory Name"), 'required'); $form->addRule('contact_alias', _("Compulsory Alias"), 'required'); - if (isset($ret["contact_enable_notifications"]["contact_enable_notifications"]) && $ret["contact_enable_notifications"]["contact_enable_notifications"] == 1) { + if (isset($ret["contact_enable_notifications"]["contact_enable_notifications"]) && + $ret["contact_enable_notifications"]["contact_enable_notifications"] == 1 + ) { if (isset($ret["contact_template_id"]) && $ret["contact_template_id"] == '') { $form->addRule('timeperiod_tp_id', _("Compulsory Period"), 'required'); $form->addRule('timeperiod_tp_id2', _("Compulsory Period"), 'required'); @@ -344,7 +447,11 @@ function myReplace() $form->registerRule('exist', 'callback', 'testContactExistence'); $form->addRule('contact_name', "* " . _("Contact already exists"), 'exist'); $form->registerRule('existAlias', 'callback', 'testAliasExistence'); - $form->addRule('contact_alias', "* " . _("Alias already exists"), 'existAlias'); + $form->addRule( + 'contact_alias', + "* " . _("Alias already exists"), + 'existAlias' + ); } elseif ($o == "mc") { if ($form->getSubmitValue("submitMC")) { $from_list_menu = false; @@ -361,11 +468,16 @@ function myReplace() $tpl = new Smarty(); $tpl = initSmartyTpl($path, $tpl); -$tpl->assign("helpattr", 'TITLE, "' . _("Help") . '", CLOSEBTN, true, FIX, [this, 0, 5], BGCOLOR, "#ffff99", BORDERCOLOR, "orange", TITLEFONTCOLOR, "black", TITLEBGCOLOR, "orange", CLOSEBTNCOLORS, ["","black", "white", "red"], WIDTH, -300, SHADOW, true, TEXTALIGN, "justify"'); +$tpl->assign( + "helpattr", + 'TITLE, "' . _("Help") . '", CLOSEBTN, true, FIX, [this, 0, 5], BGCOLOR, "#ffff99", BORDERCOLOR, ' . + '"orange", TITLEFONTCOLOR, "black", TITLEBGCOLOR, "orange", CLOSEBTNCOLORS, ["","black", "white", "red"], ' . + 'WIDTH, -300, SHADOW, true, TEXTALIGN, "justify"' +); // prepare help texts $helptext = ""; -include_once(_CENTREON_PATH_."/www/include/configuration/configObject/contact/help.php"); +include_once(_CENTREON_PATH_ . "/www/include/configuration/configObject/contact/help.php"); foreach ($help as $key => $text) { $helptext .= '' . "\n"; } @@ -374,7 +486,12 @@ function myReplace() if ($o == "w") { // Just watch a contact information if ($centreon->user->access->page($p) != 2) { - $form->addElement("button", "change", _("Modify"), array("onClick" => "javascript:window.location.href='?p=" . $p . "&o=c&contact_id=" . $contact_id . "'")); + $form->addElement( + "button", + "change", + _("Modify"), + array("onClick" => "javascript:window.location.href='?p=" . $p . "&o=c&contact_id=" . $contact_id . "'") + ); } $form->setDefaults($cct); $form->freeze(); @@ -426,8 +543,7 @@ function myReplace() } ?> diff --git a/www/include/configuration/configObject/host_dependency/help.php b/www/include/configuration/configObject/host_dependency/help.php index 7e2e0ed97bb..933b11b3543 100644 --- a/www/include/configuration/configObject/host_dependency/help.php +++ b/www/include/configuration/configObject/host_dependency/help.php @@ -2,26 +2,63 @@ $help = array(); $help["name"] = dgettext("help", "Define a short name for this dependency."); -$help["description"] = dgettext("help", "Define a description for this dependency for easier identification and differentiation."); +$help["description"] = dgettext( + "help", + "Define a description for this dependency for easier identification and differentiation." +); $help["inherits_parent"] = sprintf( "%s
%s", - dgettext("help", "This directive indicates whether or not the dependency inherits dependencies of the host that is being depended upon (also referred to as the master host). In other words, if the master host is dependent upon other hosts and any one of those dependencies fail, this dependency will also fail."), + dgettext( + "help", + "This directive indicates whether or not the dependency inherits dependencies of the host that is " . + "being depended upon (also referred to as the master host). In other words, if the master host is " . + "dependent upon other hosts and any one of those dependencies fail, this dependency will also fail." + ), dgettext("help", "Ignored by Centreon Engine.") ); -$help["execution_failure_criteria"] = dgettext("help", "This directive is used to specify the criteria that determine when the dependent host should not be actively checked. If the master host is in one of the failure states we specify, the dependent host will not be actively checked. If you specify None as an option, the execution dependency will never fail and the dependent host will always be actively checked (if other conditions allow for it to be)."); -$help["notification_failure_criteria"] = dgettext("help", "This directive is used to define the criteria that determine when notifications for the dependent host should not be sent out. If the master host is in one of the failure states we specify, notifications for the dependent host will not be sent to contacts. If you specify None as an option, the notification dependency will never fail and notifications for the dependent host will always be sent out."); +$help["execution_failure_criteria"] = dgettext( + "help", + "This directive is used to specify the criteria that determine when the dependent host should not be " . + "actively checked. If the master host is in one of the failure states we specify, the dependent host " . + "will not be actively checked. If you specify None as an option, the execution dependency will never " . + "fail and the dependent host will always be actively checked (if other conditions allow for it to be)." +); +$help["notification_failure_criteria"] = dgettext( + "help", + "This directive is used to define the criteria that determine when notifications for the dependent host " . + "should not be sent out. If the master host is in one of the failure states we specify, " . + "notifications for the dependent host will not be sent to contacts. If you specify None as an option, " . + "the notification dependency will never fail and notifications for the dependent host will always be sent out." +); -$help["host_name"] = dgettext("help", "This directive is used to identify the short name(s) of the host(s) that is being depended upon (also referred to as the master host)."); -$help["hostgroup_name"] = dgettext("help", "This directive is used to identify the short name(s) of the hostgroup(s) that is being depended upon (also referred to as the master host). The hostgroup_name may be used instead of, or in addition to, the host_name directive."); +$help["host_name"] = dgettext( + "help", + "This directive is used to identify the short name(s) of the host(s) that is being depended upon " . + "(also referred to as the master host)." +); +$help["hostgroup_name"] = dgettext( + "help", + "This directive is used to identify the short name(s) of the hostgroup(s) that is being depended upon " . + "(also referred to as the master host). The hostgroup_name may be used instead of, or in addition to, " . + "the host_name directive." +); $help["dependent_host_name"] = dgettext("help", "This directive is used to identify the dependent host(s)."); -$help["dependent_hostgroup_name"] = dgettext("help", "This directive is used to identify the short name(s) of the dependent hostgroup(s). The dependent_hostgroup_name may be used instead of, or in addition to, the dependent_host_name directive."); +$help["dependent_hostgroup_name"] = dgettext( + "help", + "This directive is used to identify the short name(s) of the dependent hostgroup(s). " . + "The dependent_hostgroup_name may be used instead of, or in addition to, the dependent_host_name directive." +); /* * unsupported in centreon */ -$help["dependency_period"] = dgettext("help", "This directive is used to specify the short name of the time period during which this dependency is valid. If this directive is not specified, the dependency is considered to be valid during all times."); +$help["dependency_period"] = dgettext( + "help", + "This directive is used to specify the short name of the time period during which this dependency is valid. " . + "If this directive is not specified, the dependency is considered to be valid during all times." +); $help["dep_hSvChi"] = sprintf( "%s
%s", diff --git a/www/include/configuration/configObject/host_dependency/listHostDependency.php b/www/include/configuration/configObject/host_dependency/listHostDependency.php index 01e73dd5b9d..dc2dca453f3 100644 --- a/www/include/configuration/configObject/host_dependency/listHostDependency.php +++ b/www/include/configuration/configObject/host_dependency/listHostDependency.php @@ -43,14 +43,14 @@ isset($_GET["list"]) ? $list = $_GET["list"] : $list = null; - $aclFrom = ""; - $aclCond = ""; +$aclFrom = ""; +$aclCond = ""; if (!$centreon->user->admin) { $aclFrom = ", $dbmon.centreon_acl acl "; $aclCond = " AND dhpr.host_host_id = acl.host_id - AND acl.group_id IN (".$acl->getAccessGroupsString().") "; + AND acl.group_id IN (" . $acl->getAccessGroupsString() . ") "; } - + $rq = "SELECT COUNT(DISTINCT dep.dep_id) as count_dep " . "FROM dependency dep, dependency_hostParent_relation dhpr " . $aclFrom . " " . "WHERE dhpr.dependency_dep_id = dep.dep_id " . $aclCond . " "; @@ -58,7 +58,8 @@ $search = ''; if (isset($_POST['searchHD']) && $_POST['searchHD']) { $search = $_POST['searchHD']; - $rq .= " AND (dep_name LIKE '%".CentreonDB::escape($search)."%' OR dep_description LIKE '%".CentreonDB::escape($search)."%')"; + $rq .= " AND (dep_name LIKE '%" . CentreonDB::escape($search) . "%' OR dep_description LIKE '%" . + CentreonDB::escape($search) . "%')"; } $DBRESULT = $pearDB->query($rq); @@ -87,14 +88,15 @@ . "WHERE dhpr.dependency_dep_id = dep.dep_id " . $aclCond . " "; if ($search) { - $rq .= " AND (dep_name LIKE '%".CentreonDB::escape($search)."%' OR dep_description LIKE '%".CentreonDB::escape($search)."%')"; + $rq .= " AND (dep_name LIKE '%" . CentreonDB::escape($search) . + "%' OR dep_description LIKE '%" . CentreonDB::escape($search) . "%')"; } -$rq .= " ORDER BY dep_name, dep_description LIMIT ".$num * $limit.", ".$limit; +$rq .= " ORDER BY dep_name, dep_description LIMIT " . $num * $limit . ", " . $limit; $DBRESULT = $pearDB->query($rq); $search = tidySearchKey($search, $advanced_search); -$form = new HTML_QuickForm('select_form', 'POST', "?p=".$p); +$form = new HTML_QuickForm('select_form', 'POST', "?p=" . $p); # Different style between each lines $style = "one"; @@ -103,14 +105,19 @@ $elemArr = array(); for ($i = 0; $dep = $DBRESULT->fetchRow(); $i++) { $moptions = ""; - $selectedElements = $form->addElement('checkbox', "select[".$dep['dep_id']."]"); - $moptions .= "  31 && (event.keyCode < 45 || event.keyCode > 57)) event.returnValue = false; if(event.which > 31 && (event.which < 45 || event.which > 57)) return false;\" maxlength=\"3\" size=\"3\" value='1' style=\"margin-bottom:0px;\" name='dupNbr[".$dep['dep_id']."]'>"; - $elemArr[$i] = array("MenuClass"=>"list_".$style, - "RowMenu_select"=>$selectedElements->toHtml(), - "RowMenu_name"=>CentreonUtils::escapeSecure(myDecode($dep["dep_name"])), - "RowMenu_description"=>CentreonUtils::escapeSecure(myDecode($dep["dep_description"])), - "RowMenu_link"=>"?p=".$p."&o=c&dep_id=".$dep['dep_id'], - "RowMenu_options"=>$moptions); + $selectedElements = $form->addElement('checkbox', "select[" . $dep['dep_id'] . "]"); + $moptions .= "  31 && (event.keyCode < 45 || event.keyCode > 57)) " . + "event.returnValue = false; if(event.which > 31 && (event.which < 45 || event.which > 57)) return false;" . + "\" maxlength=\"3\" size=\"3\" value='1' style=\"margin-bottom:0px;\" name='dupNbr[" . + $dep['dep_id'] . "]' />"; + $elemArr[$i] = array( + "MenuClass" => "list_" . $style, + "RowMenu_select" => $selectedElements->toHtml(), + "RowMenu_name" => CentreonUtils::escapeSecure(myDecode($dep["dep_name"])), + "RowMenu_description" => CentreonUtils::escapeSecure(myDecode($dep["dep_description"])), + "RowMenu_link" => "?p=" . $p . "&o=c&dep_id=" . $dep['dep_id'], + "RowMenu_options" => $moptions + ); $style != "two" ? $style = "two" : $style = "one"; } $tpl->assign("elemArr", $elemArr); @@ -118,47 +125,68 @@ /* * Different messages we put in the template */ -$tpl->assign('msg', array ("addL"=>"?p=".$p."&o=a", "addT"=>_("Add"), "delConfirm"=>_("Do you confirm the deletion ?"))); +$tpl->assign( + 'msg', + array("addL" => "?p=" . $p . "&o=a", "addT" => _("Add"), "delConfirm" => _("Do you confirm the deletion ?")) +); /* * Toolbar select */ ?> - + "javascript: " . - " var bChecked = isChecked(); ". - " if (this.form.elements['o1'].selectedIndex != 0 && !bChecked) {". - " alert('"._("Please select one or more items")."'); return false;} " . - "if (this.form.elements['o1'].selectedIndex == 1 && confirm('"._("Do you confirm the duplication ?")."')) {" . - " setO(this.form.elements['o1'].value); submit();} " . - "else if (this.form.elements['o1'].selectedIndex == 2 && confirm('"._("Do you confirm the deletion ?")."')) {" . - " setO(this.form.elements['o1'].value); submit();} " . - "else if (this.form.elements['o1'].selectedIndex == 3) {" . - " setO(this.form.elements['o1'].value); submit();} " . - ""); -$form->addElement('select', 'o1', null, array(null=>_("More actions..."), "m"=>_("Duplicate"), "d"=>_("Delete")), $attrs1); + 'onchange' => "javascript: " . + " var bChecked = isChecked(); " . + " if (this.form.elements['o1'].selectedIndex != 0 && !bChecked) {" . + " alert('" . _("Please select one or more items") . "'); return false;} " . + "if (this.form.elements['o1'].selectedIndex == 1 && confirm('" . + _("Do you confirm the duplication ?") . "')) {" . + " setO(this.form.elements['o1'].value); submit();} " . + "else if (this.form.elements['o1'].selectedIndex == 2 && confirm('" . + _("Do you confirm the deletion ?") . "')) {" . + " setO(this.form.elements['o1'].value); submit();} " . + "else if (this.form.elements['o1'].selectedIndex == 3) {" . + " setO(this.form.elements['o1'].value); submit();} " . + "" +); +$form->addElement( + 'select', + 'o1', + null, + array(null => _("More actions..."), "m" => _("Duplicate"), "d" => _("Delete")), + $attrs1 +); $form->setDefaults(array('o1' => null)); $attrs2 = array( - 'onchange'=>"javascript: " . - " var bChecked = isChecked(); ". - " if (this.form.elements['o2'].selectedIndex != 0 && !bChecked) {". - " alert('"._("Please select one or more items")."'); return false;} " . - "if (this.form.elements['o2'].selectedIndex == 1 && confirm('"._("Do you confirm the duplication ?")."')) {" . - " setO(this.form.elements['o2'].value); submit();} " . - "else if (this.form.elements['o2'].selectedIndex == 2 && confirm('"._("Do you confirm the deletion ?")."')) {" . - " setO(this.form.elements['o2'].value); submit();} " . - "else if (this.form.elements['o2'].selectedIndex == 3) {" . - " setO(this.form.elements['o2'].value); submit();} " . - ""); -$form->addElement('select', 'o2', null, array(null=>_("More actions..."), "m"=>_("Duplicate"), "d"=>_("Delete")), $attrs2); + 'onchange' => "javascript: " . + " var bChecked = isChecked(); " . + " if (this.form.elements['o2'].selectedIndex != 0 && !bChecked) {" . + " alert('" . _("Please select one or more items") . "'); return false;} " . + "if (this.form.elements['o2'].selectedIndex == 1 && confirm('" + . _("Do you confirm the duplication ?") . "')) {" . + " setO(this.form.elements['o2'].value); submit();} " . + "else if (this.form.elements['o2'].selectedIndex == 2 && confirm('" + . _("Do you confirm the deletion ?") . "')) {" . + " setO(this.form.elements['o2'].value); submit();} " . + "else if (this.form.elements['o2'].selectedIndex == 3) {" . + " setO(this.form.elements['o2'].value); submit();} " . + "" +); +$form->addElement( + 'select', + 'o2', + null, + array(null => _("More actions..."), "m" => _("Duplicate"), "d" => _("Delete")), + $attrs2 +); $form->setDefaults(array('o2' => null)); $o1 = $form->getElement('o1'); From 4e2df5919fddb670028595a2498681a42ff733fd Mon Sep 17 00:00:00 2001 From: loiclau Date: Thu, 27 Jul 2017 18:18:15 +0200 Subject: [PATCH 086/207] * fix style hostgroup --- .../configObject/hostgroup/DB-Func.php | 193 ++++++++++++------ .../configObject/hostgroup/help.php | 71 +++++-- .../configObject/hostgroup/hostGroup.php | 25 +-- 3 files changed, 205 insertions(+), 84 deletions(-) diff --git a/www/include/configuration/configObject/hostgroup/DB-Func.php b/www/include/configuration/configObject/hostgroup/DB-Func.php index 156a6f8394d..3b8f4d06af8 100644 --- a/www/include/configuration/configObject/hostgroup/DB-Func.php +++ b/www/include/configuration/configObject/hostgroup/DB-Func.php @@ -42,7 +42,7 @@ function getHGParents($hg_id, $parentList, $pearDB) /* * Get Parent Groups */ - $DBRESULT = $pearDB->query("SELECT hg_parent_id FROM hostgroup_hg_relation WHERE hg_child_id = '".$hg_id."'"); + $DBRESULT = $pearDB->query("SELECT hg_parent_id FROM hostgroup_hg_relation WHERE hg_child_id = '" . $hg_id . "'"); while ($hgs = $DBRESULT->fetchRow()) { $parentList[$hgs["hg_parent_id"]] = $hgs["hg_parent_id"]; $parentList = getHGParents($hgs["hg_parent_id"], $parentList, $pearDB); @@ -60,7 +60,9 @@ function testHostGroupExistence($name = null) $id = $form->getSubmitValue('hg_id'); } - $DBRESULT = $pearDB->query("SELECT hg_name, hg_id FROM hostgroup WHERE hg_name = '".CentreonDB::escape($centreon->checkIllegalChar($name))."'"); + $query = "SELECT hg_name, hg_id FROM hostgroup WHERE hg_name = '" . + CentreonDB::escape($centreon->checkIllegalChar($name)) . "'"; + $DBRESULT = $pearDB->query($query); $hg = $DBRESULT->fetchRow(); #Modif case if ($DBRESULT->rowCount() >= 1 && $hg["hg_id"] == $id) { @@ -86,8 +88,8 @@ function enableHostGroupInDB($hg_id = null, $hg_arr = array()) } foreach ($hg_arr as $key => $value) { - $pearDB->query("UPDATE hostgroup SET hg_activate = '1' WHERE hg_id = '".$key."'"); - $DBRESULT2 = $pearDB->query("SELECT hg_name FROM `hostgroup` WHERE `hg_id` = '".$key."' LIMIT 1"); + $pearDB->query("UPDATE hostgroup SET hg_activate = '1' WHERE hg_id = '" . $key . "'"); + $DBRESULT2 = $pearDB->query("SELECT hg_name FROM `hostgroup` WHERE `hg_id` = '" . $key . "' LIMIT 1"); $row = $DBRESULT2->fetchRow(); $centreon->CentreonLogAction->insertLog("hostgroup", $key, $row['hg_name'], "enable"); } @@ -101,12 +103,12 @@ function disableHostGroupInDB($hg_id = null, $hg_arr = array()) return; } if ($hg_id) { - $hg_arr = array($hg_id=>"1"); + $hg_arr = array($hg_id => "1"); } foreach ($hg_arr as $key => $value) { - $pearDB->query("UPDATE hostgroup SET hg_activate = '0' WHERE hg_id = '".$key."'"); - $DBRESULT2 = $pearDB->query("SELECT hg_name FROM `hostgroup` WHERE `hg_id` = '".$key."' LIMIT 1"); + $pearDB->query("UPDATE hostgroup SET hg_activate = '0' WHERE hg_id = '" . $key . "'"); + $DBRESULT2 = $pearDB->query("SELECT hg_name FROM `hostgroup` WHERE `hg_id` = '" . $key . "' LIMIT 1"); $row = $DBRESULT2->fetchRow(); $centreon->CentreonLogAction->insertLog("hostgroup", $key, $row['hg_name'], "disable"); } @@ -117,18 +119,20 @@ function deleteHostGroupInDB($hostGroups = array()) global $pearDB, $centreon; foreach ($hostGroups as $key => $value) { - $rq = "SELECT @nbr := (SELECT COUNT( * ) FROM host_service_relation WHERE service_service_id = hsr.service_service_id GROUP BY service_service_id ) AS nbr, hsr.service_service_id FROM host_service_relation hsr WHERE hsr.hostgroup_hg_id = '".$key."'"; + $rq = "SELECT @nbr := (SELECT COUNT( * ) FROM host_service_relation WHERE service_service_id = " . + "hsr.service_service_id GROUP BY service_service_id ) AS nbr, hsr.service_service_id FROM " . + "host_service_relation hsr WHERE hsr.hostgroup_hg_id = '" . $key . "'"; $DBRESULT = $pearDB->query($rq); while ($row = $DBRESULT->fetchRow()) { if ($row["nbr"] == 1) { - $DBRESULT2 = $pearDB->query("DELETE FROM service WHERE service_id = '".$row["service_service_id"]."'"); + $pearDB->query("DELETE FROM service WHERE service_id = '" . $row["service_service_id"] . "'"); } } - $DBRESULT3 = $pearDB->query("SELECT hg_name FROM `hostgroup` WHERE `hg_id` = '".$key."' LIMIT 1"); + $DBRESULT3 = $pearDB->query("SELECT hg_name FROM `hostgroup` WHERE `hg_id` = '" . $key . "' LIMIT 1"); $row = $DBRESULT3->fetchRow(); - $DBRESULT = $pearDB->query("DELETE FROM hostgroup WHERE hg_id = '".$key."'"); + $pearDB->query("DELETE FROM hostgroup WHERE hg_id = '" . $key . "'"); $centreon->CentreonLogAction->insertLog("hostgroup", $key, $row['hg_name'], "d"); } $centreon->user->access->updateACL(); @@ -140,15 +144,17 @@ function multipleHostGroupInDB($hostGroups = array(), $nbrDup = array()) $hgAcl = array(); foreach ($hostGroups as $key => $value) { - $DBRESULT = $pearDB->query("SELECT * FROM hostgroup WHERE hg_id = '".$key."' LIMIT 1"); + $DBRESULT = $pearDB->query("SELECT * FROM hostgroup WHERE hg_id = '" . $key . "' LIMIT 1"); $row = $DBRESULT->fetchRow(); $row["hg_id"] = ''; for ($i = 1; $i <= $nbrDup[$key]; $i++) { $val = null; $rq = null; foreach ($row as $key2 => $value2) { - $key2 == "hg_name" ? ($hg_name = $value2 = $value2."_".$i) : null; - $val ? $val .= ($value2 != null ? (", '".$pearDB->escape($value2)."'") : ", NULL") : $val .= ($value2 != null ? ("'".$pearDB->escape($value2)."'") : "NULL"); + $key2 == "hg_name" ? ($hg_name = $value2 = $value2 . "_" . $i) : null; + $val + ? $val .= ($value2 != null ? (", '" . $pearDB->escape($value2) . "'") : ", NULL") + : $val .= ($value2 != null ? ("'" . $pearDB->escape($value2) . "'") : "NULL"); if ($key2 != "hg_id") { $fields[$key2] = $value2; } @@ -157,8 +163,8 @@ function multipleHostGroupInDB($hostGroups = array(), $nbrDup = array()) } } if (testHostGroupExistence($hg_name)) { - $val ? $rq = "INSERT INTO hostgroup VALUES (".$val.")" : $rq = null; - $DBRESULT = $pearDB->query($rq); + $val ? $rq = "INSERT INTO hostgroup VALUES (" . $val . ")" : $rq = null; + $pearDB->query($rq); $DBRESULT = $pearDB->query("SELECT MAX(hg_id) FROM hostgroup"); $maxId = $DBRESULT->fetchRow(); if (isset($maxId["MAX(hg_id)"])) { @@ -167,22 +173,32 @@ function multipleHostGroupInDB($hostGroups = array(), $nbrDup = array()) $resource_list = $centreon->user->access->getResourceGroups(); if (count($resource_list)) { foreach ($resource_list as $res_id => $res_name) { - $DBRESULT3 = $pearDB->query("INSERT INTO `acl_resources_hg_relations` (acl_res_id, hg_hg_id) VALUES ('".$res_id."', '".$maxId["MAX(hg_id)"]."')"); + $query = "INSERT INTO `acl_resources_hg_relations` (acl_res_id, hg_hg_id) VALUES ('" . + $res_id . "', '" . $maxId["MAX(hg_id)"] . "')"; + $pearDB->query($query); } unset($resource_list); } } - # - $DBRESULT = $pearDB->query("SELECT DISTINCT hgr.host_host_id FROM hostgroup_relation hgr WHERE hgr.hostgroup_hg_id = '".$key."'"); + + $query = "SELECT DISTINCT hgr.host_host_id FROM hostgroup_relation hgr " . + "WHERE hgr.hostgroup_hg_id = '" . $key . "'"; + $DBRESULT = $pearDB->query($query); $fields["hg_hosts"] = ""; while ($host = $DBRESULT->fetchRow()) { - $DBRESULT2 = $pearDB->query("INSERT INTO hostgroup_relation VALUES ('', '".$maxId["MAX(hg_id)"]."', '".$host["host_host_id"]."')"); + $query = "INSERT INTO hostgroup_relation VALUES ('', '" . + $maxId["MAX(hg_id)"] . "', '" . $host["host_host_id"] . "')"; + $pearDB->query($query); $fields["hg_hosts"] .= $host["host_host_id"] . ","; } $fields["hg_hosts"] = trim($fields["hg_hosts"], ","); - $DBRESULT = $pearDB->query("SELECT DISTINCT cghgr.contactgroup_cg_id FROM contactgroup_hostgroup_relation cghgr WHERE cghgr.hostgroup_hg_id = '".$key."'"); + $query = "SELECT DISTINCT cghgr.contactgroup_cg_id FROM contactgroup_hostgroup_relation cghgr " . + "WHERE cghgr.hostgroup_hg_id = '" . $key . "'"; + $DBRESULT = $pearDB->query($query); while ($cg = $DBRESULT->fetchRow()) { - $DBRESULT2 = $pearDB->query("INSERT INTO contactgroup_hostgroup_relation VALUES ('', '".$cg["contactgroup_cg_id"]."', '".$maxId["MAX(hg_id)"]."')"); + $query = "INSERT INTO contactgroup_hostgroup_relation VALUES ('', '" . + $cg["contactgroup_cg_id"] . "', '" . $maxId["MAX(hg_id)"] . "')"; + $pearDB->query($query); } $centreon->CentreonLogAction->insertLog("hostgroup", $maxId["MAX(hg_id)"], $hg_name, "a", $fields); } @@ -225,38 +241,69 @@ function insertHostGroup($ret = array()) $ret["hg_name"] = $centreon->checkIllegalChar($ret["hg_name"]); $rq = "INSERT INTO hostgroup "; - $rq .= "(hg_name, hg_alias, hg_notes, hg_notes_url, hg_action_url, hg_icon_image, hg_map_icon_image, hg_rrd_retention, hg_comment, geo_coords, hg_activate) "; + $rq .= "(hg_name, hg_alias, hg_notes, hg_notes_url, hg_action_url, hg_icon_image, hg_map_icon_image, " . + "hg_rrd_retention, hg_comment, geo_coords, hg_activate) "; $rq .= "VALUES ("; - isset($ret["hg_name"]) && $ret["hg_name"] ? $rq .= "'".$pearDB->escape($ret["hg_name"])."', " : $rq .= "NULL,"; - isset($ret["hg_alias"]) && $ret["hg_alias"] ? $rq .= "'".$pearDB->escape($ret["hg_alias"])."', " : $rq .= "NULL,"; - isset($ret["hg_notes"]) && $ret["hg_notes"] ? $rq .= "'".$pearDB->escape($ret["hg_notes"])."', " : $rq .= "NULL,"; - isset($ret["hg_notes_url"]) && $ret["hg_notes_url"] ? $rq .= "'".$pearDB->escape($ret["hg_notes_url"])."', " : $rq .= "NULL,"; - isset($ret["hg_action_url"]) && $ret["hg_action_url"] ? $rq .= "'".$pearDB->escape($ret["hg_action_url"])."', " : $rq .= "NULL,"; - isset($ret["hg_icon_image"]) && $ret["hg_icon_image"] ? $rq .= "'".$pearDB->escape($ret["hg_icon_image"])."', " : $rq .= "NULL,"; - isset($ret["hg_map_icon_image"]) && $ret["hg_map_icon_image"] ? $rq .= "'".$pearDB->escape($ret["hg_map_icon_image"])."', " : $rq .= "NULL,"; - isset($ret["hg_rrd_retention"]) && $ret["hg_rrd_retention"] ? $rq .= "'".$pearDB->escape($ret["hg_rrd_retention"])."', " : $rq .= "NULL,"; - isset($ret["hg_comment"]) && $ret["hg_comment"] ? $rq .= "'".$pearDB->escape($ret["hg_comment"])."', " : $rq .= "NULL, "; - isset($ret["geo_coords"]) && $ret["geo_coords"] ? $rq .= "'".$pearDB->escape($ret["geo_coords"])."', " : $rq .= "NULL, "; - isset($ret["hg_activate"]["hg_activate"]) && $ret["hg_activate"]["hg_activate"] ? $rq .= "'".$ret["hg_activate"]["hg_activate"]."'" : $rq .= "'0'"; + isset($ret["hg_name"]) && $ret["hg_name"] + ? $rq .= "'" . $pearDB->escape($ret["hg_name"]) . "', " + : $rq .= "NULL,"; + isset($ret["hg_alias"]) && $ret["hg_alias"] + ? $rq .= "'" . $pearDB->escape($ret["hg_alias"]) . "', " + : $rq .= "NULL,"; + isset($ret["hg_notes"]) && $ret["hg_notes"] + ? $rq .= "'" . $pearDB->escape($ret["hg_notes"]) . "', " + : $rq .= "NULL,"; + isset($ret["hg_notes_url"]) && $ret["hg_notes_url"] + ? $rq .= "'" . $pearDB->escape($ret["hg_notes_url"]) . "', " + : $rq .= "NULL,"; + isset($ret["hg_action_url"]) && $ret["hg_action_url"] + ? $rq .= "'" . $pearDB->escape($ret["hg_action_url"]) . "', " + : $rq .= "NULL,"; + isset($ret["hg_icon_image"]) && $ret["hg_icon_image"] + ? $rq .= "'" . $pearDB->escape($ret["hg_icon_image"]) . "', " + : $rq .= "NULL,"; + isset($ret["hg_map_icon_image"]) && $ret["hg_map_icon_image"] + ? $rq .= "'" . $pearDB->escape($ret["hg_map_icon_image"]) . "', " + : $rq .= "NULL,"; + isset($ret["hg_rrd_retention"]) && $ret["hg_rrd_retention"] + ? $rq .= "'" . $pearDB->escape($ret["hg_rrd_retention"]) . "', " + : $rq .= "NULL,"; + isset($ret["hg_comment"]) && $ret["hg_comment"] + ? $rq .= "'" . $pearDB->escape($ret["hg_comment"]) . "', " + : $rq .= "NULL, "; + isset($ret["geo_coords"]) && $ret["geo_coords"] + ? $rq .= "'" . $pearDB->escape($ret["geo_coords"]) . "', " + : $rq .= "NULL, "; + isset($ret["hg_activate"]["hg_activate"]) && $ret["hg_activate"]["hg_activate"] + ? $rq .= "'" . $ret["hg_activate"]["hg_activate"] . "'" + : $rq .= "'0'"; $rq .= ")"; $pearDB->query($rq); $DBRESULT = $pearDB->query("SELECT MAX(hg_id) FROM hostgroup"); $hg_id = $DBRESULT->fetchRow(); - + if (!$centreon->user->admin) { $resource_list = $centreon->user->access->getResourceGroups(); if (count($resource_list)) { foreach ($resource_list as $res_id => $res_name) { - $DBRESULT3 = $pearDB->query("INSERT INTO `acl_resources_hg_relations` (acl_res_id, hg_hg_id) VALUES ('".$res_id."', '".$hg_id["MAX(hg_id)"]."')"); + $query = "INSERT INTO `acl_resources_hg_relations` (acl_res_id, hg_hg_id) " . + "VALUES ('" . $res_id . "', '" . $hg_id["MAX(hg_id)"] . "')"; + $pearDB->query($query); } unset($resource_list); } } - + /* Prepare value for changelog */ $fields = CentreonLogAction::prepareChanges($ret); - $centreon->CentreonLogAction->insertLog("hostgroup", $hg_id["MAX(hg_id)"], CentreonDB::escape($ret["hg_name"]), "a", $fields); + $centreon->CentreonLogAction->insertLog( + "hostgroup", + $hg_id["MAX(hg_id)"], + CentreonDB::escape($ret["hg_name"]), + "a", + $fields + ); return ($hg_id["MAX(hg_id)"]); } @@ -277,28 +324,50 @@ function updateHostGroup($hg_id, $ret = array()) $rq = "UPDATE hostgroup SET "; $rq .= "hg_name = "; - isset($ret["hg_name"]) && $ret["hg_name"] != null ? $rq .= "'".$pearDB->escape($ret["hg_name"])."', " : $rq .= "NULL, "; + isset($ret["hg_name"]) && $ret["hg_name"] != null + ? $rq .= "'" . $pearDB->escape($ret["hg_name"]) . "', " + : $rq .= "NULL, "; $rq .= "hg_alias = "; - isset($ret["hg_alias"]) && $ret["hg_alias"] != null ? $rq .= "'".$pearDB->escape($ret["hg_alias"])."', " : $rq .= "NULL, "; + isset($ret["hg_alias"]) && $ret["hg_alias"] != null + ? $rq .= "'" . $pearDB->escape($ret["hg_alias"]) . "', " + : $rq .= "NULL, "; $rq .= "hg_notes = "; - isset($ret["hg_notes"]) && $ret["hg_notes"] != null ? $rq .= "'".$pearDB->escape($ret["hg_notes"])."', " : $rq .= "NULL, "; + isset($ret["hg_notes"]) && $ret["hg_notes"] != null + ? $rq .= "'" . $pearDB->escape($ret["hg_notes"]) . "', " + : $rq .= "NULL, "; $rq .= "hg_notes_url = "; - isset($ret["hg_notes_url"]) && $ret["hg_notes_url"] != null ? $rq .= "'".$pearDB->escape($ret["hg_notes_url"])."', " : $rq .= "NULL, "; + isset($ret["hg_notes_url"]) && $ret["hg_notes_url"] != null + ? $rq .= "'" . $pearDB->escape($ret["hg_notes_url"]) . "', " + : $rq .= "NULL, "; $rq .= "hg_action_url = "; - isset($ret["hg_action_url"]) && $ret["hg_action_url"] != null ? $rq .= "'".$pearDB->escape($ret["hg_action_url"])."', " : $rq .= "NULL, "; + isset($ret["hg_action_url"]) && $ret["hg_action_url"] != null + ? $rq .= "'" . $pearDB->escape($ret["hg_action_url"]) . "', " + : $rq .= "NULL, "; $rq .= "hg_icon_image = "; - isset($ret["hg_icon_image"]) && $ret["hg_icon_image"] != null ? $rq .= "'".$pearDB->escape($ret["hg_icon_image"])."', " : $rq .= "NULL, "; + isset($ret["hg_icon_image"]) && $ret["hg_icon_image"] != null + ? $rq .= "'" . $pearDB->escape($ret["hg_icon_image"]) . "', " + : $rq .= "NULL, "; $rq .= "hg_map_icon_image = "; - isset($ret["hg_map_icon_image"]) && $ret["hg_map_icon_image"] != null ? $rq .= "'".$pearDB->escape($ret["hg_map_icon_image"])."', " : $rq .= "NULL, "; + isset($ret["hg_map_icon_image"]) && $ret["hg_map_icon_image"] != null + ? $rq .= "'" . $pearDB->escape($ret["hg_map_icon_image"]) . "', " + : $rq .= "NULL, "; $rq .= "hg_rrd_retention = "; - $rq .= isset($ret["hg_rrd_retention"]) && $ret["hg_rrd_retention"] ? "'".$pearDB->escape($ret["hg_rrd_retention"])."', " : "NULL, "; + $rq .= isset($ret["hg_rrd_retention"]) && $ret["hg_rrd_retention"] + ? "'" . $pearDB->escape($ret["hg_rrd_retention"]) . "', " + : "NULL, "; $rq .= "geo_coords = "; - isset($ret["geo_coords"]) && $ret["geo_coords"] != null ? $rq .= "'".$pearDB->escape($ret["geo_coords"])."', " : $rq .= "NULL, "; + isset($ret["geo_coords"]) && $ret["geo_coords"] != null + ? $rq .= "'" . $pearDB->escape($ret["geo_coords"]) . "', " + : $rq .= "NULL, "; $rq .= "hg_comment = "; - isset($ret["hg_comment"]) && $ret["hg_comment"] != null ? $rq .= "'".$pearDB->escape($ret["hg_comment"])."', " : $rq .= "NULL, "; + isset($ret["hg_comment"]) && $ret["hg_comment"] != null + ? $rq .= "'" . $pearDB->escape($ret["hg_comment"]) . "', " + : $rq .= "NULL, "; $rq .= "hg_activate = "; - isset($ret["hg_activate"]["hg_activate"]) && $ret["hg_activate"]["hg_activate"] != null ? $rq .= "'".$ret["hg_activate"]["hg_activate"]."'" : $rq .= "NULL "; - $rq .= " WHERE hg_id = '".$hg_id."'"; + isset($ret["hg_activate"]["hg_activate"]) && $ret["hg_activate"]["hg_activate"] != null + ? $rq .= "'" . $ret["hg_activate"]["hg_activate"] . "'" + : $rq .= "NULL "; + $rq .= " WHERE hg_id = '" . $hg_id . "'"; $DBRESULT = $pearDB->query($rq); /* Prepare value for changelog */ @@ -321,7 +390,7 @@ function updateHostGroupHosts($hg_id, $ret = array(), $increment = false) * Get initial Host list to make a diff after deletion */ $hostsOLD = array(); - $DBRESULT = $pearDB->query("SELECT host_host_id FROM hostgroup_relation WHERE hostgroup_hg_id = '".$hg_id."'"); + $DBRESULT = $pearDB->query("SELECT host_host_id FROM hostgroup_relation WHERE hostgroup_hg_id = '" . $hg_id . "'"); while ($host = $DBRESULT->fetchRow()) { $hostsOLD[$host["host_host_id"]] = $host["host_host_id"]; } @@ -331,7 +400,7 @@ function updateHostGroupHosts($hg_id, $ret = array(), $increment = false) * Get service lists linked to hostgroup */ $rq = "SELECT service_service_id FROM host_service_relation "; - $rq .= "WHERE hostgroup_hg_id = '".$hg_id."' AND host_host_id IS NULL"; + $rq .= "WHERE hostgroup_hg_id = '" . $hg_id . "' AND host_host_id IS NULL"; $DBRESULT = $pearDB->query($rq); $hgSVS = array(); while ($sv = $DBRESULT->fetchRow()) { @@ -342,8 +411,8 @@ function updateHostGroupHosts($hg_id, $ret = array(), $increment = false) * Update Host HG relations */ if ($increment == false) { - $rq = "DELETE FROM hostgroup_relation "; - $rq .= "WHERE hostgroup_hg_id = '".$hg_id."'"; + $rq = "DELETE FROM hostgroup_relation "; + $rq .= "WHERE hostgroup_hg_id = '" . $hg_id . "'"; $pearDB->query($rq); } @@ -353,12 +422,14 @@ function updateHostGroupHosts($hg_id, $ret = array(), $increment = false) $rq = "INSERT INTO hostgroup_relation (hostgroup_hg_id, host_host_id) VALUES "; for ($i = 0; $i < count($ret); $i++) { - $resTest = $pearDB->query("SELECT hostgroup_hg_id FROM hostgroup_relation WHERE hostgroup_hg_id = ".$hg_id." AND host_host_id = ".$ret[$i]); + $query = "SELECT hostgroup_hg_id FROM hostgroup_relation WHERE hostgroup_hg_id = " . $hg_id . + " AND host_host_id = " . $ret[$i]; + $resTest = $pearDB->query($query); if (!$resTest->rowCount()) { if ($i != 0) { $rq .= ", "; } - $rq .= " ('".$hg_id."', '".$ret[$i]."')"; + $rq .= " ('" . $hg_id . "', '" . $ret[$i] . "')"; $hostsNEW[$ret[$i]] = $ret[$i]; } } @@ -371,24 +442,26 @@ function updateHostGroupHosts($hg_id, $ret = array(), $increment = false) * Update HG HG relations */ if ($increment == false) { - $pearDB->query("DELETE FROM hostgroup_hg_relation WHERE hg_parent_id = '".$hg_id."'"); + $pearDB->query("DELETE FROM hostgroup_hg_relation WHERE hg_parent_id = '" . $hg_id . "'"); } isset($ret["hg_hg"]) ? $ret = $ret["hg_hg"] : $ret = $form->getSubmitValue("hg_hg"); $hgNEW = array(); $rq = "INSERT INTO hostgroup_hg_relation (hg_parent_id, hg_child_id) VALUES "; for ($i = 0; $i < count($ret); $i++) { - $resTest = $pearDB->query("SELECT hg_parent_id FROM hostgroup_hg_relation WHERE hg_parent_id = ".$hg_id." AND hg_child_id = ".$ret[$i]); + $query = "SELECT hg_parent_id FROM hostgroup_hg_relation WHERE hg_parent_id = " . $hg_id . + " AND hg_child_id = " . $ret[$i]; + $resTest = $pearDB->query($query); if (!$resTest->rowCount()) { if ($i != 0) { $rq .= ", "; } - $rq .= " ('".$hg_id."', '".$ret[$i]."')"; + $rq .= " ('" . $hg_id . "', '" . $ret[$i] . "')"; $hostsNEW[$ret[$i]] = $ret[$i]; } } if ($i != 0) { - $DBRESULT = $pearDB->query($rq); + $pearDB->query($rq); } /* diff --git a/www/include/configuration/configObject/hostgroup/help.php b/www/include/configuration/configObject/hostgroup/help.php index 260686cfd4f..41afd41dbcb 100644 --- a/www/include/configuration/configObject/hostgroup/help.php +++ b/www/include/configuration/configObject/hostgroup/help.php @@ -1,22 +1,69 @@ getHostsString('ID', $dbmon); switch ($o) { case "a": - require_once($path."formHostGroup.php"); + require_once($path . "formHostGroup.php"); break; #Add a Hostgroup case "w": - require_once($path."formHostGroup.php"); + require_once($path . "formHostGroup.php"); break; #Watch a Hostgroup case "c": - require_once($path."formHostGroup.php"); + require_once($path . "formHostGroup.php"); break; #Modify a Hostgroup case "s": enableHostGroupInDB($hg_id); - require_once($path."listHostGroup.php"); + require_once($path . "listHostGroup.php"); break; #Activate a Hostgroup case "ms": enableHostGroupInDB(null, isset($select) ? $select : array()); - require_once($path."listHostGroup.php"); + require_once($path . "listHostGroup.php"); break; case "u": disableHostGroupInDB($hg_id); - require_once($path."listHostGroup.php"); + require_once($path . "listHostGroup.php"); break; #Desactivate a Hostgroup case "mu": disableHostGroupInDB(null, isset($select) ? $select : array()); - require_once($path."listHostGroup.php"); + require_once($path . "listHostGroup.php"); break; case "m": multipleHostGroupInDB(isset($select) ? $select : array(), $dupNbr); - require_once($path."listHostGroup.php"); + require_once($path . "listHostGroup.php"); break; #Duplicate n Host grou case "d": deleteHostGroupInDB(isset($select) ? $select : array()); - require_once($path."listHostGroup.php"); + require_once($path . "listHostGroup.php"); break; #Delete n Host group default: - require_once($path."listHostGroup.php"); + require_once($path . "listHostGroup.php"); break; } From a06c10aa0c632176f86c7980741382e8ee522e7e Mon Sep 17 00:00:00 2001 From: loiclau Date: Thu, 27 Jul 2017 18:27:45 +0200 Subject: [PATCH 087/207] * fix style hostgroup dependency --- .../hostgroup_dependency/DB-Func.php | 128 +++++++++++++----- .../formHostGroupDependency.php | 116 +++++++++++----- .../hostGroupDependency.php | 18 +-- .../listHostGroupDependency.php | 116 ++++++++++------ 4 files changed, 253 insertions(+), 125 deletions(-) diff --git a/www/include/configuration/configObject/hostgroup_dependency/DB-Func.php b/www/include/configuration/configObject/hostgroup_dependency/DB-Func.php index 3631af3dd99..1730159338d 100644 --- a/www/include/configuration/configObject/hostgroup_dependency/DB-Func.php +++ b/www/include/configuration/configObject/hostgroup_dependency/DB-Func.php @@ -48,7 +48,8 @@ function testHostGroupDependencyExistence($name = null) if (isset($form)) { $id = $form->getSubmitValue('dep_id'); } - $DBRESULT = $pearDB->query("SELECT dep_name, dep_id FROM dependency WHERE dep_name = '".CentreonDB::escape($name)."'"); + $query = "SELECT dep_name, dep_id FROM dependency WHERE dep_name = '" . CentreonDB::escape($name) . "'"; + $DBRESULT = $pearDB->query($query); $dep = $DBRESULT->fetchRow(); #Modif case if ($DBRESULT->rowCount() >= 1 && $dep["dep_id"] == $id) { @@ -84,10 +85,10 @@ function deleteHostGroupDependencyInDB($dependencies = array()) { global $pearDB, $centreon; foreach ($dependencies as $key => $value) { - $DBRESULT2 = $pearDB->query("SELECT dep_name FROM `dependency` WHERE `dep_id` = '".$key."' LIMIT 1"); + $DBRESULT2 = $pearDB->query("SELECT dep_name FROM `dependency` WHERE `dep_id` = '" . $key . "' LIMIT 1"); $row = $DBRESULT2->fetchRow(); - $DBRESULT = $pearDB->query("DELETE FROM dependency WHERE dep_id = '".$key."'"); + $DBRESULT = $pearDB->query("DELETE FROM dependency WHERE dep_id = '" . $key . "'"); $centreon->CentreonLogAction->insertLog("hostgroup dependency", $key, $row['dep_name'], "d"); } } @@ -96,14 +97,16 @@ function multipleHostGroupDependencyInDB($dependencies = array(), $nbrDup = arra { foreach ($dependencies as $key => $value) { global $pearDB, $centreon; - $DBRESULT = $pearDB->query("SELECT * FROM dependency WHERE dep_id = '".$key."' LIMIT 1"); + $DBRESULT = $pearDB->query("SELECT * FROM dependency WHERE dep_id = '" . $key . "' LIMIT 1"); $row = $DBRESULT->fetchRow(); $row["dep_id"] = ''; for ($i = 1; $i <= $nbrDup[$key]; $i++) { $val = null; foreach ($row as $key2 => $value2) { - $key2 == "dep_name" ? ($dep_name = $value2 = $value2."_".$i) : null; - $val ? $val .= ($value2!=null?(", '".$value2."'"):", NULL") : $val .= ($value2!=null?("'".$value2."'"):"NULL"); + $key2 == "dep_name" ? ($dep_name = $value2 = $value2 . "_" . $i) : null; + $val + ? $val .= ($value2 != null ? (", '" . $value2 . "'") : ", NULL") + : $val .= ($value2 != null ? ("'" . $value2 . "'") : "NULL"); if ($key2 != "dep_id") { $fields[$key2] = $value2; } @@ -112,28 +115,42 @@ function multipleHostGroupDependencyInDB($dependencies = array(), $nbrDup = arra } } if (isset($dep_name) && testHostGroupDependencyExistence($dep_name)) { - $val ? $rq = "INSERT INTO dependency VALUES (".$val.")" : $rq = null; - $DBRESULT = $pearDB->query($rq); + $val ? $rq = "INSERT INTO dependency VALUES (" . $val . ")" : $rq = null; + $pearDB->query($rq); $DBRESULT = $pearDB->query("SELECT MAX(dep_id) FROM dependency"); $maxId = $DBRESULT->fetchRow(); if (isset($maxId["MAX(dep_id)"])) { - $DBRESULT = $pearDB->query("SELECT DISTINCT hostgroup_hg_id FROM dependency_hostgroupParent_relation WHERE dependency_dep_id = '".$key."'"); + $query = "SELECT DISTINCT hostgroup_hg_id FROM dependency_hostgroupParent_relation " . + "WHERE dependency_dep_id = '" . $key . "'"; + $DBRESULT = $pearDB->query($query); $fields["dep_hgParents"] = ""; while ($hg = $DBRESULT->fetchRow()) { - $DBRESULT2 = $pearDB->query("INSERT INTO dependency_hostgroupParent_relation VALUES ('', '".$maxId["MAX(dep_id)"]."', '".$hg["hostgroup_hg_id"]."')"); + $query = "INSERT INTO dependency_hostgroupParent_relation VALUES ('', '" . + $maxId["MAX(dep_id)"] . "', '" . $hg["hostgroup_hg_id"] . "')"; + $pearDB->query($query); $fields["dep_hgParents"] .= $hg["hostgroup_hg_id"] . ","; } $fields["dep_hgParents"] = trim($fields["dep_hgParents"], ","); $DBRESULT->closeCursor(); - $DBRESULT = $pearDB->query("SELECT DISTINCT hostgroup_hg_id FROM dependency_hostgroupChild_relation WHERE dependency_dep_id = '".$key."'"); + $query = "SELECT DISTINCT hostgroup_hg_id FROM dependency_hostgroupChild_relation " . + "WHERE dependency_dep_id = '" . $key . "'"; + $DBRESULT = $pearDB->query($query); $fields["dep_hgChilds"] = ""; while ($hg = $DBRESULT->fetchRow()) { - $DBRESULT2 = $pearDB->query("INSERT INTO dependency_hostgroupChild_relation VALUES ('', '".$maxId["MAX(dep_id)"]."', '".$hg["hostgroup_hg_id"]."')"); + $query = "INSERT INTO dependency_hostgroupChild_relation VALUES ('', '" . + $maxId["MAX(dep_id)"] . "', '" . $hg["hostgroup_hg_id"] . "')"; + $pearDB->query($query); $fields["dep_hgChilds"] .= $hg["hostgroup_hg_id"] . ","; } $fields["dep_hgChilds"] = trim($fields["dep_hgChilds"], ","); $DBRESULT->closeCursor(); - $centreon->CentreonLogAction->insertLog("hostgroup dependency", $maxId["MAX(dep_id)"], $dep_name, "a", $fields); + $centreon->CentreonLogAction->insertLog( + "hostgroup dependency", + $maxId["MAX(dep_id)"], + $dep_name, + "a", + $fields + ); } } } @@ -166,23 +183,42 @@ function insertHostGroupDependency($ret = array()) $ret = $form->getSubmitValues(); } $rq = "INSERT INTO dependency "; - $rq .= "(dep_name, dep_description, inherits_parent, execution_failure_criteria, notification_failure_criteria, dep_comment) "; + $rq .= "(dep_name, dep_description, inherits_parent, execution_failure_criteria, " . + "notification_failure_criteria, dep_comment) "; $rq .= "VALUES ("; - isset($ret["dep_name"]) && $ret["dep_name"] != null ? $rq .= "'".CentreonDB::escape($ret["dep_name"])."', " : $rq .= "NULL, "; - isset($ret["dep_description"]) && $ret["dep_description"] != null ? $rq .= "'".CentreonDB::escape($ret["dep_description"])."', " : $rq .= "NULL, "; - isset($ret["inherits_parent"]["inherits_parent"]) && $ret["inherits_parent"]["inherits_parent"] != null ? $rq .= "'".$ret["inherits_parent"]["inherits_parent"]."', " : $rq .= "NULL, "; - isset($ret["execution_failure_criteria"]) && $ret["execution_failure_criteria"] != null ? $rq .= "'".implode(",", array_keys($ret["execution_failure_criteria"]))."', " : $rq .= "NULL, "; - isset($ret["notification_failure_criteria"]) && $ret["notification_failure_criteria"] != null ? $rq .= "'".implode(",", array_keys($ret["notification_failure_criteria"]))."', " : $rq .= "NULL, "; - isset($ret["dep_comment"]) && $ret["dep_comment"] != null ? $rq .= "'".CentreonDB::escape($ret["dep_comment"])."' " : $rq .= "NULL "; + isset($ret["dep_name"]) && $ret["dep_name"] != null + ? $rq .= "'" . CentreonDB::escape($ret["dep_name"]) . "', " + : $rq .= "NULL, "; + isset($ret["dep_description"]) && $ret["dep_description"] != null + ? $rq .= "'" . CentreonDB::escape($ret["dep_description"]) . "', " + : $rq .= "NULL, "; + isset($ret["inherits_parent"]["inherits_parent"]) && $ret["inherits_parent"]["inherits_parent"] != null + ? $rq .= "'" . $ret["inherits_parent"]["inherits_parent"] . "', " + : $rq .= "NULL, "; + isset($ret["execution_failure_criteria"]) && $ret["execution_failure_criteria"] != null + ? $rq .= "'" . implode(",", array_keys($ret["execution_failure_criteria"])) . "', " + : $rq .= "NULL, "; + isset($ret["notification_failure_criteria"]) && $ret["notification_failure_criteria"] != null + ? $rq .= "'" . implode(",", array_keys($ret["notification_failure_criteria"])) . "', " + : $rq .= "NULL, "; + isset($ret["dep_comment"]) && $ret["dep_comment"] != null + ? $rq .= "'" . CentreonDB::escape($ret["dep_comment"]) . "' " + : $rq .= "NULL "; $rq .= ")"; - $DBRESULT = $pearDB->query($rq); + $pearDB->query($rq); $DBRESULT = $pearDB->query("SELECT MAX(dep_id) FROM dependency"); $dep_id = $DBRESULT->fetchRow(); - + /* Prepare value for changelog */ $fields = CentreonLogAction::prepareChanges($ret); - $centreon->CentreonLogAction->insertLog("hostgroup dependency", $dep_id["MAX(dep_id)"], CentreonDB::escape($ret["dep_name"]), "a", $fields); + $centreon->CentreonLogAction->insertLog( + "hostgroup dependency", + $dep_id["MAX(dep_id)"], + CentreonDB::escape($ret["dep_name"]), + "a", + $fields + ); return ($dep_id["MAX(dep_id)"]); } @@ -197,23 +233,41 @@ function updateHostGroupDependency($dep_id = null) $ret = $form->getSubmitValues(); $rq = "UPDATE dependency SET "; $rq .= "dep_name = "; - isset($ret["dep_name"]) && $ret["dep_name"] != null ? $rq .= "'".CentreonDB::escape($ret["dep_name"])."', " : $rq .= "NULL, "; + isset($ret["dep_name"]) && $ret["dep_name"] != null + ? $rq .= "'" . CentreonDB::escape($ret["dep_name"]) . "', " + : $rq .= "NULL, "; $rq .= "dep_description = "; - isset($ret["dep_description"]) && $ret["dep_description"] != null ? $rq .= "'".CentreonDB::escape($ret["dep_description"])."', " : $rq .= "NULL, "; + isset($ret["dep_description"]) && $ret["dep_description"] != null + ? $rq .= "'" . CentreonDB::escape($ret["dep_description"]) . "', " + : $rq .= "NULL, "; $rq .= "inherits_parent = "; - isset($ret["inherits_parent"]["inherits_parent"]) && $ret["inherits_parent"]["inherits_parent"] != null ? $rq .= "'".$ret["inherits_parent"]["inherits_parent"]."', " : $rq .= "NULL, "; + isset($ret["inherits_parent"]["inherits_parent"]) && $ret["inherits_parent"]["inherits_parent"] != null + ? $rq .= "'" . $ret["inherits_parent"]["inherits_parent"] . "', " + : $rq .= "NULL, "; $rq .= "execution_failure_criteria = "; - isset($ret["execution_failure_criteria"]) && $ret["execution_failure_criteria"] != null ? $rq .= "'".implode(",", array_keys($ret["execution_failure_criteria"]))."', " : $rq .= "NULL, "; + isset($ret["execution_failure_criteria"]) && $ret["execution_failure_criteria"] != null + ? $rq .= "'" . implode(",", array_keys($ret["execution_failure_criteria"])) . "', " + : $rq .= "NULL, "; $rq .= "notification_failure_criteria = "; - isset($ret["notification_failure_criteria"]) && $ret["notification_failure_criteria"] != null ? $rq .= "'".implode(",", array_keys($ret["notification_failure_criteria"]))."', " : $rq .= "NULL, "; + isset($ret["notification_failure_criteria"]) && $ret["notification_failure_criteria"] != null + ? $rq .= "'" . implode(",", array_keys($ret["notification_failure_criteria"])) . "', " + : $rq .= "NULL, "; $rq .= "dep_comment = "; - isset($ret["dep_comment"]) && $ret["dep_comment"] != null ? $rq .= "'".CentreonDB::escape($ret["dep_comment"])."' " : $rq .= "NULL "; - $rq .= "WHERE dep_id = '".$dep_id."'"; - $DBRESULT = $pearDB->query($rq); - + isset($ret["dep_comment"]) && $ret["dep_comment"] != null + ? $rq .= "'" . CentreonDB::escape($ret["dep_comment"]) . "' " + : $rq .= "NULL "; + $rq .= "WHERE dep_id = '" . $dep_id . "'"; + $pearDB->query($rq); + /* Prepare value for changelog */ $fields = CentreonLogAction::prepareChanges($ret); - $centreon->CentreonLogAction->insertLog("hostgroup dependency", $dep_id, CentreonDB::escape($ret["dep_name"]), "c", $fields); + $centreon->CentreonLogAction->insertLog( + "hostgroup dependency", + $dep_id, + CentreonDB::escape($ret["dep_name"]), + "c", + $fields + ); } function updateHostGroupDependencyHostGroupParents($dep_id = null, $ret = array()) @@ -224,7 +278,7 @@ function updateHostGroupDependencyHostGroupParents($dep_id = null, $ret = array( global $form; global $pearDB; $rq = "DELETE FROM dependency_hostgroupParent_relation "; - $rq .= "WHERE dependency_dep_id = '".$dep_id."'"; + $rq .= "WHERE dependency_dep_id = '" . $dep_id . "'"; $DBRESULT = $pearDB->query($rq); if (isset($ret["dep_hgParents"])) { $ret = $ret["dep_hgParents"]; @@ -235,7 +289,7 @@ function updateHostGroupDependencyHostGroupParents($dep_id = null, $ret = array( $rq = "INSERT INTO dependency_hostgroupParent_relation "; $rq .= "(dependency_dep_id, hostgroup_hg_id) "; $rq .= "VALUES "; - $rq .= "('".$dep_id."', '".$ret[$i]."')"; + $rq .= "('" . $dep_id . "', '" . $ret[$i] . "')"; $DBRESULT = $pearDB->query($rq); } } @@ -248,7 +302,7 @@ function updateHostGroupDependencyHostGroupChilds($dep_id = null, $ret = array() global $form; global $pearDB; $rq = "DELETE FROM dependency_hostgroupChild_relation "; - $rq .= "WHERE dependency_dep_id = '".$dep_id."'"; + $rq .= "WHERE dependency_dep_id = '" . $dep_id . "'"; $DBRESULT = $pearDB->query($rq); if (isset($ret["dep_hgChilds"])) { $ret = $ret["dep_hgChilds"]; @@ -259,7 +313,7 @@ function updateHostGroupDependencyHostGroupChilds($dep_id = null, $ret = array() $rq = "INSERT INTO dependency_hostgroupChild_relation "; $rq .= "(dependency_dep_id, hostgroup_hg_id) "; $rq .= "VALUES "; - $rq .= "('".$dep_id."', '".$ret[$i]."')"; + $rq .= "('" . $dep_id . "', '" . $ret[$i] . "')"; $DBRESULT = $pearDB->query($rq); } } diff --git a/www/include/configuration/configObject/hostgroup_dependency/formHostGroupDependency.php b/www/include/configuration/configObject/hostgroup_dependency/formHostGroupDependency.php index c6eaedbdb3c..42671368bb5 100644 --- a/www/include/configuration/configObject/hostgroup_dependency/formHostGroupDependency.php +++ b/www/include/configuration/configObject/hostgroup_dependency/formHostGroupDependency.php @@ -36,14 +36,14 @@ if (!isset($centreon)) { exit(); } - + # ## Database retrieve information for Dependency # $dep = array(); - $initialValues = array(); +$initialValues = array(); if (($o == "c" || $o == "w") && $dep_id) { - $DBRESULT = $pearDB->query("SELECT * FROM dependency WHERE dep_id = '".$dep_id."' LIMIT 1"); + $DBRESULT = $pearDB->query("SELECT * FROM dependency WHERE dep_id = '" . $dep_id . "' LIMIT 1"); # Set base value $dep = array_map("myDecode", $DBRESULT->fetchRow()); @@ -66,24 +66,26 @@ /* * Var information to format the element */ -$attrsText = array("size"=>"30"); -$attrsText2 = array("size"=>"10"); +$attrsText = array("size" => "30"); +$attrsText2 = array("size" => "10"); $attrsAdvSelect = array("style" => "width: 300px; height: 150px;"); -$attrsTextarea = array("rows"=>"3", "cols"=>"30"); -$eTemplate = '
{label_2}
{unselected}
{add}


{remove}
{label_3}
{selected}
'; +$attrsTextarea = array("rows" => "3", "cols" => "30"); +$eTemplate = '
{label_2}
{unselected}
{add}

' . + '
{remove}
{label_3}
{selected}
'; + +$route = './include/common/webServices/rest/internal.php?object=centreon_configuration_hostgroup&action=list'; $attrHostgroups = array( 'datasourceOrigin' => 'ajax', - 'availableDatasetRoute' => './include/common/webServices/rest/internal.php?object=centreon_configuration_hostgroup&action=list', + 'availableDatasetRoute' => $route, 'multiple' => true, 'linkedObject' => 'centreonHostgroups' ); - /* * Form begin */ -$form = new HTML_QuickForm('Form', 'post', "?p=".$p); +$form = new HTML_QuickForm('Form', 'post', "?p=" . $p); if ($o == "a") { $form->addElement('header', 'title', _("Add a Dependency")); } elseif ($o == "c") { @@ -103,14 +105,44 @@ $tab[] = HTML_QuickForm::createElement('radio', 'inherits_parent', null, _("Yes"), '1'); $tab[] = HTML_QuickForm::createElement('radio', 'inherits_parent', null, _("No"), '0'); $form->addGroup($tab, 'inherits_parent', _("Parent relationship"), ' '); -$form->setDefaults(array('inherits_parent'=>'1')); +$form->setDefaults(array('inherits_parent' => '1')); $tab = array(); -$tab[] = HTML_QuickForm::createElement('checkbox', 'o', ' ', _("Ok/Up"), array('id' => 'hUp', 'onClick' => 'uncheckAllH(this);')); -$tab[] = HTML_QuickForm::createElement('checkbox', 'd', ' ', _("Down"), array('id' => 'hDown', 'onClick' => 'uncheckAllH(this);')); -$tab[] = HTML_QuickForm::createElement('checkbox', 'u', ' ', _("Unreachable"), array('id' => 'hUnreachable', 'onClick' => 'uncheckAllH(this);')); -$tab[] = HTML_QuickForm::createElement('checkbox', 'p', ' ', _("Pending"), array('id' => 'hPending', 'onClick' => 'uncheckAllH(this);')); -$tab[] = HTML_QuickForm::createElement('checkbox', 'n', ' ', _("None"), array('id' => 'hNone', 'onClick' => 'uncheckAllH(this);')); +$tab[] = HTML_QuickForm::createElement( + 'checkbox', + 'o', + ' ', + _("Ok/Up"), + array('id' => 'hUp', 'onClick' => 'uncheckAllH(this);') +); +$tab[] = HTML_QuickForm::createElement( + 'checkbox', + 'd', + ' ', + _("Down"), + array('id' => 'hDown', 'onClick' => 'uncheckAllH(this);') +); +$tab[] = HTML_QuickForm::createElement( + 'checkbox', + 'u', + ' ', + _("Unreachable"), + array('id' => 'hUnreachable', 'onClick' => 'uncheckAllH(this);') +); +$tab[] = HTML_QuickForm::createElement( + 'checkbox', + 'p', + ' ', + _("Pending"), + array('id' => 'hPending', 'onClick' => 'uncheckAllH(this);') +); +$tab[] = HTML_QuickForm::createElement( + 'checkbox', + 'n', + ' ', + _("None"), + array('id' => 'hNone', 'onClick' => 'uncheckAllH(this);') +); $form->addGroup($tab, 'notification_failure_criteria', _("Notification Failure Criteria"), '  '); $tab = array(); @@ -121,15 +153,19 @@ $tab[] = HTML_QuickForm::createElement('checkbox', 'n', ' ', _("None")); $form->addGroup($tab, 'execution_failure_criteria', _("Execution Failure Criteria"), '  '); +$route = './include/common/webServices/rest/internal.php?object=centreon_configuration_hostgroup' . + '&action=defaultValues&target=dependency&field=dep_hgParents&id=' . $dep_id; $attrHostgroup1 = array_merge( $attrHostgroups, - array('defaultDatasetRoute' => './include/common/webServices/rest/internal.php?object=centreon_configuration_hostgroup&action=defaultValues&target=dependency&field=dep_hgParents&id=' . $dep_id) + array('defaultDatasetRoute' => $route) ); $form->addElement('select2', 'dep_hgParents', _("Host Groups Name"), array(), $attrHostgroup1); +$route = './include/common/webServices/rest/internal.php?object=centreon_configuration_hostgroup' . + '&action=defaultValues&target=dependency&field=dep_hgChilds&id=' . $dep_id; $attrHostgroup2 = array_merge( $attrHostgroups, - array('defaultDatasetRoute' => './include/common/webServices/rest/internal.php?object=centreon_configuration_hostgroup&action=defaultValues&target=dependency&field=dep_hgChilds&id=' . $dep_id) + array('defaultDatasetRoute' => $route) ); $form->addElement('select2', 'dep_hgChilds', _("Dependent Host Groups Name"), array(), $attrHostgroup2); @@ -141,7 +177,7 @@ $init = $form->addElement('hidden', 'initialValues'); $init->setValue(serialize($initialValues)); - + /* * Form Rules */ @@ -157,7 +193,7 @@ $form->addRule('dep_hgChilds', _("Circular Definition"), 'cycle'); $form->registerRule('exist', 'callback', 'testHostGroupDependencyExistence'); $form->addRule('dep_name', _("Name is already in use"), 'exist'); -$form->setRequiredNote("* ". _("Required fields")); +$form->setRequiredNote("* " . _("Required fields")); /* * Smarty template Init @@ -168,7 +204,12 @@ # Just watch a Dependency information if ($o == "w") { if ($centreon->user->access->page($p) != 2) { - $form->addElement("button", "change", _("Modify"), array("onClick"=>"javascript:window.location.href='?p=".$p."&o=c&dep_id=".$dep_id."'")); + $form->addElement( + "button", + "change", + _("Modify"), + array("onClick" => "javascript:window.location.href='?p=" . $p . "&o=c&dep_id=" . $dep_id . "'") + ); } $form->setDefaults($dep); $form->freeze(); @@ -184,12 +225,17 @@ $form->setDefaults(array('inherits_parent', '0')); } -$tpl->assign("helpattr", 'TITLE, "'._("Help").'", CLOSEBTN, true, FIX, [this, 0, 5], BGCOLOR, "#ffff99", BORDERCOLOR, "orange", TITLEFONTCOLOR, "black", TITLEBGCOLOR, "orange", CLOSEBTNCOLORS, ["","black", "white", "red"], WIDTH, -300, SHADOW, true, TEXTALIGN, "justify"'); +$tpl->assign( + "helpattr", + 'TITLE, "' . _("Help") . '", CLOSEBTN, true, FIX, [this, 0, 5], BGCOLOR, "#ffff99", BORDERCOLOR, "orange", ' . + 'TITLEFONTCOLOR, "black", TITLEBGCOLOR, "orange", CLOSEBTNCOLORS, ["","black", "white", "red"], WIDTH, -300, ' . + 'SHADOW, true, TEXTALIGN, "justify"' +); # prepare help texts $helptext = ""; include_once("include/configuration/configObject/host_dependency/help.php"); foreach ($help as $key => $text) { - $helptext .= ''."\n"; + $helptext .= '' . "\n"; } $tpl->assign("helptext", $helptext); @@ -221,18 +267,18 @@ } ?> diff --git a/www/include/configuration/configObject/hostgroup_dependency/hostGroupDependency.php b/www/include/configuration/configObject/hostgroup_dependency/hostGroupDependency.php index ccd39156227..54d71c5d4d6 100644 --- a/www/include/configuration/configObject/hostgroup_dependency/hostGroupDependency.php +++ b/www/include/configuration/configObject/hostgroup_dependency/hostGroupDependency.php @@ -32,7 +32,7 @@ * For more information : contact@centreon.com * */ - + if (!isset($centreon)) { exit(); } @@ -65,7 +65,7 @@ /* * PHP functions */ -require_once $path."DB-Func.php"; +require_once $path . "DB-Func.php"; require_once "./include/common/common-Func.php"; /* Set the real page */ @@ -76,26 +76,26 @@ $acl = $oreon->user->access; $hgs = $acl->getHostGroupAclConf(null, 'broker'); $hgstring = CentreonUtils::toStringWithQuotes($hgs); - + switch ($o) { case "a": - require_once($path."formHostGroupDependency.php"); + require_once($path . "formHostGroupDependency.php"); break; #Add a Dependency case "w": - require_once($path."formHostGroupDependency.php"); + require_once($path . "formHostGroupDependency.php"); break; #Watch a Dependency case "c": - require_once($path."formHostGroupDependency.php"); + require_once($path . "formHostGroupDependency.php"); break; #Modify a Dependency case "m": multipleHostGroupDependencyInDB(isset($select) ? $select : array(), $dupNbr); - require_once($path."listHostGroupDependency.php"); + require_once($path . "listHostGroupDependency.php"); break; #Duplicate n Dependencys case "d": deleteHostGroupDependencyInDB(isset($select) ? $select : array()); - require_once($path."listHostGroupDependency.php"); + require_once($path . "listHostGroupDependency.php"); break; #Delete n Dependency default: - require_once($path."listHostGroupDependency.php"); + require_once($path . "listHostGroupDependency.php"); break; } diff --git a/www/include/configuration/configObject/hostgroup_dependency/listHostGroupDependency.php b/www/include/configuration/configObject/hostgroup_dependency/listHostGroupDependency.php index 6eaf95dbf57..b4404b0faba 100644 --- a/www/include/configuration/configObject/hostgroup_dependency/listHostGroupDependency.php +++ b/www/include/configuration/configObject/hostgroup_dependency/listHostGroupDependency.php @@ -43,11 +43,11 @@ isset($_GET["list"]) ? $list = $_GET["list"] : $list = null; - $aclCond = ""; +$aclCond = ""; if (!$oreon->user->admin) { $aclCond = " AND hostgroup_hg_id IN ($hgstring) "; } - + $rq = "SELECT COUNT(*) FROM dependency dep"; $rq .= " WHERE ((SELECT DISTINCT COUNT(*) FROM dependency_hostgroupParent_relation dhgpr @@ -59,7 +59,8 @@ $search = ''; if (isset($_POST['searchHGD']) && $_POST['searchHGD']) { $search = $_POST['searchHGD']; - $rq .= " AND (dep_name LIKE '%".CentreonDB::escape($search)."%' OR dep_description LIKE '%".CentreonDB::escape($search)."%')"; + $rq .= " AND (dep_name LIKE '%" . CentreonDB::escape($search) . "%' OR dep_description LIKE '%" . + CentreonDB::escape($search) . "%')"; } $DBRESULT = $pearDB->query($rq); $tmp = $DBRESULT->fetchRow(); @@ -97,14 +98,15 @@ WHERE dhgpr.dependency_dep_id = dep.dep_id $aclCond) > 0)"; if ($search) { - $rq .= " AND (dep_name LIKE '%".CentreonDB::escape($search)."%' OR dep_description LIKE '%".CentreonDB::escape($search)."%')"; + $rq .= " AND (dep_name LIKE '%" . CentreonDB::escape($search) . "%' OR dep_description LIKE '%" . + CentreonDB::escape($search) . "%')"; } -$rq .= " ORDER BY dep_name, dep_description LIMIT ".$num * $limit.", ".$limit; +$rq .= " ORDER BY dep_name, dep_description LIMIT " . $num * $limit . ", " . $limit; $DBRESULT = $pearDB->query($rq); $search = tidySearchKey($search, $advanced_search); -$form = new HTML_QuickForm('select_form', 'POST', "?p=".$p); +$form = new HTML_QuickForm('select_form', 'POST', "?p=" . $p); #Different style between each lines $style = "one"; @@ -113,59 +115,85 @@ $elemArr = array(); for ($i = 0; $dep = $DBRESULT->fetchRow(); $i++) { $moptions = ""; - $selectedElements = $form->addElement('checkbox', "select[".$dep['dep_id']."]"); - $moptions .= "  31 && (event.keyCode < 45 || event.keyCode > 57)) event.returnValue = false; if(event.which > 31 && (event.which < 45 || event.which > 57)) return false;\" maxlength=\"3\" size=\"3\" value='1' style=\"margin-bottom:0px;\" name='dupNbr[".$dep['dep_id']."]'>"; - $elemArr[$i] = array( "MenuClass"=>"list_".$style, - "RowMenu_select"=>$selectedElements->toHtml(), - "RowMenu_name"=>CentreonUtils::escapeSecure($dep["dep_name"]), - "RowMenu_link"=>"?p=".$p."&o=c&dep_id=".$dep['dep_id'], - "RowMenu_description"=>CentreonUtils::escapeSecure($dep["dep_description"]), - "RowMenu_options"=>$moptions); + $selectedElements = $form->addElement('checkbox', "select[" . $dep['dep_id'] . "]"); + $moptions .= "  31 && (event.keyCode < 45 || event.keyCode > 57))" . + "event.returnValue = false; if(event.which > 31 && (event.which < 45 || event.which > 57)) return false;" . + "\" maxlength=\"3\" size=\"3\" value='1' style=\"margin-bottom:0px;\" name='dupNbr[" . + $dep['dep_id'] . "]' />"; + $elemArr[$i] = array( + "MenuClass" => "list_" . $style, + "RowMenu_select" => $selectedElements->toHtml(), + "RowMenu_name" => CentreonUtils::escapeSecure($dep["dep_name"]), + "RowMenu_link" => "?p=" . $p . "&o=c&dep_id=" . $dep['dep_id'], + "RowMenu_description" => CentreonUtils::escapeSecure($dep["dep_description"]), + "RowMenu_options" => $moptions + ); $style != "two" ? $style = "two" : $style = "one"; } $tpl->assign("elemArr", $elemArr); # Different messages we put in the template -$tpl->assign('msg', array ("addL"=>"?p=".$p."&o=a", "addT"=>_("Add"), "delConfirm"=>_("Do you confirm the deletion ?"))); +$tpl->assign( + 'msg', + array("addL" => "?p=" . $p . "&o=a", "addT" => _("Add"), "delConfirm" => _("Do you confirm the deletion ?")) +); /* * Toolbar */ ?> - + "javascript: " . - " var bChecked = isChecked(); ". - " if (this.form.elements['o1'].selectedIndex != 0 && !bChecked) {". - " alert('"._("Please select one or more items")."'); return false;} " . - "if (this.form.elements['o1'].selectedIndex == 1 && confirm('"._("Do you confirm the duplication ?")."')) {" . - " setO(this.form.elements['o1'].value); submit();} " . - "else if (this.form.elements['o1'].selectedIndex == 2 && confirm('"._("Do you confirm the deletion ?")."')) {" . - " setO(this.form.elements['o1'].value); submit();} " . - "else if (this.form.elements['o1'].selectedIndex == 3) {" . - " setO(this.form.elements['o1'].value); submit();} " . - ""); -$form->addElement('select', 'o1', null, array(null=>_("More actions..."), "m"=>_("Duplicate"), "d"=>_("Delete")), $attrs1); + 'onchange' => "javascript: " . + " var bChecked = isChecked(); " . + " if (this.form.elements['o1'].selectedIndex != 0 && !bChecked) {" . + " alert('" . _("Please select one or more items") . "'); return false;} " . + "if (this.form.elements['o1'].selectedIndex == 1 && confirm('" . + _("Do you confirm the duplication ?") . "')) {" . + " setO(this.form.elements['o1'].value); submit();} " . + "else if (this.form.elements['o1'].selectedIndex == 2 && confirm('" . + _("Do you confirm the deletion ?") . "')) {" . + " setO(this.form.elements['o1'].value); submit();} " . + "else if (this.form.elements['o1'].selectedIndex == 3) {" . + " setO(this.form.elements['o1'].value); submit();} " . + "" +); +$form->addElement( + 'select', + 'o1', + null, + array(null => _("More actions..."), "m" => _("Duplicate"), "d" => _("Delete")), + $attrs1 +); $form->setDefaults(array('o1' => null)); $attrs2 = array( - 'onchange'=>"javascript: " . - " var bChecked = isChecked(); ". - " if (this.form.elements['o2'].selectedIndex != 0 && !bChecked) {". - " alert('"._("Please select one or more items")."'); return false;} " . - "if (this.form.elements['o2'].selectedIndex == 1 && confirm('"._("Do you confirm the duplication ?")."')) {" . - " setO(this.form.elements['o2'].value); submit();} " . - "else if (this.form.elements['o2'].selectedIndex == 2 && confirm('"._("Do you confirm the deletion ?")."')) {" . - " setO(this.form.elements['o2'].value); submit();} " . - "else if (this.form.elements['o2'].selectedIndex == 3) {" . - " setO(this.form.elements['o2'].value); submit();} " . - ""); -$form->addElement('select', 'o2', null, array(null=>_("More actions..."), "m"=>_("Duplicate"), "d"=>_("Delete")), $attrs2); + 'onchange' => "javascript: " . + " var bChecked = isChecked(); " . + " if (this.form.elements['o2'].selectedIndex != 0 && !bChecked) {" . + " alert('" . _("Please select one or more items") . "'); return false;} " . + "if (this.form.elements['o2'].selectedIndex == 1 && confirm('" . + _("Do you confirm the duplication ?") . "')) {" . + " setO(this.form.elements['o2'].value); submit();} " . + "else if (this.form.elements['o2'].selectedIndex == 2 && confirm('" . + _("Do you confirm the deletion ?") . "')) {" . + " setO(this.form.elements['o2'].value); submit();} " . + "else if (this.form.elements['o2'].selectedIndex == 3) {" . + " setO(this.form.elements['o2'].value); submit();} " . + "" +); +$form->addElement( + 'select', + 'o2', + null, + array(null => _("More actions..."), "m" => _("Duplicate"), "d" => _("Delete")), + $attrs2 +); $form->setDefaults(array('o2' => null)); $o1 = $form->getElement('o1'); From c3ed57f72de1fbb5d9ecdb2cf6bb495e6d71f8a1 Mon Sep 17 00:00:00 2001 From: mariegallardo Date: Fri, 28 Jul 2017 09:13:26 +0200 Subject: [PATCH 088/207] Test FeatureHostConfiguration upgraded (#5465) * Test upgraded * Behat upgraded * File cleaned --- behat.yml | 10 - features/HostConfiguration.feature | 16 +- features/HostCreationDuplication.feature | 21 - features/HostDuplicationCheck.feature | 12 - .../bootstrap/HostConfigurationContext.php | 409 +++++++++++++++--- .../HostCreationDuplicationContext.php | 123 ------ .../bootstrap/HostDuplicationCheckContext.php | 66 --- 7 files changed, 355 insertions(+), 302 deletions(-) delete mode 100644 features/HostCreationDuplication.feature delete mode 100644 features/HostDuplicationCheck.feature delete mode 100644 features/bootstrap/HostCreationDuplicationContext.php delete mode 100644 features/bootstrap/HostDuplicationCheckContext.php diff --git a/behat.yml b/behat.yml index 81524028b63..ce458bac5cf 100644 --- a/behat.yml +++ b/behat.yml @@ -179,11 +179,6 @@ default: contexts: - ContactConfigurationContext - host_creation_duplication: - paths: [ %paths.base%/features/HostCreationDuplication.feature ] - contexts: - - HostCreationDuplicationContext - host_configuration: paths: [ %paths.base%/features/HostConfiguration.feature ] contexts: @@ -199,11 +194,6 @@ default: contexts: - ContactGroupConfigurationContext - host_duplication_check: - paths: [ %paths.base%/features/HostDuplicationCheck.feature ] - contexts: - - HostDuplicationCheckContext - contact_group_creation_duplication: paths: [ %paths.base%/features/ContactGroupCreationDuplication.feature ] contexts: diff --git a/features/HostConfiguration.feature b/features/HostConfiguration.feature index f0185c0bd43..f343eb72e8b 100644 --- a/features/HostConfiguration.feature +++ b/features/HostConfiguration.feature @@ -8,13 +8,13 @@ Feature: HostConfiguration And an host is configured Scenario: Edit the name of an host - When I configure the name of an host - Then the name has changed on the Host page + When I change the properties of a host + Then its properties are updated - Scenario: Edit the alias of an host - When I configure the alias of an host - Then the alias has changed on the Host page + Scenario: Duplicate one existing host + When I duplicate a host + Then a new host is created with identical properties - Scenario: Edit the address of an host - When I configure the address of an host - Then the address has changed on the Host page + Scenario: Delete one existing host + When I delete the host + Then the host is not visible anymore diff --git a/features/HostCreationDuplication.feature b/features/HostCreationDuplication.feature deleted file mode 100644 index 98a2e3e8a05..00000000000 --- a/features/HostCreationDuplication.feature +++ /dev/null @@ -1,21 +0,0 @@ -Feature: HostCreationDuplication - As a Centreon admin user - I want to create an host - To duplicate an delete it - - Background: - Given I am logged in a Centreon server - - Scenario: Create a host - When I create a host - Then the new record is displayed in the hosts list - - Scenario: Duplication of a host - Given a host is configured - When I duplicate a host - Then the new host is displayed in the hosts list - - Scenario: Delete a host - Given a host is configured - When I delete a host - Then the deleted host is not displayed in the hosts list diff --git a/features/HostDuplicationCheck.feature b/features/HostDuplicationCheck.feature deleted file mode 100644 index 3708d9302e6..00000000000 --- a/features/HostDuplicationCheck.feature +++ /dev/null @@ -1,12 +0,0 @@ -Feature: HostDuplicationCheck - As a Centreon admin user - I want to duplicate a host - To see if the Properties have changed - - Background: - Given I am logged in a Centreon server - - Scenario: Duplicate a host and check the properties - Given a host is created - When I duplicate a host - Then the host properties are updated diff --git a/features/bootstrap/HostConfigurationContext.php b/features/bootstrap/HostConfigurationContext.php index 0425d55ffeb..2d3c3daf108 100644 --- a/features/bootstrap/HostConfigurationContext.php +++ b/features/bootstrap/HostConfigurationContext.php @@ -3,27 +3,259 @@ use Centreon\Test\Behat\CentreonContext; use Centreon\Test\Behat\Configuration\HostConfigurationPage; use Centreon\Test\Behat\Configuration\HostConfigurationListingPage; +use Centreon\Test\Behat\Configuration\HostGroupConfigurationPage; +use Centreon\Test\Behat\Configuration\HostCategoryConfigurationPage; +use Centreon\Test\Behat\Configuration\HostTemplateConfigurationPage; class HostConfigurationContext extends CentreonContext { protected $currentPage; - protected $hostName; - protected $changedName; - protected $hostAlias; - protected $changedAlias; - protected $hostAddress; - protected $changedAddress; - - public function __construct() - { - parent::__construct(); - $this->hostName = 'hostName'; - $this->changedName = 'hostNameChanged'; - $this->hostAlias = 'hostAlias'; - $this->changedAlias = 'hostAliasChanged'; - $this->hostAddress = 'local'; - $this->changedAddress = '10.30.2.105'; - } + + protected $host2 = array( + 'name' => 'hostName2', + 'alias' => 'hostAlias2', + 'address' => 'host2@localhost' + ); + + protected $host3 = array( + 'name' => 'hostName3', + 'alias' => 'hostAlias3', + 'address' => 'host3@localhost' + ); + + protected $hostGroup1 = array( + 'name' => 'hostGroupName1', + 'alias' => 'hostGroupAlias1' + ); + + protected $hostGroup2 = array( + 'name' => 'hostGroupName2', + 'alias' => 'hostGroupAlias2' + ); + + protected $hostCategory1 = array( + 'name' => 'hostCategoryName1', + 'alias' => 'hostCategoryAlias1', + 'severity' => 1, + 'severity_level' => 2, + 'severity_icon' => ' centreon (png)' + ); + + protected $hostCategory2 = array( + 'name' => 'hostCategoryName2', + 'alias' => 'hostCategoryAlias2' + ); + + protected $hostCategory3 = array( + 'name' => 'hostCategoryName3', + 'alias' => 'hostCategoryAlias3' + ); + + protected $hostTemplate = array( + 'name' => 'hostTemplateName', + 'alias' => 'hostTemplateAlias' + ); + + protected $initialProperties = array( + 'name' => 'hostName', + 'alias' => 'hostAlias', + 'address' => 'host@localhost', + 'snmp_community' => 'hostSnmpCommunity', + 'snmp_version' => '1', + 'location' => 'America/Caracas', + 'templates' => array( + 'generic-host' + ), + 'check_command' => 'check_http', + 'command_arguments' => 'hostCommandArgument', + 'check_period' => 'workhours', + 'max_check_attempts' => 34, + 'normal_check_interval' => 5, + 'retry_check_interval' => 10, + 'active_checks_enabled' => 2, + 'passive_checks_enabled' => 0, + 'notifications_enabled' => 1, + 'contact_additive_inheritance' => 1, + 'contacts' => 'Guest', + 'contact_group_additive_inheritance' => 0, + 'contact_groups' => 'Supervisors', + 'notify_on_none' => 0, + 'notify_on_down' => 1, + 'notify_on_unreachable' => 0, + 'notify_on_recovery' => 1, + 'notify_on_flapping' => 0, + 'notify_on_downtime_scheduled' => 1, + 'notification_interval' => 17, + 'notification_period' => 'none', + 'first_notification_delay' => 4, + 'recovery_notification_delay' => 3, + 'parent_host_groups' => 'hostGroupName1', + 'parent_host_categories' => 'hostCategoryName2', + 'parent_hosts' => 'Centreon-Server', + 'child_hosts' => 'hostName2', + 'obsess_over_host' => 2, + 'acknowledgement_timeout' => 2, + 'check_freshness' => 1, + 'freshness_threshold' => 34, + 'flap_detection_enabled' => 1, + 'low_flap_threshold' => 67, + 'high_flap_threshold' => 85, + 'retain_status_information' => 2, + 'retain_non_status_information' => 0, + 'stalking_option_on_up' => 1, + 'stalking_option_on_down' => 0, + 'stalking_option_on_unreachable' => 1, + 'event_handler_enabled' => 2, + 'event_handler' => 'check_https', + 'event_handler_arguments' => 'event_handler_arguments', + 'url' => 'hostMassiveChangeUrl', + 'notes' => 'hostMassiveChangeNotes', + 'action_url' => 'hostMassiveChangeActionUrl', + 'icon' => ' centreon (png)', + 'alt_icon' => 'hostMassiveChangeIcon', + 'status_map_image' => '', + 'geo_coordinates' => 'Paris', + '2d_coords' => '15,84', + '3d_coords' => '15,84,76', + 'severity_level' => 'hostCategoryName1 (2)', + 'enabled' => 1, + 'comments' => 'hostMassiveChangeComments' + ); + + protected $duplicatedProperties = array( + 'name' => 'hostName_1', + 'alias' => 'hostAlias', + 'address' => 'host@localhost', + 'snmp_community' => 'hostSnmpCommunity', + 'snmp_version' => '1', + 'location' => 'America/Caracas', + 'templates' => array( + 'generic-host' + ), + 'check_command' => 'check_http', + 'command_arguments' => 'hostCommandArgument', + 'check_period' => 'workhours', + 'max_check_attempts' => 34, + 'normal_check_interval' => 5, + 'retry_check_interval' => 10, + 'active_checks_enabled' => 2, + 'passive_checks_enabled' => 0, + 'notifications_enabled' => 1, + 'contact_additive_inheritance' => 1, + 'contacts' => 'Guest', + 'contact_group_additive_inheritance' => 0, + 'contact_groups' => 'Supervisors', + 'notify_on_none' => 0, + 'notify_on_down' => 1, + 'notify_on_unreachable' => 0, + 'notify_on_recovery' => 1, + 'notify_on_flapping' => 0, + 'notify_on_downtime_scheduled' => 1, + 'notification_interval' => 17, + 'notification_period' => 'none', + 'first_notification_delay' => 4, + 'recovery_notification_delay' => 3, + 'parent_host_groups' => 'hostGroupName1', + 'parent_host_categories' => 'hostCategoryName2', + 'parent_hosts' => 'Centreon-Server', + 'child_hosts' => 'hostName2', + 'obsess_over_host' => 2, + 'acknowledgement_timeout' => 2, + 'check_freshness' => 1, + 'freshness_threshold' => 34, + 'flap_detection_enabled' => 1, + 'low_flap_threshold' => 67, + 'high_flap_threshold' => 85, + 'retain_status_information' => 2, + 'retain_non_status_information' => 0, + 'stalking_option_on_up' => 1, + 'stalking_option_on_down' => 0, + 'stalking_option_on_unreachable' => 1, + 'event_handler_enabled' => 2, + 'event_handler' => 'check_https', + 'event_handler_arguments' => 'event_handler_arguments', + 'url' => 'hostMassiveChangeUrl', + 'notes' => 'hostMassiveChangeNotes', + 'action_url' => 'hostMassiveChangeActionUrl', + 'icon' => ' centreon (png)', + 'alt_icon' => 'hostMassiveChangeIcon', + 'status_map_image' => '', + 'geo_coordinates' => 'Paris', + '2d_coords' => '15,84', + '3d_coords' => '15,84,76', + 'severity_level' => 'hostCategoryName1 (2)', + 'enabled' => 1, + 'comments' => 'hostMassiveChangeComments' + ); + + protected $updatedProperties = array( + 'name' => 'hostNameChanged', + 'alias' => 'hostAliasChanged', + 'address' => 'hostChanged@localhost', + 'snmp_community' => 'hostSnmpCommunitychanged', + 'snmp_version' => '3', + 'macros' => array( + 'HOSTMACROCHANGED' => 5 + ), + 'location' => 'Europe/Paris', + 'templates' => array( + 'hostTemplateName' + ), + 'check_command' => 'check_https', + 'command_arguments' => 'hostCommandArgumentChanged', + 'check_period' => 'none', + 'max_check_attempts' => 43, + 'normal_check_interval' => 4, + 'retry_check_interval' => 25, + 'active_checks_enabled' => 0, + 'passive_checks_enabled' => 1, + 'notifications_enabled' => 0, + 'contact_additive_inheritance' => 0, + 'contacts' => 'User', + 'contact_group_additive_inheritance' => 1, + 'contact_groups' => 'Guest', + 'notify_on_none' => 0, + 'notify_on_down' => 0, + 'notify_on_unreachable' => 1, + 'notify_on_recovery' => 0, + 'notify_on_flapping' => 1, + 'notify_on_downtime_scheduled' => 0, + 'notification_interval' => 34, + 'notification_period' => 'workhours', + 'first_notification_delay' => 7, + 'recovery_notification_delay' => 4, + 'parent_host_groups' => 'hostGroupName2', + 'parent_host_categories' => 'hostCategoryName3', + 'parent_hosts' => 'hostName3', + 'child_hosts' => 'Centreon-Server', + 'obsess_over_host' => 1, + 'acknowledgement_timeout' => 0, + 'check_freshness' => 2, + 'freshness_threshold' => 65, + 'flap_detection_enabled' => 0, + 'low_flap_threshold' => 38, + 'high_flap_threshold' => 51, + 'retain_status_information' => 1, + 'retain_non_status_information' => 1, + 'stalking_option_on_up' => 0, + 'stalking_option_on_down' => 1, + 'stalking_option_on_unreachable' => 0, + 'event_handler_enabled' => 1, + 'event_handler' => 'check_http', + 'event_handler_arguments' => 'eventHandlerArgumentsChanged', + 'url' => 'hostMassiveChangeUrlChanged', + 'notes' => 'hostMassiveChangeNotesChanged', + 'action_url' => 'hostMassiveChangeActionUrlChanged', + 'icon' => '', + 'alt_icon' => 'hostMassiveChangeIconChanged', + 'status_map_image' => ' centreon (png)', + 'geo_coordinates' => 'Issy', + '2d_coords' => '2,3', + '3d_coords' => '42,24,66', + 'severity_level' => '', + 'enabled' => 1, + 'comments' => 'hostMassiveChangeCommentsChanged' + ); /** * @Given an host is configured @@ -31,89 +263,142 @@ public function __construct() public function anHostIsConfigured() { $this->currentPage = new HostConfigurationPage($this); - $this->currentPage->setProperties(array( - 'name' => $this->hostName, - 'alias' => $this->hostAlias, - 'address' => $this->hostAddress - )); + $this->currentPage->setProperties($this->host2); + $this->currentPage->save(); + $this->currentPage = new HostConfigurationPage($this); + $this->currentPage->setProperties($this->host3); + $this->currentPage->save(); + $this->currentPage = new HostGroupConfigurationPage($this); + $this->currentPage->setProperties($this->hostGroup1); + $this->currentPage->save(); + $this->currentPage = new HostGroupConfigurationPage($this); + $this->currentPage->setProperties($this->hostGroup2); + $this->currentPage->save(); + $this->currentPage = new HostCategoryConfigurationPage($this); + $this->currentPage->setProperties($this->hostCategory1); + $this->currentPage->save(); + $this->currentPage = new HostCategoryConfigurationPage($this); + $this->currentPage->setProperties($this->hostCategory2); + $this->currentPage->save(); + $this->currentPage = new HostCategoryConfigurationPage($this); + $this->currentPage->setProperties($this->hostCategory3); + $this->currentPage->save(); + $this->currentPage = new HostTemplateConfigurationPage($this); + $this->currentPage->setProperties($this->hostTemplate); + $this->currentPage->save(); + $this->currentPage = new HostConfigurationPage($this); + $this->currentPage->setProperties($this->initialProperties); $this->currentPage->save(); } /** - * @When I configure the name of an host + * @When I change the properties of a host */ - public function iConfigureTheIPAddressOfAnHost() + public function iChangeThePropertiesOfAHost() { $this->currentPage = new HostConfigurationListingPage($this); - $this->currentPage = $this->currentPage->inspect($this->hostName); - $this->currentPage->setProperties(array( - 'name' => $this->changedName - )); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['name']); + $this->currentPage->setProperties($this->updatedProperties); $this->currentPage->save(); } /** - * @Then the name has changed on the Host page + * @Then its properties are updated */ - public function theIPAddressHasChangedOnTheHostPage() + public function itsPropertiesAreUpdated() { - $this->currentPage = new HostConfigurationListingPage($this); + $this->tableau = array(); try { - $this->currentPage->getEntry($this->changedName); + $this->spin( + function ($context) { + $this->currentPage = new HostConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->updatedProperties['name']); + $object = $this->currentPage->getProperties(); + foreach ($this->updatedProperties as $key => $value) { + if ($value != $object[$key]) { + $this->tableau[] = $key; + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); } catch (\Exception $e) { - throw new \Exception('The name has not changed: ' . $e->getMessage()); + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); } } /** - * @When I configure the alias of an host + * @When I duplicate a host */ - public function iConfigureTheAliasOfAnHost() + public function iDuplicateAHost() { $this->currentPage = new HostConfigurationListingPage($this); - $this->currentPage = $this->currentPage->inspect($this->hostName); - $this->currentPage->setProperties(array( - 'alias' => $this->changedAlias - )); - $this->currentPage->save(); + $object = $this->currentPage->getEntry($this->initialProperties['name']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Duplicate'); } /** - * @Then the alias has changed on the Host page + * @Then a new host is created with identical properties */ - public function theAliasHasChangedOnTheHostPage() + public function aNewHostIsCreatedWithIdenticalProperties() { - $this->currentPage = new HostConfigurationListingPage($this); - $this->currentPage = $this->currentPage->inspect($this->hostName); - $object = $this->currentPage->getProperties(); - if (!$object['alias'] == $this->changedAlias) { - throw new \Exception("The alias was not changed."); + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new HostConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->duplicatedProperties['name']); + $object = $this->currentPage->getProperties(); + foreach ($this->duplicatedProperties as $key => $value) { + if ($value != $object[$key]) { + $this->tableau[] = $key; + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); } } /** - * @When I configure the address of an host + * @When I delete the host */ - public function iConfigureTheAddressOfAnHost() + public function iDeleteTheHost() { $this->currentPage = new HostConfigurationListingPage($this); - $this->currentPage = $this->currentPage->inspect($this->hostName); - $this->currentPage->setProperties(array( - 'address' => $this->changedAlias - )); - $this->currentPage->save(); + $object = $this->currentPage->getEntry($this->initialProperties['name']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Delete'); } /** - * @Then the address has changed on the Host page + * @Then the host is not visible anymore */ - public function theAddressHasChangedOnTheHostPage() + public function theHostIsNotVisibleAnymore() { - $this->currentPage = new HostConfigurationListingPage($this); - $this->currentPage = $this->currentPage->inspect($this->hostName); - $object = $this->currentPage->getProperties(); - if (!$object['address'] == $this->changedAddress) { - throw new \Exception("The address was not changed."); - } + $this->spin( + function ($context) { + $this->currentPage = new HostConfigurationListingPage($this); + $object = $this->currentPage->getEntries(); + $bool = true; + foreach ($object as $value) { + $bool = $bool && $value['name'] != $this->initialProperties['name']; + } + return $bool; + }, + "The host is not being deleted.", + 5 + ); } } diff --git a/features/bootstrap/HostCreationDuplicationContext.php b/features/bootstrap/HostCreationDuplicationContext.php deleted file mode 100644 index 5d2b434f897..00000000000 --- a/features/bootstrap/HostCreationDuplicationContext.php +++ /dev/null @@ -1,123 +0,0 @@ -hostName = 'hostName'; - $this->hostAlias = 'hostAlias'; - $this->hostAddress = 'local'; - } - - /** - * @When I create a host - */ - public function iCreateAHost() - { - $this->currentPage = new HostConfigurationPage($this); - $this->currentPage->setProperties(array( - 'name' => $this->hostName, - 'alias' => $this->hostAlias, - 'address' => $this->hostAddress - )); - $this->currentPage->save(); - } - - /** - * @Then the new record is displayed in the hosts list - */ - public function theNewRecordIsDisplayedInTheHostsList() - { - $this->spin( - function ($context) { - $this->currentPage = new HostConfigurationListingPage($this); - return $this->currentPage->getEntry($this->hostName); - }, - "The new host is not displayed in the hosts list.", - 30 - ); - } - - /** - * @Given a host is configured - */ - public function aHostIsConfigured() - { - $this->currentPage = new HostConfigurationPage($this); - $this->currentPage->setProperties(array( - 'name' => $this->hostName, - 'alias' => $this->hostAlias, - 'address' => $this->hostAddress - )); - $this->currentPage->save(); - } - - /** - * @When I duplicate a host - */ - public function iDuplicateAHost() - { - $this->currentPage = new HostConfigurationListingPage($this); - $object = $this->currentPage->getEntry($this->hostName); - $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); - $this->setConfirmBox(true); - $this->selectInList('select[name="o1"]', 'Duplicate'); - } - - /** - * @Then the new host is displayed in the hosts list - */ - public function theNewHostIsDisplayedInTheHostsList() - { - $this->spin( - function ($context) { - $this->currentPage = new HostConfigurationListingPage($this); - return $this->currentPage->getEntry($this->hostName . '_1'); - }, - "The duplicated host was not found.", - 30 - ); - } - - /** - * @When I delete a host - */ - public function iDeleteAHost() - { - $this->currentPage = new HostConfigurationListingPage($this); - $object = $this->currentPage->getEntry($this->hostName); - $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); - $this->setConfirmBox(true); - $this->selectInList('select[name="o1"]', 'Delete'); - } - - /** - * @Then the deleted host is not displayed in the hosts list - */ - public function theDeletedHostIsNotDisplayedInTheHostsList() - { - $this->spin( - function ($context) { - $this->currentPage = new HostConfigurationListingPage($this); - $object = $this->currentPage->getEntries(); - $bool = true; - foreach ($object as $value) { - $bool = $bool && $value['name'] != $this->hostName; - } - return $bool; - }, - "The host was not deleted.", - 30 - ); - } -} diff --git a/features/bootstrap/HostDuplicationCheckContext.php b/features/bootstrap/HostDuplicationCheckContext.php deleted file mode 100644 index 5b23fe4a95c..00000000000 --- a/features/bootstrap/HostDuplicationCheckContext.php +++ /dev/null @@ -1,66 +0,0 @@ - 'hostName', - 'alias' => 'hostAlias', - 'address' => 'host@localhost', - 'enabled' => 1 - ); - - private $updatedProperties = array( - 'name' => 'hostName_1', - 'alias' => 'hostAlias', - 'address' => 'host@localhost', - 'enabled' => 1 - ); - - /** - * @Given a host is created - */ - public function aHostIsCreated() - { - $this->currentPage = new HostConfigurationPage($this); - $this->currentPage->setProperties($this->initialProperties); - $this->currentPage->save(); - } - - /** - * @When I duplicate a host - */ - public function whenIDuplicateAHost() - { - $this->currentPage = new HostConfigurationListingPage($this); - $object = $this->currentPage->getEntry($this->initialProperties['name']); - $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); - $this->setConfirmBox(true); - $this->selectInList('select[name="o1"]', 'Duplicate'); - } - - /** - * @Then the host properties are updated - */ - public function theHostPropertiesAreUpdated() - { - $this->currentPage = new HostConfigurationListingPage($this); - $this->currentPage = $this->currentPage->inspect($this->updatedProperties['name']); - $object = $this->currentPage->getProperties(); - $tableau = array(); - foreach ($this->updatedProperties as $key => $value) { - if ($value != $object[$key]) { - $tableau[] = $key; - } - } - if (count($tableau) > 0) { - throw new \Exception("Some properties are not being updated : " . implode(', ', $tableau)); - } - } -} From fbf876e398c7e7c7202484fd1378b58c9b7874cb Mon Sep 17 00:00:00 2001 From: loiclau Date: Fri, 28 Jul 2017 11:26:51 +0200 Subject: [PATCH 089/207] * fix style host categories --- .../configObject/host_categories/DB-Func.php | 138 ++++++++++++------ .../configObject/host_categories/help.php | 16 +- .../host_categories/hostCategories.php | 22 +-- .../host_categories/listHostCategories.php | 104 +++++++------ 4 files changed, 182 insertions(+), 98 deletions(-) diff --git a/www/include/configuration/configObject/host_categories/DB-Func.php b/www/include/configuration/configObject/host_categories/DB-Func.php index d6a880d979a..bca897bcc8c 100644 --- a/www/include/configuration/configObject/host_categories/DB-Func.php +++ b/www/include/configuration/configObject/host_categories/DB-Func.php @@ -62,7 +62,8 @@ function testHostCategorieExistence($name = null) if (isset($form)) { $id = $form->getSubmitValue('hc_id'); } - $DBRESULT = $pearDB->query("SELECT hc_name, hc_id FROM hostcategories WHERE hc_name = '".CentreonDB::escape($name)."'"); + $query = "SELECT hc_name, hc_id FROM hostcategories WHERE hc_name = '" . CentreonDB::escape($name) . "'"; + $DBRESULT = $pearDB->query($query); $hc = $DBRESULT->fetchRow(); # Modif case if ($DBRESULT->rowCount() >= 1 && $hc["hc_id"] == $id) { @@ -93,12 +94,12 @@ function enableHostCategoriesInDB($hc_id = null, $hc_arr = array()) } if ($hc_id) { - $hc_arr = array($hc_id=>"1"); + $hc_arr = array($hc_id => "1"); } foreach ($hc_arr as $key => $value) { - $DBRESULT = $pearDB->query("UPDATE hostcategories SET hc_activate = '1' WHERE hc_id = '".$key."'"); - $DBRESULT2 = $pearDB->query("SELECT hc_name FROM `hostcategories` WHERE `hc_id` = '".$key."' LIMIT 1"); + $pearDB->query("UPDATE hostcategories SET hc_activate = '1' WHERE hc_id = '" . $key . "'"); + $DBRESULT2 = $pearDB->query("SELECT hc_name FROM `hostcategories` WHERE `hc_id` = '" . $key . "' LIMIT 1"); $row = $DBRESULT2->fetchRow(); $centreon->CentreonLogAction->insertLog("hostcategories", $key, $row['hc_name'], "enable"); } @@ -112,11 +113,11 @@ function disableHostCategoriesInDB($hc_id = null, $hc_arr = array()) return; } if ($hc_id) { - $hc_arr = array($hc_id=>"1"); + $hc_arr = array($hc_id => "1"); } foreach ($hc_arr as $key => $value) { - $DBRESULT = $pearDB->query("UPDATE hostcategories SET hc_activate = '0' WHERE hc_id = '".$key."'"); - $DBRESULT2 = $pearDB->query("SELECT hc_name FROM `hostcategories` WHERE `hc_id` = '".$key."' LIMIT 1"); + $pearDB->query("UPDATE hostcategories SET hc_activate = '0' WHERE hc_id = '" . $key . "'"); + $DBRESULT2 = $pearDB->query("SELECT hc_name FROM `hostcategories` WHERE `hc_id` = '" . $key . "' LIMIT 1"); $row = $DBRESULT2->fetchRow(); $centreon->CentreonLogAction->insertLog("hostcategories", $key, $row['hc_name'], "disable"); } @@ -127,9 +128,9 @@ function deleteHostCategoriesInDB($hostcategoriess = array()) global $pearDB, $centreon; foreach ($hostcategoriess as $key => $value) { - $DBRESULT3 = $pearDB->query("SELECT hc_name FROM `hostcategories` WHERE `hc_id` = '".$key."' LIMIT 1"); + $DBRESULT3 = $pearDB->query("SELECT hc_name FROM `hostcategories` WHERE `hc_id` = '" . $key . "' LIMIT 1"); $row = $DBRESULT3->fetchRow(); - $DBRESULT = $pearDB->query("DELETE FROM hostcategories WHERE hc_id = '".$key."'"); + $pearDB->query("DELETE FROM hostcategories WHERE hc_id = '" . $key . "'"); $centreon->CentreonLogAction->insertLog("hostcategories", $key, $row['hc_name'], "d"); } $centreon->user->access->updateACL(); @@ -141,35 +142,47 @@ function multipleHostCategoriesInDB($hostcategories = array(), $nbrDup = array() $hcAcl = array(); foreach ($hostcategories as $key => $value) { - $DBRESULT = $pearDB->query("SELECT * FROM hostcategories WHERE hc_id = '".$key."' LIMIT 1"); + $DBRESULT = $pearDB->query("SELECT * FROM hostcategories WHERE hc_id = '" . $key . "' LIMIT 1"); $row = $DBRESULT->fetchRow(); $row["hc_id"] = ''; for ($i = 1; $i <= $nbrDup[$key]; $i++) { $val = null; $rq = null; foreach ($row as $key2 => $value2) { - (isset($key2) && $key2 == "hc_name") ? ($hc_name = $value2 = $value2."_".$i) : null; - $val ? $val .= ($value2!=null?(", '".$value2."'"):", NULL") : $val .= ($value2!=null?("'".$value2."'"):"NULL"); + (isset($key2) && $key2 == "hc_name") ? ($hc_name = $value2 = $value2 . "_" . $i) : null; + $val + ? $val .= ($value2 != null ? (", '" . $value2 . "'") : ", NULL") + : $val .= ($value2 != null ? ("'" . $value2 . "'") : "NULL"); if ($key2 != "hc_id") { $fields[$key2] = $value2; } } $fields["hc_name"] = $hc_name; if (testHostCategorieExistence($hc_name)) { - $val ? $rq = "INSERT INTO hostcategories VALUES (".$val.")" : $rq = null; - $DBRESULT = $pearDB->query($rq); + $val ? $rq = "INSERT INTO hostcategories VALUES (" . $val . ")" : $rq = null; + $pearDB->query($rq); $DBRESULT = $pearDB->query("SELECT MAX(hc_id) FROM hostcategories"); $maxId = $DBRESULT->fetchRow(); if (isset($maxId["MAX(hc_id)"])) { - $hcAcl[$maxId["MAX(hc_id)"]] = $key; - $DBRESULT = $pearDB->query("SELECT DISTINCT hgr.host_host_id FROM hostcategories_relation hgr WHERE hgr.hostcategories_hc_id = '".$key."'"); + $hcAcl[$maxId["MAX(hc_id)"]] = $key; + $query = "SELECT DISTINCT hgr.host_host_id FROM hostcategories_relation hgr " . + "WHERE hgr.hostcategories_hc_id = '" . $key . "'"; + $DBRESULT = $pearDB->query($query); $fields["hc_hosts"] = ""; while ($host = $DBRESULT->fetchRow()) { - $DBRESULT2 = $pearDB->query("INSERT INTO hostcategories_relation VALUES ('', '".$maxId["MAX(hc_id)"]."', '".$host["host_host_id"]."')"); + $query = "INSERT INTO hostcategories_relation VALUES ('', '" . $maxId["MAX(hc_id)"] . + "', '" . $host["host_host_id"] . "')"; + $pearDB->query($query); $fields["hc_hosts"] .= $host["host_host_id"] . ","; } $fields["hc_hosts"] = trim($fields["hc_hosts"], ","); - $centreon->CentreonLogAction->insertLog("hostcategories", $maxId["MAX(hc_id)"], $hc_name, "a", $fields); + $centreon->CentreonLogAction->insertLog( + "hostcategories", + $maxId["MAX(hc_id)"], + $hc_name, + "a", + $fields + ); } } } @@ -206,16 +219,28 @@ function insertHostCategories($ret = array()) if (!count($ret)) { $ret = $form->getSubmitValues(); } - + $rq = "INSERT INTO hostcategories "; $rq .= "(hc_name, hc_alias, level, icon_id, hc_comment, hc_activate) "; $rq .= "VALUES ("; - isset($ret["hc_name"]) && $ret["hc_name"] ? $rq .= "'".$pearDB->escape($ret["hc_name"])."', " : $rq .= "NULL,"; - isset($ret["hc_alias"]) && $ret["hc_alias"] ? $rq .= "'".$pearDB->escape($ret["hc_alias"])."', " : $rq .= "NULL,"; - isset($ret["hc_severity_level"]) && $ret["hc_severity_level"] && isset($ret['hc_type']) ? $rq .= "'".$pearDB->escape($ret["hc_severity_level"])."', " : $rq .= "NULL,"; - isset($ret["hc_severity_icon"]) && $ret["hc_severity_icon"] ? $rq .= "'".$pearDB->escape($ret["hc_severity_icon"])."', " : $rq .= "NULL,"; - isset($ret["hc_comment"]) && $ret["hc_comment"] ? $rq .= "'".$pearDB->escape($ret["hc_comment"])."', " : $rq .= "NULL, "; - isset($ret["hc_activate"]["hc_activate"]) && $ret["hc_activate"]["hc_activate"] ? $rq .= "'".$ret["hc_activate"]["hc_activate"]."'" : $rq .= "'0'"; + isset($ret["hc_name"]) && $ret["hc_name"] + ? $rq .= "'" . $pearDB->escape($ret["hc_name"]) . "', " + : $rq .= "NULL,"; + isset($ret["hc_alias"]) && $ret["hc_alias"] + ? $rq .= "'" . $pearDB->escape($ret["hc_alias"]) . "', " + : $rq .= "NULL,"; + isset($ret["hc_severity_level"]) && $ret["hc_severity_level"] && isset($ret['hc_type']) + ? $rq .= "'" . $pearDB->escape($ret["hc_severity_level"]) . "', " + : $rq .= "NULL,"; + isset($ret["hc_severity_icon"]) && $ret["hc_severity_icon"] + ? $rq .= "'" . $pearDB->escape($ret["hc_severity_icon"]) . "', " + : $rq .= "NULL,"; + isset($ret["hc_comment"]) && $ret["hc_comment"] + ? $rq .= "'" . $pearDB->escape($ret["hc_comment"]) . "', " + : $rq .= "NULL, "; + isset($ret["hc_activate"]["hc_activate"]) && $ret["hc_activate"]["hc_activate"] + ? $rq .= "'" . $ret["hc_activate"]["hc_activate"] . "'" + : $rq .= "'0'"; $rq .= ")"; $pearDB->query($rq); @@ -224,8 +249,14 @@ function insertHostCategories($ret = array()) /* Prepare value for changelog */ $fields = CentreonLogAction::prepareChanges($ret); - - $centreon->CentreonLogAction->insertLog("hostcategories", $hc_id["MAX(hc_id)"], CentreonDB::escape($ret["hc_name"]), "a", $fields); + + $centreon->CentreonLogAction->insertLog( + "hostcategories", + $hc_id["MAX(hc_id)"], + CentreonDB::escape($ret["hc_name"]), + "a", + $fields + ); return ($hc_id["MAX(hc_id)"]); } @@ -239,24 +270,42 @@ function updateHostCategories($hc_id) $ret = $form->getSubmitValues(); $rq = "UPDATE hostcategories SET "; $rq .= "hc_name = "; - isset($ret["hc_name"]) && $ret["hc_name"] != null ? $rq .= "'".$pearDB->escape($ret["hc_name"])."', " : $rq .= "NULL, "; + isset($ret["hc_name"]) && $ret["hc_name"] != null + ? $rq .= "'" . $pearDB->escape($ret["hc_name"]) . "', " + : $rq .= "NULL, "; $rq .= "hc_alias = "; - isset($ret["hc_alias"]) && $ret["hc_alias"] != null ? $rq .= "'".$pearDB->escape($ret["hc_alias"])."', " : $rq .= "NULL, "; + isset($ret["hc_alias"]) && $ret["hc_alias"] != null + ? $rq .= "'" . $pearDB->escape($ret["hc_alias"]) . "', " + : $rq .= "NULL, "; $rq .= "level = "; - isset($ret["hc_severity_level"]) && $ret["hc_severity_level"] && isset($ret['hc_type']) ? $rq .= "'".$pearDB->escape($ret["hc_severity_level"])."', " : $rq .= "NULL, "; + isset($ret["hc_severity_level"]) && $ret["hc_severity_level"] && isset($ret['hc_type']) + ? $rq .= "'" . $pearDB->escape($ret["hc_severity_level"]) . "', " + : $rq .= "NULL, "; $rq .= "icon_id = "; - isset($ret["hc_severity_icon"]) && $ret["hc_severity_icon"] ? $rq .= "'".$pearDB->escape($ret["hc_severity_icon"])."', " : $rq .= "NULL, "; + isset($ret["hc_severity_icon"]) && $ret["hc_severity_icon"] + ? $rq .= "'" . $pearDB->escape($ret["hc_severity_icon"]) . "', " + : $rq .= "NULL, "; $rq .= "hc_comment = "; - isset($ret["hc_comment"]) && $ret["hc_comment"] != null ? $rq .= "'".$pearDB->escape($ret["hc_comment"])."', " : $rq .= "NULL, "; + isset($ret["hc_comment"]) && $ret["hc_comment"] != null + ? $rq .= "'" . $pearDB->escape($ret["hc_comment"]) . "', " + : $rq .= "NULL, "; $rq .= "hc_activate = "; - isset($ret["hc_activate"]["hc_activate"]) && $ret["hc_activate"]["hc_activate"] != null ? $rq .= "'".$ret["hc_activate"]["hc_activate"]."'" : $rq .= "NULL "; - $rq .= "WHERE hc_id = '".$hc_id."'"; - $DBRESULT = $pearDB->query($rq); + isset($ret["hc_activate"]["hc_activate"]) && $ret["hc_activate"]["hc_activate"] != null + ? $rq .= "'" . $ret["hc_activate"]["hc_activate"] . "'" + : $rq .= "NULL "; + $rq .= "WHERE hc_id = '" . $hc_id . "'"; + $pearDB->query($rq); /* Prepare value for changelog */ $fields = CentreonLogAction::prepareChanges($ret); - - $centreon->CentreonLogAction->insertLog("hostcategories", $hc_id, CentreonDB::escape($ret["hc_name"]), "c", $fields); + + $centreon->CentreonLogAction->insertLog( + "hostcategories", + $hc_id, + CentreonDB::escape($ret["hc_name"]), + "c", + $fields + ); } function updateHostCategoriesHosts($hc_id, $ret = array()) @@ -274,7 +323,8 @@ function updateHostCategoriesHosts($hc_id, $ret = array()) * Get initial Host list to make a diff after deletion */ $hostsOLD = array(); - $DBRESULT = $pearDB->query("SELECT host_host_id FROM hostcategories_relation WHERE hostcategories_hc_id = '".$hc_id."'"); + $query = "SELECT host_host_id FROM hostcategories_relation WHERE hostcategories_hc_id = '" . $hc_id . "'"; + $DBRESULT = $pearDB->query($query); while ($host = $DBRESULT->fetchRow()) { $hostsOLD[$host["host_host_id"]] = $host["host_host_id"]; } @@ -283,9 +333,9 @@ function updateHostCategoriesHosts($hc_id, $ret = array()) /* * Update Host HG relations */ - $pearDB->query("DELETE FROM hostcategories_relation WHERE hostcategories_hc_id = '".$hc_id."'"); + $pearDB->query("DELETE FROM hostcategories_relation WHERE hostcategories_hc_id = '" . $hc_id . "'"); + - $ret = isset($ret["hc_hosts"]) ? $ret["hc_hosts"] : CentreonUtils::mergeWithInitialValues($form, 'hc_hosts'); $hgNEW = array(); @@ -294,20 +344,22 @@ function updateHostCategoriesHosts($hc_id, $ret = array()) if ($i != 0) { $rq .= ", "; } - $rq .= " ('".$hc_id."', '".$ret[$i]."')"; + $rq .= " ('" . $hc_id . "', '" . $ret[$i] . "')"; $hostsNEW[$ret[$i]] = $ret[$i]; } if ($i != 0) { $DBRESULT = $pearDB->query($rq); } - isset($ret["hc_hostsTemplate"]) ? $ret = $ret["hc_hostsTemplate"] : $ret = $form->getSubmitValue("hc_hostsTemplate"); + isset($ret["hc_hostsTemplate"]) + ? $ret = $ret["hc_hostsTemplate"] + : $ret = $form->getSubmitValue("hc_hostsTemplate"); $rq = "INSERT INTO hostcategories_relation (hostcategories_hc_id, host_host_id) VALUES "; for ($i = 0; $i < count($ret); $i++) { if ($i != 0) { $rq .= ", "; } - $rq .= " ('".$hc_id."', '".$ret[$i]."')"; + $rq .= " ('" . $hc_id . "', '" . $ret[$i] . "')"; $hostsNEW[$ret[$i]] = $ret[$i]; } diff --git a/www/include/configuration/configObject/host_categories/help.php b/www/include/configuration/configObject/host_categories/help.php index 285e395f263..93cd073a52e 100644 --- a/www/include/configuration/configObject/host_categories/help.php +++ b/www/include/configuration/configObject/host_categories/help.php @@ -1,11 +1,21 @@ escape($search)."%' OR hc_alias LIKE '%".$pearDB->escape($search)."%')"; + $SearchTool = " WHERE (hc_name LIKE '%" . $pearDB->escape($search) . "%' OR hc_alias LIKE '%" . + $pearDB->escape($search) . "%')"; } $hcFilter = ""; @@ -97,12 +98,13 @@ /* * Hostgroup list */ -$rq = "SELECT hc_id, hc_name, hc_alias, level, hc_activate FROM hostcategories $SearchTool $hcFilter ORDER BY hc_name LIMIT ".$num * $limit .", $limit"; -$DBRESULT = $pearDB->query($rq); +$query = "SELECT hc_id, hc_name, hc_alias, level, hc_activate FROM hostcategories $SearchTool $hcFilter " . + "ORDER BY hc_name LIMIT " . $num * $limit . ", $limit"; +$DBRESULT = $pearDB->query($query); $search = tidySearchKey($search, $advanced_search); -$form = new HTML_QuickForm('select_form', 'POST', "?p=".$p); +$form = new HTML_QuickForm('select_form', 'POST', "?p=" . $p); /* * Different style between each lines */ @@ -113,14 +115,20 @@ */ $elemArr = array(); for ($i = 0; $hc = $DBRESULT->fetchRow(); $i++) { - $selectedElements = $form->addElement('checkbox', "select[".$hc['hc_id']."]"); + $selectedElements = $form->addElement('checkbox', "select[" . $hc['hc_id'] . "]"); $moptions = ""; if ($hc["hc_activate"]) { - $moptions .= "
"._("Disabled").""; + $moptions .= "" . _("Disabled") . ""; } else { - $moptions .= ""._("Enabled").""; + $moptions .= "" . _("Enabled") . ""; } - $moptions .= " 31 && (event.keyCode < 45 || event.keyCode > 57)) event.returnValue = false; if(event.which > 31 && (event.which < 45 || event.which > 57)) return false;\" maxlength=\"3\" size=\"3\" value='1' style=\"margin-bottom:0px;\" name='dupNbr[".$hc['hc_id']."]'>"; + $moptions .= " 31 && (event.keyCode < 45 || event.keyCode > 57)) " . + "event.returnValue = false; if(event.which > 31 && (event.which < 45 || event.which > 57)) return false;" . + "\" maxlength=\"3\" size=\"3\" value='1' style=\"margin-bottom:0px;\" name='dupNbr[" . $hc['hc_id'] . "]' />"; /* * Check Nbr of Host / hc @@ -134,11 +142,11 @@ $aclCond = ""; if (!$centreon->user->admin) { $aclFrom = ", $aclDbName.centreon_acl acl "; - $aclCond = " AND h.host_id = acl.host_id AND acl.group_id IN (".$acl->getAccessGroupsString().") "; + $aclCond = " AND h.host_id = acl.host_id AND acl.group_id IN (" . $acl->getAccessGroupsString() . ") "; } $rq = "SELECT h.host_id, h.host_activate FROM hostcategories_relation hcr, host h $aclFrom - WHERE hostcategories_hc_id = '".$hc['hc_id']."' + WHERE hostcategories_hc_id = '" . $hc['hc_id'] . "' AND h.host_id = hcr.host_host_id $aclCond AND h.host_register = '1' "; $DBRESULT2 = $pearDB->query($rq); @@ -154,17 +162,19 @@ $nbrhostAct = count($nbrhostActArr); $nbrhostDeact = count($nbrhostDeactArr); - $elemArr[$i] = array("MenuClass"=>"list_".$style, - "RowMenu_select"=>$selectedElements->toHtml(), - "RowMenu_name"=>CentreonUtils::escapeSecure($hc["hc_name"]), - "RowMenu_link"=>"?p=".$p."&o=c&hc_id=".$hc['hc_id'], - "RowMenu_desc"=>CentreonUtils::escapeSecure($hc["hc_alias"]), - "RowMenu_hc_type"=>($hc["level"] ? _('Severity') . ' ('.$hc['level'].')' : _('Regular')), - "RowMenu_status"=>$hc["hc_activate"] ? _("Enabled") : _("Disabled"), - "RowMenu_badge" => $hc["hc_activate"] ? "service_ok" : "service_critical", - "RowMenu_hostAct"=>$nbrhostAct, - "RowMenu_hostDeact"=>$nbrhostDeact, - "RowMenu_options"=>$moptions); + $elemArr[$i] = array( + "MenuClass" => "list_" . $style, + "RowMenu_select" => $selectedElements->toHtml(), + "RowMenu_name" => CentreonUtils::escapeSecure($hc["hc_name"]), + "RowMenu_link" => "?p=" . $p . "&o=c&hc_id=" . $hc['hc_id'], + "RowMenu_desc" => CentreonUtils::escapeSecure($hc["hc_alias"]), + "RowMenu_hc_type" => ($hc["level"] ? _('Severity') . ' (' . $hc['level'] . ')' : _('Regular')), + "RowMenu_status" => $hc["hc_activate"] ? _("Enabled") : _("Disabled"), + "RowMenu_badge" => $hc["hc_activate"] ? "service_ok" : "service_critical", + "RowMenu_hostAct" => $nbrhostAct, + "RowMenu_hostDeact" => $nbrhostDeact, + "RowMenu_options" => $moptions + ); /* * Switch color line */ @@ -175,31 +185,43 @@ /* * Different messages we put in the template */ -$tpl->assign('msg', array ("addL"=>"?p=".$p."&o=a", "addT"=>_("Add"), "delConfirm"=>_("Do you confirm the deletion ?"))); +$tpl->assign( + 'msg', + array("addL" => "?p=" . $p . "&o=a", "addT" => _("Add"), "delConfirm" => _("Do you confirm the deletion ?")) +); ?> - + "javascript: " . - "var bChecked = isChecked(); ". - "if (this.form.elements['".$option."'].selectedIndex != 0 && !bChecked) {". - " alert('"._("Please select one or more items")."'); return false;} " . - "if (this.form.elements['".$option."'].selectedIndex == 1 && confirm('"._("Do you confirm the duplication ?")."')) {" . - " setO(this.form.elements['".$option."'].value); submit();} " . - "else if (this.form.elements['".$option."'].selectedIndex == 2 && confirm('"._("Do you confirm the deletion ?")."')) {" . - " setO(this.form.elements['".$option."'].value); submit();} " . - "else if (this.form.elements['".$option."'].selectedIndex == 3) {" . - " setO(this.form.elements['".$option."'].value); submit();} " . - "else if (this.form.elements['".$option."'].selectedIndex == 4) {" . - " setO(this.form.elements['".$option."'].value); submit();} " . - "this.form.elements['".$option."'].selectedIndex = 0"); - $form->addElement('select', $option, null, array(null=>_("More actions..."), "m"=>_("Duplicate"), "d"=>_("Delete"), "ms"=>_("Enable"), "mu"=>_("Disable")), $attrs1); + 'onchange' => "javascript: " . + "var bChecked = isChecked(); " . + "if (this.form.elements['" . $option . "'].selectedIndex != 0 && !bChecked) {" . + " alert('" . _("Please select one or more items") . "'); return false;} " . + "if (this.form.elements['" . $option . "'].selectedIndex == 1 && confirm('" . + _("Do you confirm the duplication ?") . "')) {" . + " setO(this.form.elements['" . $option . "'].value); submit();} " . + "else if (this.form.elements['" . $option . "'].selectedIndex == 2 && confirm('" . + _("Do you confirm the deletion ?") . "')) {" . + " setO(this.form.elements['" . $option . "'].value); submit();} " . + "else if (this.form.elements['" . $option . "'].selectedIndex == 3) {" . + " setO(this.form.elements['" . $option . "'].value); submit();} " . + "else if (this.form.elements['" . $option . "'].selectedIndex == 4) {" . + " setO(this.form.elements['" . $option . "'].value); submit();} " . + "this.form.elements['" . $option . "'].selectedIndex = 0" + ); + $form->addElement('select', $option, null, array( + null => _("More actions..."), + "m" => _("Duplicate"), + "d" => _("Delete"), + "ms" => _("Enable"), + "mu" => _("Disable") + ), $attrs1); $form->setDefaults(array($option => null)); $o1 = $form->getElement($option); $o1->setValue(null); From fd5150e397533923e0e18f53d1e72ba6fc402ae8 Mon Sep 17 00:00:00 2001 From: loiclau Date: Fri, 28 Jul 2017 13:54:17 +0200 Subject: [PATCH 090/207] * fix style host template --- .../host_template_model/hostTemplateModel.php | 26 ++-- .../listHostTemplateModel.php | 111 +++++++++++------- 2 files changed, 82 insertions(+), 55 deletions(-) diff --git a/www/include/configuration/configObject/host_template_model/hostTemplateModel.php b/www/include/configuration/configObject/host_template_model/hostTemplateModel.php index c0a67943c55..bdd9e7a7ac0 100755 --- a/www/include/configuration/configObject/host_template_model/hostTemplateModel.php +++ b/www/include/configuration/configObject/host_template_model/hostTemplateModel.php @@ -32,7 +32,7 @@ * For more information : contact@centreon.com * */ - + if (!isset($centreon)) { exit(); } @@ -59,7 +59,7 @@ $path2 = "./include/configuration/configObject/host/"; /* PHP functions */ -require_once $path2."DB-Func.php"; +require_once $path2 . "DB-Func.php"; require_once "./include/common/common-Func.php"; $hostObj = new CentreonHost($pearDB); @@ -72,42 +72,42 @@ switch ($o) { case "a": - require_once($path."formHostTemplateModel.php"); + require_once($path . "formHostTemplateModel.php"); break; #Add a host template model case "w": - require_once($path."formHostTemplateModel.php"); + require_once($path . "formHostTemplateModel.php"); break; #Watch a host template model case "c": - require_once($path."formHostTemplateModel.php"); + require_once($path . "formHostTemplateModel.php"); break; #Modify a host template model case "mc": - require_once($path."formHostTemplateModel.php"); + require_once($path . "formHostTemplateModel.php"); break; #Massive change case "s": enableHostInDB($host_id); - require_once($path."listHostTemplateModel.php"); + require_once($path . "listHostTemplateModel.php"); break; #Activate a host template model case "ms": enableHostInDB(null, isset($select) ? $select : array()); - require_once($path."listHostTemplateModel.php"); + require_once($path . "listHostTemplateModel.php"); break; case "u": disableHostInDB($host_id); - require_once($path."listHostTemplateModel.php"); + require_once($path . "listHostTemplateModel.php"); break; #Desactivate a host template model case "mu": disableHostInDB(null, isset($select) ? $select : array()); - require_once($path."listHostTemplateModel.php"); + require_once($path . "listHostTemplateModel.php"); break; case "m": multipleHostInDB(isset($select) ? $select : array(), $dupNbr); - require_once($path."listHostTemplateModel.php"); + require_once($path . "listHostTemplateModel.php"); break; #Duplicate n host template model case "d": deleteHostInDB(isset($select) ? $select : array()); - require_once($path."listHostTemplateModel.php"); + require_once($path . "listHostTemplateModel.php"); break; #Delete n host template models default: - require_once($path."listHostTemplateModel.php"); + require_once($path . "listHostTemplateModel.php"); break; } diff --git a/www/include/configuration/configObject/host_template_model/listHostTemplateModel.php b/www/include/configuration/configObject/host_template_model/listHostTemplateModel.php index 3e52be02e38..907caf986fa 100755 --- a/www/include/configuration/configObject/host_template_model/listHostTemplateModel.php +++ b/www/include/configuration/configObject/host_template_model/listHostTemplateModel.php @@ -61,14 +61,15 @@ if (isset($_POST['searchHT'])) { $search = $_POST['searchHT']; $_SESSION['searchHT'] = $_POST['searchHT']; -} else if (isset($_SESSION['searchHT']) && $_SESSION['searchHT'] != "") { +} elseif (isset($_SESSION['searchHT']) && $_SESSION['searchHT'] != "") { $search = $_SESSION['searchHT']; } $query = "SELECT COUNT(*) " . "FROM host " . "WHERE host_register = '0' " - . "AND (host_name LIKE '%".CentreonDB::escape($search)."%' OR host_alias LIKE '%".CentreonDB::escape($search)."%') "; + . "AND (host_name LIKE '%" . CentreonDB::escape($search) . "%' OR host_alias LIKE '%" . + CentreonDB::escape($search) . "%') "; $DBRESULT = $pearDB->query($query); $tmp = $DBRESULT->fetchRow(); $rows = $tmp["COUNT(*)"]; @@ -99,15 +100,19 @@ * Host Template list */ if ($search) { - $rq = "SELECT host_id, host_name, host_alias, host_activate, host_template_model_htm_id FROM host WHERE (host_name LIKE '%".CentreonDB::escape($search)."%' OR host_alias LIKE '%".CentreonDB::escape($search)."%') AND host_register = '0' ORDER BY host_name LIMIT ".$num * $limit.", ".$limit; + $rq = "SELECT host_id, host_name, host_alias, host_activate, host_template_model_htm_id FROM host " . + "WHERE (host_name LIKE '%" . CentreonDB::escape($search) . "%' OR host_alias LIKE '%" . + CentreonDB::escape($search) . "%') AND host_register = '0' ORDER BY host_name LIMIT " . $num * $limit . + ", " . $limit; } else { - $rq = "SELECT host_id, host_name, host_alias, host_activate, host_template_model_htm_id FROM host WHERE host_register = '0' ORDER BY host_name LIMIT ".$num * $limit.", ".$limit; + $rq = "SELECT host_id, host_name, host_alias, host_activate, host_template_model_htm_id FROM host " . + "WHERE host_register = '0' ORDER BY host_name LIMIT " . $num * $limit . ", " . $limit; } $DBRESULT = $pearDB->query($rq); $search = tidySearchKey($search, $advanced_search); -$form = new HTML_QuickForm('select_form', 'POST', "?p=".$p); +$form = new HTML_QuickForm('select_form', 'POST', "?p=" . $p); /* Different style between each lines */ $style = "one"; @@ -116,17 +121,24 @@ $elemArr = array(); for ($i = 0; $host = $DBRESULT->fetchRow(); $i++) { $moptions = ""; - $selectedElements = $form->addElement('checkbox', "select[".$host['host_id']."]"); + $selectedElements = $form->addElement('checkbox', "select[" . $host['host_id'] . "]"); if (isset($lockedElements[$host['host_id']])) { $selectedElements->setAttribute('disabled', 'disabled'); } else { if ($host["host_activate"]) { - $moptions .= ""._("Disabled")."  "; + $moptions .= "" . _("Disabled") . "  "; } else { - $moptions .= ""._("Enabled")."  "; + $moptions .= "" . _("Enabled") . "  "; } $moptions .= " "; - $moptions .= " 31 && (event.keyCode < 45 || event.keyCode > 57)) event.returnValue = false; if(event.which > 31 && (event.which < 45 || event.which > 57)) return false;\" maxlength=\"3\" size=\"3\" value='1' style=\"margin-bottom:0px;\" name='dupNbr[".$host['host_id']."]'>"; + $moptions .= " 31 && (event.keyCode < 45 || event.keyCode > 57)) " . + "event.returnValue = false; if(event.which > 31 && (event.which < 45 || event.which > 57)) " . + "return false;\" maxlength=\"3\" size=\"3\" value='1' style=\"margin-bottom:0px;\" " . + "name='dupNbr[" . $host['host_id'] . "]' />"; } # If the name of our Host Model is in the Template definition, we have to catch it, whatever the level of it :-) if (!$host["host_name"]) { @@ -142,10 +154,10 @@ $firstTpl = 1; foreach ($tplArr as $key => $value) { if ($firstTpl) { - $tplStr .= "".$value.""; + $tplStr .= "" . $value . ""; $firstTpl = 0; } else { - $tplStr .= " | ".$value.""; + $tplStr .= " | " . $value . ""; } } } @@ -155,7 +167,11 @@ */ if ((isset($ehiCache[$host["host_id"]]) && $ehiCache[$host["host_id"]])) { $host_icone = "./img/media/" . $mediaObj->getFilename($ehiCache[$host["host_id"]]); - } elseif ($icone = $host_method->replaceMacroInString($host["host_id"], getMyHostExtendedInfoImage($host["host_id"], "ehi_icon_image", 1))) { + } elseif ($icone = $host_method->replaceMacroInString( + $host["host_id"], + getMyHostExtendedInfoImage($host["host_id"], "ehi_icon_image", 1) + ) + ) { $host_icone = "./img/media/" . $icone; } else { $host_icone = "./img/icons/host.png"; @@ -167,57 +183,68 @@ $svArr = array(); $svStr = null; $svArr = getMyHostServices($host['host_id']); - $elemArr[$i] = array("MenuClass" => "list_".$style, - "RowMenu_select" => $selectedElements->toHtml(), - "RowMenu_name" => CentreonUtils::escapeSecure($host["host_name"]), - "RowMenu_link" => "?p=".$p."&o=c&host_id=".$host['host_id'], - "RowMenu_desc" => CentreonUtils::escapeSecure($host["host_alias"]), - "RowMenu_icone" => $host_icone, - "RowMenu_svChilds" => count($svArr), - "RowMenu_parent" => CentreonUtils::escapeSecure($tplStr), - "RowMenu_status" => $host["host_activate"] ? _("Enabled") : _("Disabled"), - "RowMenu_badge" => $host["host_activate"] ? "service_ok" : "service_critical", - "RowMenu_options" => $moptions); + $elemArr[$i] = array( + "MenuClass" => "list_" . $style, + "RowMenu_select" => $selectedElements->toHtml(), + "RowMenu_name" => CentreonUtils::escapeSecure($host["host_name"]), + "RowMenu_link" => "?p=" . $p . "&o=c&host_id=" . $host['host_id'], + "RowMenu_desc" => CentreonUtils::escapeSecure($host["host_alias"]), + "RowMenu_icone" => $host_icone, + "RowMenu_svChilds" => count($svArr), + "RowMenu_parent" => CentreonUtils::escapeSecure($tplStr), + "RowMenu_status" => $host["host_activate"] ? _("Enabled") : _("Disabled"), + "RowMenu_badge" => $host["host_activate"] ? "service_ok" : "service_critical", + "RowMenu_options" => $moptions + ); $style != "two" ? $style = "two" : $style = "one"; } $tpl->assign("elemArr", $elemArr); /* Different messages we put in the template */ -$tpl->assign('msg', array ("addL"=>"?p=".$p."&o=a", "addT"=>_("Add"), "delConfirm"=>_("Do you confirm the deletion ?"))); +$tpl->assign( + 'msg', + array("addL" => "?p=" . $p . "&o=a", "addT" => _("Add"), "delConfirm" => _("Do you confirm the deletion ?")) +); # ## Toolbar select # ?> - + "javascript: " . - "var bChecked = isChecked();". - "if (this.form.elements['$option'].selectedIndex != 0 && !bChecked) {". - " alert('"._("Please select one or more items")."'); return false;} " . - "if (this.form.elements['$option'].selectedIndex == 1 && confirm('"._("Do you confirm the duplication ?")."')) {" . + "var bChecked = isChecked();" . + "if (this.form.elements['$option'].selectedIndex != 0 && !bChecked) {" . + " alert('" . _("Please select one or more items") . "'); return false;} " . + "if (this.form.elements['$option'].selectedIndex == 1 && confirm('" . + _("Do you confirm the duplication ?") . "')) {" . " setO(this.form.elements['$option'].value); submit();} " . - "else if (this.form.elements['$option'].selectedIndex == 2 && confirm('"._("Do you confirm the deletion ?")."')) {" . + "else if (this.form.elements['$option'].selectedIndex == 2 && confirm('" . + _("Do you confirm the deletion ?") . "')) {" . " setO(this.form.elements['$option'].value); submit();} " . - "else if (this.form.elements['$option'].selectedIndex == 3 || this.form.elements['$option'].selectedIndex == 4 || this.form.elements['$option'].selectedIndex == 5){" . + "else if (this.form.elements['$option'].selectedIndex == 3 || " . + "this.form.elements['$option'].selectedIndex == 4 || this.form.elements['$option'].selectedIndex == 5){" . " setO(this.form.elements['$option'].value); submit();} " . - "this.form.elements['o1'].selectedIndex = 0"); + "this.form.elements['o1'].selectedIndex = 0" + ); $form->addElement( 'select', $option, null, - array( null => _("More actions..."), - "m" => _("Duplicate"), - "d" => _("Delete"), - "mc" => _("Massive Change"), - "ms" => _("Enable"), - "mu" => _("Disable")), + array( + null => _("More actions..."), + "m" => _("Duplicate"), + "d" => _("Delete"), + "mc" => _("Massive Change"), + "ms" => _("Enable"), + "mu" => _("Disable") + ), $attrs1 ); $form->setDefaults(array($option => null)); From 323f8a956962b32be5ce15427dde6099ee486aab Mon Sep 17 00:00:00 2001 From: mariegallardo Date: Fri, 28 Jul 2017 14:58:22 +0200 Subject: [PATCH 091/207] Feature created (#5467) --- behat.yml | 7 +- features/HostGroupConfiguration.feature | 20 ++ .../HostGroupConfigurationContext.php | 195 ++++++++++++++++++ 3 files changed, 221 insertions(+), 1 deletion(-) create mode 100644 features/HostGroupConfiguration.feature create mode 100644 features/bootstrap/HostGroupConfigurationContext.php diff --git a/behat.yml b/behat.yml index ce458bac5cf..b2b9af670b5 100644 --- a/behat.yml +++ b/behat.yml @@ -184,11 +184,16 @@ default: contexts: - HostConfigurationContext - host_category: + host_category_configuration: paths: [ %paths.base%/features/HostCategoryConfiguration.feature ] contexts: - HostCategoryConfigurationContext + host_group_configuration: + paths: [ %paths.base%/features/HostGroupConfiguration.feature ] + contexts: + - HostGroupConfigurationContext + contact_group_configuration: paths: [ %paths.base%/features/ContactGroupConfiguration.feature ] contexts: diff --git a/features/HostGroupConfiguration.feature b/features/HostGroupConfiguration.feature new file mode 100644 index 00000000000..ce3962453bb --- /dev/null +++ b/features/HostGroupConfiguration.feature @@ -0,0 +1,20 @@ +Feature: HostGroupConfiguration + As a Centreon admin + I want to modify an host group + To see if the modification is saved on the host group page + + Background: + Given I am logged in a Centreon server + And an host group is configured + + Scenario: Edit the properties of an host group + When I change the properties of a host group + Then its properties are updated + + Scenario: Duplicate one existing host group + When I duplicate a host group + Then a new host is created with identical properties + + Scenario: Delete one existing host group + When I delete the host group + Then the host group is not visible anymore diff --git a/features/bootstrap/HostGroupConfigurationContext.php b/features/bootstrap/HostGroupConfigurationContext.php new file mode 100644 index 00000000000..7ad7a08abf4 --- /dev/null +++ b/features/bootstrap/HostGroupConfigurationContext.php @@ -0,0 +1,195 @@ + 'host1Name', + 'alias' => 'host1Alias', + 'address' => 'host1@localhost' + ); + + protected $host2 = array( + 'name' => 'host2Name', + 'alias' => 'host2Alias', + 'address' => 'host2@localhost' + ); + + protected $initialProperties = array( + 'name' => 'hostGroupName', + 'alias' => 'hostGroupAlias', + 'hosts' => 'host2Name', + 'notes' => 'hostGroupNotes', + 'notes_url' => 'hostGroupNotesUrl', + 'action_url' => 'hostGroupActionUrl', + 'icon' => '', + 'map_icon' => ' centreon (png)', + 'geo_coordinates' => 'Paris', + 'rrd_retention' => 80, + 'comments' => 'hostGroupComments', + 'enabled' => 1 + ); + + protected $duplicatedProperties = array( + 'name' => 'hostGroupName_1', + 'alias' => 'hostGroupAlias', + 'hosts' => 'host2Name', + 'notes' => 'hostGroupNotes', + 'notes_url' => 'hostGroupNotesUrl', + 'action_url' => 'hostGroupActionUrl', + 'icon' => '', + 'map_icon' => ' centreon (png)', + 'geo_coordinates' => 'Paris', + 'rrd_retention' => 80, + 'comments' => 'hostGroupComments', + 'enabled' => 1 + ); + + protected $updatedProperties = array( + 'name' => 'hostGroupNameChanged', + 'alias' => 'hostGroupAliasChanged', + 'hosts' => 'host1Name', + 'notes' => 'hostGroupNotesChanged', + 'notes_url' => 'hostGroupNotesUrlchanged', + 'action_url' => 'hostGroupActionUrlChanged', + 'icon' => ' centreon (png)', + 'map_icon' => '', + 'geo_coordinates' => '1.2.3', + 'rrd_retention' => 45, + 'comments' => 'hostGroupCommentsChanged', + 'enabled' => 0 + ); + + /** + * @Given an host group is configured + */ + public function anHostGroupIsConfigured() + { + $this->currentPage = new HostConfigurationPage($this); + $this->currentPage->setproperties($this->host1); + $this->currentPage->save(); + $this->currentPage = new HostConfigurationPage($this); + $this->currentPage->setProperties($this->host2); + $this->currentPage->save(); + $this->currentPage = new HostGroupConfigurationPage($this); + $this->currentPage->setProperties($this->initialProperties); + $this->currentPage->save(); + } + + /** + * @When I change the properties of a host group + */ + public function iChangeThePropertiesOfAHostGroup() + { + $this->currentPage = new HostGroupConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['name']); + $this->currentPage->setProperties($this->updatedProperties); + $this->currentPage->save(); + } + + /** + * @Then its properties are updated + */ + public function itsPropertiesAreUpdated() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new HostGroupConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->updatedProperties['name']); + $object = $this->currentPage->getProperties(); + foreach ($this->updatedProperties as $key => $value) { + if ($value != $object[$key]) { + $this->tableau[] = $key; + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I duplicate a host group + */ + public function iDuplicateAHostGroup() + { + $this->currentPage = new HostGroupConfigurationListingPage($this); + $object = $this->currentPage->getEntry($this->initialProperties['name']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Duplicate'); + } + + /** + * @Then a new host is created with identical properties + */ + public function aNewHostIsCreatedWithIdenticalProperties() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new HostGroupConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->duplicatedProperties['name']); + $object = $this->currentPage->getProperties(); + foreach ($this->duplicatedProperties as $key => $value) { + if ($value != $object[$key]) { + $this->tableau[] = $key; + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I delete the host group + */ + public function iDeleteTheHostGroup() + { + $this->currentPage = new HostGroupConfigurationListingPage($this); + $object = $this->currentPage->getEntry($this->initialProperties['name']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Delete'); + } + + /** + * @Then the host group is not visible anymore + */ + public function theHostGroupIsNotVisibleAnymore() + { + $this->spin( + function ($context) { + $this->currentPage = new HostGroupConfigurationListingPage($this); + $object = $this->currentPage->getEntries(); + $bool = true; + foreach ($object as $value) { + $bool = $bool && $value['name'] != $this->initialProperties['name']; + } + return $bool; + }, + "The host group is not being deleted.", + 5 + ); + } +} From 4975281042dba1ee8282def04f09f2a27a8e3d1d Mon Sep 17 00:00:00 2001 From: loiclau Date: Fri, 28 Jul 2017 15:16:47 +0200 Subject: [PATCH 092/207] * fix style meta service dependency --- .../metaservice_dependency/DB-Func.php | 119 +++++++---- .../MetaServiceDependency.php | 14 +- .../formMetaServiceDependency.php | 194 +++++++++++++----- .../listMetaServiceDependency.php | 126 +++++++----- 4 files changed, 304 insertions(+), 149 deletions(-) diff --git a/www/include/configuration/configObject/metaservice_dependency/DB-Func.php b/www/include/configuration/configObject/metaservice_dependency/DB-Func.php index b0ea2e3f849..f42cc904126 100644 --- a/www/include/configuration/configObject/metaservice_dependency/DB-Func.php +++ b/www/include/configuration/configObject/metaservice_dependency/DB-Func.php @@ -32,11 +32,11 @@ * For more information : contact@centreon.com * */ - + if (!isset($oreon)) { exit(); } - + function testExistence($name = null) { global $pearDB; @@ -48,7 +48,9 @@ function testExistence($name = null) if (isset($form)) { $id = $form->getSubmitValue('dep_id'); } - $DBRESULT = $pearDB->query("SELECT dep_name, dep_id FROM dependency WHERE dep_name = '".htmlentities($name, ENT_QUOTES, "UTF-8")."'"); + $query = "SELECT dep_name, dep_id FROM dependency WHERE dep_name = '" . + htmlentities($name, ENT_QUOTES, "UTF-8") . "'"; + $DBRESULT = $pearDB->query($query); $dep = $DBRESULT->fetchRow(); #Modif case if ($DBRESULT->rowCount() >= 1 && $dep["dep_id"] == $id) { @@ -60,7 +62,7 @@ function testExistence($name = null) return true; } } - + function testCycle($childs = null) { global $pearDB; @@ -84,37 +86,47 @@ function deleteMetaServiceDependencyInDB($dependencies = array()) { global $pearDB; foreach ($dependencies as $key => $value) { - $DBRESULT = $pearDB->query("DELETE FROM dependency WHERE dep_id = '".$key."'"); + $DBRESULT = $pearDB->query("DELETE FROM dependency WHERE dep_id = '" . $key . "'"); } } - + function multipleMetaServiceDependencyInDB($dependencies = array(), $nbrDup = array()) { foreach ($dependencies as $key => $value) { global $pearDB; - $DBRESULT = $pearDB->query("SELECT * FROM dependency WHERE dep_id = '".$key."' LIMIT 1"); + $DBRESULT = $pearDB->query("SELECT * FROM dependency WHERE dep_id = '" . $key . "' LIMIT 1"); $row = $DBRESULT->fetchRow(); $row["dep_id"] = ''; for ($i = 1; $i <= $nbrDup[$key]; $i++) { $val = null; foreach ($row as $key2 => $value2) { - $key2 == "dep_name" ? ($dep_name = $value2 = $value2."_".$i) : null; - $val ? $val .= ($value2!=null?(", '".$value2."'"):", NULL") : $val .= ($value2!=null?("'".$value2."'"):"NULL"); + $key2 == "dep_name" ? ($dep_name = $value2 = $value2 . "_" . $i) : null; + $val + ? $val .= ($value2 != null ? (", '" . $value2 . "'") : ", NULL") + : $val .= ($value2 != null ? ("'" . $value2 . "'") : "NULL"); } if (testExistence($dep_name)) { - $val ? $rq = "INSERT INTO dependency VALUES (".$val.")" : $rq = null; - $DBRESULT = $pearDB->query($rq); + $val ? $rq = "INSERT INTO dependency VALUES (" . $val . ")" : $rq = null; + $pearDB->query($rq); $DBRESULT = $pearDB->query("SELECT MAX(dep_id) FROM dependency"); $maxId = $DBRESULT->fetchRow(); if (isset($maxId["MAX(dep_id)"])) { - $DBRESULT = $pearDB->query("SELECT DISTINCT meta_service_meta_id FROM dependency_metaserviceParent_relation WHERE dependency_dep_id = '".$key."'"); + $query = "SELECT DISTINCT meta_service_meta_id FROM dependency_metaserviceParent_relation " . + "WHERE dependency_dep_id = '" . $key . "'"; + $DBRESULT = $pearDB->query($query); while ($ms = $DBRESULT->fetchRow()) { - $DBRESULT2 = $pearDB->query("INSERT INTO dependency_metaserviceParent_relation VALUES ('', '".$maxId["MAX(dep_id)"]."', '".$ms["meta_service_meta_id"]."')"); + $query = "INSERT INTO dependency_metaserviceParent_relation " . + "VALUES ('', '" . $maxId["MAX(dep_id)"] . "', '" . $ms["meta_service_meta_id"] . "')"; + $pearDB->query($query); } $DBRESULT->closeCursor(); - $DBRESULT = $pearDB->query("SELECT DISTINCT meta_service_meta_id FROM dependency_metaserviceChild_relation WHERE dependency_dep_id = '".$key."'"); + $query = "SELECT DISTINCT meta_service_meta_id FROM dependency_metaserviceChild_relation " . + "WHERE dependency_dep_id = '" . $key . "'"; + $DBRESULT = $pearDB->query($query); while ($ms = $DBRESULT->fetchRow()) { - $DBRESULT2 = $pearDB->query("INSERT INTO dependency_metaserviceChild_relation VALUES ('', '".$maxId["MAX(dep_id)"]."', '".$ms["meta_service_meta_id"]."')"); + $query = "INSERT INTO dependency_metaserviceChild_relation VALUES ('', '" . + $maxId["MAX(dep_id)"] . "', '" . $ms["meta_service_meta_id"] . "')"; + $pearDB->query($query); } $DBRESULT->closeCursor(); } @@ -122,7 +134,7 @@ function multipleMetaServiceDependencyInDB($dependencies = array(), $nbrDup = ar } } } - + function updateMetaServiceDependencyInDB($dep_id = null) { if (!$dep_id) { @@ -132,7 +144,7 @@ function updateMetaServiceDependencyInDB($dep_id = null) updateMetaServiceDependencyMetaServiceParents($dep_id); updateMetaServiceDependencyMetaServiceChilds($dep_id); } - + function insertMetaServiceDependencyInDB() { $dep_id = insertMetaServiceDependency(); @@ -140,7 +152,7 @@ function insertMetaServiceDependencyInDB() updateMetaServiceDependencyMetaServiceChilds($dep_id); return ($dep_id); } - + function insertMetaServiceDependency() { global $form; @@ -148,21 +160,34 @@ function insertMetaServiceDependency() $ret = array(); $ret = $form->getSubmitValues(); $rq = "INSERT INTO dependency "; - $rq .= "(dep_name, dep_description, inherits_parent, execution_failure_criteria, notification_failure_criteria, dep_comment) "; + $rq .= "(dep_name, dep_description, inherits_parent, execution_failure_criteria, " . + "notification_failure_criteria, dep_comment) "; $rq .= "VALUES ("; - isset($ret["dep_name"]) && $ret["dep_name"] != null ? $rq .= "'".htmlentities($ret["dep_name"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; - isset($ret["dep_description"]) && $ret["dep_description"] != null ? $rq .= "'".htmlentities($ret["dep_description"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; - isset($ret["inherits_parent"]["inherits_parent"]) && $ret["inherits_parent"]["inherits_parent"] != null ? $rq .= "'".$ret["inherits_parent"]["inherits_parent"]."', " : $rq .= "NULL, "; - isset($ret["execution_failure_criteria"]) && $ret["execution_failure_criteria"] != null ? $rq .= "'".implode(",", array_keys($ret["execution_failure_criteria"]))."', " : $rq .= "NULL, "; - isset($ret["notification_failure_criteria"]) && $ret["notification_failure_criteria"] != null ? $rq .= "'".implode(",", array_keys($ret["notification_failure_criteria"]))."', " : $rq .= "NULL, "; - isset($ret["dep_comment"]) && $ret["dep_comment"] != null ? $rq .= "'".htmlentities($ret["dep_comment"], ENT_QUOTES, "UTF-8")."' " : $rq .= "NULL "; + isset($ret["dep_name"]) && $ret["dep_name"] != null + ? $rq .= "'" . htmlentities($ret["dep_name"], ENT_QUOTES, "UTF-8") . "', " + : $rq .= "NULL, "; + isset($ret["dep_description"]) && $ret["dep_description"] != null + ? $rq .= "'" . htmlentities($ret["dep_description"], ENT_QUOTES, "UTF-8") . "', " + : $rq .= "NULL, "; + isset($ret["inherits_parent"]["inherits_parent"]) && $ret["inherits_parent"]["inherits_parent"] != null + ? $rq .= "'" . $ret["inherits_parent"]["inherits_parent"] . "', " + : $rq .= "NULL, "; + isset($ret["execution_failure_criteria"]) && $ret["execution_failure_criteria"] != null + ? $rq .= "'" . implode(",", array_keys($ret["execution_failure_criteria"])) . "', " + : $rq .= "NULL, "; + isset($ret["notification_failure_criteria"]) && $ret["notification_failure_criteria"] != null + ? $rq .= "'" . implode(",", array_keys($ret["notification_failure_criteria"])) . "', " + : $rq .= "NULL, "; + isset($ret["dep_comment"]) && $ret["dep_comment"] != null + ? $rq .= "'" . htmlentities($ret["dep_comment"], ENT_QUOTES, "UTF-8") . "' " + : $rq .= "NULL "; $rq .= ")"; - $DBRESULT = $pearDB->query($rq); + $pearDB->query($rq); $DBRESULT = $pearDB->query("SELECT MAX(dep_id) FROM dependency"); $dep_id = $DBRESULT->fetchRow(); return ($dep_id["MAX(dep_id)"]); } - + function updateMetaServiceDependency($dep_id = null) { if (!$dep_id) { @@ -174,21 +199,33 @@ function updateMetaServiceDependency($dep_id = null) $ret = $form->getSubmitValues(); $rq = "UPDATE dependency SET "; $rq .= "dep_name = "; - isset($ret["dep_name"]) && $ret["dep_name"] != null ? $rq .= "'".htmlentities($ret["dep_name"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + isset($ret["dep_name"]) && $ret["dep_name"] != null + ? $rq .= "'" . htmlentities($ret["dep_name"], ENT_QUOTES, "UTF-8") . "', " + : $rq .= "NULL, "; $rq .= "dep_description = "; - isset($ret["dep_description"]) && $ret["dep_description"] != null ? $rq .= "'".htmlentities($ret["dep_description"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + isset($ret["dep_description"]) && $ret["dep_description"] != null + ? $rq .= "'" . htmlentities($ret["dep_description"], ENT_QUOTES, "UTF-8") . "', " + : $rq .= "NULL, "; $rq .= "inherits_parent = "; - isset($ret["inherits_parent"]["inherits_parent"]) && $ret["inherits_parent"]["inherits_parent"] != null ? $rq .= "'".$ret["inherits_parent"]["inherits_parent"]."', " : $rq .= "NULL, "; + isset($ret["inherits_parent"]["inherits_parent"]) && $ret["inherits_parent"]["inherits_parent"] != null + ? $rq .= "'" . $ret["inherits_parent"]["inherits_parent"] . "', " + : $rq .= "NULL, "; $rq .= "execution_failure_criteria = "; - isset($ret["execution_failure_criteria"]) && $ret["execution_failure_criteria"] != null ? $rq .= "'".implode(",", array_keys($ret["execution_failure_criteria"]))."', " : $rq .= "NULL, "; + isset($ret["execution_failure_criteria"]) && $ret["execution_failure_criteria"] != null + ? $rq .= "'" . implode(",", array_keys($ret["execution_failure_criteria"])) . "', " + : $rq .= "NULL, "; $rq .= "notification_failure_criteria = "; - isset($ret["notification_failure_criteria"]) && $ret["notification_failure_criteria"] != null ? $rq .= "'".implode(",", array_keys($ret["notification_failure_criteria"]))."', " : $rq .= "NULL, "; + isset($ret["notification_failure_criteria"]) && $ret["notification_failure_criteria"] != null + ? $rq .= "'" . implode(",", array_keys($ret["notification_failure_criteria"])) . "', " + : $rq .= "NULL, "; $rq .= "dep_comment = "; - isset($ret["dep_comment"]) && $ret["dep_comment"] != null ? $rq .= "'".htmlentities($ret["dep_comment"], ENT_QUOTES, "UTF-8")."' " : $rq .= "NULL "; - $rq .= "WHERE dep_id = '".$dep_id."'"; - $DBRESULT = $pearDB->query($rq); + isset($ret["dep_comment"]) && $ret["dep_comment"] != null + ? $rq .= "'" . htmlentities($ret["dep_comment"], ENT_QUOTES, "UTF-8") . "' " + : $rq .= "NULL "; + $rq .= "WHERE dep_id = '" . $dep_id . "'"; + $pearDB->query($rq); } - + function updateMetaServiceDependencyMetaServiceParents($dep_id = null) { if (!$dep_id) { @@ -197,7 +234,7 @@ function updateMetaServiceDependencyMetaServiceParents($dep_id = null) global $form; global $pearDB; $rq = "DELETE FROM dependency_metaserviceParent_relation "; - $rq .= "WHERE dependency_dep_id = '".$dep_id."'"; + $rq .= "WHERE dependency_dep_id = '" . $dep_id . "'"; $DBRESULT = $pearDB->query($rq); $ret = array(); $ret = CentreonUtils::mergeWithInitialValues($form, 'dep_msParents'); @@ -205,11 +242,11 @@ function updateMetaServiceDependencyMetaServiceParents($dep_id = null) $rq = "INSERT INTO dependency_metaserviceParent_relation "; $rq .= "(dependency_dep_id, meta_service_meta_id) "; $rq .= "VALUES "; - $rq .= "('".$dep_id."', '".$ret[$i]."')"; + $rq .= "('" . $dep_id . "', '" . $ret[$i] . "')"; $DBRESULT = $pearDB->query($rq); } } - + function updateMetaServiceDependencyMetaServiceChilds($dep_id = null) { if (!$dep_id) { @@ -218,7 +255,7 @@ function updateMetaServiceDependencyMetaServiceChilds($dep_id = null) global $form; global $pearDB; $rq = "DELETE FROM dependency_metaserviceChild_relation "; - $rq .= "WHERE dependency_dep_id = '".$dep_id."'"; + $rq .= "WHERE dependency_dep_id = '" . $dep_id . "'"; $DBRESULT = $pearDB->query($rq); $ret = array(); $ret = CentreonUtils::mergeWithInitialValues($form, 'dep_msChilds'); @@ -226,7 +263,7 @@ function updateMetaServiceDependencyMetaServiceChilds($dep_id = null) $rq = "INSERT INTO dependency_metaserviceChild_relation "; $rq .= "(dependency_dep_id, meta_service_meta_id) "; $rq .= "VALUES "; - $rq .= "('".$dep_id."', '".$ret[$i]."')"; + $rq .= "('" . $dep_id . "', '" . $ret[$i] . "')"; $DBRESULT = $pearDB->query($rq); } } diff --git a/www/include/configuration/configObject/metaservice_dependency/MetaServiceDependency.php b/www/include/configuration/configObject/metaservice_dependency/MetaServiceDependency.php index 2254f16c716..a3e7320ae74 100644 --- a/www/include/configuration/configObject/metaservice_dependency/MetaServiceDependency.php +++ b/www/include/configuration/configObject/metaservice_dependency/MetaServiceDependency.php @@ -58,7 +58,7 @@ $path = "./include/configuration/configObject/metaservice_dependency/"; #PHP functions -require_once $path."DB-Func.php"; +require_once $path . "DB-Func.php"; require_once "./include/common/common-Func.php"; /* Set the real page */ @@ -71,23 +71,23 @@ switch ($o) { case "a": - require_once($path."formMetaServiceDependency.php"); + require_once($path . "formMetaServiceDependency.php"); break; #Add a Meta Service case "w": - require_once($path."formMetaServiceDependency.php"); + require_once($path . "formMetaServiceDependency.php"); break; #Watch a Meta Service case "c": - require_once($path."formMetaServiceDependency.php"); + require_once($path . "formMetaServiceDependency.php"); break; #Modify a Meta Service case "m": multipleMetaServiceDependencyInDB(isset($select) ? $select : array(), $dupNbr); - require_once($path."listMetaServiceDependency.php"); + require_once($path . "listMetaServiceDependency.php"); break; #Duplicate n Meta Services case "d": deleteMetaServiceDependencyInDB(isset($select) ? $select : array()); - require_once($path."listMetaServiceDependency.php"); + require_once($path . "listMetaServiceDependency.php"); break; #Delete n Meta Service default: - require_once($path."listMetaServiceDependency.php"); + require_once($path . "listMetaServiceDependency.php"); break; } diff --git a/www/include/configuration/configObject/metaservice_dependency/formMetaServiceDependency.php b/www/include/configuration/configObject/metaservice_dependency/formMetaServiceDependency.php index ee06a40d271..7dfcdc6e800 100644 --- a/www/include/configuration/configObject/metaservice_dependency/formMetaServiceDependency.php +++ b/www/include/configuration/configObject/metaservice_dependency/formMetaServiceDependency.php @@ -40,7 +40,7 @@ $initialValues = array(); if (($o == "c" || $o == "w") && $dep_id) { - $DBRESULT = $pearDB->query("SELECT * FROM dependency WHERE dep_id = '".$dep_id."' LIMIT 1"); + $DBRESULT = $pearDB->query("SELECT * FROM dependency WHERE dep_id = '" . $dep_id . "' LIMIT 1"); # Set base value $dep = array_map("myDecode", $DBRESULT->fetchRow()); @@ -65,9 +65,9 @@ # Meta Service comes from DB -> Store in $metas Array $metas = array(); $DBRESULT = $pearDB->query("SELECT meta_id, meta_name - FROM meta_service ". - $acl->queryBuilder('WHERE', 'meta_id', $metastr). - " ORDER BY meta_name"); + FROM meta_service " . + $acl->queryBuilder('WHERE', 'meta_id', $metastr) . + " ORDER BY meta_name"); while ($meta = $DBRESULT->fetchRow()) { $metas[$meta["meta_id"]] = $meta["meta_name"]; } @@ -78,14 +78,17 @@ ########################################################## # Var information to format the element # -$attrsText = array("size"=>"30"); -$attrsText2 = array("size"=>"10"); +$attrsText = array("size" => "30"); +$attrsText2 = array("size" => "10"); $attrsAdvSelect = array("style" => "width: 300px; height: 150px;"); -$attrsTextarea = array("rows"=>"3", "cols"=>"30"); -$eTemplate = '
{label_2}
{unselected}
{add}


{remove}
{label_3}
{selected}
'; +$attrsTextarea = array("rows" => "3", "cols" => "30"); +$eTemplate = '
{label_2}
{unselected}
{add}

' . + '
{remove}
{label_3}
{selected}
'; + +$route = './include/common/webServices/rest/internal.php?object=centreon_configuration_meta&action=list'; $attrMetas = array( 'datasourceOrigin' => 'ajax', - 'availableDatasetRoute' => './include/common/webServices/rest/internal.php?object=centreon_configuration_meta&action=list', + 'availableDatasetRoute' => $route, 'multiple' => true, 'linkedObject' => 'centreonMeta' ); @@ -93,7 +96,7 @@ # ## Form begin # -$form = new HTML_QuickForm('Form', 'post', "?p=".$p); +$form = new HTML_QuickForm('Form', 'post', "?p=" . $p); if ($o == "a") { $form->addElement('header', 'title', _("Add a Dependency")); } elseif ($o == "c") { @@ -113,35 +116,111 @@ $tab[] = HTML_QuickForm::createElement('radio', 'inherits_parent', null, _("Yes"), '1'); $tab[] = HTML_QuickForm::createElement('radio', 'inherits_parent', null, _("No"), '0'); $form->addGroup($tab, 'inherits_parent', _("Parent relationship"), ' '); -$form->setDefaults(array('inherits_parent'=>'1')); +$form->setDefaults(array('inherits_parent' => '1')); $tab = array(); -$tab[] = HTML_QuickForm::createElement('checkbox', 'o', ' ', _("Ok"), array('id' => 'sOk', 'onClick' => 'uncheckAllS(this);')); -$tab[] = HTML_QuickForm::createElement('checkbox', 'w', ' ', _("Warning"), array('id' => 'sWarning', 'onClick' => 'uncheckAllS(this);')); -$tab[] = HTML_QuickForm::createElement('checkbox', 'u', ' ', _("Unknown"), array('id' => 'sUnknown', 'onClick' => 'uncheckAllS(this);')); -$tab[] = HTML_QuickForm::createElement('checkbox', 'c', ' ', _("Critical"), array('id' => 'sCritical', 'onClick' => 'uncheckAllS(this);')); -$tab[] = HTML_QuickForm::createElement('checkbox', 'p', ' ', _("Pending"), array('id' => 'sPending', 'onClick' => 'uncheckAllS(this);')); -$tab[] = HTML_QuickForm::createElement('checkbox', 'n', ' ', _("None"), array('id' => 'sNone', 'onClick' => 'uncheckAllS(this);')); +$tab[] = HTML_QuickForm::createElement( + 'checkbox', + 'o', + ' ', + _("Ok"), + array('id' => 'sOk', 'onClick' => 'uncheckAllS(this);') +); +$tab[] = HTML_QuickForm::createElement( + 'checkbox', + 'w', + ' ', + _("Warning"), + array('id' => 'sWarning', 'onClick' => 'uncheckAllS(this);') +); +$tab[] = HTML_QuickForm::createElement( + 'checkbox', + 'u', + ' ', + _("Unknown"), + array('id' => 'sUnknown', 'onClick' => 'uncheckAllS(this);') +); +$tab[] = HTML_QuickForm::createElement( + 'checkbox', + 'c', + ' ', + _("Critical"), + array('id' => 'sCritical', 'onClick' => 'uncheckAllS(this);') +); +$tab[] = HTML_QuickForm::createElement( + 'checkbox', + 'p', + ' ', + _("Pending"), + array('id' => 'sPending', 'onClick' => 'uncheckAllS(this);') +); +$tab[] = HTML_QuickForm::createElement( + 'checkbox', + 'n', + ' ', + _("None"), + array('id' => 'sNone', 'onClick' => 'uncheckAllS(this);') +); $form->addGroup($tab, 'notification_failure_criteria', _("Notification Failure Criteria"), '  '); $tab = array(); -$tab[] = HTML_QuickForm::createElement('checkbox', 'o', ' ', _("Ok"), array('id' => 'sOk2', 'onClick' => 'uncheckAllS2(this);')); -$tab[] = HTML_QuickForm::createElement('checkbox', 'w', ' ', _("Warning"), array('id' => 'sWarning2', 'onClick' => 'uncheckAllS2(this);')); -$tab[] = HTML_QuickForm::createElement('checkbox', 'u', ' ', _("Unknown"), array('id' => 'sUnknown2', 'onClick' => 'uncheckAllS2(this);')); -$tab[] = HTML_QuickForm::createElement('checkbox', 'c', ' ', _("Critical"), array('id' => 'sCritical2', 'onClick' => 'uncheckAllS2(this);')); -$tab[] = HTML_QuickForm::createElement('checkbox', 'p', ' ', _("Pending"), array('id' => 'sPending2', 'onClick' => 'uncheckAllS2(this);')); -$tab[] = HTML_QuickForm::createElement('checkbox', 'n', ' ', _("None"), array('id' => 'sNone2', 'onClick' => 'uncheckAllS2(this);')); +$tab[] = HTML_QuickForm::createElement( + 'checkbox', + 'o', + ' ', + _("Ok"), + array('id' => 'sOk2', 'onClick' => 'uncheckAllS2(this);') +); +$tab[] = HTML_QuickForm::createElement( + 'checkbox', + 'w', + ' ', + _("Warning"), + array('id' => 'sWarning2', 'onClick' => 'uncheckAllS2(this);') +); +$tab[] = HTML_QuickForm::createElement( + 'checkbox', + 'u', + ' ', + _("Unknown"), + array('id' => 'sUnknown2', 'onClick' => 'uncheckAllS2(this);') +); +$tab[] = HTML_QuickForm::createElement( + 'checkbox', + 'c', + ' ', + _("Critical"), + array('id' => 'sCritical2', 'onClick' => 'uncheckAllS2(this);') +); +$tab[] = HTML_QuickForm::createElement( + 'checkbox', + 'p', + ' ', + _("Pending"), + array('id' => 'sPending2', 'onClick' => 'uncheckAllS2(this);') +); +$tab[] = HTML_QuickForm::createElement( + 'checkbox', + 'n', + ' ', + _("None"), + array('id' => 'sNone2', 'onClick' => 'uncheckAllS2(this);') +); $form->addGroup($tab, 'execution_failure_criteria', _("Execution Failure Criteria"), '  '); +$route = './include/common/webServices/rest/internal.php?object=centreon_configuration_meta' . + '&action=defaultValues&target=dependency&field=dep_msParents&id=' . $dep_id; $attrMeta1 = array_merge( $attrMetas, - array('defaultDatasetRoute' => './include/common/webServices/rest/internal.php?object=centreon_configuration_meta&action=defaultValues&target=dependency&field=dep_msParents&id=' . $dep_id) + array('defaultDatasetRoute' => $route) ); $form->addElement('select2', 'dep_msParents', _("Meta Service Names"), array(), $attrMeta1); +$route = './include/common/webServices/rest/internal.php?object=centreon_configuration_meta' . + '&action=defaultValues&target=dependency&field=dep_msChilds&id=' . $dep_id; $attrMeta2 = array_merge( $attrMetas, - array('defaultDatasetRoute' => './include/common/webServices/rest/internal.php?object=centreon_configuration_meta&action=defaultValues&target=dependency&field=dep_msChilds&id=' . $dep_id) + array('defaultDatasetRoute' => $route) ); $form->addElement('select2', 'dep_msChilds', _("Dependent Meta Service Names"), array(), $attrMeta2); @@ -150,7 +229,7 @@ $form->addElement('hidden', 'dep_id'); $redirect = $form->addElement('hidden', 'o'); $redirect->setValue($o); - + $init = $form->addElement('hidden', 'initialValues'); $init->setValue(serialize($initialValues)); @@ -166,7 +245,7 @@ $form->addRule('dep_msChilds', _("Circular Definition"), 'cycle'); $form->registerRule('exist', 'callback', 'testExistence'); $form->addRule('dep_name', _("Name is already in use"), 'exist'); -$form->setRequiredNote("* ". _("Required fields")); +$form->setRequiredNote("* " . _("Required fields")); # ##End of form definition @@ -179,7 +258,12 @@ # Just watch a Dependency information if ($o == "w") { if ($centreon->user->access->page($p) != 2) { - $form->addElement("button", "change", _("Modify"), array("onClick"=>"javascript:window.location.href='?p=".$p."&o=c&dep_id=".$dep_id."'")); + $form->addElement( + "button", + "change", + _("Modify"), + array("onClick" => "javascript:window.location.href='?p=" . $p . "&o=c&dep_id=" . $dep_id . "'") + ); } $form->setDefaults($dep); $form->freeze(); @@ -195,12 +279,17 @@ $form->setDefaults(array('inherits_parent', '0')); } -$tpl->assign("helpattr", 'TITLE, "'._("Help").'", CLOSEBTN, true, FIX, [this, 0, 5], BGCOLOR, "#ffff99", BORDERCOLOR, "orange", TITLEFONTCOLOR, "black", TITLEBGCOLOR, "orange", CLOSEBTNCOLORS, ["","black", "white", "red"], WIDTH, -300, SHADOW, true, TEXTALIGN, "justify"'); +$tpl->assign( + "helpattr", + 'TITLE, "' . _("Help") . '", CLOSEBTN, true, FIX, [this, 0, 5], BGCOLOR, "#ffff99", BORDERCOLOR, "orange", ' . + 'TITLEFONTCOLOR, "black", TITLEBGCOLOR, "orange", CLOSEBTNCOLORS, ["","black", "white", "red"], WIDTH, ' . + '-300, SHADOW, true, TEXTALIGN, "justify"' +); # prepare help texts $helptext = ""; include_once("include/configuration/configObject/service_dependency/help.php"); foreach ($help as $key => $text) { - $helptext .= ''."\n"; + $helptext .= '' . "\n"; } $tpl->assign("helptext", $helptext); @@ -230,28 +319,29 @@ } ?> diff --git a/www/include/configuration/configObject/metaservice_dependency/listMetaServiceDependency.php b/www/include/configuration/configObject/metaservice_dependency/listMetaServiceDependency.php index b0d1cc5a244..4a35fbe218c 100644 --- a/www/include/configuration/configObject/metaservice_dependency/listMetaServiceDependency.php +++ b/www/include/configuration/configObject/metaservice_dependency/listMetaServiceDependency.php @@ -38,16 +38,16 @@ } include_once("./class/centreonUtils.class.php"); - + include("./include/common/autoNumLimit.php"); isset($_GET["list"]) ? $list = $_GET["list"] : $list = null; - $aclCond = ""; +$aclCond = ""; if (!$centreon->user->admin) { $aclCond = " AND meta_service_meta_id IN ($metastr) "; } - + # HostGroup LCA $rq = "SELECT COUNT(*) FROM dependency dep"; $rq .= " WHERE ((SELECT DISTINCT COUNT(*) @@ -59,7 +59,8 @@ $search = ''; if (isset($_POST['searchMSD']) && $_POST['searchMSD']) { $search = $_POST['searchMSD']; - $rq .= " AND (dep_name LIKE '%".htmlentities($search, ENT_QUOTES, "UTF-8")."%' OR dep_description LIKE '%".htmlentities($search, ENT_QUOTES, "UTF-8")."%')"; + $rq .= " AND (dep_name LIKE '%" . htmlentities($search, ENT_QUOTES, "UTF-8") . + "%' OR dep_description LIKE '%" . htmlentities($search, ENT_QUOTES, "UTF-8") . "%')"; } $DBRESULT = $pearDB->query($rq); $tmp = $DBRESULT->fetchRow(); @@ -89,33 +90,42 @@ FROM dependency_metaserviceChild_relation dmspr WHERE dmspr.dependency_dep_id = dep.dep_id $aclCond) > 0)"; if ($search) { - $rq .= " AND (dep_name LIKE '%".htmlentities($search, ENT_QUOTES, "UTF-8")."%' OR dep_description LIKE '%".htmlentities($search, ENT_QUOTES, "UTF-8")."%')"; + $rq .= " AND (dep_name LIKE '%" . htmlentities($search, ENT_QUOTES, "UTF-8") . + "%' OR dep_description LIKE '%" . htmlentities($search, ENT_QUOTES, "UTF-8") . "%')"; } -$rq .= " ORDER BY dep_name, dep_description LIMIT ".$num * $limit.", ".$limit; +$rq .= " ORDER BY dep_name, dep_description LIMIT " . $num * $limit . ", " . $limit; $DBRESULT = $pearDB->query($rq); $search = tidySearchKey($search, $advanced_search); -$form = new HTML_QuickForm('select_form', 'POST', "?p=".$p); +$form = new HTML_QuickForm('select_form', 'POST', "?p=" . $p); #Different style between each lines $style = "one"; #Fill a tab with a mutlidimensionnal Array we put in $tpl $elemArr = array(); for ($i = 0; $dep = $DBRESULT->fetchRow(); $i++) { $moptions = ""; - $selectedElements = $form->addElement('checkbox', "select[".$dep['dep_id']."]"); - $moptions .= "  31 && (event.keyCode < 45 || event.keyCode > 57)) event.returnValue = false; if(event.which > 31 && (event.which < 45 || event.which > 57)) return false;\" maxlength=\"3\" size=\"3\" value='1' style=\"margin-bottom:0px;\" name='dupNbr[".$dep['dep_id']."]'>"; - $elemArr[$i] = array("MenuClass"=>"list_".$style, - "RowMenu_select"=>$selectedElements->toHtml(), - "RowMenu_name"=>CentreonUtils::escapeSecure($dep["dep_name"]), - "RowMenu_link"=>"?p=".$p."&o=c&dep_id=".$dep['dep_id'], - "RowMenu_description"=>CentreonUtils::escapeSecure($dep["dep_description"]), - "RowMenu_options"=>$moptions); + $selectedElements = $form->addElement('checkbox', "select[" . $dep['dep_id'] . "]"); + $moptions .= "  31 && (event.keyCode < 45 || event.keyCode > 57)) " . + "event.returnValue = false; if(event.which > 31 && (event.which < 45 || event.which > 57)) return false;" . + "\" maxlength=\"3\" size=\"3\" value='1' style=\"margin-bottom:0px;\" name='dupNbr[" . $dep['dep_id'] . "]' />"; + + $elemArr[$i] = array( + "MenuClass" => "list_" . $style, + "RowMenu_select" => $selectedElements->toHtml(), + "RowMenu_name" => CentreonUtils::escapeSecure($dep["dep_name"]), + "RowMenu_link" => "?p=" . $p . "&o=c&dep_id=" . $dep['dep_id'], + "RowMenu_description" => CentreonUtils::escapeSecure($dep["dep_description"]), + "RowMenu_options" => $moptions + ); $style != "two" ? $style = "two" : $style = "one"; } $tpl->assign("elemArr", $elemArr); #Different messages we put in the template -$tpl->assign('msg', array ("addL"=>"?p=".$p."&o=a", "addT"=>_("Add"), "delConfirm"=>_("Do you confirm the deletion ?"))); +$tpl->assign( + 'msg', + array("addL" => "?p=" . $p . "&o=a", "addT" => _("Add"), "delConfirm" => _("Do you confirm the deletion ?")) +); include("./include/common/checkPagination.php"); @@ -124,46 +134,64 @@ ##Toolbar select more_actions # ?> - + "javascript: " . - " var bChecked = isChecked(); ". - " if (this.form.elements['o1'].selectedIndex != 0 && !bChecked) {". - " alert('"._("Please select one or more items")."'); return false;} " . - "if (this.form.elements['o1'].selectedIndex == 1 && confirm('"._("Do you confirm the duplication ?")."')) {" . - " setO(this.form.elements['o1'].value); submit();} " . - "else if (this.form.elements['o1'].selectedIndex == 2 && confirm('"._("Do you confirm the deletion ?")."')) {" . - " setO(this.form.elements['o1'].value); submit();} " . - "else if (this.form.elements['o1'].selectedIndex == 3) {" . - " setO(this.form.elements['o1'].value); submit();} " . - ""); - $form->addElement('select', 'o1', null, array(null=>_("More actions..."), "m"=>_("Duplicate"), "d"=>_("Delete")), $attrs1); + 'onchange' => "javascript: " . + " var bChecked = isChecked(); " . + " if (this.form.elements['o1'].selectedIndex != 0 && !bChecked) {" . + " alert('" . _("Please select one or more items") . "'); return false;} " . + "if (this.form.elements['o1'].selectedIndex == 1 && confirm('" . + _("Do you confirm the duplication ?") . "')) {" . + " setO(this.form.elements['o1'].value); submit();} " . + "else if (this.form.elements['o1'].selectedIndex == 2 && confirm('" . + _("Do you confirm the deletion ?") . "')) {" . + " setO(this.form.elements['o1'].value); submit();} " . + "else if (this.form.elements['o1'].selectedIndex == 3) {" . + " setO(this.form.elements['o1'].value); submit();} " . + "" +); +$form->addElement( + 'select', + 'o1', + null, + array(null => _("More actions..."), "m" => _("Duplicate"), "d" => _("Delete")), + $attrs1 +); $form->setDefaults(array('o1' => null)); - $o1 = $form->getElement('o1'); - $o1->setValue(null); +$o1 = $form->getElement('o1'); +$o1->setValue(null); $attrs = array( - 'onchange'=>"javascript: " . - " var bChecked = isChecked(); ". - " if (this.form.elements['o2'].selectedIndex != 0 && !bChecked) {". - " alert('"._("Please select one or more items")."'); return false;} " . - "if (this.form.elements['o2'].selectedIndex == 1 && confirm('"._("Do you confirm the duplication ?")."')) {" . - " setO(this.form.elements['o2'].value); submit();} " . - "else if (this.form.elements['o2'].selectedIndex == 2 && confirm('"._("Do you confirm the deletion ?")."')) {" . - " setO(this.form.elements['o2'].value); submit();} " . - "else if (this.form.elements['o2'].selectedIndex == 3) {" . - " setO(this.form.elements['o2'].value); submit();} " . - ""); -$form->addElement('select', 'o2', null, array(null=>_("More actions..."), "m"=>_("Duplicate"), "d"=>_("Delete")), $attrs); + 'onchange' => "javascript: " . + " var bChecked = isChecked(); " . + " if (this.form.elements['o2'].selectedIndex != 0 && !bChecked) {" . + " alert('" . _("Please select one or more items") . "'); return false;} " . + "if (this.form.elements['o2'].selectedIndex == 1 && confirm('" . + _("Do you confirm the duplication ?") . "')) {" . + " setO(this.form.elements['o2'].value); submit();} " . + "else if (this.form.elements['o2'].selectedIndex == 2 && confirm('" . + _("Do you confirm the deletion ?") . "')) {" . + " setO(this.form.elements['o2'].value); submit();} " . + "else if (this.form.elements['o2'].selectedIndex == 3) {" . + " setO(this.form.elements['o2'].value); submit();} " . + "" +); +$form->addElement( + 'select', + 'o2', + null, + array(null => _("More actions..."), "m" => _("Duplicate"), "d" => _("Delete")), + $attrs +); $form->setDefaults(array('o2' => null)); - $o2 = $form->getElement('o2'); - $o2->setValue(null); +$o2 = $form->getElement('o2'); +$o2->setValue(null); $tpl->assign('limit', $limit); $tpl->assign('searchMSD', $search); From 15c0b2dd0166a476d8fc5d2a41d178c65118af90 Mon Sep 17 00:00:00 2001 From: loiclau Date: Fri, 28 Jul 2017 15:23:24 +0200 Subject: [PATCH 093/207] * fix style service template model --- .../listServiceTemplateModel.php | 164 ++++++++++++------ .../serviceTemplateModel.php | 26 +-- 2 files changed, 121 insertions(+), 69 deletions(-) diff --git a/www/include/configuration/configObject/service_template_model/listServiceTemplateModel.php b/www/include/configuration/configObject/service_template_model/listServiceTemplateModel.php index 041b040d9a6..6f7424533ef 100644 --- a/www/include/configuration/configObject/service_template_model/listServiceTemplateModel.php +++ b/www/include/configuration/configObject/service_template_model/listServiceTemplateModel.php @@ -62,7 +62,11 @@ } if ($search != '') { - $DBRESULT = $pearDB->query("SELECT COUNT(*) FROM service sv WHERE (sv.service_description LIKE '%".htmlentities($search, ENT_QUOTES, "UTF-8")."%' OR sv.service_alias LIKE '%".htmlentities($search, ENT_QUOTES, "UTF-8")."%') AND sv.service_register = '0'"); + $query = "SELECT COUNT(*) FROM service sv " . + "WHERE (sv.service_description LIKE '%" . htmlentities($search, ENT_QUOTES, "UTF-8") . + "%' OR sv.service_alias LIKE '%" . htmlentities($search, ENT_QUOTES, "UTF-8") . + "%') AND sv.service_register = '0'"; + $DBRESULT = $pearDB->query($query); } else { $DBRESULT = $pearDB->query("SELECT COUNT(*) FROM service sv WHERE service_register = '0'"); } @@ -96,15 +100,21 @@ * Service Template Model list */ if ($search) { - $rq = "SELECT sv.service_id, sv.service_description, sv.service_alias, sv.service_activate, sv.service_template_model_stm_id FROM service sv WHERE (sv.service_description LIKE '%".htmlentities($search, ENT_QUOTES, "UTF-8")."%' OR sv.service_alias LIKE '%".htmlentities($search, ENT_QUOTES, "UTF-8")."%') AND sv.service_register = '0' ORDER BY service_description LIMIT ".$num * $limit.", ".$limit; + $query = "SELECT sv.service_id, sv.service_description, sv.service_alias, sv.service_activate, " . + "sv.service_template_model_stm_id FROM service sv WHERE (sv.service_description LIKE '%" . + htmlentities($search, ENT_QUOTES, "UTF-8") . "%' OR sv.service_alias LIKE '%" . + htmlentities($search, ENT_QUOTES, "UTF-8") . "%') AND sv.service_register = '0' " . + "ORDER BY service_description LIMIT " . $num * $limit . ", " . $limit; } else { - $rq = "SELECT sv.service_id, sv.service_description, sv.service_alias, sv.service_activate, sv.service_template_model_stm_id FROM service sv WHERE sv.service_register = '0' ORDER BY service_description LIMIT ".$num * $limit.", ".$limit; + $query = "SELECT sv.service_id, sv.service_description, sv.service_alias, sv.service_activate, " . + "sv.service_template_model_stm_id FROM service sv WHERE sv.service_register = '0' " . + "ORDER BY service_description LIMIT " . $num * $limit . ", " . $limit; } -$DBRESULT = $pearDB->query($rq); +$DBRESULT = $pearDB->query($query); $search = tidySearchKey($search, $advanced_search); -$form = new HTML_QuickForm('select_form', 'POST', "?p=".$p); +$form = new HTML_QuickForm('select_form', 'POST', "?p=" . $p); /* * Different style between each lines */ @@ -122,24 +132,32 @@ for ($i = 0; $service = $DBRESULT->fetchRow(); $i++) { $moptions = ""; - $selectedElements = $form->addElement('checkbox', "select[".$service['service_id']."]"); + $selectedElements = $form->addElement('checkbox', "select[" . $service['service_id'] . "]"); if (isset($lockedElements[$service['service_id']])) { $selectedElements->setAttribute('disabled', 'disabled'); } else { if ($service["service_activate"]) { - $moptions .= ""._("Disabled")."  "; + $moptions .= "" . _("Disabled") . "  "; } else { - $moptions .= ""._("Enabled")."  "; + $moptions .= "" . _("Enabled") . "  "; } $moptions .= " "; - $moptions .= " 31 && (event.keyCode < 45 || event.keyCode > 57)) event.returnValue = false; if(event.which > 31 && (event.which < 45 || event.which > 57)) return false;\" maxlength=\"3\" size=\"3\" value='1' style=\"margin-bottom:0px;\" name='dupNbr[".$service['service_id']."]'>"; + $moptions .= " 31 && (event.keyCode < 45 || event.keyCode > 57)) " . + "event.returnValue = false; if(event.which > 31 && (event.which < 45 || event.which > 57)) return false;" . + "\" maxlength=\"3\" size=\"3\" value='1' style=\"margin-bottom:0px;\" name='dupNbr[" . + $service['service_id'] . "]' />"; } /* - * If the description of our Service Model is in the Template definition, we have to catch it, whatever the level of it :-) + * If the description of our Service Model is in the Template definition, we have to catch it, + * whatever the level of it :-) */ if (!$service["service_description"]) { - $service["service_description"] = getMyServiceName($service['service_template_model_stm_id']); + $service["service_description"] = getMyServiceName($service['service_template_model_stm_id']); } /* @@ -152,7 +170,7 @@ foreach ($tplArr as $key => $value) { $value = str_replace('#S#', "/", $value); $value = str_replace('#BS#', "\\", $value); - $tplStr .= " -> ".$value.""; + $tplStr .= " -> " . $value . ""; } } @@ -169,8 +187,10 @@ $service["service_alias"] = str_replace("#BS#", '\\', $service["service_alias"]); # Get service intervals in seconds - $normal_check_interval = getMyServiceField($service['service_id'], "service_normal_check_interval") * $interval_length; - $retry_check_interval = getMyServiceField($service['service_id'], "service_retry_check_interval") * $interval_length; + $normal_check_interval = + getMyServiceField($service['service_id'], "service_normal_check_interval") * $interval_length; + $retry_check_interval = + getMyServiceField($service['service_id'], "service_retry_check_interval") * $interval_length; if ($normal_check_interval % 60 == 0) { $normal_units = "min"; @@ -188,26 +208,33 @@ if (isset($service['esi_icon_image']) && $service['esi_icon_image']) { $svc_icon = "./img/media/" . $mediaObj->getFilename($service['esi_icon_image']); - } elseif ($icone = $mediaObj->getFilename(getMyServiceExtendedInfoField($service["service_id"], "esi_icon_image"))) { + } elseif ($icone = $mediaObj->getFilename( + getMyServiceExtendedInfoField( + $service["service_id"], + "esi_icon_image" + ) + )) { $svc_icon = "./img/media/" . $icone; } else { $svc_icon = "./img/icons/service.png"; } $elemArr[$i] = array( - "MenuClass" => "list_".$style, - "RowMenu_select" => $selectedElements->toHtml(), - "RowMenu_desc" => CentreonUtils::escapeSecure($service["service_description"]), - "RowMenu_alias" => CentreonUtils::escapeSecure($service["service_alias"]), - "RowMenu_parent" => CentreonUtils::escapeSecure($tplStr), - "RowMenu_icon" => $svc_icon, - "RowMenu_retry" => CentreonUtils::escapeSecure("$normal_check_interval $normal_units / $retry_check_interval $retry_units"), - "RowMenu_attempts" => getMyServiceField($service['service_id'], "service_max_check_attempts"), - "RowMenu_link" => "?p=".$p."&o=c&service_id=".$service['service_id'], - "RowMenu_status" => $service["service_activate"] ? _("Enabled") : _("Disabled"), - "RowMenu_badge" => $service["service_activate"] ? "service_ok" : "service_critical", - "RowMenu_options" => $moptions - ); + "MenuClass" => "list_" . $style, + "RowMenu_select" => $selectedElements->toHtml(), + "RowMenu_desc" => CentreonUtils::escapeSecure($service["service_description"]), + "RowMenu_alias" => CentreonUtils::escapeSecure($service["service_alias"]), + "RowMenu_parent" => CentreonUtils::escapeSecure($tplStr), + "RowMenu_icon" => $svc_icon, + "RowMenu_retry" => CentreonUtils::escapeSecure( + "$normal_check_interval $normal_units / $retry_check_interval $retry_units" + ), + "RowMenu_attempts" => getMyServiceField($service['service_id'], "service_max_check_attempts"), + "RowMenu_link" => "?p=" . $p . "&o=c&service_id=" . $service['service_id'], + "RowMenu_status" => $service["service_activate"] ? _("Enabled") : _("Disabled"), + "RowMenu_badge" => $service["service_activate"] ? "service_ok" : "service_critical", + "RowMenu_options" => $moptions + ); $style != "two" ? $style = "two" : $style = "one"; } $tpl->assign("elemArr", $elemArr); @@ -215,46 +242,71 @@ /* * Different messages we put in the template */ -$tpl->assign('msg', array ("addL"=>"?p=".$p."&o=a", "addT"=>_("Add"), "delConfirm"=>_("Do you confirm the deletion ?"))); +$tpl->assign( + 'msg', + array("addL" => "?p=" . $p . "&o=a", "addT" => _("Add"), "delConfirm" => _("Do you confirm the deletion ?")) +); /* * Toolbar select lgd_more_actions */ ?> "javascript: " . - " var bChecked = isChecked(); ". - " if (this.form.elements['o1'].selectedIndex != 0 && !bChecked) {". - " alert('"._("Please select one or more items")."'); return false;} " . - "if (this.form.elements['o1'].selectedIndex == 1 && confirm('"._("Do you confirm the duplication ?")."')) {" . - " setO(this.form.elements['o1'].value); submit();} " . - "else if (this.form.elements['o1'].selectedIndex == 2 && confirm('"._("Do you confirm the deletion ?")."')) {" . - " setO(this.form.elements['o1'].value); submit();} " . - "else if (this.form.elements['o1'].selectedIndex == 3 || this.form.elements['o1'].selectedIndex == 4 ||this.form.elements['o1'].selectedIndex == 5){" . - " setO(this.form.elements['o1'].value); submit();} " . - "this.form.elements['o1'].selectedIndex = 0"); -$form->addElement('select', 'o1', null, array(null=>_("More actions..."), "m"=>_("Duplicate"), "d"=>_("Delete"), "mc"=>_("Massive Change"), "ms"=>_("Enable"), "mu"=>_("Disable")), $attrs1); + 'onchange' => "javascript: " . + " var bChecked = isChecked(); " . + " if (this.form.elements['o1'].selectedIndex != 0 && !bChecked) {" . + " alert('" . _("Please select one or more items") . "'); return false;} " . + "if (this.form.elements['o1'].selectedIndex == 1 && confirm('" . + _("Do you confirm the duplication ?") . "')) {" . + " setO(this.form.elements['o1'].value); submit();} " . + "else if (this.form.elements['o1'].selectedIndex == 2 && confirm('" . + _("Do you confirm the deletion ?") . "')) {" . + " setO(this.form.elements['o1'].value); submit();} " . + "else if (this.form.elements['o1'].selectedIndex == 3 || this.form.elements['o1'].selectedIndex == 4 " . + "||this.form.elements['o1'].selectedIndex == 5){" . + " setO(this.form.elements['o1'].value); submit();} " . + "this.form.elements['o1'].selectedIndex = 0" +); +$form->addElement('select', 'o1', null, array( + null => _("More actions..."), + "m" => _("Duplicate"), + "d" => _("Delete"), + "mc" => _("Massive Change"), + "ms" => _("Enable"), + "mu" => _("Disable") +), $attrs1); $form->setDefaults(array('o1' => null)); $attrs2 = array( - 'onchange'=>"javascript: " . - " var bChecked = isChecked(); ". - " if (this.form.elements['o2'].selectedIndex != 0 && !bChecked) {". - " alert('"._("Please select one or more items")."'); return false;} " . - "if (this.form.elements['o2'].selectedIndex == 1 && confirm('"._("Do you confirm the duplication ?")."')) {" . - " setO(this.form.elements['o2'].value); submit();} " . - "else if (this.form.elements['o2'].selectedIndex == 2 && confirm('"._("Do you confirm the deletion ?")."')) {" . - " setO(this.form.elements['o2'].value); submit();} " . - "else if (this.form.elements['o2'].selectedIndex == 3 || this.form.elements['o2'].selectedIndex == 4 ||this.form.elements['o2'].selectedIndex == 5){" . - " setO(this.form.elements['o2'].value); submit();} " . - "this.form.elements['o1'].selectedIndex = 0"); -$form->addElement('select', 'o2', null, array(null=>_("More actions..."), "m"=>_("Duplicate"), "d"=>_("Delete"), "mc"=>_("Massive Change"), "ms"=>_("Enable"), "mu"=>_("Disable")), $attrs2); + 'onchange' => "javascript: " . + " var bChecked = isChecked(); " . + " if (this.form.elements['o2'].selectedIndex != 0 && !bChecked) {" . + " alert('" . _("Please select one or more items") . "'); return false;} " . + "if (this.form.elements['o2'].selectedIndex == 1 && confirm('" . + _("Do you confirm the duplication ?") . "')) {" . + " setO(this.form.elements['o2'].value); submit();} " . + "else if (this.form.elements['o2'].selectedIndex == 2 && confirm('" . + _("Do you confirm the deletion ?") . "')) {" . + " setO(this.form.elements['o2'].value); submit();} " . + "else if (this.form.elements['o2'].selectedIndex == 3 || this.form.elements['o2'].selectedIndex == 4 " . + "||this.form.elements['o2'].selectedIndex == 5){" . + " setO(this.form.elements['o2'].value); submit();} " . + "this.form.elements['o1'].selectedIndex = 0" +); +$form->addElement('select', 'o2', null, array( + null => _("More actions..."), + "m" => _("Duplicate"), + "d" => _("Delete"), + "mc" => _("Massive Change"), + "ms" => _("Enable"), + "mu" => _("Disable") +), $attrs2); $form->setDefaults(array('o2' => null)); $o1 = $form->getElement('o1'); diff --git a/www/include/configuration/configObject/service_template_model/serviceTemplateModel.php b/www/include/configuration/configObject/service_template_model/serviceTemplateModel.php index 6b901492115..da6fb8039bc 100644 --- a/www/include/configuration/configObject/service_template_model/serviceTemplateModel.php +++ b/www/include/configuration/configObject/service_template_model/serviceTemplateModel.php @@ -73,12 +73,12 @@ /* * PHP functions */ -require_once $path2."DB-Func.php"; +require_once $path2 . "DB-Func.php"; require_once "./include/common/common-Func.php"; $serviceObj = new CentreonService($pearDB); $lockedElements = $serviceObj->getLockedServiceTemplates(); - + /* Set the real page */ if ($ret['topology_page'] != "" && $p != $ret['topology_page']) { $p = $ret['topology_page']; @@ -86,42 +86,42 @@ switch ($o) { case "a": - require_once($path."formServiceTemplateModel.php"); + require_once($path . "formServiceTemplateModel.php"); break; #Add a Service Template Model case "w": - require_once($path."formServiceTemplateModel.php"); + require_once($path . "formServiceTemplateModel.php"); break; #Watch a Service Template Model case "c": - require_once($path."formServiceTemplateModel.php"); + require_once($path . "formServiceTemplateModel.php"); break; #Modify a Service Template Model case "mc": - require_once($path."formServiceTemplateModel.php"); + require_once($path . "formServiceTemplateModel.php"); break; #Massive change case "s": enableServiceInDB($service_id); - require_once($path."listServiceTemplateModel.php"); + require_once($path . "listServiceTemplateModel.php"); break; #Activate a Service Template Model case "ms": enableServiceInDB(null, isset($select) ? $select : array()); - require_once($path."listServiceTemplateModel.php"); + require_once($path . "listServiceTemplateModel.php"); break; case "u": disableServiceInDB($service_id); - require_once($path."listServiceTemplateModel.php"); + require_once($path . "listServiceTemplateModel.php"); break; #Desactivate a Service Template Model case "mu": disableServiceInDB(null, isset($select) ? $select : array()); - require_once($path."listServiceTemplateModel.php"); + require_once($path . "listServiceTemplateModel.php"); break; case "m": multipleServiceInDB(isset($select) ? $select : array(), $dupNbr); - require_once($path."listServiceTemplateModel.php"); + require_once($path . "listServiceTemplateModel.php"); break; #Duplicate n Service Template Models case "d": deleteServiceInDB(isset($select) ? $select : array()); - require_once($path."listServiceTemplateModel.php"); + require_once($path . "listServiceTemplateModel.php"); break; #Delete n Service Template Models default: - require_once($path."listServiceTemplateModel.php"); + require_once($path . "listServiceTemplateModel.php"); break; } From 9f25142c48bb5024a84e45fc7f4bbf28f3db354f Mon Sep 17 00:00:00 2001 From: loiclau Date: Fri, 28 Jul 2017 16:09:30 +0200 Subject: [PATCH 094/207] * fix style servicegroup dependency --- .../servicegroup_dependency/DB-Func.php | 125 ++++++++---- .../formServiceGroupDependency.php | 192 +++++++++++++----- .../listServiceGroupDependency.php | 119 ++++++----- .../serviceGroupDependency.php | 18 +- 4 files changed, 313 insertions(+), 141 deletions(-) diff --git a/www/include/configuration/configObject/servicegroup_dependency/DB-Func.php b/www/include/configuration/configObject/servicegroup_dependency/DB-Func.php index 360384c5a5e..283bda80fe5 100644 --- a/www/include/configuration/configObject/servicegroup_dependency/DB-Func.php +++ b/www/include/configuration/configObject/servicegroup_dependency/DB-Func.php @@ -51,7 +51,9 @@ function testServiceGroupDependencyExistence($name = null) if (isset($form)) { $id = $form->getSubmitValue('dep_id'); } - $DBRESULT = $pearDB->query("SELECT dep_name, dep_id FROM dependency WHERE dep_name = '".htmlentities($name, ENT_QUOTES, "UTF-8")."'"); + $query = "SELECT dep_name, dep_id FROM dependency WHERE dep_name = '" . + htmlentities($name, ENT_QUOTES, "UTF-8") . "'"; + $DBRESULT = $pearDB->query($query); $dep = $DBRESULT->fetchRow(); #Modif case if ($DBRESULT->rowCount() >= 1 && $dep["dep_id"] == $id) { @@ -87,10 +89,10 @@ function deleteServiceGroupDependencyInDB($dependencies = array()) { global $pearDB, $oreon; foreach ($dependencies as $key => $value) { - $DBRESULT2 = $pearDB->query("SELECT dep_name FROM `dependency` WHERE `dep_id` = '".$key."' LIMIT 1"); + $DBRESULT2 = $pearDB->query("SELECT dep_name FROM `dependency` WHERE `dep_id` = '" . $key . "' LIMIT 1"); $row = $DBRESULT2->fetchRow(); - $DBRESULT = $pearDB->query("DELETE FROM dependency WHERE dep_id = '".$key."'"); + $pearDB->query("DELETE FROM dependency WHERE dep_id = '" . $key . "'"); $oreon->CentreonLogAction->insertLog("servicegroup dependency", $key, $row['dep_name'], "d"); } } @@ -99,14 +101,16 @@ function multipleServiceGroupDependencyInDB($dependencies = array(), $nbrDup = a { foreach ($dependencies as $key => $value) { global $pearDB, $oreon; - $DBRESULT = $pearDB->query("SELECT * FROM dependency WHERE dep_id = '".$key."' LIMIT 1"); + $DBRESULT = $pearDB->query("SELECT * FROM dependency WHERE dep_id = '" . $key . "' LIMIT 1"); $row = $DBRESULT->fetchRow(); $row["dep_id"] = ''; for ($i = 1; $i <= $nbrDup[$key]; $i++) { $val = null; foreach ($row as $key2 => $value2) { - $key2 == "dep_name" ? ($dep_name = $value2 = $value2."_".$i) : null; - $val ? $val .= ($value2!=null?(", '".$value2."'"):", NULL") : $val .= ($value2!=null?("'".$value2."'"):"NULL"); + $key2 == "dep_name" ? ($dep_name = $value2 = $value2 . "_" . $i) : null; + $val + ? $val .= ($value2 != null ? (", '" . $value2 . "'") : ", NULL") + : $val .= ($value2 != null ? ("'" . $value2 . "'") : "NULL"); if ($key2 != "dep_id") { $fields[$key2] = $value2; } @@ -115,27 +119,41 @@ function multipleServiceGroupDependencyInDB($dependencies = array(), $nbrDup = a } } if (isset($dep_name) && testServiceGroupDependencyExistence($dep_name)) { - $val ? $rq = "INSERT INTO dependency VALUES (".$val.")" : $rq = null; - $DBRESULT = $pearDB->query($rq); + $val ? $rq = "INSERT INTO dependency VALUES (" . $val . ")" : $rq = null; + $pearDB->query($rq); $DBRESULT = $pearDB->query("SELECT MAX(dep_id) FROM dependency"); $maxId = $DBRESULT->fetchRow(); if (isset($maxId["MAX(dep_id)"])) { - $DBRESULT = $pearDB->query("SELECT DISTINCT servicegroup_sg_id FROM dependency_servicegroupParent_relation WHERE dependency_dep_id = '".$key."'"); + $query = "SELECT DISTINCT servicegroup_sg_id FROM dependency_servicegroupParent_relation " . + "WHERE dependency_dep_id = '" . $key . "'"; + $DBRESULT = $pearDB->query($query); $fields["dep_sgParents"] = ""; while ($sg = $DBRESULT->fetchRow()) { - $DBRESULT2 = $pearDB->query("INSERT INTO dependency_servicegroupParent_relation VALUES ('', '".$maxId["MAX(dep_id)"]."', '".$sg["servicegroup_sg_id"]."')"); + $query = "INSERT INTO dependency_servicegroupParent_relation " . + "VALUES ('', '" . $maxId["MAX(dep_id)"] . "', '" . $sg["servicegroup_sg_id"] . "')"; + $pearDB->query($query); $fields["dep_sgParents"] .= $sg["servicegroup_sg_id"] . ","; } $fields["dep_sgParents"] = trim($fields["dep_sgParents"], ","); $DBRESULT->closeCursor(); - $DBRESULT = $pearDB->query("SELECT DISTINCT servicegroup_sg_id FROM dependency_servicegroupChild_relation WHERE dependency_dep_id = '".$key."'"); + $query = "SELECT DISTINCT servicegroup_sg_id FROM dependency_servicegroupChild_relation " . + "WHERE dependency_dep_id = '" . $key . "'"; + $DBRESULT = $pearDB->query($query); $fields["dep_sgChilds"] = ""; while ($sg = $DBRESULT->fetchRow()) { - $DBRESULT2 = $pearDB->query("INSERT INTO dependency_servicegroupChild_relation VALUES ('', '".$maxId["MAX(dep_id)"]."', '".$sg["servicegroup_sg_id"]."')"); + $query = "INSERT INTO dependency_servicegroupChild_relation " . + "VALUES ('', '" . $maxId["MAX(dep_id)"] . "', '" . $sg["servicegroup_sg_id"] . "')"; + $pearDB->query($query); $fields["dep_sgChilds"] .= $sg["servicegroup_sg_id"] . ","; } $fields["dep_sgChilds"] = trim($fields["dep_sgChilds"], ","); - $oreon->CentreonLogAction->insertLog("servicegroup dependency", $maxId["MAX(dep_id)"], $dep_name, "a", $fields); + $oreon->CentreonLogAction->insertLog( + "servicegroup dependency", + $maxId["MAX(dep_id)"], + $dep_name, + "a", + $fields + ); $DBRESULT->closeCursor(); } } @@ -169,16 +187,29 @@ function insertServiceGroupDependency($ret = array()) $ret = $form->getSubmitValues(); } $rq = "INSERT INTO dependency "; - $rq .= "(dep_name, dep_description, inherits_parent, execution_failure_criteria, notification_failure_criteria, dep_comment) "; + $rq .= "(dep_name, dep_description, inherits_parent, execution_failure_criteria, " . + "notification_failure_criteria, dep_comment) "; $rq .= "VALUES ("; - isset($ret["dep_name"]) && $ret["dep_name"] != null ? $rq .= "'".htmlentities($ret["dep_name"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; - isset($ret["dep_description"]) && $ret["dep_description"] != null ? $rq .= "'".htmlentities($ret["dep_description"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; - isset($ret["inherits_parent"]["inherits_parent"]) && $ret["inherits_parent"]["inherits_parent"] != null ? $rq .= "'".$ret["inherits_parent"]["inherits_parent"]."', " : $rq .= "NULL, "; - isset($ret["execution_failure_criteria"]) && $ret["execution_failure_criteria"] != null ? $rq .= "'".implode(",", array_keys($ret["execution_failure_criteria"]))."', " : $rq .= "NULL, "; - isset($ret["notification_failure_criteria"]) && $ret["notification_failure_criteria"] != null ? $rq .= "'".implode(",", array_keys($ret["notification_failure_criteria"]))."', " : $rq .= "NULL, "; - isset($ret["dep_comment"]) && $ret["dep_comment"] != null ? $rq .= "'".htmlentities($ret["dep_comment"], ENT_QUOTES, "UTF-8")."' " : $rq .= "NULL "; + isset($ret["dep_name"]) && $ret["dep_name"] != null + ? $rq .= "'" . htmlentities($ret["dep_name"], ENT_QUOTES, "UTF-8") . "', " + : $rq .= "NULL, "; + isset($ret["dep_description"]) && $ret["dep_description"] != null + ? $rq .= "'" . htmlentities($ret["dep_description"], ENT_QUOTES, "UTF-8") . "', " + : $rq .= "NULL, "; + isset($ret["inherits_parent"]["inherits_parent"]) && $ret["inherits_parent"]["inherits_parent"] != null + ? $rq .= "'" . $ret["inherits_parent"]["inherits_parent"] . "', " + : $rq .= "NULL, "; + isset($ret["execution_failure_criteria"]) && $ret["execution_failure_criteria"] != null + ? $rq .= "'" . implode(",", array_keys($ret["execution_failure_criteria"])) . "', " + : $rq .= "NULL, "; + isset($ret["notification_failure_criteria"]) && $ret["notification_failure_criteria"] != null + ? $rq .= "'" . implode(",", array_keys($ret["notification_failure_criteria"])) . "', " + : $rq .= "NULL, "; + isset($ret["dep_comment"]) && $ret["dep_comment"] != null + ? $rq .= "'" . htmlentities($ret["dep_comment"], ENT_QUOTES, "UTF-8") . "' " + : $rq .= "NULL "; $rq .= ")"; - $DBRESULT = $pearDB->query($rq); + $pearDB->query($rq); $DBRESULT = $pearDB->query("SELECT MAX(dep_id) FROM dependency"); $dep_id = $DBRESULT->fetchRow(); @@ -196,7 +227,13 @@ function insertServiceGroupDependency($ret = array()) if (isset($ret["dep_sgChilds"])) { $fields["dep_sgChilds"] = implode(",", $ret["dep_sgChilds"]); } - $oreon->CentreonLogAction->insertLog("servicegroup dependency", $dep_id["MAX(dep_id)"], htmlentities($ret["dep_name"], ENT_QUOTES, "UTF-8"), "a", $fields); + $oreon->CentreonLogAction->insertLog( + "servicegroup dependency", + $dep_id["MAX(dep_id)"], + htmlentities($ret["dep_name"], ENT_QUOTES, "UTF-8"), + "a", + $fields + ); return ($dep_id["MAX(dep_id)"]); } @@ -212,19 +249,31 @@ function updateServiceGroupDependency($dep_id = null) $ret = $form->getSubmitValues(); $rq = "UPDATE dependency SET "; $rq .= "dep_name = "; - isset($ret["dep_name"]) && $ret["dep_name"] != null ? $rq .= "'".htmlentities($ret["dep_name"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + isset($ret["dep_name"]) && $ret["dep_name"] != null + ? $rq .= "'" . htmlentities($ret["dep_name"], ENT_QUOTES, "UTF-8") . "', " + : $rq .= "NULL, "; $rq .= "dep_description = "; - isset($ret["dep_description"]) && $ret["dep_description"] != null ? $rq .= "'".htmlentities($ret["dep_description"], ENT_QUOTES, "UTF-8")."', " : $rq .= "NULL, "; + isset($ret["dep_description"]) && $ret["dep_description"] != null + ? $rq .= "'" . htmlentities($ret["dep_description"], ENT_QUOTES, "UTF-8") . "', " + : $rq .= "NULL, "; $rq .= "inherits_parent = "; - isset($ret["inherits_parent"]["inherits_parent"]) && $ret["inherits_parent"]["inherits_parent"] != null ? $rq .= "'".$ret["inherits_parent"]["inherits_parent"]."', " : $rq .= "NULL, "; + isset($ret["inherits_parent"]["inherits_parent"]) && $ret["inherits_parent"]["inherits_parent"] != null + ? $rq .= "'" . $ret["inherits_parent"]["inherits_parent"] . "', " + : $rq .= "NULL, "; $rq .= "execution_failure_criteria = "; - isset($ret["execution_failure_criteria"]) && $ret["execution_failure_criteria"] != null ? $rq .= "'".implode(",", array_keys($ret["execution_failure_criteria"]))."', " : $rq .= "NULL, "; + isset($ret["execution_failure_criteria"]) && $ret["execution_failure_criteria"] != null + ? $rq .= "'" . implode(",", array_keys($ret["execution_failure_criteria"])) . "', " + : $rq .= "NULL, "; $rq .= "notification_failure_criteria = "; - isset($ret["notification_failure_criteria"]) && $ret["notification_failure_criteria"] != null ? $rq .= "'".implode(",", array_keys($ret["notification_failure_criteria"]))."', " : $rq .= "NULL, "; + isset($ret["notification_failure_criteria"]) && $ret["notification_failure_criteria"] != null + ? $rq .= "'" . implode(",", array_keys($ret["notification_failure_criteria"])) . "', " + : $rq .= "NULL, "; $rq .= "dep_comment = "; - isset($ret["dep_comment"]) && $ret["dep_comment"] != null ? $rq .= "'".htmlentities($ret["dep_comment"], ENT_QUOTES, "UTF-8")."' " : $rq .= "NULL "; - $rq .= "WHERE dep_id = '".$dep_id."'"; - $DBRESULT = $pearDB->query($rq); + isset($ret["dep_comment"]) && $ret["dep_comment"] != null + ? $rq .= "'" . htmlentities($ret["dep_comment"], ENT_QUOTES, "UTF-8") . "' " + : $rq .= "NULL "; + $rq .= "WHERE dep_id = '" . $dep_id . "'"; + $pearDB->query($rq); $fields["dep_name"] = htmlentities($ret["dep_name"], ENT_QUOTES, "UTF-8"); $fields["dep_description"] = htmlentities($ret["dep_description"], ENT_QUOTES, "UTF-8"); @@ -240,7 +289,13 @@ function updateServiceGroupDependency($dep_id = null) if (isset($ret["dep_sgChilds"])) { $fields["dep_sgChilds"] = implode(",", $ret["dep_sgChilds"]); } - $oreon->CentreonLogAction->insertLog("servicegroup dependency", $dep_id, htmlentities($ret["dep_name"], ENT_QUOTES, "UTF-8"), "c", $fields); + $oreon->CentreonLogAction->insertLog( + "servicegroup dependency", + $dep_id, + htmlentities($ret["dep_name"], ENT_QUOTES, "UTF-8"), + "c", + $fields + ); } function updateServiceGroupDependencyServiceGroupParents($dep_id = null, $ret = array()) @@ -251,7 +306,7 @@ function updateServiceGroupDependencyServiceGroupParents($dep_id = null, $ret = global $form; global $pearDB; $rq = "DELETE FROM dependency_servicegroupParent_relation "; - $rq .= "WHERE dependency_dep_id = '".$dep_id."'"; + $rq .= "WHERE dependency_dep_id = '" . $dep_id . "'"; $DBRESULT = $pearDB->query($rq); if (isset($ret["dep_sgParents"])) { $ret = $ret["dep_sgParents"]; @@ -262,7 +317,7 @@ function updateServiceGroupDependencyServiceGroupParents($dep_id = null, $ret = $rq = "INSERT INTO dependency_servicegroupParent_relation "; $rq .= "(dependency_dep_id, servicegroup_sg_id) "; $rq .= "VALUES "; - $rq .= "('".$dep_id."', '".$ret[$i]."')"; + $rq .= "('" . $dep_id . "', '" . $ret[$i] . "')"; $DBRESULT = $pearDB->query($rq); } } @@ -275,7 +330,7 @@ function updateServiceGroupDependencyServiceGroupChilds($dep_id = null, $ret = a global $form; global $pearDB; $rq = "DELETE FROM dependency_servicegroupChild_relation "; - $rq .= "WHERE dependency_dep_id = '".$dep_id."'"; + $rq .= "WHERE dependency_dep_id = '" . $dep_id . "'"; $DBRESULT = $pearDB->query($rq); if (isset($ret["dep_sgChilds"])) { $ret = $ret["dep_sgChilds"]; @@ -286,7 +341,7 @@ function updateServiceGroupDependencyServiceGroupChilds($dep_id = null, $ret = a $rq = "INSERT INTO dependency_servicegroupChild_relation "; $rq .= "(dependency_dep_id, servicegroup_sg_id) "; $rq .= "VALUES "; - $rq .= "('".$dep_id."', '".$ret[$i]."')"; + $rq .= "('" . $dep_id . "', '" . $ret[$i] . "')"; $DBRESULT = $pearDB->query($rq); } } diff --git a/www/include/configuration/configObject/servicegroup_dependency/formServiceGroupDependency.php b/www/include/configuration/configObject/servicegroup_dependency/formServiceGroupDependency.php index 87678bcd58d..e4946d76957 100644 --- a/www/include/configuration/configObject/servicegroup_dependency/formServiceGroupDependency.php +++ b/www/include/configuration/configObject/servicegroup_dependency/formServiceGroupDependency.php @@ -38,9 +38,9 @@ ## Database retrieve information for Dependency # $dep = array(); - $initialValues = array(); +$initialValues = array(); if (($o == "c" || $o == "w") && $dep_id) { - $DBRESULT = $pearDB->query("SELECT * FROM dependency WHERE dep_id = '".$dep_id."' LIMIT 1"); + $DBRESULT = $pearDB->query("SELECT * FROM dependency WHERE dep_id = '" . $dep_id . "' LIMIT 1"); # Set base value $dep = array_map("myDecode", $DBRESULT->fetchRow()); @@ -68,14 +68,17 @@ /* * Var information to format the element */ -$attrsText = array("size"=>"30"); -$attrsText2 = array("size"=>"10"); +$attrsText = array("size" => "30"); +$attrsText2 = array("size" => "10"); $attrsAdvSelect = array("style" => "width: 300px; height: 150px;"); -$attrsTextarea = array("rows"=>"3", "cols"=>"30"); -$eTemplate = '
{label_2}
{unselected}
{add}


{remove}
{label_3}
{selected}
'; +$attrsTextarea = array("rows" => "3", "cols" => "30"); +$eTemplate = '
{label_2}
{unselected}
{add}

' . + '
{remove}
{label_3}
{selected}
'; + +$route = './include/common/webServices/rest/internal.php?object=centreon_configuration_servicegroup&action=list'; $attrServicegroups = array( 'datasourceOrigin' => 'ajax', - 'availableDatasetRoute' => './include/common/webServices/rest/internal.php?object=centreon_configuration_servicegroup&action=list', + 'availableDatasetRoute' => $route, 'multiple' => true, 'linkedObject' => 'centreonServicegroups' ); @@ -83,7 +86,7 @@ /* * Form begin */ -$form = new HTML_QuickForm('Form', 'post', "?p=".$p); +$form = new HTML_QuickForm('Form', 'post', "?p=" . $p); if ($o == "a") { $form->addElement('header', 'title', _("Add a Dependency")); } elseif ($o == "c") { @@ -103,35 +106,111 @@ $tab[] = HTML_QuickForm::createElement('radio', 'inherits_parent', null, _("Yes"), '1'); $tab[] = HTML_QuickForm::createElement('radio', 'inherits_parent', null, _("No"), '0'); $form->addGroup($tab, 'inherits_parent', _("Parent relationship"), ' '); -$form->setDefaults(array('inherits_parent'=>'1')); +$form->setDefaults(array('inherits_parent' => '1')); $tab = array(); -$tab[] = HTML_QuickForm::createElement('checkbox', 'o', ' ', _("Ok"), array('id' => 'sOk', 'onClick' => 'uncheckAllS(this);')); -$tab[] = HTML_QuickForm::createElement('checkbox', 'w', ' ', _("Warning"), array('id' => 'sWarning', 'onClick' => 'uncheckAllS(this);')); -$tab[] = HTML_QuickForm::createElement('checkbox', 'u', ' ', _("Unknown"), array('id' => 'sUnknown', 'onClick' => 'uncheckAllS(this);')); -$tab[] = HTML_QuickForm::createElement('checkbox', 'c', ' ', _("Critical"), array('id' => 'sCritical', 'onClick' => 'uncheckAllS(this);')); -$tab[] = HTML_QuickForm::createElement('checkbox', 'p', ' ', _("Pending"), array('id' => 'sPending', 'onClick' => 'uncheckAllS(this);')); -$tab[] = HTML_QuickForm::createElement('checkbox', 'n', ' ', _("None"), array('id' => 'sNone', 'onClick' => 'uncheckAllS(this);')); +$tab[] = HTML_QuickForm::createElement( + 'checkbox', + 'o', + ' ', + _("Ok"), + array('id' => 'sOk', 'onClick' => 'uncheckAllS(this);') +); +$tab[] = HTML_QuickForm::createElement( + 'checkbox', + 'w', + ' ', + _("Warning"), + array('id' => 'sWarning', 'onClick' => 'uncheckAllS(this);') +); +$tab[] = HTML_QuickForm::createElement( + 'checkbox', + 'u', + ' ', + _("Unknown"), + array('id' => 'sUnknown', 'onClick' => 'uncheckAllS(this);') +); +$tab[] = HTML_QuickForm::createElement( + 'checkbox', + 'c', + ' ', + _("Critical"), + array('id' => 'sCritical', 'onClick' => 'uncheckAllS(this);') +); +$tab[] = HTML_QuickForm::createElement( + 'checkbox', + 'p', + ' ', + _("Pending"), + array('id' => 'sPending', 'onClick' => 'uncheckAllS(this);') +); +$tab[] = HTML_QuickForm::createElement( + 'checkbox', + 'n', + ' ', + _("None"), + array('id' => 'sNone', 'onClick' => 'uncheckAllS(this);') +); $form->addGroup($tab, 'notification_failure_criteria', _("Notification Failure Criteria"), '  '); $tab = array(); -$tab[] = HTML_QuickForm::createElement('checkbox', 'o', ' ', _("Ok"), array('id' => 'sOk2', 'onClick' => 'uncheckAllS2(this);')); -$tab[] = HTML_QuickForm::createElement('checkbox', 'w', ' ', _("Warning"), array('id' => 'sWarning2', 'onClick' => 'uncheckAllS2(this);')); -$tab[] = HTML_QuickForm::createElement('checkbox', 'u', ' ', _("Unknown"), array('id' => 'sUnknown2', 'onClick' => 'uncheckAllS2(this);')); -$tab[] = HTML_QuickForm::createElement('checkbox', 'c', ' ', _("Critical"), array('id' => 'sCritical2', 'onClick' => 'uncheckAllS2(this);')); -$tab[] = HTML_QuickForm::createElement('checkbox', 'p', ' ', _("Pending"), array('id' => 'sPending2', 'onClick' => 'uncheckAllS2(this);')); -$tab[] = HTML_QuickForm::createElement('checkbox', 'n', ' ', _("None"), array('id' => 'sNone2', 'onClick' => 'uncheckAllS2(this);')); +$tab[] = HTML_QuickForm::createElement( + 'checkbox', + 'o', + ' ', + _("Ok"), + array('id' => 'sOk2', 'onClick' => 'uncheckAllS2(this);') +); +$tab[] = HTML_QuickForm::createElement( + 'checkbox', + 'w', + ' ', + _("Warning"), + array('id' => 'sWarning2', 'onClick' => 'uncheckAllS2(this);') +); +$tab[] = HTML_QuickForm::createElement( + 'checkbox', + 'u', + ' ', + _("Unknown"), + array('id' => 'sUnknown2', 'onClick' => 'uncheckAllS2(this);') +); +$tab[] = HTML_QuickForm::createElement( + 'checkbox', + 'c', + ' ', + _("Critical"), + array('id' => 'sCritical2', 'onClick' => 'uncheckAllS2(this);') +); +$tab[] = HTML_QuickForm::createElement( + 'checkbox', + 'p', + ' ', + _("Pending"), + array('id' => 'sPending2', 'onClick' => 'uncheckAllS2(this);') +); +$tab[] = HTML_QuickForm::createElement( + 'checkbox', + 'n', + ' ', + _("None"), + array('id' => 'sNone2', 'onClick' => 'uncheckAllS2(this);') +); $form->addGroup($tab, 'execution_failure_criteria', _("Execution Failure Criteria"), '  '); +$query = './include/common/webServices/rest/internal.php?object=centreon_configuration_servicegroup' . + '&action=defaultValues&target=dependency&field=dep_sgParents&id=' . $dep_id; $attrServicegroup1 = array_merge( $attrServicegroups, - array('defaultDatasetRoute' => './include/common/webServices/rest/internal.php?object=centreon_configuration_servicegroup&action=defaultValues&target=dependency&field=dep_sgParents&id=' . $dep_id) + array('defaultDatasetRoute' => $query) ); $form->addElement('select2', 'dep_sgParents', _("Linked with Servicegroups"), array(), $attrServicegroup1); -$attrServicegroup2= array_merge( +$route = './include/common/webServices/rest/internal.php?object=centreon_configuration_servicegroup' . + '&action=defaultValues&target=dependency&field=dep_sgChilds&id=' . $dep_id; +$attrServicegroup2 = array_merge( $attrServicegroups, - array('defaultDatasetRoute' => './include/common/webServices/rest/internal.php?object=centreon_configuration_servicegroup&action=defaultValues&target=dependency&field=dep_sgChilds&id=' . $dep_id) + array('defaultDatasetRoute' => $route) ); $form->addElement('select2', 'dep_sgChilds', _("Linked with Servicegroups"), array(), $attrServicegroup2); @@ -141,9 +220,9 @@ $redirect = $form->addElement('hidden', 'o'); $redirect->setValue($o); - $init = $form->addElement('hidden', 'initialValues'); - $init->setValue(serialize($initialValues)); - +$init = $form->addElement('hidden', 'initialValues'); +$init->setValue(serialize($initialValues)); + /* * Form Rules */ @@ -159,7 +238,7 @@ $form->addRule('dep_sgChilds', _("Circular Definition"), 'cycle'); $form->registerRule('exist', 'callback', 'testServiceGroupDependencyExistence'); $form->addRule('dep_name', _("Name is already in use"), 'exist'); -$form->setRequiredNote("* ". _("Required fields")); +$form->setRequiredNote("* " . _("Required fields")); /* * Smarty template Init @@ -172,7 +251,12 @@ */ if ($o == "w") { if ($centreon->user->access->page($p) != 2) { - $form->addElement("button", "change", _("Modify"), array("onClick"=>"javascript:window.location.href='?p=".$p."&o=c&dep_id=".$dep_id."'")); + $form->addElement( + "button", + "change", + _("Modify"), + array("onClick" => "javascript:window.location.href='?p=" . $p . "&o=c&dep_id=" . $dep_id . "'") + ); } $form->setDefaults($dep); $form->freeze(); @@ -187,12 +271,17 @@ $res = $form->addElement('reset', 'reset', _("Reset"), array("class" => "btc bt_default")); $form->setDefaults(array('inherits_parent', '0')); } -$tpl->assign("helpattr", 'TITLE, "'._("Help").'", CLOSEBTN, true, FIX, [this, 0, 5], BGCOLOR, "#ffff99", BORDERCOLOR, "orange", TITLEFONTCOLOR, "black", TITLEBGCOLOR, "orange", CLOSEBTNCOLORS, ["","black", "white", "red"], WIDTH, -300, SHADOW, true, TEXTALIGN, "justify"'); +$tpl->assign( + "helpattr", + 'TITLE, "' . _("Help") . '", CLOSEBTN, true, FIX, [this, 0, 5], BGCOLOR, "#ffff99", BORDERCOLOR, ' . + '"orange", TITLEFONTCOLOR, "black", TITLEBGCOLOR, "orange", CLOSEBTNCOLORS, ["","black", "white", "red"], ' . + 'WIDTH, -300, SHADOW, true, TEXTALIGN, "justify"' +); # prepare help texts $helptext = ""; include_once("include/configuration/configObject/service_dependency/help.php"); foreach ($help as $key => $text) { - $helptext .= ''."\n"; + $helptext .= '' . "\n"; } $tpl->assign("helptext", $helptext); @@ -224,26 +313,27 @@ } ?> diff --git a/www/include/configuration/configObject/servicegroup_dependency/listServiceGroupDependency.php b/www/include/configuration/configObject/servicegroup_dependency/listServiceGroupDependency.php index 85e4fce0928..02b9175e18a 100644 --- a/www/include/configuration/configObject/servicegroup_dependency/listServiceGroupDependency.php +++ b/www/include/configuration/configObject/servicegroup_dependency/listServiceGroupDependency.php @@ -38,16 +38,16 @@ } include_once("./class/centreonUtils.class.php"); - + include("./include/common/autoNumLimit.php"); isset($_GET["list"]) ? $list = $_GET["list"] : $list = null; - + $aclCond = ""; if (!$centreon->user->admin) { $aclCond = " AND servicegroup_sg_id IN ($sgstring) "; } - + $rq = "SELECT COUNT(*) FROM dependency dep"; $rq .= " WHERE ((SELECT DISTINCT COUNT(*) FROM dependency_servicegroupParent_relation dsgpr @@ -62,7 +62,8 @@ $search = ''; if (isset($_POST['searchSGD']) && $_POST['searchSGD']) { $search = $_POST['searchSGD']; - $rq .= " AND (dep_name LIKE '%".htmlentities($search, ENT_QUOTES, "UTF-8")."%' OR dep_description LIKE '%".htmlentities($search, ENT_QUOTES, "UTF-8")."%')"; + $rq .= " AND (dep_name LIKE '%" . htmlentities($search, ENT_QUOTES, "UTF-8") . + "%' OR dep_description LIKE '%" . htmlentities($search, ENT_QUOTES, "UTF-8") . "%')"; } $DBRESULT = $pearDB->query($rq); @@ -103,14 +104,15 @@ * Search Case */ if ($search) { - $rq .= " AND (dep_name LIKE '%".htmlentities($search, ENT_QUOTES, "UTF-8")."%' OR dep_description LIKE '%".htmlentities($search, ENT_QUOTES, "UTF-8")."%')"; + $rq .= " AND (dep_name LIKE '%" . htmlentities($search, ENT_QUOTES, "UTF-8") . + "%' OR dep_description LIKE '%" . htmlentities($search, ENT_QUOTES, "UTF-8") . "%')"; } -$rq .= " ORDER BY dep_name, dep_description LIMIT ".$num * $limit.", ".$limit; +$rq .= " ORDER BY dep_name, dep_description LIMIT " . $num * $limit . ", " . $limit; $DBRESULT = $pearDB->query($rq); $search = tidySearchKey($search, $advanced_search); -$form = new HTML_QuickForm('select_form', 'POST', "?p=".$p); +$form = new HTML_QuickForm('select_form', 'POST', "?p=" . $p); /* * Different style between each lines @@ -123,14 +125,18 @@ $elemArr = array(); for ($i = 0; $dep = $DBRESULT->fetchRow(); $i++) { $moptions = ""; - $selectedElements = $form->addElement('checkbox', "select[".$dep['dep_id']."]"); - $moptions .= "  31 && (event.keyCode < 45 || event.keyCode > 57)) event.returnValue = false; if(event.which > 31 && (event.which < 45 || event.which > 57)) return false;\" maxlength=\"3\" size=\"3\" value='1' style=\"margin-bottom:0px;\" name='dupNbr[".$dep['dep_id']."]'>"; - $elemArr[$i] = array( "MenuClass"=>"list_".$style, - "RowMenu_select"=>$selectedElements->toHtml(), - "RowMenu_name"=>CentreonUtils::escapeSecure(htmlentities($dep["dep_name"])), - "RowMenu_link"=>"?p=".$p."&o=c&dep_id=".$dep['dep_id'], - "RowMenu_description"=>CentreonUtils::escapeSecure(htmlentities($dep["dep_description"])), - "RowMenu_options"=>$moptions); + $selectedElements = $form->addElement('checkbox', "select[" . $dep['dep_id'] . "]"); + $moptions .= "  31 && (event.keyCode < 45 || event.keyCode > 57)) " . + "event.returnValue = false; if(event.which > 31 && (event.which < 45 || event.which > 57)) return false;" . + "\" maxlength=\"3\" size=\"3\" value='1' style=\"margin-bottom:0px;\" name='dupNbr[" . $dep['dep_id'] . "]' />"; + $elemArr[$i] = array( + "MenuClass" => "list_" . $style, + "RowMenu_select" => $selectedElements->toHtml(), + "RowMenu_name" => CentreonUtils::escapeSecure(htmlentities($dep["dep_name"])), + "RowMenu_link" => "?p=" . $p . "&o=c&dep_id=" . $dep['dep_id'], + "RowMenu_description" => CentreonUtils::escapeSecure(htmlentities($dep["dep_description"])), + "RowMenu_options" => $moptions + ); $style != "two" ? $style = "two" : $style = "one"; } $tpl->assign("elemArr", $elemArr); @@ -138,47 +144,68 @@ /* * Different messages we put in the template */ -$tpl->assign('msg', array ("addL"=>"?p=".$p."&o=a", "addT"=>_("Add"), "delConfirm"=>_("Do you confirm the deletion ?"))); +$tpl->assign( + 'msg', + array("addL" => "?p=" . $p . "&o=a", "addT" => _("Add"), "delConfirm" => _("Do you confirm the deletion ?")) +); /* * Toolbar select */ ?> - + "javascript: " . - " var bChecked = isChecked(); ". - " if (this.form.elements['o1'].selectedIndex != 0 && !bChecked) {". - " alert('"._("Please select one or more items")."'); return false;} " . - "if (this.form.elements['o1'].selectedIndex == 1 && confirm('"._("Do you confirm the duplication ?")."')) {" . - " setO(this.form.elements['o1'].value); submit();} " . - "else if (this.form.elements['o1'].selectedIndex == 2 && confirm('"._("Do you confirm the deletion ?")."')) {" . - " setO(this.form.elements['o1'].value); submit();} " . - "else if (this.form.elements['o1'].selectedIndex == 3) {" . - " setO(this.form.elements['o1'].value); submit();} " . - ""); -$form->addElement('select', 'o1', null, array(null=>_("More actions..."), "m"=>_("Duplicate"), "d"=>_("Delete")), $attrs1); + 'onchange' => "javascript: " . + " var bChecked = isChecked(); " . + " if (this.form.elements['o1'].selectedIndex != 0 && !bChecked) {" . + " alert('" . _("Please select one or more items") . "'); return false;} " . + "if (this.form.elements['o1'].selectedIndex == 1 && confirm('" . + _("Do you confirm the duplication ?") . "')) {" . + " setO(this.form.elements['o1'].value); submit();} " . + "else if (this.form.elements['o1'].selectedIndex == 2 && confirm('" . + _("Do you confirm the deletion ?") . "')) {" . + " setO(this.form.elements['o1'].value); submit();} " . + "else if (this.form.elements['o1'].selectedIndex == 3) {" . + " setO(this.form.elements['o1'].value); submit();} " . + "" +); +$form->addElement( + 'select', + 'o1', + null, + array(null => _("More actions..."), "m" => _("Duplicate"), "d" => _("Delete")), + $attrs1 +); $form->setDefaults(array('o1' => null)); - + $attrs2 = array( - 'onchange'=>"javascript: " . - " var bChecked = isChecked(); ". - " if (this.form.elements['o2'].selectedIndex != 0 && !bChecked) {". - " alert('"._("Please select one or more items")."'); return false;} " . - "if (this.form.elements['o2'].selectedIndex == 1 && confirm('"._("Do you confirm the duplication ?")."')) {" . - " setO(this.form.elements['o2'].value); submit();} " . - "else if (this.form.elements['o2'].selectedIndex == 2 && confirm('"._("Do you confirm the deletion ?")."')) {" . - " setO(this.form.elements['o2'].value); submit();} " . - "else if (this.form.elements['o2'].selectedIndex == 3) {" . - " setO(this.form.elements['o2'].value); submit();} " . - ""); -$form->addElement('select', 'o2', null, array(null=>_("More actions..."), "m"=>_("Duplicate"), "d"=>_("Delete")), $attrs2); + 'onchange' => "javascript: " . + " var bChecked = isChecked(); " . + " if (this.form.elements['o2'].selectedIndex != 0 && !bChecked) {" . + " alert('" . _("Please select one or more items") . "'); return false;} " . + "if (this.form.elements['o2'].selectedIndex == 1 && confirm('" . + _("Do you confirm the duplication ?") . "')) {" . + " setO(this.form.elements['o2'].value); submit();} " . + "else if (this.form.elements['o2'].selectedIndex == 2 && confirm('" . + _("Do you confirm the deletion ?") . "')) {" . + " setO(this.form.elements['o2'].value); submit();} " . + "else if (this.form.elements['o2'].selectedIndex == 3) {" . + " setO(this.form.elements['o2'].value); submit();} " . + "" +); +$form->addElement( + 'select', + 'o2', + null, + array(null => _("More actions..."), "m" => _("Duplicate"), "d" => _("Delete")), + $attrs2 +); $form->setDefaults(array('o2' => null)); $o1 = $form->getElement('o1'); diff --git a/www/include/configuration/configObject/servicegroup_dependency/serviceGroupDependency.php b/www/include/configuration/configObject/servicegroup_dependency/serviceGroupDependency.php index b249bc06947..33d2f6a283e 100644 --- a/www/include/configuration/configObject/servicegroup_dependency/serviceGroupDependency.php +++ b/www/include/configuration/configObject/servicegroup_dependency/serviceGroupDependency.php @@ -36,7 +36,7 @@ if (!isset($centreon)) { exit(); } - + isset($_GET["dep_id"]) ? $cG = $_GET["dep_id"] : $cG = null; isset($_POST["dep_id"]) ? $cP = $_POST["dep_id"] : $cP = null; $cG ? $dep_id = $cG : $dep_id = $cP; @@ -64,7 +64,7 @@ /* * PHP functions */ -require_once $path."DB-Func.php"; +require_once $path . "DB-Func.php"; require_once "./include/common/common-Func.php"; /* Set the real page */ @@ -75,26 +75,26 @@ $acl = $oreon->user->access; $sgs = $acl->getServiceGroupAclConf(null, 'broker'); $sgstring = CentreonUtils::toStringWithQuotes($sgs); - + switch ($o) { case "a": - require_once($path."formServiceGroupDependency.php"); + require_once($path . "formServiceGroupDependency.php"); break; #Add a Dependency case "w": - require_once($path."formServiceGroupDependency.php"); + require_once($path . "formServiceGroupDependency.php"); break; #Watch a Dependency case "c": - require_once($path."formServiceGroupDependency.php"); + require_once($path . "formServiceGroupDependency.php"); break; #Modify a Dependency case "m": multipleServiceGroupDependencyInDB(isset($select) ? $select : array(), $dupNbr); - require_once($path."listServiceGroupDependency.php"); + require_once($path . "listServiceGroupDependency.php"); break; #Duplicate n Dependencys case "d": deleteServiceGroupDependencyInDB(isset($select) ? $select : array()); - require_once($path."listServiceGroupDependency.php"); + require_once($path . "listServiceGroupDependency.php"); break; #Delete n Dependency default: - require_once($path."listServiceGroupDependency.php"); + require_once($path . "listServiceGroupDependency.php"); break; } From 695b46f928402047832d607717af56f5935baaa6 Mon Sep 17 00:00:00 2001 From: loiclau Date: Fri, 28 Jul 2017 16:25:58 +0200 Subject: [PATCH 095/207] * fix style timeperiod --- .../configObject/timeperiod/DB-Func.php | 159 +++++++++------ .../configObject/timeperiod/help.php | 27 ++- .../timeperiod/listTimeperiod.php | 79 ++++--- .../timeperiod/renderTimeperiod.php | 124 +++++------ .../configObject/timeperiod/timeperiod.php | 16 +- .../configObject/timeperiod/timeperiod_JS.php | 193 +++++++++--------- 6 files changed, 341 insertions(+), 257 deletions(-) diff --git a/www/include/configuration/configObject/timeperiod/DB-Func.php b/www/include/configuration/configObject/timeperiod/DB-Func.php index 3a410ccdfbc..acc92ef9fdb 100644 --- a/www/include/configuration/configObject/timeperiod/DB-Func.php +++ b/www/include/configuration/configObject/timeperiod/DB-Func.php @@ -48,12 +48,12 @@ function includeExcludeTimeperiods($tpId, $includeTab = array(), $excludeTab = a $str = ""; foreach ($includeTab as $tpIncludeId) { if ($str != "") { - $str.= ", "; + $str .= ", "; } - $str .= "('".$tpId."', '".$tpIncludeId."')"; + $str .= "('" . $tpId . "', '" . $tpIncludeId . "')"; } if (strlen($str)) { - $query = "INSERT INTO timeperiod_include_relations (timeperiod_id, timeperiod_include_id ) VALUES ".$str; + $query = "INSERT INTO timeperiod_include_relations (timeperiod_id, timeperiod_include_id ) VALUES " . $str; $pearDB->query($query); } } @@ -65,12 +65,12 @@ function includeExcludeTimeperiods($tpId, $includeTab = array(), $excludeTab = a $str = ""; foreach ($excludeTab as $tpExcludeId) { if ($str != "") { - $str.= ", "; + $str .= ", "; } - $str .= "('".$tpId."', '".$tpExcludeId."')"; + $str .= "('" . $tpId . "', '" . $tpExcludeId . "')"; } if (strlen($str)) { - $query = "INSERT INTO timeperiod_exclude_relations (timeperiod_id, timeperiod_exclude_id ) VALUES ".$str; + $query = "INSERT INTO timeperiod_exclude_relations (timeperiod_id, timeperiod_exclude_id ) VALUES " . $str; $pearDB->query($query); } } @@ -85,7 +85,9 @@ function testTPExistence($name = null) $id = $form->getSubmitValue('tp_id'); } - $DBRESULT = $pearDB->query("SELECT tp_name, tp_id FROM timeperiod WHERE tp_name = '".htmlentities($centreon->checkIllegalChar($name), ENT_QUOTES, "UTF-8")."'"); + $query = "SELECT tp_name, tp_id FROM timeperiod WHERE tp_name = '" . + htmlentities($centreon->checkIllegalChar($name), ENT_QUOTES, "UTF-8") . "'"; + $DBRESULT = $pearDB->query($query); $tp = $DBRESULT->fetchRow(); #Modif case if ($DBRESULT->rowCount() >= 1 && $tp["tp_id"] == $id) { @@ -102,9 +104,9 @@ function deleteTimeperiodInDB($timeperiods = array()) { global $pearDB, $centreon; foreach ($timeperiods as $key => $value) { - $DBRESULT2 = $pearDB->query("SELECT tp_name FROM `timeperiod` WHERE `tp_id` = '".$key."' LIMIT 1"); + $DBRESULT2 = $pearDB->query("SELECT tp_name FROM `timeperiod` WHERE `tp_id` = '" . $key . "' LIMIT 1"); $row = $DBRESULT2->fetchRow(); - $DBRESULT = $pearDB->query("DELETE FROM timeperiod WHERE tp_id = '".$key."'"); + $DBRESULT = $pearDB->query("DELETE FROM timeperiod WHERE tp_id = '" . $key . "'"); $centreon->CentreonLogAction->insertLog("timeperiod", $key, $row['tp_name'], "d"); } } @@ -117,9 +119,9 @@ function multipleTimeperiodInDB($timeperiods = array(), $nbrDup = array()) global $pearDB; $fields = array(); - $DBRESULT = $pearDB->query("SELECT * FROM timeperiod WHERE tp_id = '".$key."' LIMIT 1"); + $DBRESULT = $pearDB->query("SELECT * FROM timeperiod WHERE tp_id = '" . $key . "' LIMIT 1"); - $query = "SELECT days, timerange FROM timeperiod_exceptions WHERE timeperiod_id = '".$key."'"; + $query = "SELECT days, timerange FROM timeperiod_exceptions WHERE timeperiod_id = '" . $key . "'"; $res = $pearDB->query($query); while ($row = $res->fetchRow()) { foreach ($row as $keyz => $valz) { @@ -136,7 +138,9 @@ function multipleTimeperiodInDB($timeperiods = array(), $nbrDup = array()) $value2 .= "_" . $i; } $key2 == "tp_name" ? ($tp_name = $value2) : ""; - $val ? $val .= ($value2!=null?(", '".$value2."'"):", NULL") : $val .= ($value2!=null?("'".$value2."'"):"NULL"); + $val + ? $val .= ($value2 != null ? (", '" . $value2 . "'") : ", NULL") + : $val .= ($value2 != null ? ("'" . $value2 . "'") : "NULL"); if ($key2 != "tp_id") { $fields[$key2] = $value2; } @@ -145,7 +149,7 @@ function multipleTimeperiodInDB($timeperiods = array(), $nbrDup = array()) } } if (isset($tp_name) && testTPExistence($tp_name)) { - $DBRESULT = $pearDB->query($val ? $rq = "INSERT INTO timeperiod VALUES (".$val.")" : $rq = null); + $pearDB->query($val ? $rq = "INSERT INTO timeperiod VALUES (" . $val . ")" : $rq = null); /* * Get Max ID @@ -153,16 +157,19 @@ function multipleTimeperiodInDB($timeperiods = array(), $nbrDup = array()) $DBRESULT = $pearDB->query("SELECT MAX(tp_id) FROM `timeperiod`"); $tp_id = $DBRESULT->fetchRow(); - $query = "INSERT INTO timeperiod_exceptions (timeperiod_id, days, timerange) - SELECT ".$tp_id['MAX(tp_id)'].", days, timerange FROM timeperiod_exceptions WHERE timeperiod_id = '".$key."'"; + $query = "INSERT INTO timeperiod_exceptions (timeperiod_id, days, timerange) " . + "SELECT " . $tp_id['MAX(tp_id)'] . ", days, timerange FROM timeperiod_exceptions " . + "WHERE timeperiod_id = '" . $key . "'"; $pearDB->query($query); - $query = "INSERT INTO timeperiod_include_relations (timeperiod_id, timeperiod_include_id) - SELECT ".$tp_id['MAX(tp_id)'].", timeperiod_include_id FROM timeperiod_include_relations WHERE timeperiod_id = '".$key."'"; + $query = "INSERT INTO timeperiod_include_relations (timeperiod_id, timeperiod_include_id) " . + "SELECT " . $tp_id['MAX(tp_id)'] . ", timeperiod_include_id FROM timeperiod_include_relations " . + "WHERE timeperiod_id = '" . $key . "'"; $pearDB->query($query); - $query = "INSERT INTO timeperiod_exclude_relations (timeperiod_id, timeperiod_exclude_id) - SELECT ".$tp_id['MAX(tp_id)'].", timeperiod_exclude_id FROM timeperiod_exclude_relations WHERE timeperiod_id = '".$key."'"; + $query = "INSERT INTO timeperiod_exclude_relations (timeperiod_id, timeperiod_exclude_id) " . + "SELECT " . $tp_id['MAX(tp_id)'] . ", timeperiod_exclude_id FROM timeperiod_exclude_relations " . + "WHERE timeperiod_id = '" . $key . "'"; $pearDB->query($query); $centreon->CentreonLogAction->insertLog("timeperiod", $tp_id["MAX(tp_id)"], $tp_name, "a", $fields); @@ -196,20 +203,20 @@ function updateTimeperiod($tp_id, $params = array()) $ret["tp_name"] = $centreon->checkIllegalChar($ret["tp_name"]); $rq = "UPDATE timeperiod "; - $rq .= "SET tp_name = '".htmlentities($ret["tp_name"], ENT_QUOTES, "UTF-8")."', " . - "tp_alias = '".htmlentities($ret["tp_alias"], ENT_QUOTES, "UTF-8")."', " . - "tp_sunday = '".htmlentities($ret["tp_sunday"], ENT_QUOTES, "UTF-8")."', " . - "tp_monday = '".htmlentities($ret["tp_monday"], ENT_QUOTES, "UTF-8")."', " . - "tp_tuesday = '".htmlentities($ret["tp_tuesday"], ENT_QUOTES, "UTF-8")."', " . - "tp_wednesday = '".htmlentities($ret["tp_wednesday"], ENT_QUOTES, "UTF-8")."', " . - "tp_thursday = '".htmlentities($ret["tp_thursday"], ENT_QUOTES, "UTF-8")."', " . - "tp_friday = '".htmlentities($ret["tp_friday"], ENT_QUOTES, "UTF-8")."', " . - "tp_saturday = '".htmlentities($ret["tp_saturday"], ENT_QUOTES, "UTF-8")."' " . - "WHERE tp_id = '".$tp_id."'"; - $DBRESULT = $pearDB->query($rq); - - $pearDB->query("DELETE FROM timeperiod_include_relations WHERE timeperiod_id = '".$tp_id."'"); - $pearDB->query("DELETE FROM timeperiod_exclude_relations WHERE timeperiod_id = '".$tp_id."'"); + $rq .= "SET tp_name = '" . htmlentities($ret["tp_name"], ENT_QUOTES, "UTF-8") . "', " . + "tp_alias = '" . htmlentities($ret["tp_alias"], ENT_QUOTES, "UTF-8") . "', " . + "tp_sunday = '" . htmlentities($ret["tp_sunday"], ENT_QUOTES, "UTF-8") . "', " . + "tp_monday = '" . htmlentities($ret["tp_monday"], ENT_QUOTES, "UTF-8") . "', " . + "tp_tuesday = '" . htmlentities($ret["tp_tuesday"], ENT_QUOTES, "UTF-8") . "', " . + "tp_wednesday = '" . htmlentities($ret["tp_wednesday"], ENT_QUOTES, "UTF-8") . "', " . + "tp_thursday = '" . htmlentities($ret["tp_thursday"], ENT_QUOTES, "UTF-8") . "', " . + "tp_friday = '" . htmlentities($ret["tp_friday"], ENT_QUOTES, "UTF-8") . "', " . + "tp_saturday = '" . htmlentities($ret["tp_saturday"], ENT_QUOTES, "UTF-8") . "' " . + "WHERE tp_id = '" . $tp_id . "'"; + $pearDB->query($rq); + + $pearDB->query("DELETE FROM timeperiod_include_relations WHERE timeperiod_id = '" . $tp_id . "'"); + $pearDB->query("DELETE FROM timeperiod_exclude_relations WHERE timeperiod_id = '" . $tp_id . "'"); if (!isset($ret['tp_include'])) { $ret['tp_include'] = array(); @@ -223,14 +230,18 @@ function updateTimeperiod($tp_id, $params = array()) if (isset($_POST['nbOfExceptions'])) { $my_tab = $_POST; $already_stored = array(); - $res = $pearDB->query("DELETE FROM `timeperiod_exceptions` WHERE `timeperiod_id`='".$tp_id."'"); - for ($i=0; $i <= $my_tab['nbOfExceptions']; $i++) { + $pearDB->query("DELETE FROM `timeperiod_exceptions` WHERE `timeperiod_id`='" . $tp_id . "'"); + for ($i = 0; $i <= $my_tab['nbOfExceptions']; $i++) { $exInput = "exceptionInput_" . $i; $exValue = "exceptionTimerange_" . $i; - if (isset($my_tab[$exInput]) && !isset($already_stored[strtolower($my_tab[$exInput])]) && $my_tab[$exInput]) { - $rq = "INSERT INTO timeperiod_exceptions (`timeperiod_id`, `days`, `timerange`) - VALUES ('". $tp_id ."', LOWER('". $pearDB->escape($my_tab[$exInput]) ."'), '". $pearDB->escape($my_tab[$exValue]) ."')"; - $DBRESULT = $pearDB->query($rq); + if (isset($my_tab[$exInput]) && + !isset($already_stored[strtolower($my_tab[$exInput])]) && + $my_tab[$exInput] + ) { + $query = "INSERT INTO timeperiod_exceptions (`timeperiod_id`, `days`, `timerange`) " . + "VALUES ('" . $tp_id . "', LOWER('" . $pearDB->escape($my_tab[$exInput]) . "'), '" . + $pearDB->escape($my_tab[$exValue]) . "')"; + $pearDB->query($query); $fields[$my_tab[$exInput]] = $my_tab[$exValue]; $already_stored[strtolower($my_tab[$exInput])] = 1; } @@ -239,7 +250,13 @@ function updateTimeperiod($tp_id, $params = array()) /* Prepare value for changelog */ $fields = CentreonLogAction::prepareChanges($ret); - $centreon->CentreonLogAction->insertLog("timeperiod", $tp_id, htmlentities($ret["tp_name"], ENT_QUOTES, "UTF-8"), "c", $fields); + $centreon->CentreonLogAction->insertLog( + "timeperiod", + $tp_id, + htmlentities($ret["tp_name"], ENT_QUOTES, "UTF-8"), + "c", + $fields + ); } function insertTimeperiodInDB($ret = array()) @@ -261,17 +278,35 @@ function insertTimeperiod($ret = array(), $exceptions = null) $rq = "INSERT INTO timeperiod "; $rq .= "(tp_name, tp_alias, tp_sunday, tp_monday, tp_tuesday, tp_wednesday, tp_thursday, tp_friday, tp_saturday) "; $rq .= "VALUES ("; - isset($ret["tp_name"]) && $ret["tp_name"] != null ? $rq .= "'".htmlentities($ret["tp_name"], ENT_QUOTES, "UTF-8")."', ": $rq .= "NULL, "; - isset($ret["tp_alias"]) && $ret["tp_alias"] != null ? $rq .= "'".htmlentities($ret["tp_alias"], ENT_QUOTES, "UTF-8")."', ": $rq .= "NULL, "; - isset($ret["tp_sunday"]) && $ret["tp_sunday"] != null ? $rq .= "'".htmlentities($ret["tp_sunday"], ENT_QUOTES, "UTF-8")."', ": $rq .= "NULL, "; - isset($ret["tp_monday"]) && $ret["tp_monday"] != null ? $rq .= "'".htmlentities($ret["tp_monday"], ENT_QUOTES, "UTF-8")."', ": $rq .= "NULL, "; - isset($ret["tp_tuesday"]) && $ret["tp_tuesday"] != null ? $rq .= "'".htmlentities($ret["tp_tuesday"], ENT_QUOTES, "UTF-8")."', ": $rq .= "NULL, "; - isset($ret["tp_wednesday"]) && $ret["tp_wednesday"] != null ? $rq .= "'".htmlentities($ret["tp_wednesday"], ENT_QUOTES, "UTF-8")."', ": $rq .= "NULL, "; - isset($ret["tp_thursday"]) && $ret["tp_thursday"] != null ? $rq .= "'".htmlentities($ret["tp_thursday"], ENT_QUOTES, "UTF-8")."', ": $rq .= "NULL, "; - isset($ret["tp_friday"]) && $ret["tp_friday"] != null ? $rq .= "'".htmlentities($ret["tp_friday"], ENT_QUOTES, "UTF-8")."', ": $rq .= "NULL, "; - isset($ret["tp_saturday"]) && $ret["tp_saturday"] != null ? $rq .= "'".htmlentities($ret["tp_saturday"], ENT_QUOTES, "UTF-8")."'": $rq .= "NULL"; + isset($ret["tp_name"]) && $ret["tp_name"] != null + ? $rq .= "'" . htmlentities($ret["tp_name"], ENT_QUOTES, "UTF-8") . "', " + : $rq .= "NULL, "; + isset($ret["tp_alias"]) && $ret["tp_alias"] != null + ? $rq .= "'" . htmlentities($ret["tp_alias"], ENT_QUOTES, "UTF-8") . "', " + : $rq .= "NULL, "; + isset($ret["tp_sunday"]) && $ret["tp_sunday"] != null + ? $rq .= "'" . htmlentities($ret["tp_sunday"], ENT_QUOTES, "UTF-8") . "', " + : $rq .= "NULL, "; + isset($ret["tp_monday"]) && $ret["tp_monday"] != null + ? $rq .= "'" . htmlentities($ret["tp_monday"], ENT_QUOTES, "UTF-8") . "', " + : $rq .= "NULL, "; + isset($ret["tp_tuesday"]) && $ret["tp_tuesday"] != null + ? $rq .= "'" . htmlentities($ret["tp_tuesday"], ENT_QUOTES, "UTF-8") . "', " + : $rq .= "NULL, "; + isset($ret["tp_wednesday"]) && $ret["tp_wednesday"] != null + ? $rq .= "'" . htmlentities($ret["tp_wednesday"], ENT_QUOTES, "UTF-8") . "', " + : $rq .= "NULL, "; + isset($ret["tp_thursday"]) && $ret["tp_thursday"] != null + ? $rq .= "'" . htmlentities($ret["tp_thursday"], ENT_QUOTES, "UTF-8") . "', " + : $rq .= "NULL, "; + isset($ret["tp_friday"]) && $ret["tp_friday"] != null + ? $rq .= "'" . htmlentities($ret["tp_friday"], ENT_QUOTES, "UTF-8") . "', " + : $rq .= "NULL, "; + isset($ret["tp_saturday"]) && $ret["tp_saturday"] != null + ? $rq .= "'" . htmlentities($ret["tp_saturday"], ENT_QUOTES, "UTF-8") . "'" + : $rq .= "NULL"; $rq .= ")"; - $DBRESULT = $pearDB->query($rq); + $pearDB->query($rq); $DBRESULT = $pearDB->query("SELECT MAX(tp_id) FROM timeperiod"); $tp_id = $DBRESULT->fetchRow(); @@ -294,22 +329,32 @@ function insertTimeperiod($ret = array(), $exceptions = null) } if (isset($my_tab['nbOfExceptions'])) { $already_stored = array(); - for ($i=0; $i <= $my_tab['nbOfExceptions']; $i++) { + for ($i = 0; $i <= $my_tab['nbOfExceptions']; $i++) { $exInput = "exceptionInput_" . $i; $exValue = "exceptionTimerange_" . $i; - if (isset($my_tab[$exInput]) && !isset($already_stored[strtolower($my_tab[$exInput])]) && $my_tab[$exInput]) { - $rq = "INSERT INTO timeperiod_exceptions (`timeperiod_id`, `days`, `timerange`) - VALUES ('". $tp_id['MAX(tp_id)'] ."', LOWER('". $pearDB->escape($my_tab[$exInput]) ."'), '". $pearDB->escape($my_tab[$exValue]) ."')"; - $DBRESULT = $pearDB->query($rq); + if (isset($my_tab[$exInput]) && !isset($already_stored[strtolower($my_tab[$exInput])]) && + $my_tab[$exInput] + ) { + $query = "INSERT INTO timeperiod_exceptions (`timeperiod_id`, `days`, `timerange`) " . + "VALUES ('" . $tp_id['MAX(tp_id)'] . "', LOWER('" . $pearDB->escape($my_tab[$exInput]) . "'), '" . + $pearDB->escape($my_tab[$exValue]) . "')"; + $pearDB->query($query); $fields[$my_tab[$exInput]] = $my_tab[$exValue]; $already_stored[strtolower($my_tab[$exInput])] = 1; } + } } /* Prepare value for changelog */ $fields = CentreonLogAction::prepareChanges($ret); - $centreon->CentreonLogAction->insertLog("timeperiod", $tp_id["MAX(tp_id)"], htmlentities($ret["tp_name"], ENT_QUOTES, "UTF-8"), "a", $fields); + $centreon->CentreonLogAction->insertLog( + "timeperiod", + $tp_id["MAX(tp_id)"], + htmlentities($ret["tp_name"], ENT_QUOTES, "UTF-8"), + "a", + $fields + ); return ($tp_id["MAX(tp_id)"]); } @@ -367,7 +412,7 @@ function getTimeperiodIdByName($name) global $pearDB; $id = 0; - $res = $pearDB->query("SELECT tp_id FROM timeperiod WHERE tp_name = '".$pearDB->escape($name)."'"); + $res = $pearDB->query("SELECT tp_id FROM timeperiod WHERE tp_name = '" . $pearDB->escape($name) . "'"); if ($res->rowCount()) { $row = $res->fetchRow(); $id = $row['tp_id']; diff --git a/www/include/configuration/configObject/timeperiod/help.php b/www/include/configuration/configObject/timeperiod/help.php index 2c8ef12f74e..1f9211b7cd1 100644 --- a/www/include/configuration/configObject/timeperiod/help.php +++ b/www/include/configuration/configObject/timeperiod/help.php @@ -32,7 +32,7 @@ * For more information : contact@centreon.com * */ - + $help = array(); /* @@ -40,11 +40,30 @@ */ $help["timeperiod_name"] = dgettext("help", "Define a short name to identify the time period."); $help["alias"] = dgettext("help", "Use the alias as a longer name or description to identify the time period."); -$help["weekday"] = dgettext("help", "The weekday directives are comma-delimited lists of time ranges that are \"valid\" times for a particular day of the week. Each time range is in the form of HH:MM-HH:MM, where hours are specified on a 24 hour clock. For example, 00:15-24:00 means 12:15am in the morning for this day until 12:00am midnight (a 23 hour, 45 minute total time range). If you wish to exclude an entire day from the timeperiod, simply do not include it in the timeperiod definition."); -$help["exception"] = dgettext("help", "You can specify several different types of exceptions to the standard rotating weekday schedule. Exceptions can take a number of different forms including single days of a specific or generic month, single weekdays in a month, or single calendar dates. You can also specify a range of days/dates and even specify skip intervals to obtain functionality described by \"every 3 days between these dates\". Weekdays and different types of exceptions all have different levels of precedence, so it is important to understand how they can affect each other."); +$help["weekday"] = dgettext( + "help", + "The weekday directives are comma-delimited lists of time ranges that are \"valid\" times for a particular " . + "day of the week. Each time range is in the form of HH:MM-HH:MM, where hours are specified on a 24 hour " . + "clock. For example, 00:15-24:00 means 12:15am in the morning for this day until 12:00am midnight " . + "(a 23 hour, 45 minute total time range). If you wish to exclude an entire day from the timeperiod, simply " . + "do not include it in the timeperiod definition." +); +$help["exception"] = dgettext( + "help", + "You can specify several different types of exceptions to the standard rotating weekday schedule. " . + "Exceptions can take a number of different forms including single days of a specific or generic month, " . + "single weekdays in a month, or single calendar dates. You can also specify a range of days/dates and even " . + "specify skip intervals to obtain functionality described by \"every 3 days between these dates\". " . + "Weekdays and different types of exceptions all have different levels of precedence, so it is important " . + "to understand how they can affect each other." +); /* * Advanced Settings */ $help["include"] = dgettext("help", "This directive is used to specify other timeperiod used as a timeperiod model."); -$help["exclude"] = dgettext("help", "This directive is used to specify other timeperiod definitions whose time ranges should be excluded from this timeperiod."); +$help["exclude"] = dgettext( + "help", + "This directive is used to specify other timeperiod definitions whose time ranges should be excluded " . + "from this timeperiod." +); diff --git a/www/include/configuration/configObject/timeperiod/listTimeperiod.php b/www/include/configuration/configObject/timeperiod/listTimeperiod.php index 4e0f22a224e..bc18ac419aa 100644 --- a/www/include/configuration/configObject/timeperiod/listTimeperiod.php +++ b/www/include/configuration/configObject/timeperiod/listTimeperiod.php @@ -43,7 +43,7 @@ $search = ''; if (isset($_POST['searchTP']) && $_POST['searchTP']) { $search = $_POST['searchTP']; - $SearchTool = " WHERE tp_name LIKE '%".htmlentities($search, ENT_QUOTES, "UTF-8")."%'"; + $SearchTool = " WHERE tp_name LIKE '%" . htmlentities($search, ENT_QUOTES, "UTF-8") . "%'"; } $DBRESULT = $pearDB->query("SELECT COUNT(*) FROM timeperiod $SearchTool"); @@ -72,11 +72,13 @@ /* * Timeperiod list */ -$DBRESULT = $pearDB->query("SELECT tp_id, tp_name, tp_alias FROM timeperiod $SearchTool ORDER BY tp_name LIMIT ".$num * $limit.", ".$limit); +$query = "SELECT tp_id, tp_name, tp_alias FROM timeperiod $SearchTool " . + "ORDER BY tp_name LIMIT " . $num * $limit . ", " . $limit; +$DBRESULT = $pearDB->query($query); $search = tidySearchKey($search, $advanced_search); -$form = new HTML_QuickForm('select_form', 'POST', "?p=".$p); +$form = new HTML_QuickForm('select_form', 'POST', "?p=" . $p); /* * Different style between each lines */ @@ -89,48 +91,65 @@ for ($i = 0; $timeperiod = $DBRESULT->fetchRow(); $i++) { $moptions = ""; - $selectedElements = $form->addElement('checkbox', "select[".$timeperiod['tp_id']."]"); - $moptions .= "  31 && (event.keyCode < 45 || event.keyCode > 57)) event.returnValue = false; if(event.which > 31 && (event.which < 45 || event.which > 57)) return false;\" maxlength=\"3\" size=\"3\" value='1' style=\"margin-bottom:0px;\" name='dupNbr[".$timeperiod['tp_id']."]'>"; - $elemArr[$i] = array("MenuClass"=>"list_".$style, - "RowMenu_select"=>$selectedElements->toHtml(), - "RowMenu_name"=>$timeperiod["tp_name"], - "RowMenu_link"=>"?p=".$p."&o=c&tp_id=".$timeperiod['tp_id'], - "RowMenu_desc"=>$timeperiod["tp_alias"], - "RowMenu_options"=>$moptions, - "resultingLink" => "?p=".$p."&o=s&tp_id=".$timeperiod['tp_id']); + $selectedElements = $form->addElement('checkbox', "select[" . $timeperiod['tp_id'] . "]"); + $moptions .= "  31 && (event.keyCode < 45 || event.keyCode > 57)) " . + "event.returnValue = false; if(event.which > 31 && (event.which < 45 || event.which > 57)) return false;" . + "\" maxlength=\"3\" size=\"3\" value='1' style=\"margin-bottom:0px;\" name='dupNbr[" . + $timeperiod['tp_id'] . "]' />"; + $elemArr[$i] = array( + "MenuClass" => "list_" . $style, + "RowMenu_select" => $selectedElements->toHtml(), + "RowMenu_name" => $timeperiod["tp_name"], + "RowMenu_link" => "?p=" . $p . "&o=c&tp_id=" . $timeperiod['tp_id'], + "RowMenu_desc" => $timeperiod["tp_alias"], + "RowMenu_options" => $moptions, + "resultingLink" => "?p=" . $p . "&o=s&tp_id=" . $timeperiod['tp_id'] + ); $style != "two" ? $style = "two" : $style = "one"; } $tpl->assign("elemArr", $elemArr); /* * Different messages we put in the template */ -$tpl->assign('msg', array ("addL"=>"?p=".$p."&o=a", "addT"=>_("Add"), "delConfirm"=>_("Do you confirm the deletion ?"))); +$tpl->assign( + 'msg', + array("addL" => "?p=" . $p . "&o=a", "addT" => _("Add"), "delConfirm" => _("Do you confirm the deletion ?")) +); /* * Toolbar select */ ?> - + "javascript: " . - " var bChecked = isChecked(); ". - "if (this.form.elements['".$option."'].selectedIndex != 0 && !bChecked) {". - " alert('"._("Please select one or more items")."'); return false;} " . - "if (this.form.elements['".$option."'].selectedIndex == 1 && confirm('"._("Do you confirm the duplication ?")."')) {" . - " setO(this.form.elements['".$option."'].value); submit();} " . - "else if (this.form.elements['".$option."'].selectedIndex == 2 && confirm('"._("Do you confirm the deletion ?")."')) {" . - " setO(this.form.elements['".$option."'].value); submit();} " . - "else if (this.form.elements['".$option."'].selectedIndex == 3) {" . - " setO(this.form.elements['".$option."'].value); submit();} " . - ""); - $form->addElement('select', $option, null, array(null => _("More actions..."), "m" => _("Duplicate"), "d" => _("Delete")), $attrs1); + 'onchange' => "javascript: " . + " var bChecked = isChecked(); " . + "if (this.form.elements['" . $option . "'].selectedIndex != 0 && !bChecked) {" . + " alert('" . _("Please select one or more items") . "'); return false;} " . + "if (this.form.elements['" . $option . "'].selectedIndex == 1 && confirm('" . + _("Do you confirm the duplication ?") . "')) {" . + " setO(this.form.elements['" . $option . "'].value); submit();} " . + "else if (this.form.elements['" . $option . "'].selectedIndex == 2 && confirm('" . + _("Do you confirm the deletion ?") . "')) {" . + " setO(this.form.elements['" . $option . "'].value); submit();} " . + "else if (this.form.elements['" . $option . "'].selectedIndex == 3) {" . + " setO(this.form.elements['" . $option . "'].value); submit();} " . + "" + ); + $form->addElement( + 'select', + $option, + null, + array(null => _("More actions..."), "m" => _("Duplicate"), "d" => _("Delete")), + $attrs1 + ); $form->setDefaults(array($option => null)); $o1 = $form->getElement($option); $o1->setValue(null); diff --git a/www/include/configuration/configObject/timeperiod/renderTimeperiod.php b/www/include/configuration/configObject/timeperiod/renderTimeperiod.php index 4efc930a3e7..3e5475e1600 100644 --- a/www/include/configuration/configObject/timeperiod/renderTimeperiod.php +++ b/www/include/configuration/configObject/timeperiod/renderTimeperiod.php @@ -40,7 +40,7 @@ isset($_POST["tp_id"]) ? $tpP = $_POST["tp_id"] : $tpP = null; $tpG ? $tp_id = $tpG : $tp_id = $tpP; $path = "./include/configuration/configObject/timeperiod/"; -require_once $path."DB-Func.php"; +require_once $path . "DB-Func.php"; require_once "./include/common/common-Func.php"; require_once _CENTREON_PATH_ . "www/class/centreonTimeperiodRenderer.class.php"; $imgpath = "./include/common/javascript/scriptaculous/images/bramus/"; @@ -56,8 +56,8 @@ while ($row = $DBRESULT->fetchRow()) { $tplist[$row['tp_id']] = $row['tp_name']; } -$form = new HTML_QuickForm('form', 'POST', "?p=".$p."&o=s"); -$attrs1 = array('onchange'=>"javascript: setTP(this.form.elements['tp_id'].value); submit();"); +$form = new HTML_QuickForm('form', 'POST', "?p=" . $p . "&o=s"); +$attrs1 = array('onchange' => "javascript: setTP(this.form.elements['tp_id'].value); submit();"); $form->addElement('select', 'tp_id', null, $tplist, $attrs1); $form->setDefaults(array('tp_id' => null)); $tpel = $form->getElement('tp_id'); @@ -66,7 +66,7 @@ $tpel->setSelected($tp_id); } -$attrsTextLong = array("size"=>"55"); +$attrsTextLong = array("size" => "55"); $form->addElement('header', 'title', _("Resulting Time Period with inclusions")); $form->addElement('header', 'information', _("General Information")); $form->addElement('header', 'notification', _("Time Range")); @@ -85,13 +85,13 @@ $renderer = new HTML_QuickForm_Renderer_ArraySmarty($tpl); $form->accept($renderer); $labels = array( - 'unset_timerange' => _('Unset Timerange'), - 'included_timerange' => _('Included Timerange'), - 'excluded_timerange' => _('Excluded Timerange'), - 'timerange_overlaps' => _('Timerange Overlaps'), - 'hover_for_info' => _('Hover on timeline to see more information'), - 'no_tp_selected' => _('No time period selected') - ); + 'unset_timerange' => _('Unset Timerange'), + 'included_timerange' => _('Included Timerange'), + 'excluded_timerange' => _('Excluded Timerange'), + 'timerange_overlaps' => _('Timerange Overlaps'), + 'hover_for_info' => _('Hover on timeline to see more information'), + 'no_tp_selected' => _('No time period selected') +); $tpl->assign('labels', $labels); $tpl->assign('form', $renderer->toArray()); $tpl->assign('tpId', $tp_id); @@ -100,66 +100,66 @@ $tpl->display("renderTimeperiod.ihtml"); ?> diff --git a/www/include/configuration/configObject/timeperiod/timeperiod.php b/www/include/configuration/configObject/timeperiod/timeperiod.php index fafcb4a80e1..3254e81457e 100644 --- a/www/include/configuration/configObject/timeperiod/timeperiod.php +++ b/www/include/configuration/configObject/timeperiod/timeperiod.php @@ -59,7 +59,7 @@ $path = "./include/configuration/configObject/timeperiod/"; //PHP functions -require_once $path."DB-Func.php"; +require_once $path . "DB-Func.php"; require_once "./include/common/common-Func.php"; /* Set the real page */ @@ -69,26 +69,26 @@ switch ($o) { case "a": - require_once($path."formTimeperiod.php"); + require_once($path . "formTimeperiod.php"); break; //Add a Timeperiod case "w": - require_once($path."formTimeperiod.php"); + require_once($path . "formTimeperiod.php"); break; //Watch a Timeperiod case "c": - require_once($path."formTimeperiod.php"); + require_once($path . "formTimeperiod.php"); break; //Modify a Timeperiod case "s": - require_once($path."renderTimeperiod.php"); + require_once($path . "renderTimeperiod.php"); break; //Show Timeperiod case "m": multipleTimeperiodInDB(isset($select) ? $select : array(), $dupNbr); - require_once($path."listTimeperiod.php"); + require_once($path . "listTimeperiod.php"); break; #Duplicate n Timeperiods case "d": deleteTimeperiodInDB(isset($select) ? $select : array()); - require_once($path."listTimeperiod.php"); + require_once($path . "listTimeperiod.php"); break; #Delete n Timeperiods default: - require_once($path."listTimeperiod.php"); + require_once($path . "listTimeperiod.php"); break; } diff --git a/www/include/configuration/configObject/timeperiod/timeperiod_JS.php b/www/include/configuration/configObject/timeperiod/timeperiod_JS.php index 2094f0199bb..e29413db973 100644 --- a/www/include/configuration/configObject/timeperiod/timeperiod_JS.php +++ b/www/include/configuration/configObject/timeperiod/timeperiod_JS.php @@ -33,78 +33,17 @@ * */ -?> \ No newline at end of file From c218e66d183a833d9b7646114cef492fa6629151 Mon Sep 17 00:00:00 2001 From: loiclau Date: Fri, 28 Jul 2017 17:33:27 +0200 Subject: [PATCH 096/207] * fix style traps --- .../configObject/traps/formTraps.php | 168 +++++++++++------- .../configuration/configObject/traps/help.php | 103 +++++++++-- .../configObject/traps/listTraps.php | 5 +- .../configObject/traps/traps.php | 14 +- 4 files changed, 200 insertions(+), 90 deletions(-) diff --git a/www/include/configuration/configObject/traps/formTraps.php b/www/include/configuration/configObject/traps/formTraps.php index 19709a8ce81..25335ee2855 100644 --- a/www/include/configuration/configObject/traps/formTraps.php +++ b/www/include/configuration/configObject/traps/formTraps.php @@ -50,7 +50,7 @@ function testTrapExistence() function myDecodeTrap($arg) { $arg = html_entity_decode($arg, ENT_QUOTES, "UTF-8"); - return($arg); + return ($arg); } function myReplace() @@ -66,14 +66,14 @@ function myReplace() $hServices = array(); if (($o == "c" || $o == "w") && $traps_id) { - $DBRESULT = $pearDB->query("SELECT * FROM traps WHERE traps_id = '".$traps_id."' LIMIT 1"); + $DBRESULT = $pearDB->query("SELECT * FROM traps WHERE traps_id = '" . $traps_id . "' LIMIT 1"); # Set base value $trap = array_map("myDecodeTrap", $DBRESULT->fetchRow()); - $trap['severity'] = $trap['severity_id']; + $trap['severity'] = $trap['severity_id']; $DBRESULT->closeCursor(); - + $cdata = CentreonData::getInstance(); - + /* * Preset values of preexec commands */ @@ -83,7 +83,7 @@ function myReplace() ENT_QUOTES )); $cdata->addJsData('clone-count-preexec', count($preexecArray)); - + /* * Preset values of matching rules */ @@ -101,26 +101,33 @@ function myReplace() } $DBRESULT->closeCursor(); -$attrsText = array("size"=>"50"); -$attrsLongText = array("size"=>"120"); -$attrsTextarea = array("rows"=>"10", "cols"=>"120"); -$attrsAdvSelect = array("style" => "width: 270px; height: 100px;"); -$eTemplate = '
{label_2}
{unselected}
{add}


{remove}
{label_3}
{selected}
'; -$attrManufacturer= array( +$attrsText = array("size" => "50"); +$attrsLongText = array("size" => "120"); +$attrsTextarea = array("rows" => "10", "cols" => "120"); +$attrsAdvSelect = array("style" => "width: 270px; height: 100px;"); +$eTemplate = '
{label_2}
{unselected}
{add}

' . + '
{remove}
{label_3}
{selected}
'; + +$route = './include/common/webServices/rest/internal.php?object=centreon_configuration_manufacturer&action=list'; +$attrManufacturer = array( 'datasourceOrigin' => 'ajax', - 'availableDatasetRoute' => './include/common/webServices/rest/internal.php?object=centreon_configuration_manufacturer&action=list', + 'availableDatasetRoute' => $route, 'multiple' => false, 'linkedObject' => 'centreonManufacturer' ); + +$route = './include/common/webServices/rest/internal.php?object=centreon_configuration_service&action=list&s=s'; $attrServices = array( 'datasourceOrigin' => 'ajax', - 'availableDatasetRoute' => './include/common/webServices/rest/internal.php?object=centreon_configuration_service&action=list&s=s', + 'availableDatasetRoute' => $route, 'multiple' => true, 'linkedObject' => 'centreonService' ); + +$route = './include/common/webServices/rest/internal.php?object=centreon_configuration_servicetemplate&action=list'; $attrServicetemplates = array( 'datasourceOrigin' => 'ajax', - 'availableDatasetRoute' => './include/common/webServices/rest/internal.php?object=centreon_configuration_servicetemplate&action=list', + 'availableDatasetRoute' => $route, 'multiple' => true, 'linkedObject' => 'centreonServicetemplates' ); @@ -128,8 +135,8 @@ function myReplace() /* * Form begin */ -$form = new HTML_QuickForm('Form', 'post', "?p=".$p); - $trapObj->setForm($form); +$form = new HTML_QuickForm('Form', 'post', "?p=" . $p); +$trapObj->setForm($form); if ($o == "a") { $form->addElement('header', 'title', _("Add a Trap definition")); } elseif ($o == "c") { @@ -141,7 +148,7 @@ function myReplace() /** * Initializes nbOfInitialRows */ -$query = "SELECT MAX(tmo_order) FROM traps_matching_properties WHERE trap_id = '".$traps_id."' "; +$query = "SELECT MAX(tmo_order) FROM traps_matching_properties WHERE trap_id = '" . $traps_id . "' "; $res = $pearDB->query($query); if ($res->rowCount()) { $row = $res->fetchRow(); @@ -155,9 +162,11 @@ function myReplace() */ $form->addElement('text', 'traps_name', _("Trap name"), $attrsText); +$route = './include/common/webServices/rest/internal.php?object=centreon_configuration_manufacturer' . + '&action=defaultValues&target=traps&field=manufacturer_id&id=' . $traps_id; $attrManufacturer1 = array_merge( $attrManufacturer, - array('defaultDatasetRoute' => './include/common/webServices/rest/internal.php?object=centreon_configuration_manufacturer&action=defaultValues&target=traps&field=manufacturer_id&id=' . $traps_id) + array('defaultDatasetRoute' => $route) ); $form->addElement('select2', 'manufacturer_id', _("Vendor Name"), array(), $attrManufacturer1); $form->addElement('textarea', 'traps_comments', _("Comments"), $attrsTextarea); @@ -166,15 +175,27 @@ function myReplace() * Generic fields */ $form->addElement('text', 'traps_oid', _("OID"), $attrsText); -$form->addElement('select', 'traps_status', _("Default Status"), array(0=>_("Ok"), 1=>_("Warning"), 2=>_("Critical"), 3=>_("Unknown")), array('id' => 'trapStatus')); +$form->addElement( + 'select', + 'traps_status', + _("Default Status"), + array(0 => _("Ok"), 1 => _("Warning"), 2 => _("Critical"), 3 => _("Unknown")), + array('id' => 'trapStatus') +); $severities = $severityObj->getList(null, "level", 'ASC', null, null, true); - $severityArr = array(null=>null); +$severityArr = array(null => null); foreach ($severities as $severity_id => $severity) { - $severityArr[$severity_id] = $severity['sc_name'].' ('.$severity['level'].')'; + $severityArr[$severity_id] = $severity['sc_name'] . ' (' . $severity['level'] . ')'; } - $form->addElement('select', 'severity', _("Default Severity"), $severityArr); - $form->addElement('text', 'traps_args', _("Output Message"), $attrsText); -$form->addElement('checkbox', 'traps_advanced_treatment', _("Advanced matching mode"), null, array('id' => 'traps_advanced_treatment')); +$form->addElement('select', 'severity', _("Default Severity"), $severityArr); +$form->addElement('text', 'traps_args', _("Output Message"), $attrsText); +$form->addElement( + 'checkbox', + 'traps_advanced_treatment', + _("Advanced matching mode"), + null, + array('id' => 'traps_advanced_treatment') +); $form->setDefaults(0); /* ******************************************************************* @@ -215,12 +236,13 @@ function myReplace() ) ); $form->addElement('select2', 'services', _("Linked Services"), array(), $attrService1); - + +$query = './api/internal.php?object=centreon_configuration_servicetemplate&action=defaultValues' . + '&target=traps&field=service_templates&id=' . $traps_id; $attrServicetemplate1 = array_merge( $attrServicetemplates, array( - 'defaultDatasetRoute' => './api/internal.php?object=centreon_configuration_servicetemplate&action=defaultValues' . - '&target=traps&field=service_templates&id=' . $traps_id + 'defaultDatasetRoute' => $query ) ); $form->addElement('select2', 'service_templates', _("Linked Service Templates"), array(), $attrServicetemplate1); @@ -251,35 +273,35 @@ function myReplace() 'rule[#index#]', _("String"), array( - "size"=>"50", - "id" => "rule_#index#", - "value" => "@OUTPUT@" - ) + "size" => "50", + "id" => "rule_#index#", + "value" => "@OUTPUT@" + ) ); $cloneSetMaching[] = $form->addElement( 'text', 'regexp[#index#]', _("Regexp"), array( - "size"=>"50", - "id" => "regexp_#index#", - "value" => "//" - ) + "size" => "50", + "id" => "regexp_#index#", + "value" => "//" + ) ); $cloneSetMaching[] = $form->addElement( 'select', 'rulestatus[#index#]', _("Status"), array( - 0 => _('OK'), - 1 => _('Warning'), - 2 => _('Critical'), - 3 => _('Unknown') - ), + 0 => _('OK'), + 1 => _('Warning'), + 2 => _('Critical'), + 3 => _('Unknown') + ), array( - "id" => "rulestatus_#index#", - "type" => "select-one" - ) + "id" => "rulestatus_#index#", + "type" => "select-one" + ) ); $cloneSetMaching[] = $form->addElement( 'select', @@ -287,9 +309,9 @@ function myReplace() _("Severity"), $severityArr, array( - "id" => "ruleseverity_#index#", - "type" => "select-one" - ) + "id" => "ruleseverity_#index#", + "type" => "select-one" + ) ); $form->addElement( @@ -311,7 +333,7 @@ function myReplace() 'traps_log', _("Insert trap's information into database") ); - + $form->addElement( 'text', 'traps_output_transform', @@ -321,22 +343,32 @@ function myReplace() $form->addElement('textarea', 'traps_customcode', _("Custom code"), $attrsTextarea); -$form->addElement('select', 'traps_advanced_treatment_default', _("Advanced matching behavior"), array(0=>_("If no match, submit default status"), 1=>_("If no match, disable submit"), 2=>_("If match, disable submit")), array('id' => 'traps_advanced_treatment')); - +$form->addElement('select', 'traps_advanced_treatment_default', _("Advanced matching behavior"), array( + 0 => _("If no match, submit default status"), + 1 => _("If no match, disable submit"), + 2 => _("If match, disable submit") +), array('id' => 'traps_advanced_treatment')); + $excecution_type[] = HTML_QuickForm::createElement('radio', 'traps_exec_interval_type', null, _("None"), '0'); $excecution_type[] = HTML_QuickForm::createElement('radio', 'traps_exec_interval_type', null, _("By OID"), '1'); -$excecution_type[] = HTML_QuickForm::createElement('radio', 'traps_exec_interval_type', null, _("By OID and Host"), '2'); +$excecution_type[] = HTML_QuickForm::createElement( + 'radio', + 'traps_exec_interval_type', + null, + _("By OID and Host"), + '2' +); $form->addGroup($excecution_type, 'traps_exec_interval_type', _("Execution type"), ' '); - + $excecution_method[] = HTML_QuickForm::createElement('radio', 'traps_exec_method', null, _("Parallel"), '0'); $excecution_method[] = HTML_QuickForm::createElement('radio', 'traps_exec_method', null, _("Sequential"), '1'); $form->addGroup($excecution_method, 'traps_exec_method', _("Execution method"), ' '); - + $downtime[] = HTML_QuickForm::createElement('radio', 'traps_downtime', null, _("None"), '0'); $downtime[] = HTML_QuickForm::createElement('radio', 'traps_downtime', null, _("Real-Time"), '1'); $downtime[] = HTML_QuickForm::createElement('radio', 'traps_downtime', null, _("History"), '2'); $form->addGroup($downtime, 'traps_downtime', _("Check Downtime"), ' '); - + /* * Pre exec */ @@ -346,11 +378,11 @@ function myReplace() 'preexec[#index#]', _("Preexec definition"), array( - "size"=>"50", - "id" => "preexec_#index#" - ) + "size" => "50", + "id" => "preexec_#index#" + ) ); - + /* * Form Rules */ @@ -362,7 +394,7 @@ function myReplace() $form->addRule('traps_args', _("Compulsory Name"), 'required'); $form->registerRule('exist', 'callback', 'testTrapExistence'); $form->addRule('traps_oid', _("The same OID element already exists"), 'exist'); -$form->setRequiredNote("* ". _("Required fields")); +$form->setRequiredNote("* " . _("Required fields")); /* * Smarty template Init @@ -371,20 +403,30 @@ function myReplace() $tpl = initSmartyTpl($path, $tpl); $tpl->assign('trap_adv_args', _("Advanced matching rules")); -$tpl->assign("helpattr", 'TITLE, "'._("Help").'", CLOSEBTN, true, FIX, [this, 0, 5], BGCOLOR, "#ffff99", BORDERCOLOR, "orange", TITLEFONTCOLOR, "black", TITLEBGCOLOR, "orange", CLOSEBTNCOLORS, ["","black", "white", "red"], WIDTH, -300, SHADOW, true, TEXTALIGN, "justify"'); +$tpl->assign( + "helpattr", + 'TITLE, "' . _("Help") . '", CLOSEBTN, true, FIX, [this, 0, 5], BGCOLOR, "#ffff99", BORDERCOLOR, "orange", ' . + 'TITLEFONTCOLOR, "black", TITLEBGCOLOR, "orange", CLOSEBTNCOLORS, ["","black", "white", "red"], WIDTH, -300, ' . + 'SHADOW, true, TEXTALIGN, "justify"' +); /* prepare help texts */ $helptext = ""; include_once("help.php"); foreach ($help as $key => $text) { - $helptext .= ''."\n"; + $helptext .= '' . "\n"; } $tpl->assign("helptext", $helptext); if ($o == "w") { # Just watch a Command information if ($centreon->user->access->page($p) != 2) { - $form->addElement("button", "change", _("Modify"), array("onClick"=>"javascript:window.location.href='?p=".$p."&o=c&traps_id=".$traps_id."'")); + $form->addElement( + "button", + "change", + _("Modify"), + array("onClick" => "javascript:window.location.href='?p=" . $p . "&o=c&traps_id=" . $traps_id . "'") + ); } $form->setDefaults($trap); $form->freeze(); @@ -413,7 +455,7 @@ function myReplace() } if ($valid) { - require_once($path."listTraps.php"); + require_once($path . "listTraps.php"); } else { /* prepare help texts */ $renderer = new HTML_QuickForm_Renderer_ArraySmarty($tpl); diff --git a/www/include/configuration/configObject/traps/help.php b/www/include/configuration/configObject/traps/help.php index c0349b26c6e..ed233b5d703 100644 --- a/www/include/configuration/configObject/traps/help.php +++ b/www/include/configuration/configObject/traps/help.php @@ -35,31 +35,96 @@ $help = array(); -$help["trapname"] = dgettext("help", "Enter the trap name as specified in the MIB file and send by the SNMP master agent."); +$help["trapname"] = dgettext( + "help", + "Enter the trap name as specified in the MIB file and send by the SNMP master agent." +); $help["oid"] = dgettext("help", "Enter the full numeric object identifier (OID) starting with .1.3.6 (.iso.org.dod)."); $help["vendor"] = dgettext("help", "Choose a vendor from the list. The vendor must have been created beforehand."); -$help["submit_result_enabled"] = dgettext("help", "Switch the submission of trap results to monitoring engine on or off."); -$help["trap_args"] = dgettext("help", "Enter the status message to be submitted to monitoring engine. The original trap message will be placed into the entered string at the position of the variable \$*."); -$help["trap_status"] = dgettext("help", "Choose the service state to be submitted to monitoring engine together with the status message. This simple mode can be used if each trap can be mapped to exactly 1 monitoring engine status."); +$help["submit_result_enabled"] = dgettext( + "help", + "Switch the submission of trap results to monitoring engine on or off." +); +$help["trap_args"] = dgettext( + "help", + "Enter the status message to be submitted to monitoring engine. The original trap message will be " . + "placed into the entered string at the position of the variable \$*." +); +$help["trap_status"] = dgettext( + "help", + "Choose the service state to be submitted to monitoring engine together with the status message. " . + "This simple mode can be used if each trap can be mapped to exactly 1 monitoring engine status." +); $help["severity"] = dgettext("help", "Severities are defined in the service category object."); -$help["trap_advanced"] = dgettext("help", "Enable advanced matching mode for cases where a trap relates to multiple monitoring engine states and the trap message has to be parsed."); -$help["trap_adv_args"] = dgettext("help", "Define one or multiple regular expressions to match against the trap message and map it to the related monitoring engine service state. Use perlre for the format and place the expression between two slashes."); -$help["reschedule_enabled"] = dgettext("help", "Choose whether or not the associated service should be actively rechecked after submission of this trap."); -$help["command_enabled"] = dgettext("help", "Choose whether or not a special command should be run by centreontrapd when this trap was received."); -$help["command_args"] = dgettext("help", "Define the command to execute by centreontrapd's trap handler. The command must be located in the PATH of the centreontrapd user."); -$help["comments"] = dgettext("help", "Comment to describe per example the situation in which this trap will be send. Additionally the format and the parameters of the trap can be described."); +$help["trap_advanced"] = dgettext( + "help", + "Enable advanced matching mode for cases where a trap relates to multiple monitoring engine states and the " . + "trap message has to be parsed." +); +$help["trap_adv_args"] = dgettext( + "help", + "Define one or multiple regular expressions to match against the trap message and map it to the related " . + "monitoring engine service state. Use perlre for " . + "the format and place the expression between two slashes." +); +$help["reschedule_enabled"] = dgettext( + "help", + "Choose whether or not the associated service should be actively rechecked after submission of this trap." +); +$help["command_enabled"] = dgettext( + "help", + "Choose whether or not a special command should be run by centreontrapd when this trap was received." +); +$help["command_args"] = dgettext( + "help", + "Define the command to execute by centreontrapd's trap handler. The command must be located in the " . + "PATH of the centreontrapd user." +); +$help["comments"] = dgettext( + "help", + "Comment to describe per example the situation in which this trap will be send. Additionally " . + "the format and the parameters of the trap can be described." +); $help["traps_routing_mode"] = dgettext("help", "Enable/Disable routing definition"); $help["traps_routing_value"] = dgettext("help", "Routing definition to choose host(s)"); -$help["traps_routing_filter_services"] = dgettext("help", "Permits to filter services of host(s). Skip if service_description not equals to the value set."); -$help["preexeccmd"] = dgettext("help", "PREEXEC commands are executed after 'routing' and before 'matching', 'actions'"); +$help["traps_routing_filter_services"] = dgettext( + "help", + "Permits to filter services of host(s). Skip if service_description not equals to the value set." +); +$help["preexeccmd"] = dgettext( + "help", + "PREEXEC commands are executed after 'routing' and before 'matching', 'actions'" +); $help["traps_log"] = dgettext("help", "Whether or not traps will be inserted into database. Disabled by default"); $help["traps_exec_interval"] = dgettext("help", "Minimum delay necessary for a trap to be processed after another one"); -$help["traps_exec_interval_type"] = dgettext("help", "Whether execution interval will be applied to identical OIDs or identical OIDs and hosts"); +$help["traps_exec_interval_type"] = dgettext( + "help", + "Whether execution interval will be applied to identical OIDs or identical OIDs and hosts" +); $help["traps_exec_method"] = dgettext("help", "Defines the trap execution method"); -$help["traps_downtime"] = dgettext("help", "Skip trap if host or service is in downtime when centreontrapd proceeds. 'History' option is more accurate but needs more powers. The option works only with centreon-broker AND central mode."); -$help["traps_output_transform"] = dgettext("help", "Regexp for removing or change some characters in output message (Example: s/\|/-/g)."); -$help["traps_advanced_treatment_default"] = dgettext("help", "Submit or not the status to the monitoring engine, related to the rules"); -$help["traps_timeout"] = dgettext("help", "Maximum execution time of trap processing. This includes Preexec commands, submit command and special command"); -$help["traps_customcode"] = dgettext("help", "Custom Perl code. Will be executed with no change (security issue. Need to set centreontrapd secure_mode to '1')"); +$help["traps_downtime"] = dgettext( + "help", + "Skip trap if host or service is in downtime when centreontrapd proceeds. 'History' option is more accurate " . + "but needs more powers. The option works only with centreon-broker AND central mode." +); +$help["traps_output_transform"] = dgettext( + "help", + "Regexp for removing or change some characters in output message (Example: s/\|/-/g)." +); +$help["traps_advanced_treatment_default"] = dgettext( + "help", + "Submit or not the status to the monitoring engine, related to the rules" +); +$help["traps_timeout"] = dgettext( + "help", + "Maximum execution time of trap processing. This includes Preexec commands, submit command and special command" +); +$help["traps_customcode"] = dgettext( + "help", + "Custom Perl code. Will be executed with no change (security issue. Need to set centreontrapd secure_mode to '1')" +); $help["services"] = dgettext("help", "Choose a service from the list. The service must have been created beforehand."); -$help["service_templates"] = dgettext("help", "Choose a service template from the list. The service template must have been created beforehand."); +$help["service_templates"] = dgettext( + "help", + "Choose a service template from the list. The service template must have been created beforehand." +); diff --git a/www/include/configuration/configObject/traps/listTraps.php b/www/include/configuration/configObject/traps/listTraps.php index 28eacdbf9c5..7b4bfae7676 100644 --- a/www/include/configuration/configObject/traps/listTraps.php +++ b/www/include/configuration/configObject/traps/listTraps.php @@ -128,7 +128,10 @@ $moptions = ""; $selectedElements = $form->addElement('checkbox', "select[" . $trap['traps_id'] . "]"); $moptions .= "   "; - $moptions .= " 31 && (event.keyCode < 45 || event.keyCode > 57)) event.returnValue = false; if(event.which > 31 && (event.which < 45 || event.which > 57)) return false;\" maxlength=\"3\" size=\"3\" value='1' style=\"margin-bottom:0px;\" name='dupNbr[" . $trap['traps_id'] . "]'>"; + $moptions .= " 31 && (event.keyCode < 45 || event.keyCode > 57)) " . + "event.returnValue = false; if(event.which > 31 && (event.which < 45 || event.which > 57)) return false;" . + "\" maxlength=\"3\" size=\"3\" value='1' style=\"margin-bottom:0px;\" name='dupNbr[" . + $trap['traps_id'] . "]' />"; $DBRESULT2 = $pearDB->query("select alias from traps_vendor where id='" . $trap['manufacturer_id'] . "' LIMIT 1"); $mnftr = $DBRESULT2->fetchRow(); $DBRESULT2->closeCursor(); diff --git a/www/include/configuration/configObject/traps/traps.php b/www/include/configuration/configObject/traps/traps.php index fdb8bd109ff..7068be31e27 100644 --- a/www/include/configuration/configObject/traps/traps.php +++ b/www/include/configuration/configObject/traps/traps.php @@ -32,7 +32,7 @@ * For more information : contact@centreon.com * */ - + if (!isset($centreon)) { exit(); } @@ -96,23 +96,23 @@ switch ($o) { case "a": - require_once($path."formTraps.php"); + require_once($path . "formTraps.php"); break; #Add a Trap case "w": - require_once($path."formTraps.php"); + require_once($path . "formTraps.php"); break; #Watch a Trap case "c": - require_once($path."formTraps.php"); + require_once($path . "formTraps.php"); break; #Modify a Trap case "m": $trapObj->duplicate(isset($select) ? $select : array(), $dupNbr); - require_once($path."listTraps.php"); + require_once($path . "listTraps.php"); break; #Duplicate n Traps case "d": $trapObj->delete(isset($select) ? $select : array()); - require_once($path."listTraps.php"); + require_once($path . "listTraps.php"); break; #Delete n Traps default: - require_once($path."listTraps.php"); + require_once($path . "listTraps.php"); break; } From d23df7b2c22ba9f353f6194e509fb8d485fd5638 Mon Sep 17 00:00:00 2001 From: loiclau Date: Fri, 28 Jul 2017 17:55:58 +0200 Subject: [PATCH 097/207] * fix style traps groups --- .../configObject/traps-groups/DB-Func.php | 84 +++++++------ .../configObject/traps-groups/formGroups.php | 39 ++++-- .../configObject/traps-groups/groups.php | 2 +- .../configObject/traps-groups/listGroups.php | 113 +++++++++++------- 4 files changed, 146 insertions(+), 92 deletions(-) diff --git a/www/include/configuration/configObject/traps-groups/DB-Func.php b/www/include/configuration/configObject/traps-groups/DB-Func.php index 89d806e25f9..1bdf3be3f05 100644 --- a/www/include/configuration/configObject/traps-groups/DB-Func.php +++ b/www/include/configuration/configObject/traps-groups/DB-Func.php @@ -32,17 +32,19 @@ * For more information : contact@centreon.com * */ - + function testTrapGroupExistence($name = null) { global $pearDB, $form; $id = null; - + if (isset($form)) { $id = $form->getSubmitValue('id'); } - $DBRESULT = $pearDB->query("SELECT traps_group_id as id FROM traps_group WHERE traps_group_name = '". $pearDB->escape(htmlentities($name, ENT_QUOTES, "UTF-8")) ."'"); + $query = "SELECT traps_group_id as id FROM traps_group WHERE traps_group_name = '" . + $pearDB->escape(htmlentities($name, ENT_QUOTES, "UTF-8")) . "'"; + $DBRESULT = $pearDB->query($query); $trap_group = $DBRESULT->fetchRow(); # Modif case if ($DBRESULT->rowCount() >= 1 && $trap_group["id"] == $id) { @@ -60,45 +62,53 @@ function deleteTrapGroupInDB($trap_groups = array()) global $pearDB, $oreon; foreach ($trap_groups as $key => $value) { - $DBRESULT2 = $pearDB->query("SELECT traps_group_name as name FROM `traps_group` WHERE `traps_group_id` = '" . $pearDB->escape($key) . "' LIMIT 1"); + $query = "SELECT traps_group_name as name FROM `traps_group` WHERE `traps_group_id` = '" . + $pearDB->escape($key) . "' LIMIT 1"; + $DBRESULT2 = $pearDB->query($query); $row = $DBRESULT2->fetchRow(); - - $DBRESULT = $pearDB->query("DELETE FROM traps_group WHERE traps_group_id = '" . $pearDB->escape($key) . "'"); + + $pearDB->query("DELETE FROM traps_group WHERE traps_group_id = '" . $pearDB->escape($key) . "'"); $oreon->CentreonLogAction->insertLog("traps_group", $key, $row['name'], "d"); } } - + function multipleTrapGroupInDB($trap_groups = array(), $nbrDup = array()) { global $pearDB, $oreon; foreach ($trap_groups as $key => $value) { - $DBRESULT = $pearDB->query("SELECT * FROM traps_group WHERE traps_group_id = '". $pearDB->escape($key) . "' LIMIT 1"); + $query = "SELECT * FROM traps_group WHERE traps_group_id = '" . $pearDB->escape($key) . "' LIMIT 1"; + $DBRESULT = $pearDB->query($query); $row = $DBRESULT->fetchRow(); $row["traps_group_id"] = ''; - + for ($i = 1; $i <= $nbrDup[$key]; $i++) { $val = null; foreach ($row as $key2 => $value2) { $key2 == "traps_group_name" ? ($name = $value2 = $value2 . "_" . $i) : null; - $val ? $val .= ($value2 != null ? (", '" . $value2 . "'") : ", NULL") : $val .= ($value2 != null ? ("'" . $value2 . "'") : "NULL"); + $val + ? $val .= ($value2 != null ? (", '" . $value2 . "'") : ", NULL") + : $val .= ($value2 != null ? ("'" . $value2 . "'") : "NULL"); if ($key2 != "traps_group_id") { $fields[$key2] = $value2; } $fields["name"] = $name; } - + if (testTrapGroupExistence($name)) { - $val ? $rq = "INSERT INTO traps_group VALUES (".$val.")" : $rq = null; - $DBRESULT = $pearDB->query($rq); + $val ? $rq = "INSERT INTO traps_group VALUES (" . $val . ")" : $rq = null; + $pearDB->query($rq); $oreon->CentreonLogAction->insertLog("traps_group", $key, $name, "a", $fields); - - $pearDB->query("INSERT INTO traps_group_relation (traps_group_id, traps_id) SELECT (SELECT MAX(traps_group_id) as max_id FROM traps_group), traps_id FROM traps_group_relation WHERE traps_group_id = '" . $pearDB->escape($key) . "'"); + + $query = "INSERT INTO traps_group_relation (traps_group_id, traps_id) SELECT " . + "(SELECT MAX(traps_group_id) as max_id FROM traps_group), traps_id FROM traps_group_relation " . + "WHERE traps_group_id = '" . $pearDB->escape($key) . "'"; + $pearDB->query($query); } } } } - + function updateTrapGroupInDB($id = null) { if (!$id) { @@ -106,69 +116,71 @@ function updateTrapGroupInDB($id = null) } updateTrapGroup($id); } - + function updateTrapGroup($id = null) { global $form, $pearDB, $oreon; - + if (!$id) { return; } - + $ret = array(); $ret = $form->getSubmitValues(); - + $rq = "UPDATE traps_group "; - $rq .= "SET traps_group_name = '" . $pearDB->escape(htmlentities($ret["name"], ENT_QUOTES, "UTF-8")) ."' "; + $rq .= "SET traps_group_name = '" . $pearDB->escape(htmlentities($ret["name"], ENT_QUOTES, "UTF-8")) . "' "; $rq .= "WHERE traps_group_id = '" . $pearDB->escape($id) . "'"; - $DBRESULT = $pearDB->query($rq); - + $pearDB->query($rq); + $pearDB->query("DELETE FROM traps_group_relation WHERE traps_group_id = '" . $pearDB->escape($id) . "'"); if (isset($ret['traps'])) { foreach ($ret['traps'] as $trap_id) { - $pearDB->query("INSERT INTO traps_group_relation (traps_group_id, traps_id) VALUES (" . $pearDB->escape($id) . - ",'" . $pearDB->escape($trap_id) . "')"); + $query = "INSERT INTO traps_group_relation (traps_group_id, traps_id) VALUES (" . $pearDB->escape($id) . + ",'" . $pearDB->escape($trap_id) . "')"; + $pearDB->query($query); } } - + /* Prepare value for changelog */ $fields = CentreonLogAction::prepareChanges($ret); $oreon->CentreonLogAction->insertLog("traps_group", $id, $fields["name"], "c", $fields); } - + function insertTrapGroupInDB($ret = array()) { $id = insertTrapGroup($ret); return ($id); } - + function insertTrapGroup($ret = array()) { global $form, $pearDB, $oreon; - + if (!count($ret)) { $ret = $form->getSubmitValues(); } - + $rq = "INSERT INTO traps_group "; $rq .= "(traps_group_name) "; $rq .= "VALUES "; - $rq .= "('". $pearDB->escape(htmlentities($ret["name"], ENT_QUOTES, "UTF-8")) ."')"; + $rq .= "('" . $pearDB->escape(htmlentities($ret["name"], ENT_QUOTES, "UTF-8")) . "')"; $DBRESULT = $pearDB->query($rq); $DBRESULT = $pearDB->query("SELECT MAX(traps_group_id) as max_id FROM traps_group"); $trap_group_id = $DBRESULT->fetchRow(); - + $fields = array(); if (isset($ret['traps'])) { foreach ($ret['traps'] as $trap_id) { - $pearDB->query("INSERT INTO traps_group_relation (traps_group_id, traps_id) VALUES (" . $pearDB->escape($trap_group_id['max_id']) . - ",'" . $pearDB->escape($trap_id) . "')"); + $query = "INSERT INTO traps_group_relation (traps_group_id, traps_id) VALUES (" . + $pearDB->escape($trap_group_id['max_id']) . ",'" . $pearDB->escape($trap_id) . "')"; + $pearDB->query($query); } } - + /* Prepare value for changelog */ $fields = CentreonLogAction::prepareChanges($ret); $oreon->CentreonLogAction->insertLog("traps_group", $trap_group_id['max_id'], $fields['name'], 'a', $fields); - + return ($trap_group_id["max_id"]); } diff --git a/www/include/configuration/configObject/traps-groups/formGroups.php b/www/include/configuration/configObject/traps-groups/formGroups.php index fe34384c289..da5a54df607 100644 --- a/www/include/configuration/configObject/traps-groups/formGroups.php +++ b/www/include/configuration/configObject/traps-groups/formGroups.php @@ -40,12 +40,14 @@ function myDecodeGroup($arg) { $arg = html_entity_decode($arg, ENT_QUOTES, "UTF-8"); - return($arg); + return ($arg); } $group = array(); if (($o == "c" || $o == "w") && $id) { - $DBRESULT = $pearDB->query("SELECT traps_group_name as name, traps_group_id as id FROM traps_group WHERE traps_group_id = '" . $pearDB->escape($id) . "' LIMIT 1"); + $query = "SELECT traps_group_name as name, traps_group_id as id FROM traps_group " . + "WHERE traps_group_id = '" . $pearDB->escape($id) . "' LIMIT 1"; + $DBRESULT = $pearDB->query($query); # Set base value $group = array_map("myDecodeGroup", $DBRESULT->fetchRow()); $DBRESULT->closeCursor(); @@ -54,12 +56,12 @@ function myDecodeGroup($arg) ########################################################## # Var information to format the element # -$attrsText = array("size"=>"50"); -$attrsTextarea = array("rows"=>"5", "cols"=>"40"); +$attrsText = array("size" => "50"); +$attrsTextarea = array("rows" => "5", "cols" => "40"); # ## Form begin # -$form = new HTML_QuickForm('Form', 'post', "?p=".$p); +$form = new HTML_QuickForm('Form', 'post', "?p=" . $p); if ($o == "a") { $form->addElement('header', 'title', _("Add Group")); } elseif ($o == "c") { @@ -73,12 +75,15 @@ function myDecodeGroup($arg) # $form->addElement('text', 'name', _("Name"), $attrsText); +$avRoute = './include/common/webServices/rest/internal.php?object=centreon_configuration_trap&action=list'; +$deRoute = './include/common/webServices/rest/internal.php?object=centreon_configuration_trap' . + '&action=defaultValues&target=Traps&field=groups&id=' . $id; $attrTraps = array( 'datasourceOrigin' => 'ajax', - 'availableDatasetRoute' => './include/common/webServices/rest/internal.php?object=centreon_configuration_trap&action=list', + 'availableDatasetRoute' => $avRoute, 'multiple' => true, 'linkedObject' => 'centreonTraps', - 'defaultDatasetRoute' => './include/common/webServices/rest/internal.php?object=centreon_configuration_trap&action=defaultValues&target=Traps&field=groups&id=' . $id, + 'defaultDatasetRoute' => $deRoute, ); $form->addElement('select2', 'traps', _("Traps"), array(), $attrTraps); @@ -96,7 +101,7 @@ function myDecodeGroup($arg) $form->addRule('name', _("Compulsory Name"), 'required'); $form->registerRule('exist', 'callback', 'testTrapGroupExistence'); $form->addRule('name', _("Name is already in use"), 'exist'); -$form->setRequiredNote("* ". _("Required fields")); +$form->setRequiredNote("* " . _("Required fields")); # ##End of form definition @@ -105,20 +110,30 @@ function myDecodeGroup($arg) # Smarty template Init $tpl = new Smarty(); $tpl = initSmartyTpl($path, $tpl); -$tpl->assign("helpattr", 'TITLE, "'._("Help").'", CLOSEBTN, true, FIX, [this, 0, 5], BGCOLOR, "#ffff99", BORDERCOLOR, "orange", TITLEFONTCOLOR, "black", TITLEBGCOLOR, "orange", CLOSEBTNCOLORS, ["","black", "white", "red"], WIDTH, -300, SHADOW, true, TEXTALIGN, "justify"'); +$tpl->assign( + "helpattr", + 'TITLE, "' . _("Help") . '", CLOSEBTN, true, FIX, [this, 0, 5], BGCOLOR, "#ffff99", BORDERCOLOR, "orange", ' . + 'TITLEFONTCOLOR, "black", TITLEBGCOLOR, "orange", CLOSEBTNCOLORS, ["","black", "white", "red"], WIDTH, ' . + '-300, SHADOW, true, TEXTALIGN, "justify"' +); # prepare help texts $helptext = ""; include_once("help.php"); foreach ($help as $key => $text) { - $helptext .= ''."\n"; + $helptext .= '' . "\n"; } $tpl->assign("helptext", $helptext); # Just watch a Trap Group information if ($o == "w") { if ($centreon->user->access->page($p) != 2) { - $form->addElement("button", "change", _("Modify"), array("onClick"=>"javascript:window.location.href='?p=".$p."&o=c&id=".$id."'")); + $form->addElement( + "button", + "change", + _("Modify"), + array("onClick" => "javascript:window.location.href='?p=" . $p . "&o=c&id=" . $id . "'") + ); } $form->setDefaults($group); $form->freeze(); @@ -146,7 +161,7 @@ function myDecodeGroup($arg) } if ($valid) { - require_once($path."listGroups.php"); + require_once($path . "listGroups.php"); } else { ##Apply a template definition $renderer = new HTML_QuickForm_Renderer_ArraySmarty($tpl); diff --git a/www/include/configuration/configObject/traps-groups/groups.php b/www/include/configuration/configObject/traps-groups/groups.php index 7274135fef7..35435be0e05 100644 --- a/www/include/configuration/configObject/traps-groups/groups.php +++ b/www/include/configuration/configObject/traps-groups/groups.php @@ -32,7 +32,7 @@ * For more information : contact@centreon.com * */ - + if (!isset($centreon)) { exit(); } diff --git a/www/include/configuration/configObject/traps-groups/listGroups.php b/www/include/configuration/configObject/traps-groups/listGroups.php index 1209968e51e..83d78018241 100644 --- a/www/include/configuration/configObject/traps-groups/listGroups.php +++ b/www/include/configuration/configObject/traps-groups/listGroups.php @@ -36,15 +36,15 @@ if (!isset($centreon)) { exit(); } - + include("./include/common/autoNumLimit.php"); $mnftr_id = null; - + $SearchTool = null; $search = ''; if (isset($_POST['searchTM']) && $_POST['searchTM']) { $search = $_POST['searchTM']; - $SearchTool = " WHERE (traps_group_name LIKE '%".htmlentities($search, ENT_QUOTES, "UTF-8")."%')"; + $SearchTool = " WHERE (traps_group_name LIKE '%" . htmlentities($search, ENT_QUOTES, "UTF-8") . "%')"; } $DBRESULT = $pearDB->query("SELECT COUNT(*) FROM traps_group $SearchTool"); @@ -72,8 +72,9 @@ /* * List of elements - Depends on different criteria */ -$DBRESULT = $pearDB->query("SELECT * FROM traps_group $SearchTool ORDER BY traps_group_name LIMIT ".$num * $limit.", ".$limit); -$form = new HTML_QuickForm('form', 'POST', "?p=".$p); +$query = "SELECT * FROM traps_group $SearchTool ORDER BY traps_group_name LIMIT " . $num * $limit . ", " . $limit; +$DBRESULT = $pearDB->query($query); +$form = new HTML_QuickForm('form', 'POST', "?p=" . $p); /* * Different style between each lines @@ -86,13 +87,18 @@ $elemArr = array(); for ($i = 0; $group = $DBRESULT->fetchRow(); $i++) { $moptions = ""; - $selectedElements = $form->addElement('checkbox', "select[".$group['traps_group_id']."]"); - $moptions = "  31 && (event.keyCode < 45 || event.keyCode > 57)) event.returnValue = false; if(event.which > 31 && (event.which < 45 || event.which > 57)) return false;\" maxlength=\"3\" size=\"3\" value='1' style=\"margin-bottom:0px;\" name='dupNbr[".$group['traps_group_id']."]'>"; - $elemArr[$i] = array("MenuClass"=>"list_".$style, - "RowMenu_select"=>$selectedElements->toHtml(), - "RowMenu_name"=>myDecode($group["traps_group_name"]), - "RowMenu_link"=>"?p=".$p."&o=c&id=".$group['traps_group_id'], - "RowMenu_options"=>$moptions); + $selectedElements = $form->addElement('checkbox', "select[" . $group['traps_group_id'] . "]"); + $moptions = "  31 && (event.keyCode < 45 || event.keyCode > 57)) " . + "event.returnValue = false; if(event.which > 31 && (event.which < 45 || event.which > 57)) return false;\" " . + "maxlength=\"3\" size=\"3\" value='1' style=\"margin-bottom:0px;\" name='dupNbr[" . + $group['traps_group_id'] . "]' />"; + $elemArr[$i] = array( + "MenuClass" => "list_" . $style, + "RowMenu_select" => $selectedElements->toHtml(), + "RowMenu_name" => myDecode($group["traps_group_name"]), + "RowMenu_link" => "?p=" . $p . "&o=c&id=" . $group['traps_group_id'], + "RowMenu_options" => $moptions + ); $style != "two" ? $style = "two" : $style = "one"; } $tpl->assign("elemArr", $elemArr); @@ -100,46 +106,67 @@ /* * Different messages we put in the template */ -$tpl->assign('msg', array ("addL"=>"?p=".$p."&o=a", "addT"=>_("Add"), "delConfirm"=>_("Do you confirm the deletion ?"))); +$tpl->assign( + 'msg', + array("addL" => "?p=" . $p . "&o=a", "addT" => _("Add"), "delConfirm" => _("Do you confirm the deletion ?")) +); /* * Toolbar select */ ?> - + "javascript: " . - " var bChecked = isChecked(); ". - " if (this.form.elements['o1'].selectedIndex != 0 && !bChecked) {". - " alert('"._("Please select one or more items")."'); return false;} " . - "if (this.form.elements['o1'].selectedIndex == 1 && confirm('"._("Do you confirm the duplication ?")."')) {" . - " setO(this.form.elements['o1'].value); submit();} " . - "else if (this.form.elements['o1'].selectedIndex == 2 && confirm('"._("Do you confirm the deletion ?")."')) {" . - " setO(this.form.elements['o1'].value); submit();} " . - "else if (this.form.elements['o1'].selectedIndex == 3) {" . - " setO(this.form.elements['o1'].value); submit();} " . - ""); -$form->addElement('select', 'o1', null, array(null=>_("More actions..."), "m"=>_("Duplicate"), "d"=>_("Delete")), $attrs1); + 'onchange' => "javascript: " . + " var bChecked = isChecked(); " . + " if (this.form.elements['o1'].selectedIndex != 0 && !bChecked) {" . + " alert('" . _("Please select one or more items") . "'); return false;} " . + "if (this.form.elements['o1'].selectedIndex == 1 && confirm('" . + _("Do you confirm the duplication ?") . "')) {" . + " setO(this.form.elements['o1'].value); submit();} " . + "else if (this.form.elements['o1'].selectedIndex == 2 && confirm('" . + _("Do you confirm the deletion ?") . "')) {" . + " setO(this.form.elements['o1'].value); submit();} " . + "else if (this.form.elements['o1'].selectedIndex == 3) {" . + " setO(this.form.elements['o1'].value); submit();} " . + "" +); +$form->addElement( + 'select', + 'o1', + null, + array(null => _("More actions..."), "m" => _("Duplicate"), "d" => _("Delete")), + $attrs1 +); $form->setDefaults(array('o1' => null)); - + $attrs2 = array( - 'onchange'=>"javascript: " . - " var bChecked = isChecked(); ". - " if (this.form.elements['o2'].selectedIndex != 0 && !bChecked) {". - " alert('"._("Please select one or more items")."'); return false;} " . - "if (this.form.elements['o2'].selectedIndex == 1 && confirm('"._("Do you confirm the duplication ?")."')) {" . - " setO(this.form.elements['o2'].value); submit();} " . - "else if (this.form.elements['o2'].selectedIndex == 2 && confirm('"._("Do you confirm the deletion ?")."')) {" . - " setO(this.form.elements['o2'].value); submit();} " . - "else if (this.form.elements['o2'].selectedIndex == 3) {" . - " setO(this.form.elements['o2'].value); submit();} " . - ""); -$form->addElement('select', 'o2', null, array(null=>_("More actions..."), "m"=>_("Duplicate"), "d"=>_("Delete")), $attrs2); + 'onchange' => "javascript: " . + " var bChecked = isChecked(); " . + " if (this.form.elements['o2'].selectedIndex != 0 && !bChecked) {" . + " alert('" . _("Please select one or more items") . "'); return false;} " . + "if (this.form.elements['o2'].selectedIndex == 1 && confirm('" . + _("Do you confirm the duplication ?") . "')) {" . + " setO(this.form.elements['o2'].value); submit();} " . + "else if (this.form.elements['o2'].selectedIndex == 2 && confirm('" . + _("Do you confirm the deletion ?") . "')) {" . + " setO(this.form.elements['o2'].value); submit();} " . + "else if (this.form.elements['o2'].selectedIndex == 3) {" . + " setO(this.form.elements['o2'].value); submit();} " . + "" +); +$form->addElement( + 'select', + 'o2', + null, + array(null => _("More actions..."), "m" => _("Duplicate"), "d" => _("Delete")), + $attrs2 +); $form->setDefaults(array('o2' => null)); $o1 = $form->getElement('o1'); From ed7f478cf99c96038ce3d8639fc0d32180a8ea77 Mon Sep 17 00:00:00 2001 From: loiclau Date: Fri, 28 Jul 2017 18:01:35 +0200 Subject: [PATCH 098/207] * fix style traps manufacturer --- .../traps-manufacturer/DB-Func.php | 70 ++++++----- .../traps-manufacturer/formMnftr.php | 31 +++-- .../configObject/traps-manufacturer/help.php | 5 +- .../traps-manufacturer/listMnftr.php | 115 +++++++++++------- .../configObject/traps-manufacturer/mnftr.php | 14 +-- 5 files changed, 143 insertions(+), 92 deletions(-) diff --git a/www/include/configuration/configObject/traps-manufacturer/DB-Func.php b/www/include/configuration/configObject/traps-manufacturer/DB-Func.php index 42e9b379434..1407885d5d3 100644 --- a/www/include/configuration/configObject/traps-manufacturer/DB-Func.php +++ b/www/include/configuration/configObject/traps-manufacturer/DB-Func.php @@ -32,7 +32,7 @@ * For more information : contact@centreon.com * */ - + function testMnftrExistence($name = null) { @@ -42,7 +42,8 @@ function testMnftrExistence($name = null) if (isset($form)) { $id = $form->getSubmitValue('id'); } - $DBRESULT = $pearDB->query("SELECT name, id FROM traps_vendor WHERE name = '".htmlentities($name, ENT_QUOTES, "UTF-8")."'"); + $query = "SELECT name, id FROM traps_vendor WHERE name = '" . htmlentities($name, ENT_QUOTES, "UTF-8") . "'"; + $DBRESULT = $pearDB->query($query); $mnftr = $DBRESULT->fetchRow(); #Modif case if ($DBRESULT->rowCount() >= 1 && $mnftr["id"] == $id) { @@ -59,40 +60,49 @@ function deleteMnftrInDB($mnftr = array()) { global $pearDB, $oreon; foreach ($mnftr as $key => $value) { - $DBRESULT2 = $pearDB->query("SELECT name FROM `traps_vendor` WHERE `id` = '".$key."' LIMIT 1"); + $DBRESULT2 = $pearDB->query("SELECT name FROM `traps_vendor` WHERE `id` = '" . $key . "' LIMIT 1"); $row = $DBRESULT2->fetchRow(); - - $DBRESULT = $pearDB->query("DELETE FROM traps_vendor WHERE id = '".htmlentities($key, ENT_QUOTES, "UTF-8")."'"); + + $pearDB->query("DELETE FROM traps_vendor WHERE id = '" . htmlentities($key, ENT_QUOTES, "UTF-8") . "'"); $oreon->CentreonLogAction->insertLog("manufacturer", $key, $row['name'], "d"); } } - + function multipleMnftrInDB($mnftr = array(), $nbrDup = array()) { foreach ($mnftr as $key => $value) { global $pearDB, $oreon; - $DBRESULT = $pearDB->query("SELECT * FROM traps_vendor WHERE id = '".htmlentities($key, ENT_QUOTES, "UTF-8")."' LIMIT 1"); + $query = "SELECT * FROM traps_vendor WHERE id = '" . htmlentities($key, ENT_QUOTES, "UTF-8") . "' LIMIT 1"; + $DBRESULT = $pearDB->query($query); $row = $DBRESULT->fetchRow(); $row["id"] = ''; for ($i = 1; $i <= $nbrDup[$key]; $i++) { $val = null; foreach ($row as $key2 => $value2) { - $key2 == "name" ? ($name = $value2 = $value2."_".$i) : null; - $val ? $val .= ($value2!=null?(", '".$value2."'"):", NULL") : $val .= ($value2!=null?("'".$value2."'"):"NULL"); + $key2 == "name" ? ($name = $value2 = $value2 . "_" . $i) : null; + $val + ? $val .= ($value2 != null ? (", '" . $value2 . "'") : ", NULL") + : $val .= ($value2 != null ? ("'" . $value2 . "'") : "NULL"); if ($key2 != "id") { $fields[$key2] = $value2; } $fields["name"] = $name; } if (testMnftrExistence($name)) { - $val ? $rq = "INSERT INTO traps_vendor VALUES (".$val.")" : $rq = null; - $DBRESULT = $pearDB->query($rq); - $oreon->CentreonLogAction->insertLog("manufacturer", htmlentities($key, ENT_QUOTES, "UTF-8"), $name, "a", $fields); + $val ? $rq = "INSERT INTO traps_vendor VALUES (" . $val . ")" : $rq = null; + $pearDB->query($rq); + $oreon->CentreonLogAction->insertLog( + "manufacturer", + htmlentities($key, ENT_QUOTES, "UTF-8"), + $name, + "a", + $fields + ); } } } } - + function updateMnftrInDB($id = null) { if (!$id) { @@ -100,56 +110,56 @@ function updateMnftrInDB($id = null) } updateMnftr($id); } - + function updateMnftr($id = null) { global $form, $pearDB, $oreon; - + if (!$id) { return; } - + $ret = array(); $ret = $form->getSubmitValues(); $rq = "UPDATE traps_vendor "; - $rq .= "SET name = '".htmlentities($ret["name"], ENT_QUOTES, "UTF-8")."', "; - $rq .= "alias = '".htmlentities($ret["alias"], ENT_QUOTES, "UTF-8")."', "; - $rq .= "description = '".htmlentities($ret["description"], ENT_QUOTES, "UTF-8")."' "; - $rq .= "WHERE id = '".$id."'"; + $rq .= "SET name = '" . htmlentities($ret["name"], ENT_QUOTES, "UTF-8") . "', "; + $rq .= "alias = '" . htmlentities($ret["alias"], ENT_QUOTES, "UTF-8") . "', "; + $rq .= "description = '" . htmlentities($ret["description"], ENT_QUOTES, "UTF-8") . "' "; + $rq .= "WHERE id = '" . $id . "'"; $DBRESULT = $pearDB->query($rq); - + /* Prepare value for changelog */ $fields = CentreonLogAction::prepareChanges($ret); $oreon->CentreonLogAction->insertLog("manufacturer", $id, $fields["name"], "c", $fields); } - + function insertMnftrInDB($ret = array()) { $id = insertMnftr($ret); return ($id); } - + function insertMnftr($ret = array()) { global $form, $pearDB, $oreon; - + if (!count($ret)) { $ret = $form->getSubmitValues(); } - + $rq = "INSERT INTO traps_vendor "; $rq .= "(name, alias, description) "; $rq .= "VALUES "; - $rq .= "('".htmlentities($ret["name"], ENT_QUOTES, "UTF-8")."', "; - $rq .= "'".htmlentities($ret["alias"], ENT_QUOTES, "UTF-8")."', "; - $rq .= "'".htmlentities($ret["description"], ENT_QUOTES, "UTF-8")."')"; + $rq .= "('" . htmlentities($ret["name"], ENT_QUOTES, "UTF-8") . "', "; + $rq .= "'" . htmlentities($ret["alias"], ENT_QUOTES, "UTF-8") . "', "; + $rq .= "'" . htmlentities($ret["description"], ENT_QUOTES, "UTF-8") . "')"; $DBRESULT = $pearDB->query($rq); $DBRESULT = $pearDB->query("SELECT MAX(id) FROM traps_vendor"); $mnftr_id = $DBRESULT->fetchRow(); - + /* Prepare value for changelog */ $fields = CentreonLogAction::prepareChanges($ret); $oreon->CentreonLogAction->insertLog("manufacturer", $mnftr_id["MAX(id)"], $fields["name"], "a", $fields); - + return ($mnftr_id["MAX(id)"]); } diff --git a/www/include/configuration/configObject/traps-manufacturer/formMnftr.php b/www/include/configuration/configObject/traps-manufacturer/formMnftr.php index f2beb5ae90d..732efb05f56 100644 --- a/www/include/configuration/configObject/traps-manufacturer/formMnftr.php +++ b/www/include/configuration/configObject/traps-manufacturer/formMnftr.php @@ -40,12 +40,12 @@ function myDecodeMnftr($arg) { $arg = html_entity_decode($arg, ENT_QUOTES, "UTF-8"); - return($arg); + return ($arg); } $mnftr = array(); if (($o == "c" || $o == "w") && $id) { - $DBRESULT = $pearDB->query("SELECT * FROM traps_vendor WHERE id = '".$id."' LIMIT 1"); + $DBRESULT = $pearDB->query("SELECT * FROM traps_vendor WHERE id = '" . $id . "' LIMIT 1"); # Set base value $mnftr = array_map("myDecodeMnftr", $DBRESULT->fetchRow()); $DBRESULT->closeCursor(); @@ -54,12 +54,12 @@ function myDecodeMnftr($arg) ########################################################## # Var information to format the element # -$attrsText = array("size"=>"50"); -$attrsTextarea = array("rows"=>"5", "cols"=>"40"); +$attrsText = array("size" => "50"); +$attrsTextarea = array("rows" => "5", "cols" => "40"); # ## Form begin # -$form = new HTML_QuickForm('Form', 'post', "?p=".$p); +$form = new HTML_QuickForm('Form', 'post', "?p=" . $p); if ($o == "a") { $form->addElement('header', 'title', _("Add Vendor")); } elseif ($o == "c") { @@ -90,13 +90,14 @@ function myReplace() global $form; return (str_replace(" ", "_", $form->getSubmitValue("name"))); } + $form->applyFilter('__ALL__', 'myTrim'); $form->applyFilter('name', 'myReplace'); $form->addRule('name', _("Compulsory Name"), 'required'); $form->addRule('alias', _("Compulsory Name"), 'required'); $form->registerRule('exist', 'callback', 'testMnftrExistence'); $form->addRule('name', _("Name is already in use"), 'exist'); -$form->setRequiredNote("* ". _("Required fields")); +$form->setRequiredNote("* " . _("Required fields")); # ##End of form definition @@ -105,20 +106,30 @@ function myReplace() # Smarty template Init $tpl = new Smarty(); $tpl = initSmartyTpl($path, $tpl); -$tpl->assign("helpattr", 'TITLE, "'._("Help").'", CLOSEBTN, true, FIX, [this, 0, 5], BGCOLOR, "#ffff99", BORDERCOLOR, "orange", TITLEFONTCOLOR, "black", TITLEBGCOLOR, "orange", CLOSEBTNCOLORS, ["","black", "white", "red"], WIDTH, -300, SHADOW, true, TEXTALIGN, "justify"'); +$tpl->assign( + "helpattr", + 'TITLE, "' . _("Help") . '", CLOSEBTN, true, FIX, [this, 0, 5], BGCOLOR, "#ffff99", BORDERCOLOR, "orange", ' . + 'TITLEFONTCOLOR, "black", TITLEBGCOLOR, "orange", CLOSEBTNCOLORS, ["","black", "white", "red"], WIDTH, -300, ' . + 'SHADOW, true, TEXTALIGN, "justify"' +); # prepare help texts $helptext = ""; include_once("help.php"); foreach ($help as $key => $text) { - $helptext .= ''."\n"; + $helptext .= '' . "\n"; } $tpl->assign("helptext", $helptext); # Just watch a Command information if ($o == "w") { if ($centreon->user->access->page($p) != 2) { - $form->addElement("button", "change", _("Modify"), array("onClick"=>"javascript:window.location.href='?p=".$p."&o=c&id=".$id."'")); + $form->addElement( + "button", + "change", + _("Modify"), + array("onClick" => "javascript:window.location.href='?p=" . $p . "&o=c&id=" . $id . "'") + ); } $form->setDefaults($mnftr); $form->freeze(); @@ -146,7 +157,7 @@ function myReplace() } if ($valid) { - require_once($path."listMnftr.php"); + require_once($path . "listMnftr.php"); } else { ##Apply a template definition $renderer = new HTML_QuickForm_Renderer_ArraySmarty($tpl); diff --git a/www/include/configuration/configObject/traps-manufacturer/help.php b/www/include/configuration/configObject/traps-manufacturer/help.php index 02788ece296..c2e06cadff2 100644 --- a/www/include/configuration/configObject/traps-manufacturer/help.php +++ b/www/include/configuration/configObject/traps-manufacturer/help.php @@ -3,4 +3,7 @@ $help["alias"] = dgettext("help", "The alias is a longer name or description for the vendor/manufacturer."); $help["name"] = dgettext("help", "The name is used to identify the vendor/manufacturer with a short name."); -$help["description"] = dgettext("help", "Use this for an optional description or comments about the vendor/manufacturer."); +$help["description"] = dgettext( + "help", + "Use this for an optional description or comments about the vendor/manufacturer." +); diff --git a/www/include/configuration/configObject/traps-manufacturer/listMnftr.php b/www/include/configuration/configObject/traps-manufacturer/listMnftr.php index c22f6fadc15..9ac77a94d13 100644 --- a/www/include/configuration/configObject/traps-manufacturer/listMnftr.php +++ b/www/include/configuration/configObject/traps-manufacturer/listMnftr.php @@ -32,7 +32,7 @@ * For more information : contact@centreon.com * */ - + if (!isset($centreon)) { exit(); } @@ -41,12 +41,13 @@ include("./include/common/autoNumLimit.php"); $mnftr_id = null; - + $SearchTool = null; $search = ''; if (isset($_POST['searchTM']) && $_POST['searchTM']) { $search = $_POST['searchTM']; - $SearchTool = " WHERE (alias LIKE '%".htmlentities($search, ENT_QUOTES, "UTF-8")."%') OR (name LIKE '%".htmlentities($search, ENT_QUOTES, "UTF-8")."%')"; + $SearchTool = " WHERE (alias LIKE '%" . htmlentities($search, ENT_QUOTES, "UTF-8") . + "%') OR (name LIKE '%" . htmlentities($search, ENT_QUOTES, "UTF-8") . "%')"; } $DBRESULT = $pearDB->query("SELECT COUNT(*) FROM traps_vendor $SearchTool"); @@ -76,8 +77,9 @@ /* * List of elements - Depends on different criteria */ -$DBRESULT = $pearDB->query("SELECT * FROM traps_vendor $SearchTool ORDER BY name, alias LIMIT ".$num * $limit.", ".$limit); -$form = new HTML_QuickForm('form', 'POST', "?p=".$p); +$query = "SELECT * FROM traps_vendor $SearchTool ORDER BY name, alias LIMIT " . $num * $limit . ", " . $limit; +$DBRESULT = $pearDB->query($query); +$form = new HTML_QuickForm('form', 'POST', "?p=" . $p); /* * Different style between each lines @@ -90,14 +92,18 @@ $elemArr = array(); for ($i = 0; $mnftr = $DBRESULT->fetchRow(); $i++) { $moptions = ""; - $selectedElements = $form->addElement('checkbox', "select[".$mnftr['id']."]"); - $moptions = "  31 && (event.keyCode < 45 || event.keyCode > 57)) event.returnValue = false; if(event.which > 31 && (event.which < 45 || event.which > 57)) return false;\" maxlength=\"3\" size=\"3\" value='1' style=\"margin-bottom:0px;\" name='dupNbr[".$mnftr['id']."]'>"; - $elemArr[$i] = array("MenuClass"=>"list_".$style, - "RowMenu_select"=>$selectedElements->toHtml(), - "RowMenu_name"=>CentreonUtils::escapeSecure(myDecode($mnftr["name"])), - "RowMenu_link"=>"?p=".$p."&o=c&id=".$mnftr['id'], - "RowMenu_alias"=>CentreonUtils::escapeSecure(myDecode($mnftr["alias"])), - "RowMenu_options"=>$moptions); + $selectedElements = $form->addElement('checkbox', "select[" . $mnftr['id'] . "]"); + $moptions = "  31 && (event.keyCode < 45 || event.keyCode > 57)) " . + "event.returnValue = false; if(event.which > 31 && (event.which < 45 || event.which > 57)) return false;\" " . + "maxlength=\"3\" size=\"3\" value='1' style=\"margin-bottom:0px;\" name='dupNbr[" . $mnftr['id'] . "]' />"; + $elemArr[$i] = array( + "MenuClass" => "list_" . $style, + "RowMenu_select" => $selectedElements->toHtml(), + "RowMenu_name" => CentreonUtils::escapeSecure(myDecode($mnftr["name"])), + "RowMenu_link" => "?p=" . $p . "&o=c&id=" . $mnftr['id'], + "RowMenu_alias" => CentreonUtils::escapeSecure(myDecode($mnftr["alias"])), + "RowMenu_options" => $moptions + ); $style != "two" ? $style = "two" : $style = "one"; } $tpl->assign("elemArr", $elemArr); @@ -105,46 +111,67 @@ /* * Different messages we put in the template */ -$tpl->assign('msg', array ("addL"=>"?p=".$p."&o=a", "addT"=>_("Add"), "delConfirm"=>_("Do you confirm the deletion ?"))); +$tpl->assign( + 'msg', + array("addL" => "?p=" . $p . "&o=a", "addT" => _("Add"), "delConfirm" => _("Do you confirm the deletion ?")) +); /* * Toolbar select */ ?> - + "javascript: " . - " var bChecked = isChecked(); ". - " if (this.form.elements['o1'].selectedIndex != 0 && !bChecked) {". - " alert('"._("Please select one or more items")."'); return false;} " . - "if (this.form.elements['o1'].selectedIndex == 1 && confirm('"._("Do you confirm the duplication ?")."')) {" . - " setO(this.form.elements['o1'].value); submit();} " . - "else if (this.form.elements['o1'].selectedIndex == 2 && confirm('"._("Do you confirm the deletion ?")."')) {" . - " setO(this.form.elements['o1'].value); submit();} " . - "else if (this.form.elements['o1'].selectedIndex == 3) {" . - " setO(this.form.elements['o1'].value); submit();} " . - ""); -$form->addElement('select', 'o1', null, array(null=>_("More actions..."), "m"=>_("Duplicate"), "d"=>_("Delete")), $attrs1); + 'onchange' => "javascript: " . + " var bChecked = isChecked(); " . + " if (this.form.elements['o1'].selectedIndex != 0 && !bChecked) {" . + " alert('" . _("Please select one or more items") . "'); return false;} " . + "if (this.form.elements['o1'].selectedIndex == 1 && confirm('" . + _("Do you confirm the duplication ?") . "')) {" . + " setO(this.form.elements['o1'].value); submit();} " . + "else if (this.form.elements['o1'].selectedIndex == 2 && confirm('" . + _("Do you confirm the deletion ?") . "')) {" . + " setO(this.form.elements['o1'].value); submit();} " . + "else if (this.form.elements['o1'].selectedIndex == 3) {" . + " setO(this.form.elements['o1'].value); submit();} " . + "" +); +$form->addElement( + 'select', + 'o1', + null, + array(null => _("More actions..."), "m" => _("Duplicate"), "d" => _("Delete")), + $attrs1 +); $form->setDefaults(array('o1' => null)); - + $attrs2 = array( - 'onchange'=>"javascript: " . - " var bChecked = isChecked(); ". - " if (this.form.elements['o2'].selectedIndex != 0 && !bChecked) {". - " alert('"._("Please select one or more items")."'); return false;} " . - "if (this.form.elements['o2'].selectedIndex == 1 && confirm('"._("Do you confirm the duplication ?")."')) {" . - " setO(this.form.elements['o2'].value); submit();} " . - "else if (this.form.elements['o2'].selectedIndex == 2 && confirm('"._("Do you confirm the deletion ?")."')) {" . - " setO(this.form.elements['o2'].value); submit();} " . - "else if (this.form.elements['o2'].selectedIndex == 3) {" . - " setO(this.form.elements['o2'].value); submit();} " . - ""); -$form->addElement('select', 'o2', null, array(null=>_("More actions..."), "m"=>_("Duplicate"), "d"=>_("Delete")), $attrs2); + 'onchange' => "javascript: " . + " var bChecked = isChecked(); " . + " if (this.form.elements['o2'].selectedIndex != 0 && !bChecked) {" . + " alert('" . _("Please select one or more items") . "'); return false;} " . + "if (this.form.elements['o2'].selectedIndex == 1 && confirm('" . + _("Do you confirm the duplication ?") . "')) {" . + " setO(this.form.elements['o2'].value); submit();} " . + "else if (this.form.elements['o2'].selectedIndex == 2 && confirm('" . + _("Do you confirm the deletion ?") . "')) {" . + " setO(this.form.elements['o2'].value); submit();} " . + "else if (this.form.elements['o2'].selectedIndex == 3) {" . + " setO(this.form.elements['o2'].value); submit();} " . + "" +); +$form->addElement( + 'select', + 'o2', + null, + array(null => _("More actions..."), "m" => _("Duplicate"), "d" => _("Delete")), + $attrs2 +); $form->setDefaults(array('o2' => null)); $o1 = $form->getElement('o1'); diff --git a/www/include/configuration/configObject/traps-manufacturer/mnftr.php b/www/include/configuration/configObject/traps-manufacturer/mnftr.php index 448b837e3f4..3b2e7ced4be 100644 --- a/www/include/configuration/configObject/traps-manufacturer/mnftr.php +++ b/www/include/configuration/configObject/traps-manufacturer/mnftr.php @@ -57,7 +57,7 @@ $path = "./include/configuration/configObject/traps-manufacturer/"; #PHP functions -require_once $path."DB-Func.php"; +require_once $path . "DB-Func.php"; require_once "./include/common/common-Func.php"; /* Set the real page */ @@ -67,23 +67,23 @@ switch ($o) { case "a": - require_once($path."formMnftr.php"); + require_once($path . "formMnftr.php"); break; #Add a Trap case "w": - require_once($path."formMnftr.php"); + require_once($path . "formMnftr.php"); break; #Watch a Trap case "c": - require_once($path."formMnftr.php"); + require_once($path . "formMnftr.php"); break; #Modify a Trap case "m": multipleMnftrInDB(isset($select) ? $select : array(), $dupNbr); - require_once($path."listMnftr.php"); + require_once($path . "listMnftr.php"); break; #Duplicate n Traps case "d": deleteMnftrInDB(isset($select) ? $select : array()); - require_once($path."listMnftr.php"); + require_once($path . "listMnftr.php"); break; #Delete n Traps default: - require_once($path."listMnftr.php"); + require_once($path . "listMnftr.php"); break; } From 1c2c28e99bcc1b9f90b4360373f0a40a376e4cad Mon Sep 17 00:00:00 2001 From: loiclau Date: Fri, 28 Jul 2017 18:04:43 +0200 Subject: [PATCH 099/207] * fix style traps mib --- .../configObject/traps-mibs/formMibs.php | 43 ++++++++++++------- .../configObject/traps-mibs/help.php | 6 ++- .../configObject/traps-mibs/mibs.php | 4 +- 3 files changed, 35 insertions(+), 18 deletions(-) diff --git a/www/include/configuration/configObject/traps-mibs/formMibs.php b/www/include/configuration/configObject/traps-mibs/formMibs.php index b544a28e66c..50f399f2312 100644 --- a/www/include/configuration/configObject/traps-mibs/formMibs.php +++ b/www/include/configuration/configObject/traps-mibs/formMibs.php @@ -36,12 +36,12 @@ if (!isset($centreon)) { exit(); } - + /* * Debug Flag */ $debug = 0; - $max_characters = 20000; +$max_characters = 20000; /* * Database retrieve information for Manufacturer @@ -50,27 +50,31 @@ function myDecodeMib($arg) { $arg = html_entity_decode($arg, ENT_QUOTES, "UTF-8"); - return($arg); + return ($arg); } /* * Init Formulary */ -$form = new HTML_QuickForm('Form', 'post', "?p=".$p); +$form = new HTML_QuickForm('Form', 'post', "?p=" . $p); $form->addElement('header', 'title', _("Import SNMP traps from MIB file")); /* * Manufacturer information */ -$attrManufacturer= array( +$route = './include/common/webServices/rest/internal.php?object=centreon_configuration_manufacturer&action=list'; +$attrManufacturer = array( 'datasourceOrigin' => 'ajax', - 'availableDatasetRoute' => './include/common/webServices/rest/internal.php?object=centreon_configuration_manufacturer&action=list', + 'availableDatasetRoute' => $route, 'multiple' => false, 'linkedObject' => 'centreonManufacturer' ); + +$route = './include/common/webServices/rest/internal.php?object=centreon_configuration_manufacturer' . + '&action=defaultValues&target=traps&field=manufacturer_id&id='; $attrManufacturer1 = array_merge( $attrManufacturer, - array('defaultDatasetRoute' => './include/common/webServices/rest/internal.php?object=centreon_configuration_manufacturer&action=defaultValues&target=traps&field=manufacturer_id&id=') + array('defaultDatasetRoute' => $route) ); $form->addElement('select2', 'mnftr', _("Vendor Name"), array(), $attrManufacturer1); @@ -82,7 +86,7 @@ function myDecodeMib($arg) $form->applyFilter('__ALL__', 'myTrim'); $form->addRule('mnftr', _("Compulsory Name"), 'required'); $form->addRule('filename', _("Compulsory Name"), 'required'); -$form->setRequiredNote("* ". _("Required fields")); +$form->setRequiredNote("* " . _("Required fields")); /* * Smarty template Init @@ -91,13 +95,17 @@ function myDecodeMib($arg) $tpl = initSmartyTpl($path, $tpl); - -$tpl->assign("helpattr", 'TITLE, "'._("Help").'", CLOSEBTN, true, FIX, [this, 0, 5], BGCOLOR, "#ffff99", BORDERCOLOR, "orange", TITLEFONTCOLOR, "black", TITLEBGCOLOR, "orange", CLOSEBTNCOLORS, ["","black", "white", "red"], WIDTH, -300, SHADOW, true, TEXTALIGN, "justify"'); +$tpl->assign( + "helpattr", + 'TITLE, "' . _("Help") . '", CLOSEBTN, true, FIX, [this, 0, 5], BGCOLOR, "#ffff99", BORDERCOLOR, "orange", ' . + 'TITLEFONTCOLOR, "black", TITLEBGCOLOR, "orange", CLOSEBTNCOLORS, ["","black", "white", "red"], WIDTH, -300, ' . + 'SHADOW, true, TEXTALIGN, "justify"' +); # prepare help texts $helptext = ""; include_once("help.php"); foreach ($help as $key => $text) { - $helptext .= ''."\n"; + $helptext .= '' . "\n"; } $tpl->assign("helptext", $helptext); @@ -123,16 +131,21 @@ function myDecodeMib($arg) $msg .= "
Moving traps in DataBase..."; if ($debug) { - print("@CENTREONTRAPD_BINDIR@/centFillTrapDB -f '".$values["tmp_name"]."' -m ".htmlentities($ret["mnftr"], ENT_QUOTES, "UTF-8")." --severity=info 2>&1"); + print("@CENTREONTRAPD_BINDIR@/centFillTrapDB -f '" . $values["tmp_name"] . "' -m " . + htmlentities($ret["mnftr"], ENT_QUOTES, "UTF-8") . " --severity=info 2>&1"); } - $stdout = shell_exec("@CENTREONTRAPD_BINDIR@/centFillTrapDB -f '".$values["tmp_name"]."' -m ".htmlentities($ret["mnftr"], ENT_QUOTES, "UTF-8")." --severity=info 2>&1"); + $stdout = shell_exec( + "@CENTREONTRAPD_BINDIR@/centFillTrapDB -f '" . $values["tmp_name"] . + "' -m " . htmlentities($ret["mnftr"], ENT_QUOTES, "UTF-8") . " --severity=info 2>&1" + ); unlink($values['tmp_name']); - $msg .= "
".str_replace("\n", "
", $stdout); + $msg .= "
" . str_replace("\n", "
", $stdout); $msg .= "
Generate Traps configuration files from Monitoring Engine configuration form!"; if ($msg) { if (strlen($msg) > $max_characters) { - $msg = substr($msg, 0, $max_characters)."...".sprintf(_("Message truncated (exceeded %s characters)"), $max_characters); + $msg = substr($msg, 0, $max_characters) . "..." . + sprintf(_("Message truncated (exceeded %s characters)"), $max_characters); } $tpl->assign('msg', $msg); } diff --git a/www/include/configuration/configObject/traps-mibs/help.php b/www/include/configuration/configObject/traps-mibs/help.php index d595c50e749..ca074181541 100644 --- a/www/include/configuration/configObject/traps-mibs/help.php +++ b/www/include/configuration/configObject/traps-mibs/help.php @@ -2,4 +2,8 @@ $help = array(); $help["vendor"] = dgettext("help", "Choose a vendor from the list. The vendor must have been created beforehand."); -$help["filename"] = dgettext("help", "Choose a local MIB file containing SNMP trap definitions to upload and import. The file will be parsed with snmpttconvertmib."); +$help["filename"] = dgettext( + "help", + "Choose a local MIB file containing SNMP trap definitions to upload and import. " . + "The file will be parsed with snmpttconvertmib." +); diff --git a/www/include/configuration/configObject/traps-mibs/mibs.php b/www/include/configuration/configObject/traps-mibs/mibs.php index 25263f11404..70a9c505d81 100644 --- a/www/include/configuration/configObject/traps-mibs/mibs.php +++ b/www/include/configuration/configObject/traps-mibs/mibs.php @@ -54,9 +54,9 @@ switch ($o) { case "a": - require_once($path."formMibs.php"); + require_once($path . "formMibs.php"); break; #Show command execution default: - require_once($path."formMibs.php"); + require_once($path . "formMibs.php"); break; } From d5957964f21b3fcce674fb2a3a6c7e9c2da4d2d0 Mon Sep 17 00:00:00 2001 From: loiclau Date: Fri, 28 Jul 2017 18:11:36 +0200 Subject: [PATCH 100/207] * fix style config resources --- .../configuration/configResources/DB-Func.php | 77 ++++++++---- .../configResources/formResources.php | 30 ++++- .../configResources/listResources.php | 111 +++++++++++------- .../configResources/resources.php | 76 ++++++------ 4 files changed, 181 insertions(+), 113 deletions(-) diff --git a/www/include/configuration/configResources/DB-Func.php b/www/include/configuration/configResources/DB-Func.php index 2c4e4df192d..f2315b5ba1f 100644 --- a/www/include/configuration/configResources/DB-Func.php +++ b/www/include/configuration/configResources/DB-Func.php @@ -56,8 +56,8 @@ function testExistence($name = null, $instanceId = null) $DBRESULT = $pearDB->query("SELECT cr.resource_name, crir.resource_id, crir.instance_id FROM cfg_resource cr, cfg_resource_instance_relations crir WHERE cr.resource_id = crir.resource_id - AND crir.instance_id IN (".implode(",", $instances).") - AND cr.resource_name = '".$pearDB->escape($name)."'"); + AND crir.instance_id IN (" . implode(",", $instances) . ") + AND cr.resource_name = '" . $pearDB->escape($name) . "'"); $res = $DBRESULT->fetchRow(); if ($DBRESULT->rowCount() >= 1 && $res["resource_id"] == $id) { return true; @@ -73,7 +73,7 @@ function deleteResourceInDB($DBRESULT = array()) global $pearDB; foreach ($DBRESULT as $key => $value) { - $DBRESULT = $pearDB->query("DELETE FROM cfg_resource WHERE resource_id = '".$key."'"); + $DBRESULT = $pearDB->query("DELETE FROM cfg_resource WHERE resource_id = '" . $key . "'"); } } @@ -84,7 +84,7 @@ function enableResourceInDB($resource_id = null) if (!$resource_id) { exit(); } - $DBRESULT = $pearDB->query("UPDATE cfg_resource SET resource_activate = '1' WHERE resource_id = '".$resource_id."'"); + $pearDB->query("UPDATE cfg_resource SET resource_activate = '1' WHERE resource_id = '" . $resource_id . "'"); } function disableResourceInDB($resource_id = null) @@ -93,7 +93,7 @@ function disableResourceInDB($resource_id = null) if (!$resource_id) { return; } - $DBRESULT = $pearDB->query("UPDATE cfg_resource SET resource_activate = '0' WHERE resource_id = '".$resource_id."'"); + $pearDB->query("UPDATE cfg_resource SET resource_activate = '0' WHERE resource_id = '" . $resource_id . "'"); } function multipleResourceInDB($DBRESULT = array(), $nbrDup = array()) @@ -101,17 +101,19 @@ function multipleResourceInDB($DBRESULT = array(), $nbrDup = array()) global $pearDB; foreach ($DBRESULT as $key => $value) { - $DBRESULT = $pearDB->query("SELECT * FROM cfg_resource WHERE resource_id = '".$key."' LIMIT 1"); + $DBRESULT = $pearDB->query("SELECT * FROM cfg_resource WHERE resource_id = '" . $key . "' LIMIT 1"); $row = $DBRESULT->fetchRow(); $row["resource_id"] = ''; for ($i = 1; $i <= $nbrDup[$key]; $i++) { $val = null; foreach ($row as $key2 => $value2) { - $key2 == "resource_name" ? ($resource_name = $value2 = $value2."_".$i) : null; - $val ? $val .= ($value2!=null?(", '".$value2."'"):", NULL") : $val .= ($value2!=null?("'".$value2."'"):"NULL"); + $key2 == "resource_name" ? ($resource_name = $value2 = $value2 . "_" . $i) : null; + $val + ? $val .= ($value2 != null ? (", '" . $value2 . "'") : ", NULL") + : $val .= ($value2 != null ? ("'" . $value2 . "'") : "NULL"); } if (testExistence($resource_name)) { - $DBRESULT = $pearDB->query($val ? $rq = "INSERT INTO cfg_resource VALUES (".$val.")" : $rq = null); + $pearDB->query($val ? $rq = "INSERT INTO cfg_resource VALUES (" . $val . ")" : $rq = null); } } } @@ -136,16 +138,22 @@ function updateResource($resource_id) $ret = array(); $ret = $form->getSubmitValues(); $rq = "UPDATE cfg_resource "; - $rq .= "SET resource_name = '".$pearDB->escape($ret["resource_name"])."', " . - "resource_line = '".$pearDB->escape($ret["resource_line"])."', " . - "resource_comment= '".$pearDB->escape($ret["resource_comment"])."', " . - "resource_activate= '".$ret["resource_activate"]["resource_activate"]."' " . - "WHERE resource_id = '".$resource_id."'"; - $DBRESULT = $pearDB->query($rq); + $rq .= "SET resource_name = '" . $pearDB->escape($ret["resource_name"]) . "', " . + "resource_line = '" . $pearDB->escape($ret["resource_line"]) . "', " . + "resource_comment= '" . $pearDB->escape($ret["resource_comment"]) . "', " . + "resource_activate= '" . $ret["resource_activate"]["resource_activate"] . "' " . + "WHERE resource_id = '" . $resource_id . "'"; + $pearDB->query($rq); /* Prepare value for changelog */ $fields = CentreonLogAction::prepareChanges($ret); - $centreon->CentreonLogAction->insertLog("resource", $resource_id["MAX(resource_id)"], CentreonDB::escape($ret["resource_name"]), "c", $fields); + $centreon->CentreonLogAction->insertLog( + "resource", + $resource_id["MAX(resource_id)"], + CentreonDB::escape($ret["resource_name"]), + "c", + $fields + ); } function insertResourceInDB() @@ -158,25 +166,39 @@ function insertResourceInDB() function insertResource($ret = array()) { global $form, $pearDB, $centreon; - + if (!count($ret)) { $ret = $form->getSubmitValues(); } $rq = "INSERT INTO cfg_resource "; $rq .= "(resource_name, resource_line, resource_comment, resource_activate) "; $rq .= "VALUES ("; - isset($ret["resource_name"]) && $ret["resource_name"] != null ? $rq .= "'".$pearDB->escape($ret["resource_name"])."', " : $rq .= "NULL, "; - isset($ret["resource_line"]) && $ret["resource_line"] != null ? $rq .= "'".$pearDB->escape($ret["resource_line"])."', " : $rq .= "NULL, "; - isset($ret["resource_comment"]) && $ret["resource_comment"] != null ? $rq .= "'".$pearDB->escape($ret["resource_comment"])."', " : $rq .= "NULL, "; - isset($ret["resource_activate"]["resource_activate"]) && $ret["resource_activate"]["resource_activate"] != null ? $rq .= "'".$ret["resource_activate"]["resource_activate"]."'" : $rq .= "NULL"; + isset($ret["resource_name"]) && $ret["resource_name"] != null + ? $rq .= "'" . $pearDB->escape($ret["resource_name"]) . "', " + : $rq .= "NULL, "; + isset($ret["resource_line"]) && $ret["resource_line"] != null + ? $rq .= "'" . $pearDB->escape($ret["resource_line"]) . "', " + : $rq .= "NULL, "; + isset($ret["resource_comment"]) && $ret["resource_comment"] != null + ? $rq .= "'" . $pearDB->escape($ret["resource_comment"]) . "', " + : $rq .= "NULL, "; + isset($ret["resource_activate"]["resource_activate"]) && $ret["resource_activate"]["resource_activate"] != null + ? $rq .= "'" . $ret["resource_activate"]["resource_activate"] . "'" + : $rq .= "NULL"; $rq .= ")"; - $DBRESULT = $pearDB->query($rq); + $pearDB->query($rq); $DBRESULT = $pearDB->query("SELECT MAX(resource_id) FROM cfg_resource"); $resource_id = $DBRESULT->fetchRow(); /* Prepare value for changelog */ $fields = CentreonLogAction::prepareChanges($ret); - $centreon->CentreonLogAction->insertLog("resource", $resource_id["MAX(resource_id)"], CentreonDB::escape($ret["resource_name"]), "a", $fields); + $centreon->CentreonLogAction->insertLog( + "resource", + $resource_id["MAX(resource_id)"], + CentreonDB::escape($ret["resource_name"]), + "a", + $fields + ); return ($resource_id["MAX(resource_id)"]); } @@ -198,7 +220,7 @@ function insertInstanceRelations($resourceId, $instanceId = null) if ($query2 != "") { $query2 .= ", "; } - $query2 .= "(" . $pearDB->escape($resourceId) .", ".$pearDB->escape($instanceId).")"; + $query2 .= "(" . $pearDB->escape($resourceId) . ", " . $pearDB->escape($instanceId) . ")"; } if ($query2) { $pearDB->query($query . $query2); @@ -210,9 +232,12 @@ function getLinkedPollerList($resource_id) global $pearDB; $str = ""; - $DBRESULT = $pearDB->query("SELECT ns.name, ns.id FROM cfg_resource_instance_relations nsr, cfg_resource r, nagios_server ns WHERE nsr.resource_id = r.resource_id AND nsr.instance_id = ns.id AND nsr.resource_id = '".$resource_id."'"); + $query = "SELECT ns.name, ns.id FROM cfg_resource_instance_relations nsr, cfg_resource r, nagios_server ns " . + "WHERE nsr.resource_id = r.resource_id AND nsr.instance_id = ns.id AND nsr.resource_id = '" . + $resource_id . "'"; + $DBRESULT = $pearDB->query($query); while ($data = $DBRESULT->fetchRow()) { - $str .= "".$data["name"]." "; + $str .= "" . $data["name"] . " "; } unset($DBRESULT); return $str; diff --git a/www/include/configuration/configResources/formResources.php b/www/include/configuration/configResources/formResources.php index 8fb85710c6f..9d16133b4ae 100644 --- a/www/include/configuration/configResources/formResources.php +++ b/www/include/configuration/configResources/formResources.php @@ -33,7 +33,11 @@ * */ -if (!$centreon->user->admin && isset($resource_id) && count($allowedResourceConf) && !isset($allowedResourceConf[$resource_id])) { +if (!$centreon->user->admin && + isset($resource_id) && + count($allowedResourceConf) && + !isset($allowedResourceConf[$resource_id]) +) { $msg = new CentreonMsg(); $msg->setImage("./img/icons/warning.png"); $msg->setTextStyle("bold"); @@ -52,7 +56,8 @@ * Database retrieve information for Resources CFG */ if (($o == "c" || $o == "w") && $resource_id) { - $DBRESULT = $pearDB->query("SELECT * FROM cfg_resource WHERE resource_id = '" . $pearDB->escape($resource_id) . "' LIMIT 1"); + $query = "SELECT * FROM cfg_resource WHERE resource_id = '" . $pearDB->escape($resource_id) . "' LIMIT 1"; + $DBRESULT = $pearDB->query($query); // Set base value $rs = array_map("myDecode", $DBRESULT->fetchRow()); $DBRESULT->closeCursor(); @@ -64,7 +69,8 @@ $attrsText = array("size" => "35"); $attrsTextarea = array("rows" => "5", "cols" => "40"); $attrsAdvSelect = array("style" => "width: 220px; height: 220px;"); -$eTemplate = '
{label_2}
{unselected}
{add}


{remove}
{label_3}
{selected}
'; +$eTemplate = '
{label_2}
{unselected}
{add}

' . + '
{remove}
{label_3}
{selected}
'; require_once _CENTREON_PATH_ . "www/class/centreonInstance.class.php"; @@ -95,9 +101,11 @@ 'linkedObject' => 'centreonInstance' ); /* Host Parents */ +$route = './api/internal.php?object=centreon_configuration_poller&action=defaultValues' . + '&target=resources&field=instance_id&id=' . $resource_id; $attrPoller1 = array_merge( $attrPoller, - array('defaultDatasetRoute' => './api/internal.php?object=centreon_configuration_poller&action=defaultValues&target=resources&field=instance_id&id='.$resource_id) + array('defaultDatasetRoute' => $route) ); $form->addElement('select2', 'instance_id', _("Linked Instances"), array(), $attrPoller1); @@ -150,7 +158,12 @@ function myReplace() // Just watch a Resources CFG information if ($o == "w") { if ($centreon->user->access->page($p) != 2) { - $form->addElement("button", "change", _("Modify"), array("onClick" => "javascript:window.location.href='?p=" . $p . "&o=c&resource_id=" . $resource_id . "'")); + $form->addElement( + "button", + "change", + _("Modify"), + array("onClick" => "javascript:window.location.href='?p=" . $p . "&o=c&resource_id=" . $resource_id . "'") + ); } $form->setDefaults($rs); $form->freeze(); @@ -174,7 +187,12 @@ function myReplace() updateResourceInDB($rsObj->getValue()); } $o = null; - $form->addElement("button", "change", _("Modify"), array("onClick" => "javascript:window.location.href='?p=" . $p . "&o=c&resource_id=" . $rsObj->getValue() . "'")); + $form->addElement( + "button", + "change", + _("Modify"), + array("onClick" => "javascript:window.location.href='?p=" . $p . "&o=c&resource_id=" . $rsObj->getValue() . "'") + ); $valid = true; } diff --git a/www/include/configuration/configResources/listResources.php b/www/include/configuration/configResources/listResources.php index 0444f29dd5e..7618dec9333 100644 --- a/www/include/configuration/configResources/listResources.php +++ b/www/include/configuration/configResources/listResources.php @@ -48,7 +48,7 @@ $search = ''; if (isset($_POST['searchR']) && $_POST['searchR']) { $search = $_POST['searchR']; - $SearchTool = " WHERE resource_name LIKE '%".htmlentities($search, ENT_QUOTES, "UTF-8")."%'"; + $SearchTool = " WHERE resource_name LIKE '%" . htmlentities($search, ENT_QUOTES, "UTF-8") . "%'"; } $aclCond = ""; @@ -58,7 +58,7 @@ } else { $aclCond = " WHERE "; } - $aclCond .= "resource_id IN (".implode(',', array_keys($allowedResourceConf)).") "; + $aclCond .= "resource_id IN (" . implode(',', array_keys($allowedResourceConf)) . ") "; } @@ -96,10 +96,10 @@ $rq = "SELECT * FROM cfg_resource $SearchTool $aclCond ORDER BY resource_name - LIMIT ".$num * $limit.", ".$limit; + LIMIT " . $num * $limit . ", " . $limit; $DBRESULT = $pearDB->query($rq); -$form = new HTML_QuickForm('select_form', 'POST', "?p=".$p); +$form = new HTML_QuickForm('select_form', 'POST', "?p=" . $p); /* * Different style between each lines @@ -112,25 +112,38 @@ $elemArr = array(); for ($i = 0; $resource = $DBRESULT->fetchRow(); $i++) { preg_match("\$USER([0-9]*)\$", $resource["resource_name"], $tabResources); - $selectedElements = $form->addElement('checkbox', "select[".$resource['resource_id']."]"); - $moptions = ""; + $selectedElements = $form->addElement('checkbox', "select[" . $resource['resource_id'] . "]"); + $moptions = ""; if ($resource["resource_activate"]) { - $moptions .= ""._("Disabled").""; + $moptions .= "" . _("Disabled") . ""; } else { - $moptions .= ""._("Enabled").""; + $moptions .= "" . _("Enabled") . ""; } - $moptions .= " 31 && (event.keyCode < 45 || event.keyCode > 57)) event.returnValue = false; if(event.which > 31 && (event.which < 45 || event.which > 57)) return false;\" maxlength=\"3\" size=\"3\" value='1' style=\"margin-bottom:0px;\" name='dupNbr[".$resource['resource_id']."]'>"; - $elemArr[$i] = array( "order" => $tabResources[1], - "MenuClass"=>"list_".$style, - "RowMenu_select"=>$selectedElements->toHtml(), - "RowMenu_name"=>CentreonUtils::escapeSecure($resource["resource_name"]), - "RowMenu_link"=>"?p=".$p."&o=c&resource_id=".$resource['resource_id'], - "RowMenu_values"=>substr($resource["resource_line"], 0, 40), - "RowMenu_comment"=>CentreonUtils::escapeSecure(substr(html_entity_decode($resource["resource_comment"], ENT_QUOTES, "UTF-8"), 0, 40)), - "RowMenu_associated_poller" => getLinkedPollerList($resource['resource_id']), - "RowMenu_status"=>$resource["resource_activate"] ? _("Enabled") : _("Disabled"), - "RowMenu_badge" => $resource["resource_activate"] ? "service_ok" : "service_critical", - "RowMenu_options"=>$moptions); + $moptions .= " 31 && (event.keyCode < 45 || event.keyCode > 57)) " . + "event.returnValue = false; if(event.which > 31 && (event.which < 45 || event.which > 57)) return false;\" " . + "maxlength=\"3\" size=\"3\" value='1' style=\"margin-bottom:0px;\" name='dupNbr[" . + $resource['resource_id'] . "]' />"; + $elemArr[$i] = array( + "order" => $tabResources[1], + "MenuClass" => "list_" . $style, + "RowMenu_select" => $selectedElements->toHtml(), + "RowMenu_name" => CentreonUtils::escapeSecure($resource["resource_name"]), + "RowMenu_link" => "?p=" . $p . "&o=c&resource_id=" . $resource['resource_id'], + "RowMenu_values" => substr($resource["resource_line"], 0, 40), + "RowMenu_comment" => CentreonUtils::escapeSecure(substr(html_entity_decode( + $resource["resource_comment"], + ENT_QUOTES, + "UTF-8" + ), 0, 40)), + "RowMenu_associated_poller" => getLinkedPollerList($resource['resource_id']), + "RowMenu_status" => $resource["resource_activate"] ? _("Enabled") : _("Disabled"), + "RowMenu_badge" => $resource["resource_activate"] ? "service_ok" : "service_critical", + "RowMenu_options" => $moptions + ); $style != "two" ? $style = "two" : $style = "one"; } @@ -138,16 +151,16 @@ while ($flag) { $flag = 0; foreach ($elemArr as $key => $value) { - $key1 = $key+1; - if (isset($elemArr[$key+1]) && $value["order"] > $elemArr[$key+1]["order"]) { - $swmapTab = $elemArr[$key+1]; - $elemArr[$key+1] = $elemArr[$key]; + $key1 = $key + 1; + if (isset($elemArr[$key + 1]) && $value["order"] > $elemArr[$key + 1]["order"]) { + $swmapTab = $elemArr[$key + 1]; + $elemArr[$key + 1] = $elemArr[$key]; $elemArr[$key] = $swmapTab; $flag = 1; - } elseif (!isset($elemArr[$key+1]) && isset($elemArr[$key-1]["order"])) { - if ($value["order"] < $elemArr[$key-1]["order"]) { - $swmapTab = $elemArr[$key-1]; - $elemArr[$key-1] = $elemArr[$key]; + } elseif (!isset($elemArr[$key + 1]) && isset($elemArr[$key - 1]["order"])) { + if ($value["order"] < $elemArr[$key - 1]["order"]) { + $swmapTab = $elemArr[$key - 1]; + $elemArr[$key - 1] = $elemArr[$key]; $elemArr[$key] = $swmapTab; $flag = 1; } @@ -159,29 +172,41 @@ /* * Different messages we put in the template */ -$tpl->assign('msg', array ("addL"=>"?p=".$p."&o=a", "addT"=>_("Add"), "delConfirm"=>_("Do you confirm the deletion ?"))); +$tpl->assign( + 'msg', + array("addL" => "?p=" . $p . "&o=a", "addT" => _("Add"), "delConfirm" => _("Do you confirm the deletion ?")) +); /* * Toolbar select */ ?> - + "javascript: " . - "if (this.form.elements['".$option."'].selectedIndex == 1 && confirm('"._("Do you confirm the duplication ?")."')) {" . - " setO(this.form.elements['".$option."'].value); submit();} " . - "else if (this.form.elements['".$option."'].selectedIndex == 2 && confirm('"._("Do you confirm the deletion ?")."')) {" . - " setO(this.form.elements['".$option."'].value); submit();} " . - "else if (this.form.elements['".$option."'].selectedIndex == 3) {" . - " setO(this.form.elements['".$option."'].value); submit();} " . - ""); - $form->addElement('select', $option, null, array(null=>_("More actions"), "m"=>_("Duplicate"), "d"=>_("Delete")), $attrs1); + 'onchange' => "javascript: " . + "if (this.form.elements['" . $option . "'].selectedIndex == 1 && confirm('" . + _("Do you confirm the duplication ?") . "')) {" . + " setO(this.form.elements['" . $option . "'].value); submit();} " . + "else if (this.form.elements['" . $option . "'].selectedIndex == 2 && confirm('" . + _("Do you confirm the deletion ?") . "')) {" . + " setO(this.form.elements['" . $option . "'].value); submit();} " . + "else if (this.form.elements['" . $option . "'].selectedIndex == 3) {" . + " setO(this.form.elements['" . $option . "'].value); submit();} " . + "" + ); + $form->addElement( + 'select', + $option, + null, + array(null => _("More actions"), "m" => _("Duplicate"), "d" => _("Delete")), + $attrs1 + ); $form->setDefaults(array($option => null)); $o1 = $form->getElement($option); $o1->setValue(null); diff --git a/www/include/configuration/configResources/resources.php b/www/include/configuration/configResources/resources.php index 643eba68f27..bb689efc03a 100644 --- a/www/include/configuration/configResources/resources.php +++ b/www/include/configuration/configResources/resources.php @@ -40,50 +40,50 @@ exit(); } - isset($_GET["resource_id"]) ? $resourceG = $_GET["resource_id"] : $resourceG = null; - isset($_POST["resource_id"]) ? $resourceP = $_POST["resource_id"] : $resourceP = null; - $resourceG ? $resource_id = $resourceG : $resource_id = $resourceP; +isset($_GET["resource_id"]) ? $resourceG = $_GET["resource_id"] : $resourceG = null; +isset($_POST["resource_id"]) ? $resourceP = $_POST["resource_id"] : $resourceP = null; +$resourceG ? $resource_id = $resourceG : $resource_id = $resourceP; - isset($_GET["select"]) ? $cG = $_GET["select"] : $cG = null; - isset($_POST["select"]) ? $cP = $_POST["select"] : $cP = null; - $cG ? $select = $cG : $select = $cP; +isset($_GET["select"]) ? $cG = $_GET["select"] : $cG = null; +isset($_POST["select"]) ? $cP = $_POST["select"] : $cP = null; +$cG ? $select = $cG : $select = $cP; - isset($_GET["dupNbr"]) ? $cG = $_GET["dupNbr"] : $cG = null; - isset($_POST["dupNbr"]) ? $cP = $_POST["dupNbr"] : $cP = null; - $cG ? $dupNbr = $cG : $dupNbr = $cP; +isset($_GET["dupNbr"]) ? $cG = $_GET["dupNbr"] : $cG = null; +isset($_POST["dupNbr"]) ? $cP = $_POST["dupNbr"] : $cP = null; +$cG ? $dupNbr = $cG : $dupNbr = $cP; - /* - * Pear library - */ - require_once "HTML/QuickForm.php"; - require_once 'HTML/QuickForm/advmultiselect.php'; - require_once 'HTML/QuickForm/Renderer/ArraySmarty.php'; +/* + * Pear library + */ +require_once "HTML/QuickForm.php"; +require_once 'HTML/QuickForm/advmultiselect.php'; +require_once 'HTML/QuickForm/Renderer/ArraySmarty.php'; - /* - * Path to the configuration dir - */ - $path = "./include/configuration/configResources/"; +/* + * Path to the configuration dir + */ +$path = "./include/configuration/configResources/"; - /* - * PHP functions - */ - require_once $path."DB-Func.php"; - require_once "./include/common/common-Func.php"; +/* + * PHP functions + */ +require_once $path . "DB-Func.php"; +require_once "./include/common/common-Func.php"; - /* Set the real page */ +/* Set the real page */ if ($ret['topology_page'] != "" && $p != $ret['topology_page']) { $p = $ret['topology_page']; } - $acl = $oreon->user->access; - $serverString = $acl->getPollerString(); - $allowedResourceConf = array(); +$acl = $oreon->user->access; +$serverString = $acl->getPollerString(); +$allowedResourceConf = array(); if ($serverString != "''" && !empty($serverString)) { $sql = "SELECT resource_id FROM cfg_resource_instance_relations - WHERE instance_id IN (".$serverString.")"; - $res = $pearDB->query($sql); + WHERE instance_id IN (" . $serverString . ")"; + $res = $pearDB->query($sql); while ($row = $res->fetchRow()) { $allowedResourceConf[$row['resource_id']] = true; } @@ -94,49 +94,49 @@ /* * Add a Resource */ - require_once($path."formResources.php"); + require_once($path . "formResources.php"); break; case "w": /* * Watch a Resource */ - require_once($path."formResources.php"); + require_once($path . "formResources.php"); break; case "c": /* * Modify a Resource */ - require_once($path."formResources.php"); + require_once($path . "formResources.php"); break; case "s": /* * Activate a Resource */ enableResourceInDB($resource_id); - require_once($path."listResources.php"); + require_once($path . "listResources.php"); break; case "u": /* * Desactivate a Resource */ disableResourceInDB($resource_id); - require_once($path."listResources.php"); + require_once($path . "listResources.php"); break; case "m": /* * Duplicate n Resources */ multipleResourceInDB(isset($select) ? $select : array(), $dupNbr); - require_once($path."listResources.php"); + require_once($path . "listResources.php"); break; case "d": /* * Delete n Resources */ deleteResourceInDB(isset($select) ? $select : array()); - require_once($path."listResources.php"); + require_once($path . "listResources.php"); break; default: - require_once($path."listResources.php"); + require_once($path . "listResources.php"); break; } From 114bef3d9baee0fa0649d53954d22387a28efcec Mon Sep 17 00:00:00 2001 From: loiclau Date: Mon, 31 Jul 2017 11:40:40 +0200 Subject: [PATCH 101/207] * fix constant error message --- .../centreon-clapi/centreonSettings.class.php | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/www/class/centreon-clapi/centreonSettings.class.php b/www/class/centreon-clapi/centreonSettings.class.php index 2ca3d0178ef..0b376df7277 100644 --- a/www/class/centreon-clapi/centreonSettings.class.php +++ b/www/class/centreon-clapi/centreonSettings.class.php @@ -66,25 +66,25 @@ public function __construct() 'centstorage' => array('values' => array('0', '1')), 'enable_perfdata_sync' => array('values' => array('0', '1')), 'enable_logs_sync' => array('values' => array('0', '1')), - 'gmt' => array('format' => ISSTRING, + 'gmt' => array('format' => self::ISSTRING, 'getterFormatMethod' => 'getTimezonenameFromId', 'setterFormatMethod' => 'getTimezoneIdFromName' ), - 'mailer_path_bin' => array('format' => ISSTRING), - 'snmptt_unknowntrap_log_file' => array('format' => ISSTRING), - 'snmpttconvertmib_path_bin' => array('format' => ISSTRING), - 'perl_library_path' => array('format' => ISSTRING), - 'rrdtool_path_bin' => array('format' => ISSTRING), - 'debug_path' => array('format' => ISSTRING), + 'mailer_path_bin' => array('format' => self::ISSTRING), + 'snmptt_unknowntrap_log_file' => array('format' => self::ISSTRING), + 'snmpttconvertmib_path_bin' => array('format' => self::ISSTRING), + 'perl_library_path' => array('format' => self::ISSTRING), + 'rrdtool_path_bin' => array('format' => self::ISSTRING), + 'debug_path' => array('format' => self::ISSTRING), 'debug_auth' => array('values' => array('0', '1')), 'debug_nagios_import' => array('values' => array('0', '1')), 'debug_rrdtool' => array('values' => array('0', '1')), 'debug_ldap_import' => array('values' => array('0', '1')), 'enable_autologin' => array('values' => array('0', '1')), - 'interval_length' => array('format' => ISNUM), + 'interval_length' => array('format' => self::ISNUM), 'enable_gmt' => array('values' => array('0', '1')), - 'nagios_path_img' => array('format' => ISSTRING), - 'broker_correlator_script' => array('format' => ISSTRING), + 'nagios_path_img' => array('format' => self::ISSTRING), + 'broker_correlator_script' => array('format' => self::ISSTRING), ); } @@ -163,9 +163,9 @@ public function setparam($parameters = null) } if (isset($this->authorizedOptions[$key]['format'])) { - if ($this->authorizedOptions[$key]['format'] == ISNUM && !is_numeric($value)) { + if ($this->authorizedOptions[$key]['format'] == self::ISNUM && !is_numeric($value)) { throw new CentreonClapiException(self::VALUENOTALLOWED); - } elseif (is_array($this->authorizedOptions[$key]['format']) == ISSTRING && !is_string($value)) { + } elseif (is_array($this->authorizedOptions[$key]['format']) == self::ISSTRING && !is_string($value)) { throw new CentreonClapiException(self::VALUENOTALLOWED); } } From 90bfa353b0e305911fb232236ab6a85b7e55334a Mon Sep 17 00:00:00 2001 From: Kevin Duret Date: Mon, 31 Jul 2017 15:32:56 +0200 Subject: [PATCH 102/207] fix array declaration in acceptance tests --- .../bootstrap/ACLResourcesAccessContext.php | 56 +++++++++---------- .../NonAdminContactCreationContext.php | 4 +- .../TrapsSNMPConfigurationContext.php | 12 ++-- 3 files changed, 36 insertions(+), 36 deletions(-) diff --git a/features/bootstrap/ACLResourcesAccessContext.php b/features/bootstrap/ACLResourcesAccessContext.php index a1e44a95495..2fd47480c23 100644 --- a/features/bootstrap/ACLResourcesAccessContext.php +++ b/features/bootstrap/ACLResourcesAccessContext.php @@ -16,7 +16,7 @@ class ACLResourcesAccessContext extends CentreonContext { protected $currentPage; - protected $initialProperties = (array( + protected $initialProperties = array( 'acl_name' => 'aclResourceName', 'acl_alias' => 'aclResourceAlias', 'acl_groups' => array( @@ -36,9 +36,9 @@ class ACLResourcesAccessContext extends CentreonContext 'pollers' => 'Central', 'host_category' => 'hostCategoryName', 'service_category' => 'serviceCategoryName' - )); + ); - protected $duplicatedProperties = (array( + protected $duplicatedProperties = array( 'acl_name' => 'aclResourceName_1', 'acl_alias' => 'aclResourceAlias', 'acl_groups' => array( @@ -58,9 +58,9 @@ class ACLResourcesAccessContext extends CentreonContext 'pollers' => 'Central', 'host_category' => 'hostCategoryName', 'service_category' => 'serviceCategoryName' - )); + ); - protected $updatedProperties = (array( + protected $updatedProperties = array( 'acl_name' => 'aclResourceNameChanged', 'acl_alias' => 'aclResourceAliasChanged', 'acl_groups' => array( @@ -80,67 +80,67 @@ class ACLResourcesAccessContext extends CentreonContext 'pollers' => 'Central', 'host_category' => 'hostCategoryName', 'service_category' => 'serviceCategoryName' - )); + ); - protected $host1 = (array( + protected $host1 = array( 'name' => 'hostName1', 'alias' => 'hostAlias1', 'address' => 'host1@localhost' - )); + ); - protected $host2 = (array( + protected $host2 = array( 'name' => 'hostName2', 'alias' => 'hostAlias2', 'address' => 'host2@localhost' - )); + ); - protected $hostGroup = (array( + protected $hostGroup = array( 'name' => 'hostGroupName', 'alias' => 'hostGroupAlias' - )); + ); - protected $hostCategory = (array( + protected $hostCategory = array( 'name' => 'hostCategoryName', 'alias' => 'hostCategoryAlias' - )); + ); - protected $serviceGroup = (array( + protected $serviceGroup = array( 'name' => 'serviceGroupName', 'description' => 'serviceGroupDescription' - )); + ); - protected $serviceCategory = (array( + protected $serviceCategory = array( 'name' => 'serviceCategoryName', 'description' => 'serviceCategoryDescription' - )); + ); - protected $metaService = (array( + protected $metaService = array( 'name' => 'metaServiceName', 'max_check_attempts' => '5' - )); + ); - protected $aclGroup1 = (array( + protected $aclGroup1 = array( 'group_name' => 'aclGroupName1', 'group_alias' => 'aclGroupAlias1' - )); + ); - protected $aclGroup2 = (array( + protected $aclGroup2 = array( 'group_name' => 'aclGroupName2', 'group_alias' => 'aclGroupAlias2' - )); + ); - protected $aclGroup3 = (array( + protected $aclGroup3 = array( 'group_name' => 'aclGroupName3', 'group_alias' => 'aclGroupAlias3' - )); + ); - protected $linkedAclResource = (array( + protected $linkedAclResource = array( 'acl_name' => 'aclResourceName', 'acl_groups' => array( 'aclGroupName1', 'aclGroupName2' ) - )); + ); /** * @Given three ACL access groups including non admin users exist diff --git a/features/bootstrap/NonAdminContactCreationContext.php b/features/bootstrap/NonAdminContactCreationContext.php index b2884dbf1f8..375762da645 100644 --- a/features/bootstrap/NonAdminContactCreationContext.php +++ b/features/bootstrap/NonAdminContactCreationContext.php @@ -10,14 +10,14 @@ class NonAdminContactCreationContext extends CentreonContext private $duplicatedAlias; private $currentPage; - private $initialProperties = (array( + private $initialProperties = array( 'name' => 'contactName', 'alias' => 'contactAlias', 'email' => 'contact@localhost', 'password' => 'contactpwd', 'password2' => 'contactpwd', 'admin' => 1 - )); + ); public function __construct() { diff --git a/features/bootstrap/TrapsSNMPConfigurationContext.php b/features/bootstrap/TrapsSNMPConfigurationContext.php index 199a253ee86..23d0d16dc1b 100644 --- a/features/bootstrap/TrapsSNMPConfigurationContext.php +++ b/features/bootstrap/TrapsSNMPConfigurationContext.php @@ -14,14 +14,14 @@ class TrapsSNMPConfigurationContext extends CentreonContext { protected $currentPage; - protected $initialProperties = (array( + protected $initialProperties = array( 'name' => 'atrapName', 'oid' => '1.2.3', 'vendor' => 'Cisco', 'output' => 'trapOutputMessage' - )); + ); - protected $updatedProperties = (array( + protected $updatedProperties = array( 'name' => 'atrapNameChanged', 'oid' => '.1.2.3.4', 'vendor' => 'HP', @@ -57,9 +57,9 @@ class TrapsSNMPConfigurationContext extends CentreonContext 'check_downtime' => 2, 'output_transform' => 'trapOutputTransform', 'custom_code' => 'trapCustomCode' - )); + ); - protected $duplicatedProperties = (array( + protected $duplicatedProperties = array( 'name' => 'atrapNameChanged_1', 'oid' => '.1.2.3.4', 'vendor' => 'HP', @@ -95,7 +95,7 @@ class TrapsSNMPConfigurationContext extends CentreonContext 'check_downtime' => 2, 'output_transform' => 'trapOutputTransform', 'custom_code' => 'trapCustomCode' - )); + ); /** * @When I add a new SNMP trap definition with an advanced matching rule From 466f0e50cf28862f80099d338f7aab416fc0703a Mon Sep 17 00:00:00 2001 From: Lionel Assepo Date: Tue, 1 Aug 2017 10:57:38 +0200 Subject: [PATCH 103/207] Merge pull request #5479 from s-duret/patch-16 Use UTF8 for db query --- bin/centreon | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/centreon b/bin/centreon index 2636ba30d53..a7d49186734 100755 --- a/bin/centreon +++ b/bin/centreon @@ -111,6 +111,7 @@ if (isset($conf_centreon['port'])) { } } $db = Centreon_Db_Manager::factory('centreon', 'pdo_mysql', $dbConfig); +$db->query('SET NAMES utf8'); $dbConfig['dbname'] = $conf_centreon['dbcstg']; $db_storage = Centreon_Db_Manager::factory('storage', 'pdo_mysql', $dbConfig); try { From e1942ec1e3e9d8c3485b5f98b9a27b995adee58f Mon Sep 17 00:00:00 2001 From: loiclau Date: Wed, 2 Aug 2017 10:00:55 +0200 Subject: [PATCH 104/207] * add clapi ldap export --- features/TrapsSNMPConfiguration.feature | 20 +-- .../TrapsSNMPConfigurationContext.php | 10 ++ .../Object/Ldap/ConfigurationLdap.php | 47 ++++++ lib/Centreon/Object/Ldap/ObjectLdap.php | 48 +++++++ lib/Centreon/Object/Ldap/ServerLdap.php | 47 ++++++ .../rest_api.postman_environment.json | 2 +- .../centreon-clapi/centreonAPI.class.php | 2 +- .../centreon-clapi/centreonLDAP.class.php | 135 ++++++++++++------ 8 files changed, 259 insertions(+), 52 deletions(-) create mode 100644 lib/Centreon/Object/Ldap/ConfigurationLdap.php create mode 100644 lib/Centreon/Object/Ldap/ObjectLdap.php create mode 100644 lib/Centreon/Object/Ldap/ServerLdap.php diff --git a/features/TrapsSNMPConfiguration.feature b/features/TrapsSNMPConfiguration.feature index 54c38b53cf6..22140e9863c 100644 --- a/features/TrapsSNMPConfiguration.feature +++ b/features/TrapsSNMPConfiguration.feature @@ -6,18 +6,18 @@ Feature: TrapsSNMPConfiguration Background: Given I am logged in a Centreon server - Scenario: Creating SNMP trap with advanced matching rule - When I add a new SNMP trap definition with an advanced matching rule - Then the trap definition is saved with its properties, especially the content of Regexp field - - Scenario: Modify SNMP trap definition - When I modify some properties of an existing SNMP trap definition - Then all changes are saved +# Scenario: Creating SNMP trap with advanced matching rule +# When I add a new SNMP trap definition with an advanced matching rule +# Then the trap definition is saved with its properties, especially the content of Regexp field +# +# Scenario: Modify SNMP trap definition +# When I modify some properties of an existing SNMP trap definition +# Then all changes are saved Scenario: Duplicate SNMP trap definition When I have duplicated one existing SNMP trap definition Then all SNMP trap properties are updated - Scenario: Delete SNMP trap definition - When I have deleted one existing SNMP trap definition - Then this definition disappears from the SNMP trap list +# Scenario: Delete SNMP trap definition +# When I have deleted one existing SNMP trap definition +# Then this definition disappears from the SNMP trap list diff --git a/features/bootstrap/TrapsSNMPConfigurationContext.php b/features/bootstrap/TrapsSNMPConfigurationContext.php index 199a253ee86..abd0361e904 100644 --- a/features/bootstrap/TrapsSNMPConfigurationContext.php +++ b/features/bootstrap/TrapsSNMPConfigurationContext.php @@ -147,6 +147,9 @@ public function iAddANewSNMPTrapDefinitionWithAnAdvancedMatchingRule() */ public function theTrapDefinitionIsSavedWithItsPropertiesEspeciallyTheContentOfRegexpField() { + + + $this->tableau = array(); try { $this->spin( @@ -324,6 +327,10 @@ public function iHaveDuplicatedOneExistingSNMPTrapDefinition() $this->currentPage = new SnmpTrapsConfigurationPage($this); $this->currentPage->setProperties($this->updatedProperties); $this->currentPage->save(); + + var_dump('toto'); + sleep(9999999); + $this->currentPage = new SnmpTrapsConfigurationListingPage($this); $object = $this->currentPage->getEntry($this->updatedProperties['name']); $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); @@ -337,6 +344,9 @@ public function iHaveDuplicatedOneExistingSNMPTrapDefinition() public function allSNMPTrapPropertiesAreUpdated() { $this->tableau = array(); + + sleep(9999999); + try { $this->spin( function ($context) { diff --git a/lib/Centreon/Object/Ldap/ConfigurationLdap.php b/lib/Centreon/Object/Ldap/ConfigurationLdap.php new file mode 100644 index 00000000000..a5687fdbef7 --- /dev/null +++ b/lib/Centreon/Object/Ldap/ConfigurationLdap.php @@ -0,0 +1,47 @@ +. + * + * Linking this program statically or dynamically with other modules is making a + * combined work based on this program. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this program give CENTREON + * permission to link this program with independent modules to produce an executable, + * regardless of the license terms of these independent modules, and to copy and + * distribute the resulting executable under terms of CENTREON choice, provided that + * CENTREON also meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module which is not + * derived from this program. If you modify this program, you may extend this + * exception to your version of the program, but you are not obliged to do so. If you + * do not wish to do so, delete this exception statement from your version. + * + * For more information : contact@centreon.com + * + */ + +require_once "Centreon/Object/Object.php"; + +/** + * Used for interacting with Instances (pollers) + * + * @author sylvestre + */ +class Centreon_Object_Configuration_Ldap extends Centreon_Object +{ + protected $table = "auth_ressource_info"; + protected $primaryKey = "ar_id"; +} diff --git a/lib/Centreon/Object/Ldap/ObjectLdap.php b/lib/Centreon/Object/Ldap/ObjectLdap.php new file mode 100644 index 00000000000..1cb82d3017f --- /dev/null +++ b/lib/Centreon/Object/Ldap/ObjectLdap.php @@ -0,0 +1,48 @@ +. + * + * Linking this program statically or dynamically with other modules is making a + * combined work based on this program. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this program give CENTREON + * permission to link this program with independent modules to produce an executable, + * regardless of the license terms of these independent modules, and to copy and + * distribute the resulting executable under terms of CENTREON choice, provided that + * CENTREON also meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module which is not + * derived from this program. If you modify this program, you may extend this + * exception to your version of the program, but you are not obliged to do so. If you + * do not wish to do so, delete this exception statement from your version. + * + * For more information : contact@centreon.com + * + */ + +require_once "Centreon/Object/Object.php"; + +/** + * Used for interacting with Instances (pollers) + * + * @author sylvestre + */ +class Centreon_Object_Ldap extends Centreon_Object +{ + protected $table = "auth_ressource"; + protected $primaryKey = "ar_id"; + protected $uniqueLabelField = "ar_name"; +} diff --git a/lib/Centreon/Object/Ldap/ServerLdap.php b/lib/Centreon/Object/Ldap/ServerLdap.php new file mode 100644 index 00000000000..98a2c9baace --- /dev/null +++ b/lib/Centreon/Object/Ldap/ServerLdap.php @@ -0,0 +1,47 @@ +. + * + * Linking this program statically or dynamically with other modules is making a + * combined work based on this program. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this program give CENTREON + * permission to link this program with independent modules to produce an executable, + * regardless of the license terms of these independent modules, and to copy and + * distribute the resulting executable under terms of CENTREON choice, provided that + * CENTREON also meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module which is not + * derived from this program. If you modify this program, you may extend this + * exception to your version of the program, but you are not obliged to do so. If you + * do not wish to do so, delete this exception statement from your version. + * + * For more information : contact@centreon.com + * + */ + +require_once "Centreon/Object/Object.php"; + +/** + * Used for interacting with Instances (pollers) + * + * @author sylvestre + */ +class Centreon_Object_Server_Ldap extends Centreon_Object +{ + protected $table = "auth_ressource_host"; + protected $primaryKey = "ldap_host_id"; +} diff --git a/tests/rest_api/rest_api.postman_environment.json b/tests/rest_api/rest_api.postman_environment.json index 377c811e7f0..515e4517c8c 100644 --- a/tests/rest_api/rest_api.postman_environment.json +++ b/tests/rest_api/rest_api.postman_environment.json @@ -1319,7 +1319,7 @@ { "enabled": true, "key": "gmt_value", - "value": "Europe/Paris", + "value": "2", "type": "text" }, { diff --git a/www/class/centreon-clapi/centreonAPI.class.php b/www/class/centreon-clapi/centreonAPI.class.php index bde994c6d0c..1b73f62ea09 100644 --- a/www/class/centreon-clapi/centreonAPI.class.php +++ b/www/class/centreon-clapi/centreonAPI.class.php @@ -288,7 +288,7 @@ public function __construct( $this->relationObject["LDAP"] = array( 'module' => 'core', 'class' => 'LDAP', - 'export' => false + 'export' => true ); $this->relationObject["SETTINGS"] = array( 'module' => 'core', diff --git a/www/class/centreon-clapi/centreonLDAP.class.php b/www/class/centreon-clapi/centreonLDAP.class.php index b835bfc0286..b75f503e796 100644 --- a/www/class/centreon-clapi/centreonLDAP.class.php +++ b/www/class/centreon-clapi/centreonLDAP.class.php @@ -37,6 +37,9 @@ require_once "centreonObject.class.php"; require_once "centreonContact.class.php"; +require_once "Centreon/Object/Ldap/ConfigurationLdap.php"; +require_once "Centreon/Object/Ldap/ObjectLdap.php"; +require_once "Centreon/Object/Ldap/ServerLdap.php"; /** * Class for managing ldap servers @@ -57,31 +60,35 @@ class CentreonLDAP extends CentreonObject public function __construct() { parent::__construct(); - $this->baseParams = array('alias' => '', - 'bind_dn' => '', - 'bind_pass' => '', - 'group_base_search' => '', - 'group_filter' => '', - 'group_member' => '', - 'group_name' => '', - 'ldap_auto_import' => '', - 'ldap_contact_tmpl' => '', - 'ldap_dns_use_domain' => '', - 'ldap_search_limit' => '', - 'ldap_search_timeout' => '', - 'ldap_srv_dns' => '', - 'ldap_store_password' => '', - 'ldap_template' => '', - 'protocol_version' => '', - 'user_base_search' => '', - 'user_email' => '', - 'user_filter' => '', - 'user_firstname' => '', - 'user_lastname' => '', - 'user_name' => '', - 'user_pager' => '', - 'user_group' => ''); + $this->baseParams = array( + 'alias' => '', + 'bind_dn' => '', + 'bind_pass' => '', + 'group_base_search' => '', + 'group_filter' => '', + 'group_member' => '', + 'group_name' => '', + 'ldap_auto_import' => '', + 'ldap_contact_tmpl' => '', + 'ldap_dns_use_domain' => '', + 'ldap_search_limit' => '', + 'ldap_search_timeout' => '', + 'ldap_srv_dns' => '', + 'ldap_store_password' => '', + 'ldap_template' => '', + 'protocol_version' => '', + 'user_base_search' => '', + 'user_email' => '', + 'user_filter' => '', + 'user_firstname' => '', + 'user_lastname' => '', + 'user_name' => '', + 'user_pager' => '', + 'user_group' => '' + ); + $this->object = new \Centreon_Object_Ldap(); $this->serverParams = array('host_address', 'host_port', 'host_order', 'use_ssl', 'use_tls'); + $this->action = "LDAP"; } /** @@ -157,22 +164,22 @@ public function showserver($arName = null) } $arId = $this->getLdapId($arName); if (is_null($arId)) { - throw new CentreonClapiException(self::OBJECT_NOT_FOUND.' '.$arName); + throw new CentreonClapiException(self::OBJECT_NOT_FOUND . ' ' . $arName); } $sql = "SELECT ldap_host_id, host_address, host_port, use_ssl, use_tls, host_order FROM auth_ressource_host - WHERE auth_ressource_id = ".$arId." + WHERE auth_ressource_id = " . $arId . " ORDER BY host_order"; $res = $this->db->query($sql); $row = $res->fetchAll(); echo "id;address;port;ssl;tls;order\n"; foreach ($row as $srv) { - echo $srv['ldap_host_id'].$this->delim. - $srv['host_address'].$this->delim. - $srv['host_port'].$this->delim. - $srv['use_ssl'].$this->delim. - $srv['use_tls'].$this->delim. - $srv['host_order']."\n"; + echo $srv['ldap_host_id'] . $this->delim . + $srv['host_address'] . $this->delim . + $srv['host_port'] . $this->delim . + $srv['use_ssl'] . $this->delim . + $srv['use_tls'] . $this->delim . + $srv['host_order'] . "\n"; } } @@ -193,7 +200,7 @@ public function add($parameters) } list($name, $description) = $params; if (!$this->isUnique($name)) { - throw new CentreonClapiException(self::NAMEALREADYINUSE.' ('.$name.')'); + throw new CentreonClapiException(self::NAMEALREADYINUSE . ' (' . $name . ')'); } $this->db->query( "INSERT INTO auth_ressource (ar_name, ar_description, ar_enable) VALUES (:name, :description, :status)", @@ -230,11 +237,11 @@ public function addserver($parameters) "INSERT INTO auth_ressource_host (auth_ressource_id, host_address, host_port, use_ssl, use_tls) VALUES (:arId, :address, :port, :ssl, :tls)", array( - ':arId' => $arId, + ':arId' => $arId, ':address' => $address, - ':port' => $port, - ':ssl' => $ssl, - ':tls' => $tls + ':port' => $port, + ':ssl' => $ssl, + ':tls' => $tls ) ); } @@ -252,7 +259,7 @@ public function del($arName = null) } $arId = $this->getLdapId($arName); if (is_null($arId)) { - throw new CentreonClapiException(self::OBJECT_NOT_FOUND.' '.$arName); + throw new CentreonClapiException(self::OBJECT_NOT_FOUND . ' ' . $arName); } $this->db->query("DELETE FROM auth_ressource WHERE ar_id = ?", array($arId)); } @@ -288,12 +295,12 @@ public function setparam($parameters) } $arId = $this->getLdapId($params[0]); if (is_null($arId)) { - throw new CentreonClapiException(self::OBJECT_NOT_FOUND.":".$params[0]); + throw new CentreonClapiException(self::OBJECT_NOT_FOUND . ":" . $params[0]); } if (in_array(strtolower($params[1]), array('name', 'description', 'enable'))) { if (strtolower($params[1]) == 'name') { if (!$this->isUnique($params[2], $arId)) { - throw new CentreonClapiException(self::NAMEALREADYINUSE.' ('.$name.')'); + throw new CentreonClapiException(self::NAMEALREADYINUSE . ' (' . $name . ')'); } } $this->db->query( @@ -344,4 +351,52 @@ public function setparamserver($parameters = null) array($value, $serverId) ); } + + + /** + * Export data + * + * @param null $filter_id + * @param null $filter_name + */ + public function export($filters = null) + { + $configurationLdapObj = new \Centreon_Object_Configuration_Ldap(); + $serverLdapObj = new \Centreon_Object_Server_Ldap(); + $ldapList = $this->object->getList('*', -1, 0, null, null, $filters); + + foreach ($ldapList as $ldap) { + echo $this->action . $this->delim . "ADD" . $this->delim + . $ldap['ar_name'] . $this->delim + . $ldap['ar_description'] . $this->delim . "\n"; + + echo $this->action . $this->delim . "SETPARAM" . $this->delim + . $ldap['ar_name'] . $this->delim + . 'enable' . $this->delim + . $ldap['ar_enable'] . $this->delim . "\n"; + + $filters = array('`ar_id`' => $ldap['ar_id']); + $ldapConfigurationList = $configurationLdapObj->getList('*', -1, 0, null, null, $filters); + + foreach ($ldapConfigurationList as $configuration) { + echo $this->action . $this->delim . "SETPARAM" . $this->delim + . $ldap['ar_name'] . $this->delim + . $configuration['ari_name'] . $this->delim + . $configuration['ari_value'] . $this->delim . "\n"; + + } + + $filters = array('`auth_ressource_id`' => $ldap['ar_id']); + $ldapServerList = $serverLdapObj->getList('*', -1, 0, null, null, $filters); + + foreach ($ldapServerList as $server) { + echo $this->action . $this->delim . "ADDSERVER" . $this->delim + . $ldap['ar_name'] . $this->delim + . $server['host_address'] . $this->delim + . $server['host_port'] . $this->delim + . $server['use_ssl'] . $this->delim + . $server['use_tls'] . $this->delim . "\n"; + } + } + } } From edc068d5866d6abaa21334847eec68eb60e68a2e Mon Sep 17 00:00:00 2001 From: loiclau Date: Wed, 2 Aug 2017 16:21:20 +0200 Subject: [PATCH 105/207] * fix acceptance --- features/TrapsSNMPConfiguration.feature | 20 +++++++++---------- .../TrapsSNMPConfigurationContext.php | 5 ----- .../rest_api.postman_environment.json | 2 +- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/features/TrapsSNMPConfiguration.feature b/features/TrapsSNMPConfiguration.feature index 22140e9863c..99797e471de 100644 --- a/features/TrapsSNMPConfiguration.feature +++ b/features/TrapsSNMPConfiguration.feature @@ -6,18 +6,18 @@ Feature: TrapsSNMPConfiguration Background: Given I am logged in a Centreon server -# Scenario: Creating SNMP trap with advanced matching rule -# When I add a new SNMP trap definition with an advanced matching rule -# Then the trap definition is saved with its properties, especially the content of Regexp field -# -# Scenario: Modify SNMP trap definition -# When I modify some properties of an existing SNMP trap definition -# Then all changes are saved + Scenario: Creating SNMP trap with advanced matching rule + When I add a new SNMP trap definition with an advanced matching rule + Then the trap definition is saved with its properties, especially the content of Regexp field + + Scenario: Modify SNMP trap definition + When I modify some properties of an existing SNMP trap definition + Then all changes are saved Scenario: Duplicate SNMP trap definition When I have duplicated one existing SNMP trap definition Then all SNMP trap properties are updated -# Scenario: Delete SNMP trap definition -# When I have deleted one existing SNMP trap definition -# Then this definition disappears from the SNMP trap list + Scenario: Delete SNMP trap definition + When I have deleted one existing SNMP trap definition + Then this definition disappears from the SNMP trap list diff --git a/features/bootstrap/TrapsSNMPConfigurationContext.php b/features/bootstrap/TrapsSNMPConfigurationContext.php index a04768ac690..ab8b3ab6fdf 100644 --- a/features/bootstrap/TrapsSNMPConfigurationContext.php +++ b/features/bootstrap/TrapsSNMPConfigurationContext.php @@ -328,9 +328,6 @@ public function iHaveDuplicatedOneExistingSNMPTrapDefinition() $this->currentPage->setProperties($this->updatedProperties); $this->currentPage->save(); - var_dump('toto'); - sleep(9999999); - $this->currentPage = new SnmpTrapsConfigurationListingPage($this); $object = $this->currentPage->getEntry($this->updatedProperties['name']); $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); @@ -345,8 +342,6 @@ public function allSNMPTrapPropertiesAreUpdated() { $this->tableau = array(); - sleep(9999999); - try { $this->spin( function ($context) { diff --git a/tests/rest_api/rest_api.postman_environment.json b/tests/rest_api/rest_api.postman_environment.json index 515e4517c8c..377c811e7f0 100644 --- a/tests/rest_api/rest_api.postman_environment.json +++ b/tests/rest_api/rest_api.postman_environment.json @@ -1319,7 +1319,7 @@ { "enabled": true, "key": "gmt_value", - "value": "2", + "value": "Europe/Paris", "type": "text" }, { From 65723ed8eb2a3e63ef6656e83a3caa76d7e2b710 Mon Sep 17 00:00:00 2001 From: loiclau Date: Wed, 2 Aug 2017 17:04:42 +0200 Subject: [PATCH 106/207] fix ldap export filter --- .../centreonCentbrokerCfg.class.php | 5 +-- .../centreon-clapi/centreonCommand.class.php | 7 +---- .../centreon-clapi/centreonContact.class.php | 9 ++---- .../centreonContactGroup.class.php | 9 +----- .../centreon-clapi/centreonDowntime.class.php | 4 +-- .../centreonEngineCfg.class.php | 4 +-- .../centreon-clapi/centreonHost.class.php | 29 ++++++++--------- .../centreonHostCategory.class.php | 4 +-- .../centreonHostGroup.class.php | 9 +----- .../centreonHostGroupService.class.php | 8 ++--- .../centreon-clapi/centreonLDAP.class.php | 31 +++++++++++++------ .../centreon-clapi/centreonService.class.php | 8 ++--- .../centreonServiceCategory.class.php | 5 ++- .../centreonServiceGroup.class.php | 6 ++-- .../centreonServiceTemplate.class.php | 29 +++++++++-------- .../centreonTimePeriod.class.php | 16 ---------- .../centreon-clapi/centreonTrap.class.php | 6 +--- 17 files changed, 75 insertions(+), 114 deletions(-) diff --git a/www/class/centreon-clapi/centreonCentbrokerCfg.class.php b/www/class/centreon-clapi/centreonCentbrokerCfg.class.php index 43ab23e9656..5c5b6b83fb1 100644 --- a/www/class/centreon-clapi/centreonCentbrokerCfg.class.php +++ b/www/class/centreon-clapi/centreonCentbrokerCfg.class.php @@ -686,9 +686,10 @@ protected function fieldIsValid($configId, $tagName, $args) * * @return void */ - public function export() + public function export($filters = null) { - $elements = $this->object->getList("*", -1, 0); + + $elements = $this->object->getList("*", -1, 0, null, null, $filters, "AND"); foreach ($elements as $element) { $addStr = $this->action.$this->delim."ADD". $this->delim.$element['config_name']. diff --git a/www/class/centreon-clapi/centreonCommand.class.php b/www/class/centreon-clapi/centreonCommand.class.php index ad42b1ee6c9..10d74e70902 100644 --- a/www/class/centreon-clapi/centreonCommand.class.php +++ b/www/class/centreon-clapi/centreonCommand.class.php @@ -214,13 +214,8 @@ public function getId($commandName) * @return void */ - public function export($filter_id = null, $filter_name = null) + public function export($filters=null) { - $filters = null; - if (!is_null($filter_id)) { - $filters = array('command_id' => $filter_id); - } - $elements = $this->object->getList("*", -1, 0, null, null, $filters); foreach ($elements as $element) { $addStr = $this->action . $this->delim . "ADD"; diff --git a/www/class/centreon-clapi/centreonContact.class.php b/www/class/centreon-clapi/centreonContact.class.php index 0ac500cf8f7..b73c22c36db 100644 --- a/www/class/centreon-clapi/centreonContact.class.php +++ b/www/class/centreon-clapi/centreonContact.class.php @@ -450,19 +450,16 @@ private function exportNotifCommands($objType, $contactId, $contactName) * @param string $parameters * @return void */ - public function export($filter_id = null, $filter_name = null) + public function export($filters=null) { - $filters = array("contact_register" => $this->register); - if (!is_null($filter_id)) { - $filters['contact_id'] = $filter_id; - } + $filters["contact_register"] = $this->register; $elements = $this->object->getList( "*", -1, 0, null, null, - array("contact_register" => $this->register), + $filters, "AND" ); foreach ($elements as $element) { diff --git a/www/class/centreon-clapi/centreonContactGroup.class.php b/www/class/centreon-clapi/centreonContactGroup.class.php index 24f4e013bad..a919d003bb9 100644 --- a/www/class/centreon-clapi/centreonContactGroup.class.php +++ b/www/class/centreon-clapi/centreonContactGroup.class.php @@ -216,15 +216,8 @@ public function __call($name, $arg) * * @return void */ - public function export($filter_id = null, $filter_name = null) + public function export($filters = null) { - $filters = array(); - if (!is_null($filter_id) && $filter_id !== 0) { - $filters['cg_id'] = $filter_id; - } - if (!is_null($filter_name)) { - $filters['cg_name'] = $filter_name; - } parent::export($filters); $relObj = new \Centreon_Object_Relation_Contact_Group_Contact(); $contactObj = new \Centreon_Object_Contact(); diff --git a/www/class/centreon-clapi/centreonDowntime.class.php b/www/class/centreon-clapi/centreonDowntime.class.php index 9a7e2f96937..1b52b20b44c 100644 --- a/www/class/centreon-clapi/centreonDowntime.class.php +++ b/www/class/centreon-clapi/centreonDowntime.class.php @@ -678,10 +678,10 @@ public function delservicegroup($parameters) /** * Export */ - public function export() + public function export($filters = null) { // generic add & setparam - parent::export(); + parent::export($filters); // handle host relationships $this->exportHostRel(); diff --git a/www/class/centreon-clapi/centreonEngineCfg.class.php b/www/class/centreon-clapi/centreonEngineCfg.class.php index 37dd4e8e099..8de6fa45025 100644 --- a/www/class/centreon-clapi/centreonEngineCfg.class.php +++ b/www/class/centreon-clapi/centreonEngineCfg.class.php @@ -284,9 +284,9 @@ public function show($parameters = null) * * @return void */ - public function export() + public function export($filters = null) { - $elements = $this->object->getList(); + $elements = $this->object->getList("*", -1, 0, null, null, $filters, "AND"); $tpObj = new \Centreon_Object_Timeperiod(); foreach ($elements as $element) { /* ADD action */ diff --git a/www/class/centreon-clapi/centreonHost.class.php b/www/class/centreon-clapi/centreonHost.class.php index 5c8da3986f5..f252221aa3c 100644 --- a/www/class/centreon-clapi/centreonHost.class.php +++ b/www/class/centreon-clapi/centreonHost.class.php @@ -895,12 +895,9 @@ public function __call($name, $arg) * * @return void */ - public function export($filter_id = null, $filter_name = null) + public function export($filters = null) { - $filters = array("host_register" => $this->register); - if (!is_null($filter_id)) { - $filters['host_id'] = $filter_id; - } + $filters["host_register"] = $this->register; $elements = $this->object->getList("*", -1, 0, null, null, $filters, "AND"); $extendedObj = new \Centreon_Object_Host_Extended(); $commandObj = new \Centreon_Object_Command(); @@ -955,7 +952,7 @@ public function export($filter_id = null, $filter_name = null) if (isset($tmp) && isset($tmp[$tmpObj->getUniqueLabelField()])) { $tmp_id = $value; $value = $tmp[$tmpObj->getUniqueLabelField()]; - if (!is_null($filter_id) && !is_null($action_tmp)) { + if (!is_null($filters['host_id']) && !is_null($action_tmp)) { $this->api->export_filter($action_tmp, $tmp_id, $value); } } @@ -1015,8 +1012,8 @@ public function export($filter_id = null, $filter_name = null) } $cgRel = new \Centreon_Object_Relation_Contact_Group_Host(); $filters_cgRel = array("host_register" => $this->register); - if (!is_null($filter_id)) { - $filters_cgRel['host_id'] = $filter_id; + if (!is_null($filters['host_id'])) { + $filters_cgRel['host_id'] = $filters['host_id']; } $elements = $cgRel->getMergedParameters( array("cg_name", "cg_id"), @@ -1037,8 +1034,8 @@ public function export($filter_id = null, $filter_name = null) } $contactRel = new \Centreon_Object_Relation_Contact_Host(); $filters_contactRel = array("host_register" => $this->register); - if (!is_null($filter_id)) { - $filters_contactRel['host_id'] = $filter_id; + if (!is_null($filters['host_id'])) { + $filters_contactRel['host_id'] = $filters['host_id']; } $elements = $contactRel->getMergedParameters( array("contact_alias", "contact_id"), @@ -1059,8 +1056,8 @@ public function export($filter_id = null, $filter_name = null) } $htplRel = new \Centreon_Object_Relation_Host_Template_Host(); $filters_htplRel = array("h.host_register" => $this->register); - if (!is_null($filter_id)) { - $filters_htplRel['h.host_id'] = $filter_id; + if (!is_null($filters['host_id'])) { + $filters_htplRel['h.host_id'] = $filters['host_id']; } $elements = $htplRel->getMergedParameters( array("host_name as host"), @@ -1081,7 +1078,7 @@ public function export($filter_id = null, $filter_name = null) } // Filter only - if (!is_null($filter_id)) { + if (!is_null($filters['host_id'])) { # service templates linked $hostRel = new \Centreon_Object_Relation_Host_Service(); $helements = $hostRel->getMergedParameters( @@ -1091,7 +1088,7 @@ public function export($filter_id = null, $filter_name = null) 0, null, null, - array("service_register" => 0, "host_id" => $filter_id), + array("service_register" => 0, "host_id" => $filters['host_id']), "AND" ); foreach ($helements as $helement) { @@ -1107,7 +1104,7 @@ public function export($filter_id = null, $filter_name = null) 0, null, null, - array("service_register" => 1, "host_id" => $filter_id), + array("service_register" => 1, "host_id" => $filters['host_id']), "AND" ); foreach ($helements as $helement) { @@ -1123,7 +1120,7 @@ public function export($filter_id = null, $filter_name = null) 0, null, null, - array("host_id" => $filter_id), + array("host_id" => $filters['host_id']), "AND" ); foreach ($helements as $helement) { diff --git a/www/class/centreon-clapi/centreonHostCategory.class.php b/www/class/centreon-clapi/centreonHostCategory.class.php index d5f9fcf85e3..d689a906b97 100644 --- a/www/class/centreon-clapi/centreonHostCategory.class.php +++ b/www/class/centreon-clapi/centreonHostCategory.class.php @@ -238,9 +238,9 @@ public function __call($name, $arg) * * @return void */ - public function export() + public function export($filters = null) { - parent::export(); + parent::export($filters); $relobj = new \Centreon_Object_Relation_Host_Category_Host(); $elements = $relobj->getMergedParameters( array($this->object->getUniqueLabelField()), diff --git a/www/class/centreon-clapi/centreonHostGroup.class.php b/www/class/centreon-clapi/centreonHostGroup.class.php index 16521b72999..446c867037a 100644 --- a/www/class/centreon-clapi/centreonHostGroup.class.php +++ b/www/class/centreon-clapi/centreonHostGroup.class.php @@ -278,15 +278,8 @@ public function __call($name, $arg) * * @return void */ - public function export($filter_id = null, $filter_name = null) + public function export($filters = null) { - $filters = array(); - if (!is_null($filter_id) && $filter_id !== 0) { - $filters['hg_id'] = $filter_id; - } - if (!is_null($filter_name)) { - $filters['hg_name'] = $filter_name; - } parent::export($filters); $relObj = new \Centreon_Object_Relation_Host_Group_Host(); diff --git a/www/class/centreon-clapi/centreonHostGroupService.class.php b/www/class/centreon-clapi/centreonHostGroupService.class.php index 0c1fb47383e..20d6d64ef8a 100644 --- a/www/class/centreon-clapi/centreonHostGroupService.class.php +++ b/www/class/centreon-clapi/centreonHostGroupService.class.php @@ -920,12 +920,10 @@ public function __call($name, $arg) * * @return void */ - public function export($filter_id = null, $filter_name = null) + public function export($filters=null) { - $filters = array("service_register" => $this->register); - if (!is_null($filter_id)) { - $filters['hg_id'] = $filter_id; - } + $filters["service_register"] = $this->register; + $hostRel = new \Centreon_Object_Relation_Host_Group_Service(); $elements = $hostRel->getMergedParameters( array("hg_name"), diff --git a/www/class/centreon-clapi/centreonLDAP.class.php b/www/class/centreon-clapi/centreonLDAP.class.php index b75f503e796..fe8db5ff259 100644 --- a/www/class/centreon-clapi/centreonLDAP.class.php +++ b/www/class/centreon-clapi/centreonLDAP.class.php @@ -375,16 +375,6 @@ public function export($filters = null) . 'enable' . $this->delim . $ldap['ar_enable'] . $this->delim . "\n"; - $filters = array('`ar_id`' => $ldap['ar_id']); - $ldapConfigurationList = $configurationLdapObj->getList('*', -1, 0, null, null, $filters); - - foreach ($ldapConfigurationList as $configuration) { - echo $this->action . $this->delim . "SETPARAM" . $this->delim - . $ldap['ar_name'] . $this->delim - . $configuration['ari_name'] . $this->delim - . $configuration['ari_value'] . $this->delim . "\n"; - - } $filters = array('`auth_ressource_id`' => $ldap['ar_id']); $ldapServerList = $serverLdapObj->getList('*', -1, 0, null, null, $filters); @@ -397,6 +387,27 @@ public function export($filters = null) . $server['use_ssl'] . $this->delim . $server['use_tls'] . $this->delim . "\n"; } + + + $filters = array('`ar_id`' => $ldap['ar_id']); + $ldapConfigurationList = $configurationLdapObj->getList('*', -1, 0, null, null, $filters); + + foreach ($ldapConfigurationList as $configuration) { + if ($configuration['ari_name'] != 'ldap_dns_use_ssl' && + $configuration['ari_name'] != 'ldap_dns_use_tls' + ) { + if ($configuration['ari_name'] == 'ldap_contact_tmpl') { + $contactObj = new \Centreon_Object_Contact(); + $contactName = $contactObj->getParameters($configuration['ari_value'], 'contact_name'); + $configuration['ari_value'] = $contactName['contact_name']; + } + + echo $this->action . $this->delim . "SETPARAM" . $this->delim + . $ldap['ar_name'] . $this->delim + . $configuration['ari_name'] . $this->delim + . $configuration['ari_value'] . $this->delim . "\n"; + } + } } } } diff --git a/www/class/centreon-clapi/centreonService.class.php b/www/class/centreon-clapi/centreonService.class.php index f0c3e7a04e9..fbf1035ef33 100644 --- a/www/class/centreon-clapi/centreonService.class.php +++ b/www/class/centreon-clapi/centreonService.class.php @@ -1063,12 +1063,10 @@ public function __call($name, $arg) * * @return void */ - public function export($filter_id = null, $filter_name = null) + public function export($filters = null) { - $filters = array("service_register" => $this->register); - if (!is_null($filter_id)) { - $filters['service_id'] = $filter_id; - } + $filters["service_register"] = $this->register; + $hostRel = new \Centreon_Object_Relation_Host_Service(); $elements = $hostRel->getMergedParameters( array("host_name", "host_id"), diff --git a/www/class/centreon-clapi/centreonServiceCategory.class.php b/www/class/centreon-clapi/centreonServiceCategory.class.php index 29177d26092..c9e5faf87c1 100644 --- a/www/class/centreon-clapi/centreonServiceCategory.class.php +++ b/www/class/centreon-clapi/centreonServiceCategory.class.php @@ -399,10 +399,9 @@ private function setServiceTemplate($args, $relobj, $obj, $categoryId) * * @return void */ - public function export() + public function export($filters = null) { - parent::export(); - $scs = $this->object->getList(array($this->object->getPrimaryKey(), $this->object->getUniqueLabelField())); + $scs = $this->object->getList(array($this->object->getPrimaryKey(), $this->object->getUniqueLabelField()), -1, 0, null, null, $filters); $relobj = new \Centreon_Object_Relation_Service_Category_Service(); $hostServiceRel = new \Centreon_Object_Relation_Host_Service(); $svcObj = new \Centreon_Object_Service(); diff --git a/www/class/centreon-clapi/centreonServiceGroup.class.php b/www/class/centreon-clapi/centreonServiceGroup.class.php index 07f78912e77..a9737969f17 100644 --- a/www/class/centreon-clapi/centreonServiceGroup.class.php +++ b/www/class/centreon-clapi/centreonServiceGroup.class.php @@ -320,10 +320,10 @@ public function __call($name, $arg) * * @return void */ - public function export() + public function export($filters = null) { - parent::export(); - $sgs = $this->object->getList(array($this->object->getPrimaryKey(), $this->object->getUniqueLabelField())); + + $sgs = $this->object->getList(array($this->object->getPrimaryKey(), $this->object->getUniqueLabelField()), -1, 0, null, null, $filters); $relobjSvc = new \Centreon_Object_Relation_Service_Group_Service(); $objSvc = new \Centreon_Object_Relation_Host_Service(); $relobjHgSvc = new \Centreon_Object_Relation_Service_Group_Host_Group_Service(); diff --git a/www/class/centreon-clapi/centreonServiceTemplate.class.php b/www/class/centreon-clapi/centreonServiceTemplate.class.php index 79dc688f5a1..0aabe65aad9 100644 --- a/www/class/centreon-clapi/centreonServiceTemplate.class.php +++ b/www/class/centreon-clapi/centreonServiceTemplate.class.php @@ -907,12 +907,9 @@ protected function parseTemplateTree($tree, $filter_id = null) * * @return void */ - public function export($filter_id = null, $filter_name = null) + public function export($filters=null) { - $filters = array("service_register" => $this->register); - if (!is_null($filter_id)) { - $filters['service_id'] = $filter_id; - } + $filters["service_register"] = $this->register; $elements = $this->object->getList( "*", -1, @@ -922,19 +919,21 @@ public function export($filter_id = null, $filter_name = null) $filters, "AND" ); + + # No need to sort all service templates. We only export the current - if (is_null($filter_id)) { + if (is_null($filters['service_id'])) { $templateTree = $this->sortTemplates($elements); $this->parseTemplateTree($templateTree); } else { - $this->parseTemplateTree($elements, $filter_id); + $this->parseTemplateTree($elements, $filters['service_id']); } // contact groups $cgRel = new \Centreon_Object_Relation_Contact_Group_Service(); $filters_cgRel = array("service_register" => $this->register); - if (!is_null($filter_id)) { - $filters_cgRel['service_id'] = $filter_id; + if (!is_null($filters['service_id'])) { + $filters_cgRel['service_id'] = $filters['service_id']; } $elements = $cgRel->getMergedParameters( array("cg_name", "cg_id"), @@ -957,8 +956,8 @@ public function export($filter_id = null, $filter_name = null) // contacts $contactRel = new \Centreon_Object_Relation_Contact_Service(); $filters_contactRel = array("service_register" => $this->register); - if (!is_null($filter_id)) { - $filters_contactRel['service_id'] = $filter_id; + if (!is_null($filters['service_id'])) { + $filters_contactRel['service_id'] = $filters['service_id']; } $elements = $contactRel->getMergedParameters( array("contact_name", "contact_id"), @@ -1001,8 +1000,8 @@ public function export($filter_id = null, $filter_name = null) // traps $trapRel = new \Centreon_Object_Relation_Trap_Service(); $filters_trapRel = array("service_register" => $this->register); - if (!is_null($filter_id)) { - $filters_trapRel['traps_service_relation.service_id'] = $filter_id; + if (!is_null($filters['service_id'])) { + $filters_trapRel['traps_service_relation.service_id'] = $filters['service_id']; } $telements = $trapRel->getMergedParameters( array("traps_name", "traps_id"), @@ -1025,8 +1024,8 @@ public function export($filter_id = null, $filter_name = null) // hosts $hostRel = new \Centreon_Object_Relation_Host_Service(); $filters_hostRel = array("service_register" => $this->register); - if (!is_null($filter_id)) { - $filters_hostRel['service_id'] = $filter_id; + if (!is_null($filters['service_id'])) { + $filters_hostRel['service_id'] = $filters['service_id']; } $helements = $hostRel->getMergedParameters( array("host_name", "host_id"), diff --git a/www/class/centreon-clapi/centreonTimePeriod.class.php b/www/class/centreon-clapi/centreonTimePeriod.class.php index 6361c10ae4d..ee73eb9ed63 100644 --- a/www/class/centreon-clapi/centreonTimePeriod.class.php +++ b/www/class/centreon-clapi/centreonTimePeriod.class.php @@ -316,20 +316,4 @@ protected function setRelations($relationType, $sourceId, $relationName) $relObj->insert($sourceId, $relId); } } - - /** - * Export data - * - * @param string $parameters - * @return void - */ - public function export($filter_id = null, $filter_name = null) - { - $filters = null; - if (!is_null($filter_id)) { - $filters = array('tp_id' => $filter_id); - } - - parent::export($filters); - } } diff --git a/www/class/centreon-clapi/centreonTrap.class.php b/www/class/centreon-clapi/centreonTrap.class.php index 8cb84c9c3a2..dd2d032d660 100644 --- a/www/class/centreon-clapi/centreonTrap.class.php +++ b/www/class/centreon-clapi/centreonTrap.class.php @@ -320,12 +320,8 @@ public function updatematching($parameters = null) * * @return void */ - public function export($filter_id = null, $filter_name = null) + public function export($filters = null) { - $filters = null; - if (!is_null($filter_id)) { - $filters['traps_id'] = $filter_id; - } $elements = $this->object->getList("*", -1, 0, null, null, $filters, "AND"); foreach ($elements as $element) { $addStr = $this->action . $this->delim . "ADD"; From 9623f90005addf5597228a71aca4203c8c80d132 Mon Sep 17 00:00:00 2001 From: Kevin Duret Date: Wed, 2 Aug 2017 18:18:58 +0200 Subject: [PATCH 107/207] fix kb acceptance tests --- features/bootstrap/KnowledgeBaseContext.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/features/bootstrap/KnowledgeBaseContext.php b/features/bootstrap/KnowledgeBaseContext.php index 5aa7cae23cf..c141cd941e5 100644 --- a/features/bootstrap/KnowledgeBaseContext.php +++ b/features/bootstrap/KnowledgeBaseContext.php @@ -4,6 +4,7 @@ use Centreon\Test\Behat\Configuration\HostConfigurationPage; use Centreon\Test\Behat\Configuration\KBServiceListingPage; use Centreon\Test\Behat\Configuration\ServiceConfigurationPage; +use Centreon\Test\Behat\Administration\KBParametersPage; /** * Defines application features from the specific context. @@ -29,6 +30,16 @@ public function iAmLoggedInACentreonServerWithWikiInstalled() $this->container->getPort(80, 'mediawiki') . '/index.php/Main_Page' ); $this->iAmLoggedIn(); + + $containerId = $this->container->getContainerId('mediawiki', false); + $page = new KBParametersPage($this); + $page->setProperties( + array( + 'kb_db_host' => $containerId, + 'kb_wiki_url' => 'http://' . $containerId + ) + ); + $page->save(); } /** From 5ec0a8d16fd85e91d23309b910647349546c7f72 Mon Sep 17 00:00:00 2001 From: Laurent Pinsivy Date: Thu, 3 Aug 2017 09:46:51 +0100 Subject: [PATCH 108/207] Add release note for Centreon web 2.8.11 --- .../centreon-2.8/centreon-2.8.11.rst | 22 +++++++++++++++++++ .../centreon-2.8/centreon-2.8.11.rst | 22 +++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 doc/en/release_notes/centreon-2.8/centreon-2.8.11.rst create mode 100644 doc/fr/release_notes/centreon-2.8/centreon-2.8.11.rst diff --git a/doc/en/release_notes/centreon-2.8/centreon-2.8.11.rst b/doc/en/release_notes/centreon-2.8/centreon-2.8.11.rst new file mode 100644 index 00000000000..97dfe8f7afe --- /dev/null +++ b/doc/en/release_notes/centreon-2.8/centreon-2.8.11.rst @@ -0,0 +1,22 @@ +################### +Centreon Web 2.8.11 +################### + +Enhancements +============ + +* Fix typos in Enabled/Disabled filters PR #5251 +* Do not list meta services in list of service to add to a SNMP trap #5418 PR #5419 + +Bugfix +====== + +* Knowledgebase - Delete wiki page not functional #5059 +* Massive Change don't modify the Recovery notification delay of a host #5451 +* Impossible to acknowledge several object from custom views #5420 +* Load custom views - fixed database entry duplication PR #5260 +* Adding SNMP traps definition : values set to fields in Relations tab are not saved #5406 PR #5415 PR #5417 +* SNMP Trap, not all parameters are saved on creation #5361 PR #5415 PR #5417 +* Page "Services by Servicegroup > Diplay > Summary" not working #5399 PR #5416 +* [CLAPI] Duplicate CMD in export #5455 +* [CLAPI] Fatal error with PDOException #5453 PR #5462 diff --git a/doc/fr/release_notes/centreon-2.8/centreon-2.8.11.rst b/doc/fr/release_notes/centreon-2.8/centreon-2.8.11.rst new file mode 100644 index 00000000000..97dfe8f7afe --- /dev/null +++ b/doc/fr/release_notes/centreon-2.8/centreon-2.8.11.rst @@ -0,0 +1,22 @@ +################### +Centreon Web 2.8.11 +################### + +Enhancements +============ + +* Fix typos in Enabled/Disabled filters PR #5251 +* Do not list meta services in list of service to add to a SNMP trap #5418 PR #5419 + +Bugfix +====== + +* Knowledgebase - Delete wiki page not functional #5059 +* Massive Change don't modify the Recovery notification delay of a host #5451 +* Impossible to acknowledge several object from custom views #5420 +* Load custom views - fixed database entry duplication PR #5260 +* Adding SNMP traps definition : values set to fields in Relations tab are not saved #5406 PR #5415 PR #5417 +* SNMP Trap, not all parameters are saved on creation #5361 PR #5415 PR #5417 +* Page "Services by Servicegroup > Diplay > Summary" not working #5399 PR #5416 +* [CLAPI] Duplicate CMD in export #5455 +* [CLAPI] Fatal error with PDOException #5453 PR #5462 From e6acb10673c731ddef2428c0a2c6e18538a513f3 Mon Sep 17 00:00:00 2001 From: loiclau Date: Thu, 3 Aug 2017 11:23:14 +0200 Subject: [PATCH 109/207] * clapi ldap dependency export --- www/class/centreon-clapi/centreonAPI.class.php | 12 ++++++------ www/class/centreon-clapi/centreonLDAP.class.php | 5 +++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/www/class/centreon-clapi/centreonAPI.class.php b/www/class/centreon-clapi/centreonAPI.class.php index 1b73f62ea09..970d86a450d 100644 --- a/www/class/centreon-clapi/centreonAPI.class.php +++ b/www/class/centreon-clapi/centreonAPI.class.php @@ -194,6 +194,11 @@ public function __construct( 'class' => 'ServiceCategory', 'export' => true ); + $this->relationObject["LDAP"] = array( + 'module' => 'core', + 'class' => 'LDAP', + 'export' => true + ); $this->relationObject["CONTACT"] = array( 'module' => 'core', 'class' => 'Contact', @@ -285,11 +290,6 @@ public function __construct( 'class' => 'ACLResource', 'export' => false ); - $this->relationObject["LDAP"] = array( - 'module' => 'core', - 'class' => 'LDAP', - 'export' => true - ); $this->relationObject["SETTINGS"] = array( 'module' => 'core', 'class' => 'Settings', @@ -420,7 +420,7 @@ protected function requireLibs($object) foreach ($this->relationObject as $sSynonyme => $oObjet) { if (isset($oObjet['class']) && isset($oObjet['module']) - && !class_exists("Centreon" . $oObjet['class']) + && !class_exists("\CentreonClapi\Centreon" . $oObjet['class']) ) { if ($oObjet['module'] == 'core') { require_once _CENTREON_PATH_ diff --git a/www/class/centreon-clapi/centreonLDAP.class.php b/www/class/centreon-clapi/centreonLDAP.class.php index fe8db5ff259..9efbf7d4d8a 100644 --- a/www/class/centreon-clapi/centreonLDAP.class.php +++ b/www/class/centreon-clapi/centreonLDAP.class.php @@ -52,6 +52,11 @@ class CentreonLDAP extends CentreonObject const NB_ADD_PARAM = 2; const AR_NOT_EXIST = "LDAP configuration ID not found"; + public $aDepends = array( + 'CONTACT' + ); + + /** * Constructor * From ac341a85d377a74b78c473232b93af8bd2e2e6bf Mon Sep 17 00:00:00 2001 From: Laurent Pinsivy Date: Thu, 3 Aug 2017 10:37:47 +0100 Subject: [PATCH 110/207] fix typo --- doc/fr/administration_guide/partitioning/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/fr/administration_guide/partitioning/index.rst b/doc/fr/administration_guide/partitioning/index.rst index 0ee098feb3a..add2978d4d8 100644 --- a/doc/fr/administration_guide/partitioning/index.rst +++ b/doc/fr/administration_guide/partitioning/index.rst @@ -8,7 +8,7 @@ Partitionnement des bases de données Présentation ============ -Le module Centreon Partioning est maintenant intégré de base avec Centreon Web, il offre différentes fonctionnalités et avantages. +Le module Centreon Partitioning est maintenant intégré de base avec Centreon Web, il offre différentes fonctionnalités et avantages. - Il permet de partitionner les tables MySQL en fonction de la date des lignes. Ce qui offre une optimisation du temps d'exécution de nombreuses requêtes. - La purge des données est améliorée, il est maintenant juste nécessaire de supprimer les partitions trop anciennes. From 1f1272440122ad9ee43294c74fff844b03831a5e Mon Sep 17 00:00:00 2001 From: loiclau Date: Thu, 3 Aug 2017 14:25:01 +0200 Subject: [PATCH 111/207] * clapi export remove first line --- www/class/centreon-clapi/centreonAPI.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/www/class/centreon-clapi/centreonAPI.class.php b/www/class/centreon-clapi/centreonAPI.class.php index 970d86a450d..3e705772287 100644 --- a/www/class/centreon-clapi/centreonAPI.class.php +++ b/www/class/centreon-clapi/centreonAPI.class.php @@ -850,7 +850,6 @@ public function export() exit($this->return_code); } else { // header - echo "{OBJECT_TYPE}{$this->delim}{COMMAND}{$this->delim}{PARAMETERS}\n"; if (count($this->aExport) > 0) { foreach ($this->aExport as $oObjet) { if (method_exists($this->objectTable[$oObjet], 'export')) { From 50a35b932967d15e11d2a8b8b89b056fc022f0c9 Mon Sep 17 00:00:00 2001 From: Kevin Duret Date: Thu, 3 Aug 2017 15:54:37 +0200 Subject: [PATCH 112/207] update slack message in jenkinsfile --- Jenkinsfile | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 1ac2c4f5eb6..55a26e8a675 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -168,10 +168,8 @@ try { build job: 'des-mbi-bundle-centos6', wait: false build job: 'des-mbi-bundle-centos7', wait: false } -} -finally { - buildStatus = currentBuild.result ?: 'SUCCESS'; - if ((buildStatus != 'SUCCESS') && (env.BRANCH_NAME == 'master')) { - slackSend channel: '#monitoring-metrology', message: "@channel Centreon Web build ${env.BUILD_NUMBER} of branch ${env.BRANCH_NAME} was broken by ${source.COMMITTER}. Please fix it ASAP." +} catch(e) { + if (env.BRANCH_NAME == 'master') { + slackSend channel: "#monitoring-metrology", color: "#F30031", message: "*FAILURE*: `CENTREON WEB` <${env.BUILD_URL}|build #${env.BUILD_NUMBER}> on branch ${env.BRANCH_NAME}\n*COMMIT*: by ${source.COMMITTER}\n*INFO*: ${e}" } } From 5dbff83daa688f39e617262cb098e9fdf82a18ac Mon Sep 17 00:00:00 2001 From: Kevin Duret Date: Fri, 4 Aug 2017 09:24:06 +0200 Subject: [PATCH 113/207] improve coding style of jenkinsfile --- Jenkinsfile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 55a26e8a675..34c7141fb54 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -170,6 +170,10 @@ try { } } catch(e) { if (env.BRANCH_NAME == 'master') { - slackSend channel: "#monitoring-metrology", color: "#F30031", message: "*FAILURE*: `CENTREON WEB` <${env.BUILD_URL}|build #${env.BUILD_NUMBER}> on branch ${env.BRANCH_NAME}\n*COMMIT*: by ${source.COMMITTER}\n*INFO*: ${e}" + slackSend channel: "#monitoring-metrology", + color: "#F30031", + message: "*FAILURE*: `CENTREON WEB` <${env.BUILD_URL}|build #${env.BUILD_NUMBER}> on branch ${env.BRANCH_NAME}\n" + + "*COMMIT*: by ${source.COMMITTER}\n" + + "*INFO*: ${e}" } } From 98bf37e4edec5bbaec1e22b24f6a77157b48bc13 Mon Sep 17 00:00:00 2001 From: mariegallardo Date: Fri, 4 Aug 2017 10:39:24 +0200 Subject: [PATCH 114/207] Feature fixed: MassiveChangeService (#5511) --- features/bootstrap/MassiveChangeServicesContext.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/features/bootstrap/MassiveChangeServicesContext.php b/features/bootstrap/MassiveChangeServicesContext.php index c6507547b26..e01971ce2e3 100644 --- a/features/bootstrap/MassiveChangeServicesContext.php +++ b/features/bootstrap/MassiveChangeServicesContext.php @@ -116,7 +116,8 @@ class MassiveChangeServicesContext extends CentreonContext 'service_groups' => 'serviceGroupName', 'update_mode_traps' => 1, 'trap_relations' => array( - 'Generic' => 'Generic - trapName' + 'trapName', + 'Generic - trapName' ), 'obsess_over_service' => 2, 'acknowledgement_timeout' => 7, From 53cea106952008a7943997153101043302755ec7 Mon Sep 17 00:00:00 2001 From: Laurent Pinsivy Date: Fri, 4 Aug 2017 10:58:51 +0200 Subject: [PATCH 115/207] 5493 - Save geo_coords on modify form (#5505) Conflicts: www/include/configuration/configObject/meta_service/DB-Func.php --- .../configuration/configObject/meta_service/DB-Func.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/www/include/configuration/configObject/meta_service/DB-Func.php b/www/include/configuration/configObject/meta_service/DB-Func.php index cf49a12f62c..cf208ccfdf3 100644 --- a/www/include/configuration/configObject/meta_service/DB-Func.php +++ b/www/include/configuration/configObject/meta_service/DB-Func.php @@ -386,6 +386,10 @@ function updateMetaService($meta_id = null) $ret["meta_comment"] != null ? $rq .= "'" . htmlentities($ret["meta_comment"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; + $rq .= "geo_coords = "; + $ret["geo_coords"] != null + ? $rq .= "'".htmlentities($ret["geo_coords"], ENT_QUOTES, "UTF-8")."', " + : $rq .= "NULL, "; $rq .= "meta_activate = "; $ret["meta_activate"]["meta_activate"] != null ? $rq .= "'" . $ret["meta_activate"]["meta_activate"] . "' " From 6bf7497eff2819e50788669b4cff64649a6f3477 Mon Sep 17 00:00:00 2001 From: Laurent Pinsivy Date: Fri, 4 Aug 2017 11:12:47 +0200 Subject: [PATCH 116/207] #5506 add coma to separate multiple values in SQL insert request (#5507) --- .../configuration/configObject/meta_service/DB-Func.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/www/include/configuration/configObject/meta_service/DB-Func.php b/www/include/configuration/configObject/meta_service/DB-Func.php index cf208ccfdf3..dae1a0fa9b6 100644 --- a/www/include/configuration/configObject/meta_service/DB-Func.php +++ b/www/include/configuration/configObject/meta_service/DB-Func.php @@ -424,6 +424,9 @@ function updateMetaServiceContact($meta_id) if (count($ret)) { $queryAddRelation = "INSERT INTO meta_contact (meta_id, contact_id) VALUES "; for ($i = 0; $i < count($ret); $i++) { + if ($i > 0) { + $queryAddRelation .= ', '; + } $queryAddRelation .= "(" . $meta_id . ", " . $ret[$i] . ")"; } $pearDB->query($queryAddRelation); From ace02ffdfe97180c94817674e42aaf475558e24f Mon Sep 17 00:00:00 2001 From: Laurent Pinsivy Date: Fri, 4 Aug 2017 11:21:57 +0200 Subject: [PATCH 117/207] 5495 duplicate contacts on meta service duplication (#5508) Conflicts: www/include/configuration/configObject/meta_service/DB-Func.php --- .../configuration/configObject/meta_service/DB-Func.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/www/include/configuration/configObject/meta_service/DB-Func.php b/www/include/configuration/configObject/meta_service/DB-Func.php index dae1a0fa9b6..87cccd3ddd4 100644 --- a/www/include/configuration/configObject/meta_service/DB-Func.php +++ b/www/include/configuration/configObject/meta_service/DB-Func.php @@ -145,8 +145,15 @@ function multipleMetaServiceInDB($metas = array(), $nbrDup = array()) if (isset($maxId["MAX(meta_id)"])) { $metaObj = new CentreonMeta($pearDB); $metaObj->insertVirtualService($maxId["MAX(meta_id)"], $meta_name); + /* Duplicate contacts */ + $DBRESULT = $pearDB->query("SELECT DISTINCT contact_id FROM meta_contact WHERE meta_id = '".$key."'"); + while ($Contact = $DBRESULT->fetchRow()) { + $DBRESULT2 = $pearDB->query("INSERT INTO meta_contact VALUES ('".$maxId["MAX(meta_id)"]."', '".$Contact["contact_id"]."')"); + } + /* Duplicate contactgroups */ $query = "SELECT DISTINCT cg_cg_id FROM meta_contactgroup_relation WHERE meta_id = '" . $key . "'"; $DBRESULT = $pearDB->query($query); + while ($Cg = $DBRESULT->fetchRow()) { $query = "INSERT INTO meta_contactgroup_relation " . "VALUES ('', '" . $maxId["MAX(meta_id)"] . "', '" . $Cg["cg_cg_id"] . "')"; From b6cd03e625aa8d94474899e41b35374afa04b3eb Mon Sep 17 00:00:00 2001 From: loiclau Date: Fri, 4 Aug 2017 13:36:22 +0200 Subject: [PATCH 118/207] * duplicate contact --- .../configObject/meta_service/DB-Func.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/www/include/configuration/configObject/meta_service/DB-Func.php b/www/include/configuration/configObject/meta_service/DB-Func.php index 87cccd3ddd4..229a54085c2 100644 --- a/www/include/configuration/configObject/meta_service/DB-Func.php +++ b/www/include/configuration/configObject/meta_service/DB-Func.php @@ -146,9 +146,12 @@ function multipleMetaServiceInDB($metas = array(), $nbrDup = array()) $metaObj = new CentreonMeta($pearDB); $metaObj->insertVirtualService($maxId["MAX(meta_id)"], $meta_name); /* Duplicate contacts */ - $DBRESULT = $pearDB->query("SELECT DISTINCT contact_id FROM meta_contact WHERE meta_id = '".$key."'"); + $query = "SELECT DISTINCT contact_id FROM meta_contact WHERE meta_id = '" . $key . "'"; + $DBRESULT = $pearDB->query($query); while ($Contact = $DBRESULT->fetchRow()) { - $DBRESULT2 = $pearDB->query("INSERT INTO meta_contact VALUES ('".$maxId["MAX(meta_id)"]."', '".$Contact["contact_id"]."')"); + $query = "INSERT INTO meta_contact VALUES ('" . + $maxId["MAX(meta_id)"] . "', '" . $Contact["contact_id"] . "')"; + $pearDB->query($query); } /* Duplicate contactgroups */ $query = "SELECT DISTINCT cg_cg_id FROM meta_contactgroup_relation WHERE meta_id = '" . $key . "'"; @@ -169,7 +172,7 @@ function multipleMetaServiceInDB($metas = array(), $nbrDup = array()) ? $val .= ($value2 != null ? (", '" . $value2 . "'") : ", NULL") : $val .= ($value2 != null ? ("'" . $value2 . "'") : "NULL"); } - $DBRESULT2 = $pearDB->query("INSERT INTO meta_service_relation VALUES (" . $val . ")"); + $pearDB->query("INSERT INTO meta_service_relation VALUES (" . $val . ")"); } } } @@ -395,7 +398,7 @@ function updateMetaService($meta_id = null) : $rq .= "NULL, "; $rq .= "geo_coords = "; $ret["geo_coords"] != null - ? $rq .= "'".htmlentities($ret["geo_coords"], ENT_QUOTES, "UTF-8")."', " + ? $rq .= "'" . htmlentities($ret["geo_coords"], ENT_QUOTES, "UTF-8") . "', " : $rq .= "NULL, "; $rq .= "meta_activate = "; $ret["meta_activate"]["meta_activate"] != null From b4cd3aa10baa5585510154c664dcbf4d3a690376 Mon Sep 17 00:00:00 2001 From: Laurent Pinsivy Date: Fri, 4 Aug 2017 15:17:07 +0200 Subject: [PATCH 119/207] 5478 - Check if category is not a severity before duplicate contacts (#5509) * #5478 - Check if category is not a severity before duplicate contacts * * fix style --- .../configuration/configObject/host_categories/DB-Func.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/www/include/configuration/configObject/host_categories/DB-Func.php b/www/include/configuration/configObject/host_categories/DB-Func.php index bca897bcc8c..43a10f3a2ac 100644 --- a/www/include/configuration/configObject/host_categories/DB-Func.php +++ b/www/include/configuration/configObject/host_categories/DB-Func.php @@ -148,6 +148,7 @@ function multipleHostCategoriesInDB($hostcategories = array(), $nbrDup = array() for ($i = 1; $i <= $nbrDup[$key]; $i++) { $val = null; $rq = null; + $level = false; foreach ($row as $key2 => $value2) { (isset($key2) && $key2 == "hc_name") ? ($hc_name = $value2 = $value2 . "_" . $i) : null; $val @@ -156,6 +157,9 @@ function multipleHostCategoriesInDB($hostcategories = array(), $nbrDup = array() if ($key2 != "hc_id") { $fields[$key2] = $value2; } + if ($key2 == "level" && $value2 != "") { + $level = true; + } } $fields["hc_name"] = $hc_name; if (testHostCategorieExistence($hc_name)) { @@ -163,7 +167,7 @@ function multipleHostCategoriesInDB($hostcategories = array(), $nbrDup = array() $pearDB->query($rq); $DBRESULT = $pearDB->query("SELECT MAX(hc_id) FROM hostcategories"); $maxId = $DBRESULT->fetchRow(); - if (isset($maxId["MAX(hc_id)"])) { + if (isset($maxId["MAX(hc_id)"]) && !$level) { $hcAcl[$maxId["MAX(hc_id)"]] = $key; $query = "SELECT DISTINCT hgr.host_host_id FROM hostcategories_relation hgr " . "WHERE hgr.hostcategories_hc_id = '" . $key . "'"; From 40900080a0989a120584f829e97a85e221f35bf3 Mon Sep 17 00:00:00 2001 From: Laurent Pinsivy Date: Fri, 4 Aug 2017 15:27:28 +0200 Subject: [PATCH 120/207] #5512 add underscore on object name on duplication (#5513) --- www/include/configuration/configObject/escalation/DB-Func.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/include/configuration/configObject/escalation/DB-Func.php b/www/include/configuration/configObject/escalation/DB-Func.php index 9e7de3d485a..b486e2fcdb2 100644 --- a/www/include/configuration/configObject/escalation/DB-Func.php +++ b/www/include/configuration/configObject/escalation/DB-Func.php @@ -84,7 +84,7 @@ function multipleEscalationInDB($escalations = array(), $nbrDup = array()) for ($i = 1; $i <= $nbrDup[$key]; $i++) { $val = null; foreach ($row as $key2 => $value2) { - $key2 == "esc_name" ? ($esc_name = $value2 = $value2 . " " . $i) : null; + $key2 == "esc_name" ? ($esc_name = $value2 = $value2 . "_" . $i) : null; $val ? $val .= ($value2 != null ? (", '" . $value2 . "'") : ", NULL") : $val .= ($value2 != null ? ("'" . $value2 . "'") : "NULL"); if ($key2 != "esc_id") { From 7dee7dbafd04ae18f26e272230e6f11b98763e80 Mon Sep 17 00:00:00 2001 From: Kevin Duret Date: Fri, 4 Aug 2017 15:34:50 +0200 Subject: [PATCH 121/207] add version 2.7.12 to previous versions --- www/install/sql/centreon/Update-DB-2.7.11_to_2.7.12.sql | 2 ++ ...1_to_2.8.0-beta1.sql => Update-DB-2.7.12_to_2.8.0-beta1.sql} | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 www/install/sql/centreon/Update-DB-2.7.11_to_2.7.12.sql rename www/install/sql/centreon/{Update-DB-2.7.11_to_2.8.0-beta1.sql => Update-DB-2.7.12_to_2.8.0-beta1.sql} (99%) diff --git a/www/install/sql/centreon/Update-DB-2.7.11_to_2.7.12.sql b/www/install/sql/centreon/Update-DB-2.7.11_to_2.7.12.sql new file mode 100644 index 00000000000..d793757626b --- /dev/null +++ b/www/install/sql/centreon/Update-DB-2.7.11_to_2.7.12.sql @@ -0,0 +1,2 @@ +-- Change version of Centreon +UPDATE `informations` SET `value` = '2.7.12' WHERE CONVERT( `informations`.`key` USING utf8 ) = 'version' AND CONVERT ( `informations`.`value` USING utf8 ) = '2.7.11' LIMIT 1; diff --git a/www/install/sql/centreon/Update-DB-2.7.11_to_2.8.0-beta1.sql b/www/install/sql/centreon/Update-DB-2.7.12_to_2.8.0-beta1.sql similarity index 99% rename from www/install/sql/centreon/Update-DB-2.7.11_to_2.8.0-beta1.sql rename to www/install/sql/centreon/Update-DB-2.7.12_to_2.8.0-beta1.sql index 0e66cc9c2f0..fdd6e97e352 100644 --- a/www/install/sql/centreon/Update-DB-2.7.11_to_2.8.0-beta1.sql +++ b/www/install/sql/centreon/Update-DB-2.7.12_to_2.8.0-beta1.sql @@ -1,5 +1,5 @@ -- Change version of Centreon -UPDATE `informations` SET `value` = '2.8.0-beta1' WHERE CONVERT( `informations`.`key` USING utf8 ) = 'version' AND CONVERT ( `informations`.`value` USING utf8 ) = '2.7.11' LIMIT 1; +UPDATE `informations` SET `value` = '2.8.0-beta1' WHERE CONVERT( `informations`.`key` USING utf8 ) = 'version' AND CONVERT ( `informations`.`value` USING utf8 ) = '2.7.12' LIMIT 1; -- Add graphite output for centreon-broker INSERT IGNORE INTO cb_module (name, libname, loading_pos, is_activated) From a83cd21ef11b7b24d0033e09d3eb0007f496c308 Mon Sep 17 00:00:00 2001 From: Laurent Pinsivy Date: Thu, 3 Aug 2017 13:28:48 +0100 Subject: [PATCH 122/207] Add Centreon Web 2.7.12 release note --- .../centreon-2.7/centreon-2.7.12.rst | 23 +++++++++++++++++++ doc/en/release_notes/centreon-2.7/index.rst | 2 ++ .../centreon-2.7/centreon-2.7.12.rst | 23 +++++++++++++++++++ doc/fr/release_notes/centreon-2.7/index.rst | 2 ++ 4 files changed, 50 insertions(+) create mode 100644 doc/en/release_notes/centreon-2.7/centreon-2.7.12.rst create mode 100644 doc/fr/release_notes/centreon-2.7/centreon-2.7.12.rst diff --git a/doc/en/release_notes/centreon-2.7/centreon-2.7.12.rst b/doc/en/release_notes/centreon-2.7/centreon-2.7.12.rst new file mode 100644 index 00000000000..8b068d2d354 --- /dev/null +++ b/doc/en/release_notes/centreon-2.7/centreon-2.7.12.rst @@ -0,0 +1,23 @@ +############### +Centreon 2.7.12 +############### + +The 2.7.12 release for Centreon Web is now available for `download `_. +The full release notes for 2.7.12 follow. + +****** +Notice +****** + +If you are upgrading from a version prior to 2.7.0, make sure to go through all the release notes available +`here `_. + +Bug Fixes +========= + +* [CLAPI] Several bugs on HG / CG when export is filtered #5297 PR #5320 +* [CLAPI] fix clapi ldap contact import +* Unable to load public custom view - No Layout... #5449 +* Impossible to acknowledge several object from custom views #5420 +* Security: avoid external command shell injection in comment + diff --git a/doc/en/release_notes/centreon-2.7/index.rst b/doc/en/release_notes/centreon-2.7/index.rst index 05f5162777d..744d7bb200f 100644 --- a/doc/en/release_notes/centreon-2.7/index.rst +++ b/doc/en/release_notes/centreon-2.7/index.rst @@ -18,3 +18,5 @@ Please find here the release notes dedicated to the last 2.7.x version of Centre centreon-2.7.8 centreon-2.7.9 centreon-2.7.10 + centreon-2.7.11 + centreon-2.7.12 diff --git a/doc/fr/release_notes/centreon-2.7/centreon-2.7.12.rst b/doc/fr/release_notes/centreon-2.7/centreon-2.7.12.rst new file mode 100644 index 00000000000..8b068d2d354 --- /dev/null +++ b/doc/fr/release_notes/centreon-2.7/centreon-2.7.12.rst @@ -0,0 +1,23 @@ +############### +Centreon 2.7.12 +############### + +The 2.7.12 release for Centreon Web is now available for `download `_. +The full release notes for 2.7.12 follow. + +****** +Notice +****** + +If you are upgrading from a version prior to 2.7.0, make sure to go through all the release notes available +`here `_. + +Bug Fixes +========= + +* [CLAPI] Several bugs on HG / CG when export is filtered #5297 PR #5320 +* [CLAPI] fix clapi ldap contact import +* Unable to load public custom view - No Layout... #5449 +* Impossible to acknowledge several object from custom views #5420 +* Security: avoid external command shell injection in comment + diff --git a/doc/fr/release_notes/centreon-2.7/index.rst b/doc/fr/release_notes/centreon-2.7/index.rst index 05f5162777d..744d7bb200f 100644 --- a/doc/fr/release_notes/centreon-2.7/index.rst +++ b/doc/fr/release_notes/centreon-2.7/index.rst @@ -18,3 +18,5 @@ Please find here the release notes dedicated to the last 2.7.x version of Centre centreon-2.7.8 centreon-2.7.9 centreon-2.7.10 + centreon-2.7.11 + centreon-2.7.12 From 14114546ce7e3406833224e1bf96572bedb8cff4 Mon Sep 17 00:00:00 2001 From: loiclau Date: Mon, 7 Aug 2017 10:26:13 +0200 Subject: [PATCH 123/207] * #5314 remove parallelize_checks in doc --- doc/en/api/clapi/objects/services.rst | 2 -- doc/fr/api/clapi/objects/services.rst | 2 -- 2 files changed, 4 deletions(-) diff --git a/doc/en/api/clapi/objects/services.rst b/doc/en/api/clapi/objects/services.rst index 1508a808e76..557ecfcc1f3 100644 --- a/doc/en/api/clapi/objects/services.rst +++ b/doc/en/api/clapi/objects/services.rst @@ -171,8 +171,6 @@ first_notification_delay First notification delay in seconds recovery_notification_delay Recovery notification delay -parallelize_checks *1* when parallelize checks are enabled, *0* otherwise - obsess_over_service *1* when obsess over service is enabled, *0* otherwise check_freshness *1* when check freshness is enabled, *0* otherwise diff --git a/doc/fr/api/clapi/objects/services.rst b/doc/fr/api/clapi/objects/services.rst index 37284bcbe4f..c1c5dd64256 100644 --- a/doc/fr/api/clapi/objects/services.rst +++ b/doc/fr/api/clapi/objects/services.rst @@ -169,8 +169,6 @@ notification_options Status linked to notifications first_notification_delay First notification delay in seconds -parallelize_checks *1* when parallelize checks are enabled, *0* otherwise - obsess_over_service *1* when obsess over service is enabled, *0* otherwise check_freshness *1* when check freshness is enabled, *0* otherwise From 55976b8f40cd1d2b6cabbbf606bfe8fa471fa7b8 Mon Sep 17 00:00:00 2001 From: loiclau Date: Mon, 7 Aug 2017 10:31:36 +0200 Subject: [PATCH 124/207] * #5315 remove process_perf_data in doc --- doc/en/api/clapi/objects/services.rst | 2 -- doc/fr/api/clapi/objects/services.rst | 2 -- 2 files changed, 4 deletions(-) diff --git a/doc/en/api/clapi/objects/services.rst b/doc/en/api/clapi/objects/services.rst index 557ecfcc1f3..fda150869d5 100644 --- a/doc/en/api/clapi/objects/services.rst +++ b/doc/en/api/clapi/objects/services.rst @@ -181,8 +181,6 @@ event_handler_enabled *1* when event handler is enabled, *0* otherwise flap_detection_enabled *1* when flap detection is enabled, *0* otherwise -process_perf_data *1* when process performance data is enabled, *0* otherwise - retain_status_information *1* when status information is retained, *0* otherwise retain_nonstatus_information *1* when non status information is retained, *0* otherwise diff --git a/doc/fr/api/clapi/objects/services.rst b/doc/fr/api/clapi/objects/services.rst index c1c5dd64256..74af764e010 100644 --- a/doc/fr/api/clapi/objects/services.rst +++ b/doc/fr/api/clapi/objects/services.rst @@ -179,8 +179,6 @@ event_handler_enabled *1* when event handler is enabled, *0* otherwise flap_detection_enabled *1* when flap detection is enabled, *0* otherwise -process_perf_data *1* when process performance data is enabled, *0* otherwise - retain_status_information *1* when status information is retained, *0* otherwise retain_nonstatus_information *1* when non status information is retained, *0* otherwise From 597aa786986806b38535bf8db0995260e5ef1c00 Mon Sep 17 00:00:00 2001 From: loiclau Date: Mon, 7 Aug 2017 10:38:58 +0200 Subject: [PATCH 125/207] * #5316 remove checks_enabled in doc --- doc/en/api/clapi/objects/hosts.rst | 2 -- doc/fr/api/clapi/objects/hosts.rst | 2 -- 2 files changed, 4 deletions(-) diff --git a/doc/en/api/clapi/objects/hosts.rst b/doc/en/api/clapi/objects/hosts.rst index 86470e8c373..7b6097559dc 100644 --- a/doc/en/api/clapi/objects/hosts.rst +++ b/doc/en/api/clapi/objects/hosts.rst @@ -125,8 +125,6 @@ check_freshness Enables check freshness check_period Check period -checks_enabled Whether or not checks are enabled - contact_additive_inheritance Enables contact additive inheritance cg_additive_inheritance Enables contactgroup additive inheritance diff --git a/doc/fr/api/clapi/objects/hosts.rst b/doc/fr/api/clapi/objects/hosts.rst index 98fbfc91388..685165ddbd7 100644 --- a/doc/fr/api/clapi/objects/hosts.rst +++ b/doc/fr/api/clapi/objects/hosts.rst @@ -125,8 +125,6 @@ check_freshness Enables check freshness check_period Check period -checks_enabled Whether or not checks are enabled - contact_additive_inheritance Enables contact additive inheritance cg_additive_inheritance Enables contactgroup additive inheritance From aaff43bb97b6e774addb6212094a8d844feafe90 Mon Sep 17 00:00:00 2001 From: mariegallardo Date: Mon, 7 Aug 2017 13:29:00 +0200 Subject: [PATCH 126/207] New feature HostGroupServiceConfiguration (#5488) * New feature HostGroupServiceConfiguration * Features fixed * File fixed --- behat.yml | 5 + .../HostGroupServiceConfiguration.feature | 20 + .../bootstrap/ACLActionsAccessContext.php | 4 +- .../HostGroupServiceConfigurationContext.php | 436 ++++++++++++++++++ .../MassiveChangeServicesContext.php | 2 +- 5 files changed, 463 insertions(+), 4 deletions(-) create mode 100644 features/HostGroupServiceConfiguration.feature create mode 100644 features/bootstrap/HostGroupServiceConfigurationContext.php diff --git a/behat.yml b/behat.yml index b2b9af670b5..17c3c3b99e4 100644 --- a/behat.yml +++ b/behat.yml @@ -273,3 +273,8 @@ default: paths: [ %paths.base%/features/VirtualMetricHandle.feature ] contexts: - VirtualMetricHandleContext + + host_group_service_configuration: + paths: [ %paths.base%/features/HostGroupServiceConfiguration.feature ] + contexts: + - HostGroupServiceConfigurationContext diff --git a/features/HostGroupServiceConfiguration.feature b/features/HostGroupServiceConfiguration.feature new file mode 100644 index 00000000000..a1b33ce8481 --- /dev/null +++ b/features/HostGroupServiceConfiguration.feature @@ -0,0 +1,20 @@ +Feature: Edit a host group service + As a Centreon user + I want to manipulate a service + To see if all simples manipulations work + + Background: + Given I am logged in a Centreon server + And a service is configured + + Scenario: Change the properties of a host group service + When I change the properties of a host group service + Then the properties are updated + + Scenario: Duplicate one existing host group service + When I duplicate a host group service + Then the new host group service has the same properties + + Scenario: Delete one existing host group service + When I delete a host group service + Then the deleted host group service is not displayed in the list diff --git a/features/bootstrap/ACLActionsAccessContext.php b/features/bootstrap/ACLActionsAccessContext.php index 3b04c8cbb66..a7e0c1f2064 100644 --- a/features/bootstrap/ACLActionsAccessContext.php +++ b/features/bootstrap/ACLActionsAccessContext.php @@ -22,9 +22,7 @@ class ACLActionsAccessContext extends CentreonContext private $adminContactGroup = array( 'name' => 'adminContactGroupName', 'alias' => 'adminContactGroupAlias', - 'contacts' => array( - 'adminUserName' - ), + 'contacts' => 'adminUserName' ); private $nonAdminUser = array( diff --git a/features/bootstrap/HostGroupServiceConfigurationContext.php b/features/bootstrap/HostGroupServiceConfigurationContext.php new file mode 100644 index 00000000000..6a471697bb0 --- /dev/null +++ b/features/bootstrap/HostGroupServiceConfigurationContext.php @@ -0,0 +1,436 @@ + 'serviceCategory1Name', + 'description' => 'serviceCategory1Description', + 'severity' => 1, + 'level' => 3, + 'icon' => ' centreon (png)' + ); + + protected $serviceCategory2 = array( + 'name' => 'serviceCategory2Name', + 'description' => 'serviceCategory2Description', + 'severity' => 1, + 'level' => 2, + 'icon' => ' centreon (png)' + ); + + protected $serviceGroup1 = array( + 'name' => 'serviceGroup1Name', + 'description' => 'serviceGroup1Description' + ); + + protected $serviceGroup2 = array( + 'name' => 'serviceGroup2Name', + 'description' => 'serviceGroup2Description' + ); + + protected $initialProperties = array( + 'hosts' => 'Windows-Servers', + 'description' => 'serviceDescription', + 'templates' => 'generic-service', + 'check_command' => 'check_http', + 'macros' => array( + 'MACRONAME' => 22 + ), + 'check_period' => 'workhours', + 'max_check_attempts' => 15, + 'normal_check_interval' => 7, + 'retry_check_interval' => 9, + 'active_checks_enabled' => 2, + 'passive_checks_enabled' => 1, + 'is_volatile' => 0, + 'notifications_enabled' => 2, + 'inherits_contacts_groups' => 0, + 'contacts' => 'Guest', + 'contact_additive_inheritance' => 1, + 'contact_groups' => 'Supervisors', + 'contact_group_additive_inheritance' => 1, + 'notification_interval' => 23, + 'notify_on_none' => 1, + 'notify_on_warning' => 0, + 'notify_on_unknown' => 0, + 'notify_on_critical' => 0, + 'notify_on_recovery' => 0, + 'notify_on_flapping' => 0, + 'notify_on_downtime_scheduled' => 0, + 'first_notification_delay' => 4, + 'recovery_notification_delay' => 3, + 'service_groups' => 'serviceGroup1Name', + 'trap_relations' => 'Generic - coldStart', + 'obsess_over_service' => 2, + 'acknowledgement_timeout' => 34, + 'check_freshness' => 1, + 'freshness_threshold' => 22, + 'flap_detection_enabled' => 0, + 'low_flap_threshold' => 15, + 'high_flap_threshold' => 18, + 'retain_status_information' => 2, + 'retain_non_status_information' => 1, + 'stalking_on_ok' => 1, + 'stalking_on_warning' => 1, + 'stalking_on_unknown' => 0, + 'stalking_on_critical' => 0, + 'event_handler_enabled' => 0, + 'event_handler' => 'check_https', + 'event_handler_arguments' => 'eventHandlerArgument', + 'graph_template' => 'CPU', + 'service_categories' => 'Disk', + 'url' => 'serviceUrl', + 'notes' => 'serviceNotes', + 'action_url' => 'serviceActionUrl', + 'icon' => ' centreon (png)', + 'alt_icon' => 'serviceAltIcon', + 'severity' => 'serviceCategory2Name (2)', + 'geo_coordinates' => 'Paris', + 'status' => 1, + 'comments' => 'serviceComments' + ); + + protected $duplicatedProperties = array( + 'hosts' => 'Windows-Servers', + 'description' => 'serviceDescription_1', + 'templates' => 'generic-service', + 'check_command' => 'check_http', + 'macros' => array( + 'MACRONAME' => 22 + ), + 'check_period' => 'workhours', + 'max_check_attempts' => 15, + 'normal_check_interval' => 7, + 'retry_check_interval' => 9, + 'active_checks_enabled' => 2, + 'passive_checks_enabled' => 1, + 'is_volatile' => 0, + 'notifications_enabled' => 2, + 'inherits_contacts_groups' => 0, + 'contacts' => 'Guest', + 'contact_additive_inheritance' => 1, + 'contact_groups' => 'Supervisors', + 'contact_group_additive_inheritance' => 1, + 'notification_interval' => 23, + 'notify_on_none' => 1, + 'notify_on_warning' => 0, + 'notify_on_unknown' => 0, + 'notify_on_critical' => 0, + 'notify_on_recovery' => 0, + 'notify_on_flapping' => 0, + 'notify_on_downtime_scheduled' => 0, + 'first_notification_delay' => 4, + 'recovery_notification_delay' => 3, + 'service_groups' => 'serviceGroup1Name', + 'trap_relations' => 'coldStart', + 'obsess_over_service' => 2, + 'acknowledgement_timeout' => 34, + 'check_freshness' => 1, + 'freshness_threshold' => 22, + 'flap_detection_enabled' => 0, + 'low_flap_threshold' => 15, + 'high_flap_threshold' => 18, + 'retain_status_information' => 2, + 'retain_non_status_information' => 1, + 'stalking_on_ok' => 1, + 'stalking_on_warning' => 1, + 'stalking_on_unknown' => 0, + 'stalking_on_critical' => 0, + 'event_handler_enabled' => 0, + 'event_handler' => 'check_https', + 'event_handler_arguments' => 'eventHandlerArgument', + 'graph_template' => 'CPU', + 'service_categories' => 'Disk', + 'url' => 'serviceUrl', + 'notes' => 'serviceNotes', + 'action_url' => 'serviceActionUrl', + 'icon' => ' centreon (png)', + 'alt_icon' => 'serviceAltIcon', + 'severity' => 'serviceCategory2Name (2)', + 'geo_coordinates' => 'Paris', + 'status' => 1, + 'comments' => 'serviceComments' + ); + + protected $update = array( + 'hosts' => 'Firewall', + 'description' => 'serviceDescriptionChanged', + 'templates' => 'Ping-WAN', + 'check_command' => 'check_https', + 'macros' => array( + 'MACRONAMECHANGED' => 11 + ), + 'check_period' => 'none', + 'max_check_attempts' => 32, + 'normal_check_interval' => 81, + 'retry_check_interval' => 12, + 'active_checks_enabled' => 0, + 'passive_checks_enabled' => 2, + 'is_volatile' => 1, + 'notifications_enabled' => 0, + 'inherits_contacts_groups' => 1, + 'notification_interval' => 14, + 'notify_on_none' => 0, + 'notify_on_warning' => 1, + 'notify_on_unknown' => 1, + 'notify_on_critical' => 1, + 'notify_on_recovery' => 1, + 'notify_on_flapping' => 1, + 'notify_on_downtime_scheduled' => 1, + 'first_notification_delay' => 8, + 'recovery_notification_delay' => 9, + 'service_groups' => 'serviceGroup2Name', + 'trap_relations' => 'HP - snTrapL4GslbRemoteControllerUp', + 'obsess_over_service' => 0, + 'acknowledgement_timeout' => 28, + 'check_freshness' => 2, + 'freshness_threshold' => 31, + 'flap_detection_enabled' => 1, + 'low_flap_threshold' => 42, + 'high_flap_threshold' => 79, + 'retain_status_information' => 1, + 'retain_non_status_information' => 0, + 'stalking_on_ok' => 0, + 'stalking_on_warning' => 0, + 'stalking_on_unknown' => 1, + 'stalking_on_critical' => 1, + 'event_handler_enabled' => 1, + 'event_handler' => 'check_http', + 'event_handler_arguments' => 'eventHandlerArgumentChanged', + 'graph_template' => 'Storage', + 'service_categories' => 'Memory', + 'url' => 'serviceUrlChanged', + 'notes' => 'serviceNotesChanged', + 'action_url' => 'serviceActionUrlChanged', + 'icon' => '', + 'alt_icon' => 'Empty', + 'severity' => 'serviceCategory1Name (3)', + 'geo_coordinates' => '1.2.3.4', + 'status' => 1, + 'comments' => 'serviceCommentsChanged' + ); + + protected $updatedProperties = array( + 'hosts' => 'Firewall', + 'description' => 'serviceDescriptionChanged', + 'templates' => 'Ping-WAN', + 'check_command' => 'check_https', + 'macros' => array( + 'MACRONAMECHANGED' => 11, + 'MACRONAME' => 22 + ), + 'check_period' => 'none', + 'max_check_attempts' => 32, + 'normal_check_interval' => 81, + 'retry_check_interval' => 12, + 'active_checks_enabled' => 0, + 'passive_checks_enabled' => 2, + 'is_volatile' => 1, + 'notifications_enabled' => 0, + 'inherits_contacts_groups' => 1, + 'contacts' => '', + 'contact_additive_inheritance' => 0, + 'contact_groups' => '', + 'contact_group_additive_inheritance' => 0, + 'notification_interval' => 14, + 'notify_on_none' => 0, + 'notify_on_warning' => 1, + 'notify_on_unknown' => 1, + 'notify_on_critical' => 1, + 'notify_on_recovery' => 1, + 'notify_on_flapping' => 1, + 'notify_on_downtime_scheduled' => 1, + 'first_notification_delay' => 8, + 'recovery_notification_delay' => 9, + 'service_groups' => 'serviceGroup2Name', + 'trap_relations' => array( + 'snTrapL4GslbRemoteControllerUp' + ), + 'obsess_over_service' => 0, + 'acknowledgement_timeout' => 28, + 'check_freshness' => 2, + 'freshness_threshold' => 31, + 'flap_detection_enabled' => 1, + 'low_flap_threshold' => 42, + 'high_flap_threshold' => 79, + 'retain_status_information' => 1, + 'retain_non_status_information' => 0, + 'stalking_on_ok' => 0, + 'stalking_on_warning' => 0, + 'stalking_on_unknown' => 1, + 'stalking_on_critical' => 1, + 'event_handler_enabled' => 1, + 'event_handler' => 'check_http', + 'event_handler_arguments' => 'eventHandlerArgumentChanged', + 'graph_template' => 'Storage', + 'service_categories' => 'Memory', + 'url' => 'serviceUrlChanged', + 'notes' => 'serviceNotesChanged', + 'action_url' => 'serviceActionUrlChanged', + 'icon' => '', + 'alt_icon' => 'Empty', + 'severity' => 'serviceCategory1Name (3)', + 'geo_coordinates' => '1.2.3.4', + 'status' => 1, + 'comments' => 'serviceCommentsChanged' + ); + + /** + * @Given a service is configured + */ + public function aServiceIsConfigured() + { + $this->currentPage = new ServiceCategoryConfigurationPage($this); + $this->currentPage->setProperties($this->serviceCategory1); + $this->currentPage->save(); + $this->currentPage = new ServiceCategoryConfigurationPage($this); + $this->currentPage->setProperties($this->serviceCategory2); + $this->currentPage->save(); + $this->currentPage = new ServiceGroupConfigurationPage($this); + $this->currentPage->setProperties($this->serviceGroup1); + $this->currentPage->save(); + $this->currentPage = new ServiceGroupConfigurationPage($this); + $this->currentPage->setProperties($this->serviceGroup2); + $this->currentPage->save(); + $this->currentPage = new HostGroupServiceConfigurationPage($this); + $this->currentPage->setProperties($this->initialProperties); + $this->currentPage->save(); + } + + /** + * @When I change the properties of a host group service + */ + public function iChangeThePropertiesOfAHostGroupService() + { + $this->currentPage = new HostGroupServiceConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['description']); + $this->currentPage->setProperties($this->update); + $this->currentPage->save(); + } + + /** + * @Then the properties are updated + */ + public function thePropertiesAreUpdated() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new HostGroupServiceConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->updatedProperties['description']); + $object = $this->currentPage->getProperties(); + foreach ($this->updatedProperties as $key => $value) { + if ($value != $object[$key]) { + if (is_array($value)) { + $value = implode(' ', $value); + } + if ($value != $object[$key]) { + $this->tableau[] = $key; + } + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I duplicate a host group service + */ + public function iDuplicateAHostGroupService() + { + $this->currentPage = new HostGroupServiceConfigurationListingPage($this); + $object = $this->currentPage->getEntry(array( + 'service' => $this->initialProperties['description'], + 'host_group' => $this->initialProperties['hosts'] + )); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Duplicate'); + } + + /** + * @Then the new host group service has the same properties + */ + public function theNewHostGroupServiceHasTheSameProperties() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new HostGroupServiceConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->duplicatedProperties['description']); + $object = $this->currentPage->getProperties(); + foreach ($this->duplicatedProperties as $key => $value) { + if ($value != $object[$key]) { + if (is_array($value)) { + $value = implode(' ', $value); + } + if ($value != $object[$key]) { + $this->tableau[] = $key; + } + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I delete a host group service + */ + public function iDeleteAHostGroupService() + { + $this->currentPage = new HostGroupServiceConfigurationListingPage($this); + $object = $this->currentPage->getEntry(array( + 'service' => $this->initialProperties['description'], + 'host_group' => $this->initialProperties['hosts'] + )); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Delete'); + } + + /** + * @Then the deleted host group service is not displayed in the list + */ + public function theDeletedHostGroupServiceIsNotDisplayedInTheList() + { + $this->spin( + function ($context) { + $this->currentPage = new HostGroupServiceConfigurationListingPage($this); + $object = $this->currentPage->getEntries(); + $bool = true; + foreach ($object as $host => $service) { + foreach ($service as $value) { + $bool = $bool && $value['service'] != $this->initialProperties['description']; + } + } + return $bool; + }, + "The service is not being deleted.", + 5 + ); + } +} diff --git a/features/bootstrap/MassiveChangeServicesContext.php b/features/bootstrap/MassiveChangeServicesContext.php index e01971ce2e3..48f5eb8d738 100644 --- a/features/bootstrap/MassiveChangeServicesContext.php +++ b/features/bootstrap/MassiveChangeServicesContext.php @@ -116,7 +116,7 @@ class MassiveChangeServicesContext extends CentreonContext 'service_groups' => 'serviceGroupName', 'update_mode_traps' => 1, 'trap_relations' => array( - 'trapName', + 'Generic', 'Generic - trapName' ), 'obsess_over_service' => 2, From 4fb56f80d12d9a7b3fa59586a616a4dc3bd81d21 Mon Sep 17 00:00:00 2001 From: mariegallardo Date: Mon, 7 Aug 2017 13:42:52 +0200 Subject: [PATCH 127/207] New Feature: CommandConfiguration (#5504) * New Feature: CommandConfiguration * File fixed * Feature fixed --- behat.yml | 5 + features/CommandConfiguration.feature | 36 +++ .../bootstrap/CommandConfigurationContext.php | 262 ++++++++++++++++++ 3 files changed, 303 insertions(+) create mode 100644 features/CommandConfiguration.feature create mode 100644 features/bootstrap/CommandConfigurationContext.php diff --git a/behat.yml b/behat.yml index 17c3c3b99e4..52fda25192c 100644 --- a/behat.yml +++ b/behat.yml @@ -274,6 +274,11 @@ default: contexts: - VirtualMetricHandleContext + command_configuration: + paths: [ %paths.base%/features/CommandConfiguration.feature ] + contexts: + - CommandConfigurationContext + host_group_service_configuration: paths: [ %paths.base%/features/HostGroupServiceConfiguration.feature ] contexts: diff --git a/features/CommandConfiguration.feature b/features/CommandConfiguration.feature new file mode 100644 index 00000000000..0bc391fb2a6 --- /dev/null +++ b/features/CommandConfiguration.feature @@ -0,0 +1,36 @@ +Feature: Edit a command + As a Centreon user + I want to manipulate a command + To see if all simples manipulations work + + Background: + Given I am logged in a Centreon server + And a command is configured + + Scenario: Change the properties of a command + When I change the properties of a command + Then the properties are updated + + Scenario: Duplicate one existing service + When I duplicate a command + Then the new command has the same properties + + Scenario: Delete one existing service + When I delete a command + Then the deleted command is not displayed in the list + + Scenario: Check if the command appears on the checks page + When I create a check command + Then the command is displayed on the checks page + + Scenario: Check if the command appears on the notifications page + When I create a notification command + Then the command is displayed on the notifications page + + Scenario: Check if the command appears on the discovery page + When I create a discovery command + Then the command is displayed on the discovery page + + Scenario: Check if the command appears on the miscellaneous page + When I create a miscellaneous command + Then the command is displayed on the miscellaneous page diff --git a/features/bootstrap/CommandConfigurationContext.php b/features/bootstrap/CommandConfigurationContext.php new file mode 100644 index 00000000000..ff693dd63a7 --- /dev/null +++ b/features/bootstrap/CommandConfigurationContext.php @@ -0,0 +1,262 @@ + 'aCommandName', + 'command_type' => 3, + 'command_line' => 'commandLine', + 'enabled_shell' => 1, + 'argument_example' => 'commandArgumentExample', + 'connectors' => 'Perl Connector', + 'graph_template' => 'Storage', + 'enabled' => 1, + 'comment' => 'commandComment' + ); + + protected $updatedProperties = array( + 'command_name' => 'aCommandNameChanged', + 'command_type' => 4, + 'command_line' => 'commandLineChanged', + 'enabled_shell' => 0, + 'argument_example' => 'commandArgumentExampleChanged', + 'connectors' => 'SSH Connector', + 'graph_template' => 'Memory', + 'enabled' => 1, + 'comment' => 'commandCommentChanged' + ); + + /** + * @Given a command is configured + */ + public function aCommandIsConfigured() + { + $this->currentPage = new CommandConfigurationPage($this); + $this->currentPage->setProperties($this->initialProperties); + $this->currentPage->save(); + } + + /** + * @When I change the properties of a command + */ + public function iChangeThePropertiesOfACommand() + { + $this->currentPage = new CommandConfigurationListingPage($this, true, 3); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['command_name']); + $this->currentPage->setProperties($this->updatedProperties); + $this->currentPage->save(); + } + + /** + * @Then the properties are updated + */ + public function thePropertiesAreUpdated() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new CommandConfigurationListingPage($this, true, 4); + $this->currentPage = $this->currentPage->inspect($this->updatedProperties['command_name']); + $object = $this->currentPage->getProperties(); + foreach ($this->updatedProperties as $key => $value) { + if ($value != $object[$key]) { + if (is_array($value)) { + $value = implode(' ', $value); + } + if ($value != $object[$key]) { + $this->tableau[] = $key; + } + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I duplicate a command + */ + public function iDuplicateACommand() + { + $this->currentPage = new CommandConfigurationListingPage($this, true, 3); + $object = $this->currentPage->getEntry($this->initialProperties['command_name']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Duplicate'); + } + + /** + * @Then the new command has the same properties + */ + public function theNewCommandHasTheSameProperties() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new CommandConfigurationListingPage($this, true, 3); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['command_name'] . '_1'); + $object = $this->currentPage->getProperties(); + foreach ($this->initialProperties as $key => $value) { + if ($key != 'command_name' && $value != $object[$key]) { + if (is_array($value)) { + $value = implode(' ', $value); + } + if ($value != $object[$key]) { + $this->tableau[] = $key; + } + } + if ($key == 'command_name' && $value .'_1' != $object[$key]) { + $this->tableau[] = $key; + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I delete a command + */ + public function iDeleteACommand() + { + $this->currentPage = new CommandConfigurationListingPage($this, true, 3); + $object = $this->currentPage->getEntry($this->initialProperties['command_name']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Delete'); + } + + /** + * @Then the deleted command is not displayed in the list + */ + public function theDeletedCommandIsNotDisplayedInTheList() + { + $this->spin( + function ($context) { + $this->currentPage = new CommandConfigurationListingPage($this, true, 3); + $object = $this->currentPage->getEntries(); + $bool = true; + foreach ($object as $value) { + $bool = $bool && $value['name'] != $this->initialProperties['command_name']; + } + return $bool; + }, + "The command is not being deleted.", + 5 + ); + } + + /** + * @When I create a check command + */ + public function iCreateACheckCommand() + { + $this->currentPage = new CommandConfigurationListingPage($this, true, 3); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['command_name']); + $this->currentPage->setProperties(array( + 'command_type' => 2 + )); + $this->currentPage->save(); + } + + /** + * @Then the command is displayed on the checks page + */ + public function theCommandIsDisplayedOnTheChecksPage() + { + /*$this->spin( + function ($context) {*/ + $this->currentPage = new CommandConfigurationListingPage($this, true, 2); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['command_name']); + /*}, + "The command is not on the good page.", + 5 + );*/ + } + + /** + * @When I create a notification command + */ + public function iCreateANotificationCommand() + { + $this->currentPage = new CommandConfigurationListingPage($this, true, 3); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['command_name']); + $this->currentPage->setProperties(array( + 'command_type' => 1 + )); + $this->currentPage->save(); + } + + /** + * @Then the command is displayed on the notifications page + */ + public function theCommandIsDisplayedOnTheNotificationsPage() + { + $this->currentPage = new CommandConfigurationListingPage($this, true, 1); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['command_name']); + } + + /** + * @When I create a discovery command + */ + public function iCreateADiscoveryCommand() + { + $this->currentPage = new CommandConfigurationListingPage($this, true, 3); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['command_name']); + $this->currentPage->setProperties(array( + 'command_type' => 3 + )); + $this->currentPage->save(); + } + + /** + * @Then the command is displayed on the discovery page + */ + public function theCommandIsDisplayedOnTheDiscoveryPage() + { + $this->currentPage = new CommandConfigurationListingPage($this, true, 3); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['command_name']); + } + + /** + * @When I create a miscellaneous command + */ + public function iCreateAMiscellaneousCommand() + { + $this->currentPage = new CommandConfigurationListingPage($this, true, 3); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['command_name']); + $this->currentPage->setProperties(array( + 'command_type' => 4 + )); + $this->currentPage->save(); + } + + /** + * @Then the command is displayed on the miscellaneous page + */ + public function theCommandIsDisplayedOnTheMiscellaneousPage() + { + $this->currentPage = new CommandConfigurationListingPage($this, true, 4); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['command_name']); + } +} From d5db6d615d40e257937ad2f6da0c094de4a12473 Mon Sep 17 00:00:00 2001 From: mariegallardo Date: Mon, 7 Aug 2017 15:25:07 +0200 Subject: [PATCH 128/207] New feature (#5486) --- behat.yml | 5 + features/ServiceGroupConfiguration.feature | 20 ++ .../ServiceGroupConfigurationContext.php | 200 ++++++++++++++++++ 3 files changed, 225 insertions(+) create mode 100644 features/ServiceGroupConfiguration.feature create mode 100644 features/bootstrap/ServiceGroupConfigurationContext.php diff --git a/behat.yml b/behat.yml index 52fda25192c..43b514eaff8 100644 --- a/behat.yml +++ b/behat.yml @@ -279,6 +279,11 @@ default: contexts: - CommandConfigurationContext + service_group_configuration: + paths: [ %paths.base%/features/ServiceGroupConfiguration.feature ] + contexts: + - ServiceGroupConfigurationContext + host_group_service_configuration: paths: [ %paths.base%/features/HostGroupServiceConfiguration.feature ] contexts: diff --git a/features/ServiceGroupConfiguration.feature b/features/ServiceGroupConfiguration.feature new file mode 100644 index 00000000000..2ff66c38f48 --- /dev/null +++ b/features/ServiceGroupConfiguration.feature @@ -0,0 +1,20 @@ +Feature: ServiceGroupConfiguration + As a Centreon admin + I want to manipulate an host + To see if all simples manipulations work + + Background: + Given I am logged in a Centreon server + And a service group is configured + + Scenario: Change the properties of a service group + When I change the properties of a service group + Then the properties are updated + + Scenario: Duplicate one existing service group + When I duplicate a service group + Then the new service group has the same properties + + Scenario: Delete one existing service group + When I delete a service group + Then the deleted service group is not displayed in the service group list diff --git a/features/bootstrap/ServiceGroupConfigurationContext.php b/features/bootstrap/ServiceGroupConfigurationContext.php new file mode 100644 index 00000000000..cae9e02e250 --- /dev/null +++ b/features/bootstrap/ServiceGroupConfigurationContext.php @@ -0,0 +1,200 @@ + 'hostGroupServiceDescription1', + 'hosts' => 'Windows-Servers', + 'check_command' => 'check_http' + ); + + protected $hostGroupService2 = array( + 'description' => 'hostGroupServiceDescription2', + 'hosts' => 'Firewall', + 'check_command' => 'check_https' + ); + + protected $initialProperties = array( + 'name' => 'serviceGroupName', + 'description' => 'serviceGroupDescription', + 'hosts' => 'Centreon-Server - Memory', + 'host_groups' => 'Windows-Servers - hostGroupServiceDescription1', + 'service_templates' => array( + 'Ping-LAN', + 'generic-host - Ping-LAN' + ), + 'geo_coordinates' => '1.2.3.4', + 'enabled' => 1, + 'comments' => 'serviceGroupComments' + ); + + protected $duplicatedProperties = array( + 'name' => 'serviceGroupName_1', + 'description' => 'serviceGroupDescription', + 'hosts' => 'Centreon-Server - Memory', + 'host_groups' => 'Windows-Servers - hostGroupServiceDescription1', + 'service_templates' => 'generic-host - Ping-LAN', + 'geo_coordinates' => '1.2.3.4', + 'enabled' => 1, + 'comments' => 'serviceGroupComments' + ); + + protected $update = array( + 'name' => 'serviceGroupNameChanged', + 'description' => 'serviceGroupDescriptionChanged', + 'hosts' => 'Centreon-Server - Load', + 'host_groups' => 'Firewall - hostGroupServiceDescription2', + 'service_templates' => array( + 'SNMP-Linux-Swap', + 'Servers-Linux - SNMP-Linux-Swap' + ), + 'geo_coordinates' => 'Paris', + 'enabled' => 1, + 'comments' => 'serviceGroupCommentsChanged' + ); + + protected $updatedProperties = array( + 'name' => 'serviceGroupNameChanged', + 'description' => 'serviceGroupDescriptionChanged', + 'hosts' => 'Centreon-Server - Load', + 'host_groups' => 'Firewall - hostGroupServiceDescription2', + 'service_templates' => 'Servers-Linux - SNMP-Linux-Swap', + 'geo_coordinates' => 'Paris', + 'enabled' => 1, + 'comments' => 'serviceGroupCommentsChanged' + ); + + /** + * @Given a service group is configured + */ + public function aServiceGroupIsConfigured() + { + $this->currentPage = new HostGroupServiceConfigurationPage($this); + $this->currentPage->setProperties($this->hostGroupService1); + $this->currentPage->save(); + $this->currentPage = new HostGroupServiceConfigurationPage($this); + $this->currentPage->setProperties($this->hostGroupService2); + $this->currentPage->save(); + $this->currentPage = new ServiceGroupConfigurationPage($this); + $this->currentPage->setProperties($this->initialProperties); + $this->currentPage->save(); + } + + /** + * @When I change the properties of a service group + */ + public function iChangeThePropertiesOfAServiceGroup() + { + $this->currentPage = new ServiceGroupConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['name']); + $this->currentPage->setProperties($this->update); + $this->currentPage->save(); + } + + /** + * @Then the properties are updated + */ + public function thePropertiesAreUpdated() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new ServiceGroupConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->updatedProperties['name']); + $object = $this->currentPage->getProperties(); + foreach ($this->updatedProperties as $key => $value) { + if ($value != $object[$key]) { + $this->tableau[] = $key; + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I duplicate a service group + */ + public function iDuplicateAServiceGroup() + { + $this->currentPage = new ServiceGroupConfigurationListingPage($this); + $object = $this->currentPage->getEntry($this->initialProperties['name']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Duplicate'); + } + + /** + * @Then the new service group has the same properties + */ + public function theNewServiceGroupHasTheSameProperties() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new ServiceGroupConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->duplicatedProperties['name']); + $object = $this->currentPage->getProperties(); + foreach ($this->duplicatedProperties as $key => $value) { + if ($value != $object[$key]) { + $this->tableau[] = $key; + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I delete a service group + */ + public function iDeleteAServiceGroup() + { + $this->currentPage = new ServiceGroupConfigurationListingPage($this); + $object = $this->currentPage->getEntry($this->initialProperties['name']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Delete'); + } + + /** + * @Then the deleted service group is not displayed in the service group list + */ + public function theDeletedServiceGroupIsNotDisplayedInTheServiceGroupList() + { + $this->spin( + function ($context) { + $this->currentPage = new ServiceGroupConfigurationListingPage($this); + $object = $this->currentPage->getEntries(); + $bool = true; + foreach ($object as $value) { + $bool = $bool && $value['name'] != $this->initialProperties['name']; + } + return $bool; + }, + "The host category is not being deleted.", + 5 + ); + } +} From 8caf0592647685860bcd560e5198a0bac198e36d Mon Sep 17 00:00:00 2001 From: loiclau Date: Mon, 7 Aug 2017 15:56:10 +0200 Subject: [PATCH 129/207] * #5497 duplicate acl --- .../configObject/contact/DB-Func.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/www/include/configuration/configObject/contact/DB-Func.php b/www/include/configuration/configObject/contact/DB-Func.php index 26b5e78e974..e25ee94fffe 100644 --- a/www/include/configuration/configObject/contact/DB-Func.php +++ b/www/include/configuration/configObject/contact/DB-Func.php @@ -253,6 +253,22 @@ function multipleContactInDB($contacts = array(), $nbrDup = array()) $DBRESULT = $pearDB->query("SELECT MAX(contact_id) FROM contact"); $maxId = $DBRESULT->fetchRow(); if (isset($maxId["MAX(contact_id)"])) { + + /* + * ACL update + */ + $query = "SELECT DISTINCT acl_group_id FROM acl_group_contacts_relations " . + "WHERE contact_contact_id = " . (int)$key; + $dbResult = $pearDB->query($query); + $fields["contact_aclRelation"] = ""; + while ($aclRelation = $dbResult->fetchRow()) { + $query = "INSERT INTO acl_group_contacts_relations VALUES ('', '" . + $maxId["MAX(contact_id)"] . "', '" . $aclRelation["acl_group_id"] . "')"; + $pearDB->query($query); + $fields["contact_aclRelation"] .= $aclRelation["acl_group_id"] . ","; + } + $fields["contact_aclRelation"] = trim($fields["contact_aclRelation"], ","); + /* * Command update */ From 7ae264cab4877d9c0afbb6387703259995ff6101 Mon Sep 17 00:00:00 2001 From: loiclau Date: Mon, 7 Aug 2017 16:10:55 +0200 Subject: [PATCH 130/207] * #5497 duplicate contactgroup acl --- .../configObject/contactgroup/DB-Func.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/www/include/configuration/configObject/contactgroup/DB-Func.php b/www/include/configuration/configObject/contactgroup/DB-Func.php index 474263e8997..41a5b90e68f 100644 --- a/www/include/configuration/configObject/contactgroup/DB-Func.php +++ b/www/include/configuration/configObject/contactgroup/DB-Func.php @@ -137,6 +137,18 @@ function multipleContactGroupInDB($contactGroups = array(), $nbrDup = array()) $maxId = $DBRESULT->fetchRow(); if (isset($maxId["MAX(cg_id)"])) { + + $query = "SELECT DISTINCT `acl_group_id` FROM `acl_group_contactgroups_relations` " . + "WHERE `cg_cg_id` = " . (int)$key; + $dbResult = $pearDB->query($query); + $fields["cg_aclRelation"] = ""; + while ($cgAcl = $dbResult->fetchRow()) { + $query = "INSERT INTO `acl_group_contactgroups_relations` VALUES ('', '" . + $maxId["MAX(cg_id)"] . "', '" . $cgAcl['acl_group_id'] . "')"; + $pearDB->query($query); + $fields["cg_aclRelation"] .= $cgAcl["acl_group_id"] . ","; + } + $DBRESULT = $pearDB->query("SELECT DISTINCT `cgcr`.`contact_contact_id` FROM `contactgroup_contact_relation` `cgcr` WHERE `cgcr`.`contactgroup_cg_id` = '" . intval($key) . "'"); $fields["cg_contacts"] = ""; while ($cct = $DBRESULT->fetchRow()) { From e3012b301a701c2892511b4eb3461fb389e32499 Mon Sep 17 00:00:00 2001 From: mariegallardo Date: Mon, 7 Aug 2017 16:45:50 +0200 Subject: [PATCH 131/207] New Feature ServiceTemplateConfiguration (#5489) --- behat.yml | 5 + features/ServiceTemplateConfiguration.feature | 20 + .../ServiceTemplateConfigurationContext.php | 417 ++++++++++++++++++ 3 files changed, 442 insertions(+) create mode 100644 features/ServiceTemplateConfiguration.feature create mode 100644 features/bootstrap/ServiceTemplateConfigurationContext.php diff --git a/behat.yml b/behat.yml index 43b514eaff8..33fee3def8b 100644 --- a/behat.yml +++ b/behat.yml @@ -288,3 +288,8 @@ default: paths: [ %paths.base%/features/HostGroupServiceConfiguration.feature ] contexts: - HostGroupServiceConfigurationContext + + service_template_configuration: + paths: [ %paths.base%/features/ServiceTemplateConfiguration.feature ] + contexts: + - ServiceTemplateConfigurationContext diff --git a/features/ServiceTemplateConfiguration.feature b/features/ServiceTemplateConfiguration.feature new file mode 100644 index 00000000000..b719cfd248d --- /dev/null +++ b/features/ServiceTemplateConfiguration.feature @@ -0,0 +1,20 @@ +Feature: Edit a service + As a Centreon user + I want to manipulate a service + To see if all simples manipulations work + + Background: + Given I am logged in a Centreon server + And a service template is configured + + Scenario: Change the properties of a service template + When I change the properties of a service template + Then the properties are updated + + Scenario: Duplicate one existing service template + When I duplicate a service template + Then the new service template has the same properties + + Scenario: Delete one existing service template + When I delete a service template + Then the deleted service template is not displayed in the list diff --git a/features/bootstrap/ServiceTemplateConfigurationContext.php b/features/bootstrap/ServiceTemplateConfigurationContext.php new file mode 100644 index 00000000000..3bb3564e2d7 --- /dev/null +++ b/features/bootstrap/ServiceTemplateConfigurationContext.php @@ -0,0 +1,417 @@ + 'hostName', + 'alias' => 'hostAlias', + 'address' => 'host@localhost' + ); + + protected $serviceCategory1 = array( + 'name' => 'serviceCategory1Name', + 'description' => 'serviceCategory1Description', + 'severity' => 1, + 'level' => 3, + 'icon' => ' centreon (png)' + ); + + protected $serviceCategory2 = array( + 'name' => 'serviceCategory2Name', + 'description' => 'serviceCategory2Description', + 'severity' => 1, + 'level' => 2, + 'icon' => ' centreon (png)' + ); + + protected $initialProperties = array( + 'description' => 'serviceDescription', + 'alias' => 'serviceAlias', + 'templates' => 'generic-service', + 'check_command' => 'check_http', + 'macros' => array( + 'MACRONAME' => 22 + ), + 'check_period' => 'workhours', + 'max_check_attempts' => 15, + 'normal_check_interval' => 7, + 'retry_check_interval' => 9, + 'active_checks_enabled' => 2, + 'passive_checks_enabled' => 1, + 'is_volatile' => 0, + 'notifications_enabled' => 2, + 'contacts' => 'Guest', + 'contact_additive_inheritance' => 1, + 'contact_groups' => 'Supervisors', + 'contact_group_additive_inheritance' => 1, + 'notification_interval' => 23, + 'notify_on_none' => 1, + 'notify_on_warning' => 0, + 'notify_on_unknown' => 0, + 'notify_on_critical' => 0, + 'notify_on_recovery' => 0, + 'notify_on_flapping' => 0, + 'notify_on_downtime_scheduled' => 0, + 'first_notification_delay' => 4, + 'recovery_notification_delay' => 3, + 'host_template' => 'Router-Cisco', + 'trap_relations' => 'Generic - coldStart', + 'obsess_over_service' => 2, + 'acknowledgement_timeout' => 34, + 'check_freshness' => 1, + 'freshness_threshold' => 22, + 'flap_detection_enabled' => 0, + 'low_flap_threshold' => 15, + 'high_flap_threshold' => 18, + 'retain_status_information' => 2, + 'retain_non_status_information' => 1, + 'stalking_on_ok' => 1, + 'stalking_on_warning' => 1, + 'stalking_on_unknown' => 0, + 'stalking_on_critical' => 0, + 'event_handler_enabled' => 0, + 'event_handler' => 'check_https', + 'event_handler_arguments' => 'eventHandlerArgument', + 'graph_template' => 'CPU', + 'service_categories' => 'Disk', + 'url' => 'serviceUrl', + 'notes' => 'serviceNotes', + 'action_url' => 'serviceActionUrl', + 'icon' => ' centreon (png)', + 'alt_icon' => 'serviceAltIcon', + 'severity' => 'serviceCategory2Name (2)', + 'status' => 1, + 'comments' => 'serviceComments' + ); + + protected $duplicatedProperties = array( + 'description' => 'serviceDescription_1', + 'alias' => 'serviceAlias', + 'templates' => 'generic-service', + 'check_command' => 'check_http', + 'macros' => array( + 'MACRONAME' => 22 + ), + 'check_period' => 'workhours', + 'max_check_attempts' => 15, + 'normal_check_interval' => 7, + 'retry_check_interval' => 9, + 'active_checks_enabled' => 2, + 'passive_checks_enabled' => 1, + 'is_volatile' => 0, + 'notifications_enabled' => 2, + 'contacts' => 'Guest', + 'contact_additive_inheritance' => 1, + 'contact_groups' => 'Supervisors', + 'contact_group_additive_inheritance' => 1, + 'notification_interval' => 23, + 'notify_on_none' => 1, + 'notify_on_warning' => 0, + 'notify_on_unknown' => 0, + 'notify_on_critical' => 0, + 'notify_on_recovery' => 0, + 'notify_on_flapping' => 0, + 'notify_on_downtime_scheduled' => 0, + 'first_notification_delay' => 4, + 'recovery_notification_delay' => 3, + 'host_template' => 'Router-Cisco', + 'trap_relations' => 'coldStart', + 'obsess_over_service' => 2, + 'acknowledgement_timeout' => 34, + 'check_freshness' => 1, + 'freshness_threshold' => 22, + 'flap_detection_enabled' => 0, + 'low_flap_threshold' => 15, + 'high_flap_threshold' => 18, + 'retain_status_information' => 2, + 'retain_non_status_information' => 1, + 'stalking_on_ok' => 1, + 'stalking_on_warning' => 1, + 'stalking_on_unknown' => 0, + 'stalking_on_critical' => 0, + 'event_handler_enabled' => 0, + 'event_handler' => 'check_https', + 'event_handler_arguments' => 'eventHandlerArgument', + 'graph_template' => 'CPU', + 'service_categories' => 'Disk', + 'url' => 'serviceUrl', + 'notes' => 'serviceNotes', + 'action_url' => 'serviceActionUrl', + 'icon' => ' centreon (png)', + 'alt_icon' => 'serviceAltIcon', + 'severity' => 'serviceCategory2Name (2)', + 'status' => 1, + 'comments' => 'serviceComments' + ); + + protected $update = array( + 'description' => 'serviceDescriptionChanged', + 'alias' => 'serviceAliasChanged', + 'templates' => 'Ping-WAN', + 'check_command' => 'check_https', + 'macros' => array( + 'MACRONAMECHANGED' => 11 + ), + 'check_period' => 'none', + 'max_check_attempts' => 32, + 'normal_check_interval' => 81, + 'retry_check_interval' => 12, + 'active_checks_enabled' => 0, + 'passive_checks_enabled' => 2, + 'is_volatile' => 1, + 'notifications_enabled' => 0, + 'contacts' => 'User', + 'contact_additive_inheritance' => 0, + 'contact_groups' => 'Guest', + 'contact_group_additive_inheritance' => 0, + 'notification_interval' => 14, + 'notify_on_none' => 0, + 'notify_on_warning' => 1, + 'notify_on_unknown' => 1, + 'notify_on_critical' => 1, + 'notify_on_recovery' => 1, + 'notify_on_flapping' => 1, + 'notify_on_downtime_scheduled' => 1, + 'first_notification_delay' => 8, + 'recovery_notification_delay' => 9, + 'host_template' => 'generic-host', + 'trap_relations' => 'HP - snTrapL4GslbRemoteControllerUp', + 'obsess_over_service' => 0, + 'acknowledgement_timeout' => 28, + 'check_freshness' => 2, + 'freshness_threshold' => 31, + 'flap_detection_enabled' => 1, + 'low_flap_threshold' => 42, + 'high_flap_threshold' => 79, + 'retain_status_information' => 1, + 'retain_non_status_information' => 0, + 'stalking_on_ok' => 0, + 'stalking_on_warning' => 0, + 'stalking_on_unknown' => 1, + 'stalking_on_critical' => 1, + 'event_handler_enabled' => 1, + 'event_handler' => 'check_http', + 'event_handler_arguments' => 'eventHandlerArgumentChanged', + 'graph_template' => 'Storage', + 'service_categories' => 'Memory', + 'url' => 'serviceUrlChanged', + 'notes' => 'serviceNotesChanged', + 'action_url' => 'serviceActionUrlChanged', + 'icon' => '', + 'alt_icon' => 'Empty', + 'severity' => 'serviceCategory1Name (3)', + 'status' => 1, + 'comments' => 'serviceCommentsChanged' + ); + + protected $updatedProperties = array( + 'description' => 'serviceDescriptionChanged', + 'alias' => 'serviceAliasChanged', + 'templates' => 'Ping-WAN', + 'check_command' => 'check_https', + 'macros' => array( + 'MACRONAMECHANGED' => 11, + 'MACRONAME' => 22 + ), + 'check_period' => 'none', + 'max_check_attempts' => 32, + 'normal_check_interval' => 81, + 'retry_check_interval' => 12, + 'active_checks_enabled' => 0, + 'passive_checks_enabled' => 2, + 'is_volatile' => 1, + 'notifications_enabled' => 0, + 'contacts' => 'User', + 'contact_additive_inheritance' => 0, + 'contact_groups' => 'Guest', + 'contact_group_additive_inheritance' => 0, + 'notification_interval' => 14, + 'notify_on_none' => 0, + 'notify_on_warning' => 1, + 'notify_on_unknown' => 1, + 'notify_on_critical' => 1, + 'notify_on_recovery' => 1, + 'notify_on_flapping' => 1, + 'notify_on_downtime_scheduled' => 1, + 'first_notification_delay' => 8, + 'recovery_notification_delay' => 9, + 'host_template' => 'generic-host', + 'trap_relations' => array( + 'snTrapL4GslbRemoteControllerUp' + ), + 'obsess_over_service' => 0, + 'acknowledgement_timeout' => 28, + 'check_freshness' => 2, + 'freshness_threshold' => 31, + 'flap_detection_enabled' => 1, + 'low_flap_threshold' => 42, + 'high_flap_threshold' => 79, + 'retain_status_information' => 1, + 'retain_non_status_information' => 0, + 'stalking_on_ok' => 0, + 'stalking_on_warning' => 0, + 'stalking_on_unknown' => 1, + 'stalking_on_critical' => 1, + 'event_handler_enabled' => 1, + 'event_handler' => 'check_http', + 'event_handler_arguments' => 'eventHandlerArgumentChanged', + 'graph_template' => 'Storage', + 'service_categories' => 'Memory', + 'url' => 'serviceUrlChanged', + 'notes' => 'serviceNotesChanged', + 'action_url' => 'serviceActionUrlChanged', + 'icon' => '', + 'alt_icon' => 'Empty', + 'severity' => 'serviceCategory1Name (3)', + 'status' => 1, + 'comments' => 'serviceCommentsChanged' + ); + + /** + * @Given a service template is configured + */ + public function aServiceTemplateIsConfigured() + { + $this->currentPage = new HostConfigurationPage($this); + $this->currentPage->setProperties($this->host); + $this->currentPage->save(); + $this->currentPage = new ServiceCategoryConfigurationPage($this); + $this->currentPage->setProperties($this->serviceCategory1); + $this->currentPage->save(); + $this->currentPage = new ServiceCategoryConfigurationPage($this); + $this->currentPage->setProperties($this->serviceCategory2); + $this->currentPage->save(); + $this->currentPage = new ServiceTemplateConfigurationPage($this); + $this->currentPage->setProperties($this->initialProperties); + $this->currentPage->save(); + } + + /** + * @When I change the properties of a service template + */ + public function iChangeThePropertiesOfAServiceTemplate() + { + $this->currentPage = new ServiceTemplateConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['description']); + $this->currentPage->setProperties($this->update); + $this->currentPage->save(); + } + + /** + * @Then the properties are updated + */ + public function thePropertiesAreUpdated() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new ServiceTemplateConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->updatedProperties['description']); + $object = $this->currentPage->getProperties(); + foreach ($this->updatedProperties as $key => $value) { + if ($value != $object[$key]) { + if (is_array($value)) { + $value = implode(' ', $value); + } + if ($value != $object[$key]) { + $this->tableau[] = $key; + } + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I duplicate a service template + */ + public function iDuplicateAServiceTemplate() + { + $this->currentPage = new ServiceTemplateConfigurationListingPage($this); + $object = $this->currentPage->getEntry($this->initialProperties['description']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Duplicate'); + } + + /** + * @Then the new service template has the same properties + */ + public function theNewServiceTemplateHasTheSameProperties() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new ServiceTemplateConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->duplicatedProperties['description']); + $object = $this->currentPage->getProperties(); + foreach ($this->duplicatedProperties as $key => $value) { + if ($value != $object[$key]) { + if (is_array($value)) { + $value = implode(' ', $value); + } + if ($value != $object[$key]) { + $this->tableau[] = $key; + } + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I delete a service template + */ + public function iDeleteAServiceTemplate() + { + $this->currentPage = new ServiceTemplateConfigurationListingPage($this); + $object = $this->currentPage->getEntry($this->initialProperties['description']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Delete'); + } + + /** + * @Then the deleted service template is not displayed in the list + */ + public function theDeletedServiceTemplateIsNotDisplayedInTheList() + { + $this->spin( + function ($context) { + $this->currentPage = new ServiceTemplateConfigurationListingPage($this); + $object = $this->currentPage->getEntries(); + $bool = true; + foreach ($object as $value) { + $bool = $bool && $value['description'] != $this->initialProperties['description']; + } + return $bool; + }, + "The service is not being deleted.", + 5 + ); + } +} From afdec3a3d3e6dba3ada25ecc4b6719e50e06939b Mon Sep 17 00:00:00 2001 From: mariegallardo Date: Mon, 7 Aug 2017 18:04:09 +0200 Subject: [PATCH 132/207] New feature: ContactTemplateConfiguration (#5499) --- behat.yml | 4 +- features/ContactTemplateConfiguration.feature | 20 ++ .../ContactTemplateConfigurationContext.php | 208 ++++++++++++++++++ 3 files changed, 230 insertions(+), 2 deletions(-) create mode 100644 features/ContactTemplateConfiguration.feature create mode 100644 features/bootstrap/ContactTemplateConfigurationContext.php diff --git a/behat.yml b/behat.yml index 33fee3def8b..790c0eab205 100644 --- a/behat.yml +++ b/behat.yml @@ -290,6 +290,6 @@ default: - HostGroupServiceConfigurationContext service_template_configuration: - paths: [ %paths.base%/features/ServiceTemplateConfiguration.feature ] + paths: [ %paths.base%/features/ContactTemplateConfiguration.feature ] contexts: - - ServiceTemplateConfigurationContext + - ContactTemplateConfigurationContext diff --git a/features/ContactTemplateConfiguration.feature b/features/ContactTemplateConfiguration.feature new file mode 100644 index 00000000000..484c5d2db2e --- /dev/null +++ b/features/ContactTemplateConfiguration.feature @@ -0,0 +1,20 @@ +Feature: Edit a service template + As a Centreon user + I want to manipulate a service template + To see if all simples manipulations work + + Background: + Given I am logged in a Centreon server + And a service template is configured + + Scenario: Change the properties of a service template + When I change the properties of a service template + Then the properties are updated + + Scenario: Duplicate one existing service template + When I duplicate a service template + Then the new service template has the same properties + + Scenario: Delete one existing service template + When I delete a service template + Then the deleted service template is not displayed in the list diff --git a/features/bootstrap/ContactTemplateConfigurationContext.php b/features/bootstrap/ContactTemplateConfigurationContext.php new file mode 100644 index 00000000000..8b7fc76970b --- /dev/null +++ b/features/bootstrap/ContactTemplateConfigurationContext.php @@ -0,0 +1,208 @@ + 'contactTemplateAlias', + 'name' => 'contactTemplateName', + 'contact_template' => 'contact_template', + 'notifications_enabled' => 1, + 'host_notification_on_down' => 1, + 'host_notification_on_unreachable' => 1, + 'host_notification_on_recovery' => 1, + 'host_notification_on_flapping' => 1, + 'host_notification_on_downtime_scheduled' => 1, + 'host_notification_on_none' => 0, + 'host_notification_period' => '24x7', + 'host_notification_command' => 'service-notify-by-email', + 'service_notification_on_none' => 1, + 'service_notification_on_warning' => 0, + 'service_notification_on_unknown' => 0, + 'service_notification_on_critical' => 0, + 'service_notification_on_recovery' => 0, + 'service_notification_on_flapping' => 0, + 'service_notification_on_downtime_scheduled' => 0, + 'service_notification_period' => 'none', + 'service_notification_command' => 'host-notify-by-email', + 'address1' => '1@localhost', + 'address2' => '2@localhost', + 'address3' => '3@localhost', + 'address4' => '4@localhost', + 'address5' => '5@localhost', + 'address6' => '6@localhost', + 'enabled' => 1, + 'comments' => 'contactTemplateComments' + ); + + protected $updatedProperties = array( + 'alias' => 'contactTemplateAliasChanged', + 'name' => 'contactTemplateNameChanged', + 'contact_template' => 'contact_template', + 'notifications_enabled' => 0, + 'host_notification_on_none' => 1, + 'host_notification_on_down' => 0, + 'host_notification_on_unreachable' => 0, + 'host_notification_on_recovery' => 0, + 'host_notification_on_flapping' => 0, + 'host_notification_on_downtime_scheduled' => 0, + 'host_notification_period' => 'nonworkhours', + 'host_notification_command' => 'service-notify-by-epager', + 'service_notification_on_warning' => 1, + 'service_notification_on_unknown' => 1, + 'service_notification_on_critical' => 1, + 'service_notification_on_recovery' => 1, + 'service_notification_on_flapping' => 1, + 'service_notification_on_none' => 0, + 'service_notification_on_downtime_scheduled' => 1, + 'service_notification_period' => 'workhours', + 'service_notification_command' => 'service-notify-by-jabber', + 'address1' => '7@localhost', + 'address2' => '8@localhost', + 'address3' => '9@localhost', + 'address4' => '10@localhost', + 'address5' => '11@localhost', + 'address6' => '12@localhost', + 'enabled' => 1, + 'comments' => 'contactTemplateCommentsChanged' + ); + + /** + * @Given a service template is configured + */ + public function aServiceTemplateIsConfigured() + { + $this->currentPage = new ContactTemplateConfigurationPage($this); + $this->currentPage->setProperties($this->initialProperties); + $this->currentPage->save(); + } + + /** + * @When I change the properties of a service template + */ + public function iChangeThePropertiesOfAServiceTemplate() + { + $this->currentPage = new ContactTemplateConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['alias']); + $this->currentPage->setProperties($this->updatedProperties); + $this->currentPage->save(); + } + + /** + * @Then the properties are updated + */ + public function thePropertiesAreUpdated() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new ContactTemplateConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->updatedProperties['alias']); + $object = $this->currentPage->getProperties(); + foreach ($this->updatedProperties as $key => $value) { + if ($value != $object[$key]) { + if (is_array($value)) { + $value = implode(' ', $value); + } + if ($value != $object[$key]) { + $this->tableau[] = $key; + } + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I duplicate a service template + */ + public function iDuplicateAServiceTemplate() + { + $this->currentPage = new ContactTemplateConfigurationListingPage($this); + $object = $this->currentPage->getEntry($this->initialProperties['alias']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Duplicate'); + } + + /** + * @Then the new service template has the same properties + */ + public function theNewServiceTemplateHasTheSameProperties() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new ContactTemplateConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['alias'] . '_1'); + $object = $this->currentPage->getProperties(); + foreach ($this->initialProperties as $key => $value) { + if ($key != 'name' && $key != 'alias' && $value != $object[$key]) { + if (is_array($value)) { + $value = implode(' ', $value); + } + if ($value != $object[$key]) { + $this->tableau[] = $key; + } + } + if (($key == 'name' || $key == 'alias') && $value . '_1' != $object[$key]) { + $this->tableau[] = $key; + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I delete a service template + */ + public function iDeleteAServiceTemplate() + { + $this->currentPage = new ContactTemplateConfigurationListingPage($this); + $object = $this->currentPage->getEntry($this->initialProperties['alias']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Delete'); + } + + /** + * @Then the deleted service template is not displayed in the list + */ + public function theDeletedServiceTemplateIsNotDisplayedInTheList() + { + $this->spin( + function ($context) { + $this->currentPage = new ContactTemplateConfigurationListingPage($this); + $object = $this->currentPage->getEntries(); + $bool = true; + foreach ($object as $value) { + $bool = $bool && $value['alias'] != $this->initialProperties['alias']; + } + return $bool; + }, + "The service is not being deleted.", + 5 + ); + } +} From e1e61b07055200ba072e08c817c4318f0bec8339 Mon Sep 17 00:00:00 2001 From: Kevin Duret Date: Tue, 8 Aug 2017 10:25:04 +0200 Subject: [PATCH 133/207] avoid check style error with namespaces --- build.xml | 10 +++++----- codingstyle.xml | 8 ++++++++ 2 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 codingstyle.xml diff --git a/build.xml b/build.xml index e798ad2df0b..4f80efbef37 100644 --- a/build.xml +++ b/build.xml @@ -26,18 +26,18 @@ - + - + - + - - + + diff --git a/codingstyle.xml b/codingstyle.xml new file mode 100644 index 00000000000..e0ce42b1011 --- /dev/null +++ b/codingstyle.xml @@ -0,0 +1,8 @@ + + + Centreon coding style. + + + 0 + + \ No newline at end of file From 7accfc776d7231cc43812dcffeeb564b493acfc0 Mon Sep 17 00:00:00 2001 From: mariegallardo Date: Tue, 8 Aug 2017 13:16:57 +0200 Subject: [PATCH 134/207] New feature: ServiceCategoryConfiguration (#5492) --- behat.yml | 5 + features/ServiceCategoryConfiguration.feature | 20 +++ .../ServiceCategoryConfigurationContext.php | 167 ++++++++++++++++++ 3 files changed, 192 insertions(+) create mode 100644 features/ServiceCategoryConfiguration.feature create mode 100644 features/bootstrap/ServiceCategoryConfigurationContext.php diff --git a/behat.yml b/behat.yml index 790c0eab205..819b00883af 100644 --- a/behat.yml +++ b/behat.yml @@ -293,3 +293,8 @@ default: paths: [ %paths.base%/features/ContactTemplateConfiguration.feature ] contexts: - ContactTemplateConfigurationContext + + service_category_configuration: + paths: [ %paths.base%/features/ServiceCategoryConfiguration.feature ] + contexts: + - ServiceCategoryConfigurationContext diff --git a/features/ServiceCategoryConfiguration.feature b/features/ServiceCategoryConfiguration.feature new file mode 100644 index 00000000000..9c17e09460f --- /dev/null +++ b/features/ServiceCategoryConfiguration.feature @@ -0,0 +1,20 @@ +Feature: Edit a service category + As a Centreon user + I want to manipulate a service + To see if all simples manipulations work + + Background: + Given I am logged in a Centreon server + And a service category is configured + + Scenario: Change the properties of a service category + When I change the properties of a service category + Then the properties are updated + + Scenario: Duplicate one existing service category + When I duplicate a service category + Then the new service category has the same properties + + Scenario: Delete one existing service + When I delete a service category + Then the deleted service category is not displayed in the list diff --git a/features/bootstrap/ServiceCategoryConfigurationContext.php b/features/bootstrap/ServiceCategoryConfigurationContext.php new file mode 100644 index 00000000000..1de3e69680f --- /dev/null +++ b/features/bootstrap/ServiceCategoryConfigurationContext.php @@ -0,0 +1,167 @@ + 'serviceCategoryName', + 'description' => 'serviceCategoryDescription', + 'template' => 'generic-service', + 'severity' => 0, + 'status' => 1 + ); + + protected $duplicatedProperties = array( + 'name' => 'serviceCategoryName_1', + 'description' => 'serviceCategoryDescription', + 'template' => 'generic-service', + 'severity' => 0, + 'status' => 1 + ); + + protected $updatedProperties = array( + 'name' => 'serviceCategoryNameChanged', + 'description' => 'serviceCategoryDescriptionChanged', + 'template' => 'Ping-WAN', + 'severity' => 1, + 'level' => '3', + 'icon' => ' centreon (png)', + 'status' => 0 + ); + + /** + * @Given a service category is configured + */ + public function aServiceCategoryIsConfigured() + { + $this->currentPage = new ServiceCategoryConfigurationPage($this); + $this->currentPage->setProperties($this->initialProperties); + $this->currentPage->save(); + } + + /** + * @When I change the properties of a service category + */ + public function iChangeThePropertiesOfAServiceCategory() + { + $this->currentPage = new ServiceCategoryConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['name']); + $this->currentPage->setProperties($this->updatedProperties); + $this->currentPage->save(); + } + + /** + * @Then the properties are updated + */ + public function thePropertiesAreUpdated() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new ServiceCategoryConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->updatedProperties['name']); + $object = $this->currentPage->getProperties(); + foreach ($this->updatedProperties as $key => $value) { + if ($value != $object[$key]) { + if (is_array($value)) { + $value = implode(' ', $value); + } + if ($value != $object[$key]) { + $this->tableau[] = $key; + } + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I duplicate a service category + */ + public function iDuplicateAServiceCategory() + { + $this->currentPage = new ServiceCategoryConfigurationListingPage($this); + $object = $this->currentPage->getEntry($this->initialProperties['name']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Duplicate'); + } + + /** + * @Then the new service category has the same properties + */ + public function theNewServiceCategoryHasTheSameProperties() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new ServiceCategoryConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->duplicatedProperties['name']); + $object = $this->currentPage->getProperties(); + foreach ($this->duplicatedProperties as $key => $value) { + if ($value != $object[$key]) { + if (is_array($value)) { + $value = implode(' ', $value); + } + if ($value != $object[$key]) { + $this->tableau[] = $key; + } + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I delete a service category + */ + public function iDeleteAServiceCategory() + { + $this->currentPage = new ServiceCategoryConfigurationListingPage($this); + $object = $this->currentPage->getEntry($this->initialProperties['name']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Delete'); + } + + /** + * @Then the deleted service category is not displayed in the list + */ + public function theDeletedServiceCategoryIsNotDisplayedInTheList() + { + $this->spin( + function ($context) { + $this->currentPage = new ServiceCategoryConfigurationListingPage($this); + $object = $this->currentPage->getEntries(); + $bool = true; + foreach ($object as $value) { + $bool = $bool && $value['name'] != $this->initialProperties['name']; + } + return $bool; + }, + "The service is not being deleted.", + 5 + ); + } +} From 8aff8bfe586ba594f5ac6adca50ef60e63983e1c Mon Sep 17 00:00:00 2001 From: mariegallardo Date: Tue, 8 Aug 2017 15:38:49 +0200 Subject: [PATCH 135/207] Feature escalation configuration (#5525) * New feature : EscalationConfiguration * * fix duplicate name --- behat.yml | 5 + features/EscalationConfiguration.feature | 20 ++ .../EscalationConfigurationContext.php | 235 ++++++++++++++++++ 3 files changed, 260 insertions(+) create mode 100644 features/EscalationConfiguration.feature create mode 100644 features/bootstrap/EscalationConfigurationContext.php diff --git a/behat.yml b/behat.yml index 819b00883af..61b9bec7dfb 100644 --- a/behat.yml +++ b/behat.yml @@ -298,3 +298,8 @@ default: paths: [ %paths.base%/features/ServiceCategoryConfiguration.feature ] contexts: - ServiceCategoryConfigurationContext + + escalation_configuration: + paths: [ %paths.base%/features/EscalationConfiguration.feature ] + contexts: + - EscalationConfigurationContext diff --git a/features/EscalationConfiguration.feature b/features/EscalationConfiguration.feature new file mode 100644 index 00000000000..62e715a82b2 --- /dev/null +++ b/features/EscalationConfiguration.feature @@ -0,0 +1,20 @@ +Feature: Edit an escalation + As a Centreon user + I want to manipulate an escalation + To see if all simples manipulations work + + Background: + Given I am logged in a Centreon server + And an escalation is configured + + Scenario: Change the properties of an escalation + When I change the properties of an escalation + Then the properties are updated + + Scenario: Duplicate one existing escalation + When I duplicate an escalation + Then the new escalation has the same properties + + Scenario: Delete one existing service + When I delete an escalation + Then the deleted escalation is not displayed in the list diff --git a/features/bootstrap/EscalationConfigurationContext.php b/features/bootstrap/EscalationConfigurationContext.php new file mode 100644 index 00000000000..ebb45e07cb9 --- /dev/null +++ b/features/bootstrap/EscalationConfigurationContext.php @@ -0,0 +1,235 @@ + 'hostName', + 'alias' => 'hostAlias', + 'address' => 'host@localhost' + ); + + protected $metaService1 = array( + 'name' => 'metaService1Name', + 'max_check_attempts' => 3 + ); + + protected $metaService2 = array( + 'name' => 'metaService2Name', + 'max_check_attempts' => 4 + ); + + protected $serviceGroup1 = array( + 'name' => 'serviceGroup1Name', + 'description' => 'serviceGroup1Description' + ); + + protected $serviceGroup2 = array( + 'name' => 'serviceGroup2Name', + 'description' => 'serviceGroup2Description' + ); + + protected $initialProperties = array( + 'name' => 'escalationName', + 'alias' => 'escalationAlias', + 'first_notification' => 5, + 'last_notification' => 15, + 'notification_interval' => 8, + 'escalation_period' => '24x7', + 'host_notify_on_down' => 1, + 'host_notify_on_unreachable' => 0, + 'host_notify_on_recovery' => 1, + 'service_notify_on_warning' => 0, + 'service_notify_on_unknown' => 1, + 'service_notify_on_critical' => 0, + 'service_notify_on_recovery' => 1, + 'contactgroups' => 'Supervisors', + 'comment' => 'escalationComment', + 'host_inheritance_to_services' => 1, + 'hosts' => 'Centreon-Server', + 'services' => 'Centreon-Server - Load', + 'hostgroup_inheritance_to_services' => 0, + 'hostgroups' => 'Linux-Servers', + 'servicegroups' => 'serviceGroup1Name', + 'metaservices' => 'metaService1Name' + ); + + protected $updatedProperties = array( + 'name' => 'escalationNameChanged', + 'alias' => 'escalationAliasChanged', + 'first_notification' => 12, + 'last_notification' => 27, + 'notification_interval' => 14, + 'escalation_period' => 'workhours', + 'host_notify_on_down' => 0, + 'host_notify_on_unreachable' => 1, + 'host_notify_on_recovery' => 0, + 'service_notify_on_warning' => 1, + 'service_notify_on_unknown' => 0, + 'service_notify_on_critical' => 1, + 'service_notify_on_recovery' => 0, + 'contactgroups' => 'Guest', + 'comment' => 'escalationCommentChanged', + 'host_inheritance_to_services' => 0, + 'hosts' => 'hostName', + 'services' => 'Centreon-Server - Memory', + 'hostgroup_inheritance_to_services' => 1, + 'hostgroups' => 'Networks', + 'servicegroups' => 'serviceGroup2Name', + 'metaservices' => 'metaService2Name' + ); + + /** + * @Given an escalation is configured + */ + public function anEscalationIsConfigured() + { + $this->currentPage = new HostConfigurationPage($this); + $this->currentPage->setProperties($this->host); + $this->currentPage->save(); + $this->currentPage = new MetaServiceConfigurationPage($this); + $this->currentPage->setProperties($this->metaService1); + $this->currentPage->save(); + $this->currentPage = new MetaServiceConfigurationPage($this); + $this->currentPage->setProperties($this->metaService2); + $this->currentPage->save(); + $this->currentPage = new ServiceGroupConfigurationPage($this); + $this->currentPage->setProperties($this->serviceGroup1); + $this->currentPage->save(); + $this->currentPage = new ServiceGroupConfigurationPage($this); + $this->currentPage->setProperties($this->serviceGroup2); + $this->currentPage->save(); + $this->currentPage = new EscalationConfigurationPage($this); + $this->currentPage->setProperties($this->initialProperties); + $this->currentPage->save(); + } + + /** + * @When I change the properties of an escalation + */ + public function iChangeThePropertiesOfAnEscalation() + { + $this->currentPage = new EscalationConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['name']); + $this->currentPage->setProperties($this->updatedProperties); + $this->currentPage->save(); + } + + /** + * @Then the properties are updated + */ + public function thePropertiesAreUpdated() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new EscalationConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->updatedProperties['name']); + $object = $this->currentPage->getProperties(); + foreach ($this->updatedProperties as $key => $value) { + if ($value != $object[$key]) { + if (is_array($value)) { + $value = implode(' ', $value); + } + if ($value != $object[$key]) { + $this->tableau[] = $key; + } + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I duplicate an escalation + */ + public function iDuplicateAnEscalation() + { + $this->currentPage = new EscalationConfigurationListingPage($this); + $object = $this->currentPage->getEntry($this->initialProperties['name']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Duplicate'); + } + + /** + * @Then the new escalation has the same properties + */ + public function theNewEscalationHasTheSameProperties() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new EscalationConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['name'] . '_1'); + $object = $this->currentPage->getProperties(); + foreach ($this->initialProperties as $key => $value) { + if ($key != 'name' && $value != $object[$key]) { + if (is_array($value)) { + $value = implode(' ', $value); + } + if ($value != $object[$key]) { + $this->tableau[] = $key; + } + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I delete an escalation + */ + public function iDeleteAnEscalation() + { + $this->currentPage = new EscalationConfigurationListingPage($this); + $object = $this->currentPage->getEntry($this->initialProperties['name']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Delete'); + } + + /** + * @Then the deleted escalation is not displayed in the list + */ + public function theDeletedEscalationIsNotDisplayedInTheList() + { + $this->spin( + function ($context) { + $this->currentPage = new EscalationConfigurationListingPage($this); + $object = $this->currentPage->getEntries(); + $bool = true; + foreach ($object as $value) { + $bool = $bool && $value['service'] != $this->initialProperties['name']; + } + return $bool; + }, + "The service is not being deleted.", + 5 + ); + } +} From 624a43e9e939782e799a9262bade07691bd91836 Mon Sep 17 00:00:00 2001 From: loiclau Date: Tue, 8 Aug 2017 16:17:01 +0200 Subject: [PATCH 136/207] * fix duplicate host service dependencies --- .../configObject/host_dependency/DB-Func.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/www/include/configuration/configObject/host_dependency/DB-Func.php b/www/include/configuration/configObject/host_dependency/DB-Func.php index 19c28ec3068..2e971f3a61b 100644 --- a/www/include/configuration/configObject/host_dependency/DB-Func.php +++ b/www/include/configuration/configObject/host_dependency/DB-Func.php @@ -119,6 +119,20 @@ function multipleHostDependencyInDB($dependencies = array(), $nbrDup = array()) $DBRESULT = $pearDB->query("SELECT MAX(dep_id) FROM dependency"); $maxId = $DBRESULT->fetchRow(); if (isset($maxId["MAX(dep_id)"])) { + + $query = "SELECT service_service_id, host_host_id FROM dependency_serviceChild_relation " . + "WHERE dependency_dep_id = " . $key; + $DBRESULT = $pearDB->query($query); + $fields["dep_serviceChilds"] = ""; + while ($service = $DBRESULT->fetchRow()) { + $query = "INSERT INTO dependency_serviceChild_relation VALUES ('', '" . + $maxId["MAX(dep_id)"] . "', '" . $service["service_service_id"] . "', '" . + $service["host_host_id"] . "')"; + $pearDB->query($query); + $fields["dep_serviceChilds"] .= $service["host_host_id"] . + '-' . $service["service_service_id"] . ","; + } + $query = "SELECT DISTINCT host_host_id FROM dependency_hostParent_relation " . "WHERE dependency_dep_id = '" . $key . "'"; $DBRESULT = $pearDB->query($query); From e2000bb4585c0d118ad087d28795424bd758c65c Mon Sep 17 00:00:00 2001 From: mariegallardo Date: Tue, 8 Aug 2017 16:43:22 +0200 Subject: [PATCH 137/207] New feature MetaServiceConfiguration (#5496) * New feature MetaServiceConfiguration * Feature enhanced * Feature fixed * * fix duplicate host service dependencies --- behat.yml | 5 + features/MetaServiceConfiguration.feature | 20 ++ .../MetaServiceConfigurationContext.php | 206 ++++++++++++++++++ 3 files changed, 231 insertions(+) create mode 100644 features/MetaServiceConfiguration.feature create mode 100644 features/bootstrap/MetaServiceConfigurationContext.php diff --git a/behat.yml b/behat.yml index 61b9bec7dfb..d70c8814f54 100644 --- a/behat.yml +++ b/behat.yml @@ -303,3 +303,8 @@ default: paths: [ %paths.base%/features/EscalationConfiguration.feature ] contexts: - EscalationConfigurationContext + + meta_service_configuration: + paths: [ %paths.base%/features/MetaServiceConfiguration.feature ] + contexts: + - MetaServiceConfigurationContext diff --git a/features/MetaServiceConfiguration.feature b/features/MetaServiceConfiguration.feature new file mode 100644 index 00000000000..c9a1a58c6b1 --- /dev/null +++ b/features/MetaServiceConfiguration.feature @@ -0,0 +1,20 @@ +Feature: Edit a meta service + As a Centreon user + I want to manipulate a meta service + To see if all simples manipulations work + + Background: + Given I am logged in a Centreon server + And a meta service is configured + + Scenario: Change the properties of a meta service + When I change the properties of a meta service + Then the properties are updated + + Scenario: Duplicate one existing meta service + When I duplicate a meta service + Then the new meta service has the same properties + + Scenario: Delete one existing meta service + When I delete a meta service + Then the deleted meta service is not displayed in the list diff --git a/features/bootstrap/MetaServiceConfigurationContext.php b/features/bootstrap/MetaServiceConfigurationContext.php new file mode 100644 index 00000000000..31ba533720b --- /dev/null +++ b/features/bootstrap/MetaServiceConfigurationContext.php @@ -0,0 +1,206 @@ + 'metaServiceName', + 'output_format' => 'metaServiceOutputFormat', + 'warning_level' => 75, + 'critical_level' => 90, + 'calculation_type' => 'Sum', + 'data_source_type' => 'ABSOLUTE', + 'selection_mode' => 2, + 'sql_like_clause_expression' => 'metaServiceExpression', + 'metric' => '', + 'check_period' => 'workhours', + 'max_check_attempts' => 10, + 'normal_check_interval' => 15, + 'retry_check_interval' => 5, + 'notification_enabled' => 1, + 'contacts' => 'User', + 'contact_groups' => 'Guest', + 'notification_interval' => 34, + 'notification_period' => 'none', + 'notification_on_warning' => 1, + 'notification_on_unknown' => 0, + 'notification_on_critical' => 1, + 'notification_on_recovery' => 0, + 'notification_on_flapping' => 1, + 'geo_coordinates' => 'Paris', + 'graph_template' => 'Latency', + 'enabled' => 1, + 'comments' => 'metaServiceComments' + ); + + protected $updatedProperties = array( + 'name' => 'metaServiceNameChanged', + 'output_format' => 'metaServiceOutputFormatChanged', + 'warning_level' => 50, + 'critical_level' => 75, + 'calculation_type' => 'Max', + 'data_source_type' => 'COUNTER', + 'selection_mode' => 1, + 'sql_like_clause_expression' => 'metaServiceExpressionChanged', + 'metric' => '', + 'check_period' => 'nonworkhours', + 'max_check_attempts' => 5, + 'normal_check_interval' => 10, + 'retry_check_interval' => 20, + 'notification_enabled' => 2, + 'contacts' => 'Guest', + 'contact_groups' => 'Supervisors', + 'notification_interval' => 12, + 'notification_period' => '24x7', + 'notification_on_warning' => 0, + 'notification_on_unknown' => 1, + 'notification_on_critical' => 0, + 'notification_on_recovery' => 1, + 'notification_on_flapping' => 0, + 'geo_coordinates' => '1.2.3.4', + 'graph_template' => 'Memory', + 'enabled' => 1, + 'comments' => 'metaServiceCommentsChanged' + ); + + /** + * @Given a meta service is configured + */ + public function aMetaServiceIsConfigured() + { + $this->currentPage = new MetaServiceConfigurationPage($this); + $this->currentPage->setProperties($this->initialProperties); + $this->currentPage->save(); + } + + /** + * @When I change the properties of a meta service + */ + public function iChangeThePropertiesOfAMetaService() + { + $this->currentPage = new MetaServiceConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['name']); + $this->currentPage->setProperties($this->updatedProperties); + $this->currentPage->save(); + } + + /** + * @Then the properties are updated + */ + public function thePropertiesAreUpdated() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new MetaServiceConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->updatedProperties['name']); + $object = $this->currentPage->getProperties(); + foreach ($this->updatedProperties as $key => $value) { + if ($value != $object[$key]) { + if (is_array($value)) { + $value = implode(' ', $value); + } + if ($value != $object[$key]) { + $this->tableau[] = $key; + } + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I duplicate a meta service + */ + public function iDuplicateAMetaService() + { + $this->currentPage = new MetaServiceConfigurationListingPage($this); + $object = $this->currentPage->getEntry($this->initialProperties['name']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Duplicate'); + } + + /** + * @Then the new meta service has the same properties + */ + public function theNewMetaServiceHasTheSameProperties() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new MetaServiceConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['name'] . '_1'); + $object = $this->currentPage->getProperties(); + foreach ($this->initialProperties as $key => $value) { + if ($value != $object[$key] && $key != 'name') { + if (is_array($value)) { + $value = implode(' ', $value); + } + if ($value != $object[$key]) { + $this->tableau[] = $key; + } + } + if ($key == 'name'&& $value . '_1' != $object[$key]) { + $this->tableau[] = $key; + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I delete a meta service + */ + public function iDeleteAMetaService() + { + $this->currentPage = new MetaServiceConfigurationListingPage($this); + $object = $this->currentPage->getEntry($this->initialProperties['name']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Delete'); + } + + /** + * @Then the deleted meta service is not displayed in the list + */ + public function theDeletedMetaServiceIsNotDisplayedInTheList() + { + $this->spin( + function ($context) { + $this->currentPage = new MetaServiceConfigurationListingPage($this); + $object = $this->currentPage->getEntries(); + $bool = true; + foreach ($object as $host => $service) { + foreach ($service as $value) { + $bool = $bool && $value['name'] != $this->initialProperties['name']; + } + } + return $bool; + }, + "The meta service is not being deleted.", + 5 + ); + } +} From d95c522f598c824d8db76e2500ebb76a37018b32 Mon Sep 17 00:00:00 2001 From: mariegallardo Date: Tue, 8 Aug 2017 17:35:47 +0200 Subject: [PATCH 138/207] Feature updated ContactGroupConfiguration (#5501) * Feature updated * File updated --- behat.yml | 15 +-- features/ContactGroupConfiguration.feature | 10 +- .../ContactGroupCreationDuplication.feature | 21 ---- .../ContactGroupConfigurationContext.php | 96 ++++++++++++--- ...ContactGroupCreationDuplicationContext.php | 110 ------------------ 5 files changed, 95 insertions(+), 157 deletions(-) delete mode 100644 features/ContactGroupCreationDuplication.feature delete mode 100644 features/bootstrap/ContactGroupCreationDuplicationContext.php diff --git a/behat.yml b/behat.yml index d70c8814f54..ea126e8a0cb 100644 --- a/behat.yml +++ b/behat.yml @@ -179,6 +179,11 @@ default: contexts: - ContactConfigurationContext + contact_group_configuration: + paths: [ %paths.base%/features/ContactGroupConfiguration.feature ] + contexts: + - ContactGroupConfigurationContext + host_configuration: paths: [ %paths.base%/features/HostConfiguration.feature ] contexts: @@ -194,16 +199,6 @@ default: contexts: - HostGroupConfigurationContext - contact_group_configuration: - paths: [ %paths.base%/features/ContactGroupConfiguration.feature ] - contexts: - - ContactGroupConfigurationContext - - contact_group_creation_duplication: - paths: [ %paths.base%/features/ContactGroupCreationDuplication.feature ] - contexts: - - ContactGroupCreationDuplicationContext - ldap_configuration: paths: [ %paths.base%/features/LdapConfiguration.feature ] contexts: diff --git a/features/ContactGroupConfiguration.feature b/features/ContactGroupConfiguration.feature index 8139550e88a..4df73b5de3a 100644 --- a/features/ContactGroupConfiguration.feature +++ b/features/ContactGroupConfiguration.feature @@ -7,6 +7,14 @@ Feature: ContactGroupConfiguration Given I am logged in a Centreon server And a contact group is configured - Scenario: Edit a contact group + Scenario: Change the properties of a contact group When I update the contact group properties Then the contact group properties are updated + + Scenario: Duplicate one existing contact group + When I duplicate a contact group + Then the new contact group has the same properties + + Scenario: Delete one existing contact group + When I delete a contact group + Then the deleted contact group is not displayed in the list diff --git a/features/ContactGroupCreationDuplication.feature b/features/ContactGroupCreationDuplication.feature deleted file mode 100644 index e0e73bd8d65..00000000000 --- a/features/ContactGroupCreationDuplication.feature +++ /dev/null @@ -1,21 +0,0 @@ -Feature: ContactGroupCreationDuplication - As a Centreon admin user - I want to create a contact group - To duplicate and delete it - - Background: - Given I am logged in a Centreon server - - Scenario: Create a contact group - When I create a contact group - Then the new record is displayed in the contact groups list - - Scenario: Duplication of a contact group - Given a contact group is configured - When I duplicate a contact group - Then the new contact group is displayed in the contact groups list - - Scenario: Delete a contact group - Given a contact group is configured - When I delete a contact group - Then the deleted contact group is not displayed in the contact groups list diff --git a/features/bootstrap/ContactGroupConfigurationContext.php b/features/bootstrap/ContactGroupConfigurationContext.php index 0a56d9c44ae..8e626c51dd1 100644 --- a/features/bootstrap/ContactGroupConfigurationContext.php +++ b/features/bootstrap/ContactGroupConfigurationContext.php @@ -3,7 +3,6 @@ use Centreon\Test\Behat\CentreonContext; use Centreon\Test\Behat\Configuration\ContactGroupsConfigurationPage; use Centreon\Test\Behat\Configuration\ContactGroupConfigurationListingPage; -use Centreon\Test\Behat\Configuration\ContactConfigurationPage; use Centreon\Test\Behat\Administration\ACLGroupConfigurationPage; class ContactGroupConfigurationContext extends CentreonContext @@ -13,14 +12,16 @@ class ContactGroupConfigurationContext extends CentreonContext protected $initialProperties = array( 'name' => 'contactGroupName', 'alias' => 'contactGroupAlias', - 'status' => 0, + 'contacts' => 'Guest', + 'acl' => 'ALL', + 'status' => 1, 'comments' => 'contactGroupComment' ); protected $updatedProperties = array( 'name' => 'contactGroupNameChanged', 'alias' => 'contactGroupAliasChanged', - 'contacts' => 'contactName', + 'contacts' => 'User', 'acl' => 'aclGroupName', 'status' => 1, 'comments' => 'contactGroupCommentChanged' @@ -31,15 +32,6 @@ class ContactGroupConfigurationContext extends CentreonContext 'group_alias' => 'aclGroupAlias' ); - protected $contact = array( - 'name' => 'contactName', - 'alias' => 'contactAlias', - 'email' => 'contact@localhost', - 'password' => 'pwd', - 'password2' => 'pwd', - 'admin' => 0 - ); - /** * @Given a contact group is configured */ @@ -55,9 +47,6 @@ public function aContactGroupIsConfigured() */ public function iConfigureTheContactGroupProperties() { - $this->currentPage = new ContactConfigurationPage($this); - $this->currentPage->setProperties($this->contact); - $this->currentPage->save(); $this->currentPage = new ACLGroupConfigurationPage($this); $this->currentPage->setProperties($this->aclGroup); $this->currentPage->save(); @@ -93,4 +82,81 @@ function ($context) { throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); } } + + /** + * @When I duplicate a contact group + */ + public function iDuplicateAContactGroup() + { + $this->currentPage = new ContactGroupConfigurationListingPage($this); + $object = $this->currentPage->getEntry($this->initialProperties['name']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Duplicate'); + } + + /** + * @Then the new contact group has the same properties + */ + public function theNewContactGroupHasTheSameProperties() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new ContactGroupConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['name'] . '_1'); + $object = $this->currentPage->getProperties(); + foreach ($this->initialProperties as $key => $value) { + if ($key != 'name' && $value != $object[$key]) { + if (is_array($value)) { + $value = implode(' ', $value); + } + if ($value != $object[$key]) { + $this->tableau[] = $key; + } + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I delete a contact group + */ + public function iDeleteAContactGroup() + { + $this->currentPage = new ContactGroupConfigurationListingPage($this); + $object = $this->currentPage->getEntry($this->initialProperties['name']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Delete'); + } + + /** + * @Then the deleted contact group is not displayed in the list + */ + public function theDeletedContactGroupIsNotDisplayedInTheList() + { + $this->spin( + function ($context) { + $this->currentPage = new ContactGroupConfigurationListingPage($this); + $object = $this->currentPage->getEntries(); + $bool = true; + foreach ($object as $value) { + $bool = $bool && $value['name'] != $this->initialProperties['name']; + } + return $bool; + }, + "The service is not being deleted.", + 5 + ); + } } diff --git a/features/bootstrap/ContactGroupCreationDuplicationContext.php b/features/bootstrap/ContactGroupCreationDuplicationContext.php deleted file mode 100644 index af937d29083..00000000000 --- a/features/bootstrap/ContactGroupCreationDuplicationContext.php +++ /dev/null @@ -1,110 +0,0 @@ -contactGroupName = 'contactGroupName'; - $this->contactGroupAlias = 'contactGroupAlias'; - } - - /** - * @When I create a contact group - */ - public function iCreateAContactGroup() - { - $this->aContactGroupIsConfigured(); - } - - /** - * @Then the new record is displayed in the contact groups list - */ - public function theNewRecordIsDisplayedInTheContactGroupList() - { - $this->currentPage = new ContactGroupConfigurationListingPage($this); - $this->currentPage->getEntry($this->contactGroupName); - } - - /** - * @Given a contact group is configured - */ - public function aContactGroupIsConfigured() - { - $this->currentPage = new ContactGroupsConfigurationPage($this); - $this->currentPage->setProperties(array( - 'name' => $this->contactGroupName, - 'alias' => $this->contactGroupAlias, - 'status' => 1 - )); - $this->currentPage->save(); - } - - /** - * @When I duplicate a contact group - */ - public function iDuplicateAContactGroup() - { - $this->currentPage = new ContactGroupConfigurationListingPage($this); - $object = $this->currentPage->getEntry($this->contactGroupName); - $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); - $this->setConfirmBox(true); - $this->selectInList('select[name="o1"]', 'Duplicate'); - } - - /** - * @Then the new contact group is displayed in the contact groups list - */ - public function theNewContactGroupIsDisplayedInTheContactGroupList() - { - $this->spin( - function ($context) { - $this->currentPage = new ContactGroupConfigurationListingPage($this); - return $this->currentPage->getEntry($this->contactGroupName . '_1'); - }, - "The duplicated contact group was not found.", - 30 - ); - } - - /** - * @When I delete a contact group - */ - public function iDeleteAContactGroup() - { - $this->currentPage = new ContactGroupConfigurationListingPage($this); - $object = $this->currentPage->getEntry($this->contactGroupName); - $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); - $this->setConfirmBox(true); - $this->selectInList('select[name="o1"]', 'Delete'); - } - - /** - * @Then the deleted contact group is not displayed in the contact groups list - */ - public function theDeletedContactGroupIsNotDisplayedInTheUserList() - { - $this->spin( - function ($context) { - $this->currentPage = new ContactGroupConfigurationListingPage($this); - $object = $this->currentPage->getEntries(); - $bool = true; - foreach ($object as $value) { - $bool = $bool && $value['name'] != $this->contactGroupName; - } - return $bool; - }, - "The contact group was not deleted.", - 30 - ); - } -} From 8e4179d4be665bc8054ec4f1983b7206089fba73 Mon Sep 17 00:00:00 2001 From: mariegallardo Date: Tue, 8 Aug 2017 17:38:19 +0200 Subject: [PATCH 139/207] Feature enhanced: ContactConfiguration (#5498) * Feature enhanced * Features fixed --- features/ContactConfiguration.feature | 12 +- .../bootstrap/ContactConfigurationContext.php | 201 ++++++++++++++++-- 2 files changed, 192 insertions(+), 21 deletions(-) diff --git a/features/ContactConfiguration.feature b/features/ContactConfiguration.feature index a8936767e51..b48ae12fa96 100644 --- a/features/ContactConfiguration.feature +++ b/features/ContactConfiguration.feature @@ -5,8 +5,16 @@ Feature: ContactConfiguration Background: Given I am logged in a Centreon server + And a contact is configured - Scenario: Edit a contact - Given a contact is configured + Scenario: Change the properties of a contact When I update contact properties Then the contact properties are updated + + Scenario: Duplicate one existing contact + When I duplicate a contact + Then the new contact has the same properties + + Scenario: Delete one existing contact + When I delete a contact + Then the deleted contact is not displayed in the list diff --git a/features/bootstrap/ContactConfigurationContext.php b/features/bootstrap/ContactConfigurationContext.php index 9a4f31c2af4..90c9c8f61dc 100644 --- a/features/bootstrap/ContactConfigurationContext.php +++ b/features/bootstrap/ContactConfigurationContext.php @@ -2,30 +2,99 @@ use Centreon\Test\Behat\CentreonContext; use Centreon\Test\Behat\Configuration\ContactConfigurationPage; use Centreon\Test\Behat\Configuration\ContactConfigurationListingPage; -use Centreon\Test\Behat\External\ListingPage; class ContactConfigurationContext extends CentreonContext { private $currentPage; + private $initialProperties = array( 'name' => 'contactName', 'alias' => 'contactAlias', 'email' => 'contact@localhost', + 'pager' => 'contactPager', + 'contact_template' => 'contact_template', + 'contact_groups' => 'Supervisors', + 'notifications_enabled' => 1, + 'host_notify_on_down' => 0, + 'host_notify_on_unreachable' => 0, + 'host_notify_on_recovery' => 0, + 'host_notify_on_flapping' => 0, + 'host_notify_on_downtime_scheduled' => 0, + 'host_notify_on_none' => 1, + 'host_notification_period' => '24x7', + 'host_notification_command' => 'service-notify-by-email', + 'service_notify_on_none' => 0, + 'service_notify_on_warning' => 1, + 'service_notify_on_unknown' => 1, + 'service_notify_on_critical' => 1, + 'service_notify_on_recovery' => 1, + 'service_notify_on_flapping' => 1, + 'service_notify_on_downtime_scheduled' => 1, + 'service_notification_period' => 'none', + 'service_notification_command' => 'host-notify-by-email', + 'access' => 0, 'password' => 'contactpwd', 'password2' => 'contactpwd', - 'admin' => 0, - 'dn' => 'contactDN', - 'host_notification_period' => 'workhours', - 'service_notification_period' => 'nonworkhours' + 'language' => 'en_US', + 'location' => 'America/Guadeloupe', + 'autologin_key' => 'contactAutologinKey', + 'authentication_source' => 'Centreon', + 'admin' => 1, + 'reach_API' => 1, + 'acl_groups' => 'ALL', + 'address1' => '1@localhost', + 'address2' => '2@localhost', + 'address3' => '3@localhost', + 'address4' => '4@localhost', + 'address5' => '5@localhost', + 'address6' => '6@localhost', + 'enabled' => 1, + 'comments' => 'contactComments' ); + private $updatedProperties = array( 'name' => 'modifiedName', 'alias' => 'modifiedAlias', 'email' => 'modified@localhost', - 'admin' => 1, - 'dn' => 'modifiedDn', - 'host_notification_period' => 'workhours', - 'service_notification_period' => 'nonworkhours' + 'pager' => 'modifiedContactPager', + 'contact_template' => 'contact_template', + 'contact_groups' => 'Guest', + 'notifications_enabled' => 0, + 'host_notify_on_none' => 0, + 'host_notify_on_down' => 1, + 'host_notify_on_unreachable' => 1, + 'host_notify_on_recovery' => 1, + 'host_notify_on_flapping' => 1, + 'host_notify_on_downtime_scheduled' => 1, + 'host_notification_period' => 'nonworkhours', + 'host_notification_command' => 'service-notify-by-epager', + 'service_notify_on_warning' => 0, + 'service_notify_on_unknown' => 0, + 'service_notify_on_critical' => 0, + 'service_notify_on_recovery' => 0, + 'service_notify_on_flapping' => 0, + 'service_notify_on_downtime_scheduled' => 0, + 'service_notify_on_none' => 1, + 'service_notification_period' => 'workhours', + 'service_notification_command' => 'service-notify-by-jabber', + 'access' => 1, + 'password' => 'contactpwd2', + 'password2' => 'contactpwd2', + 'language' => 'Detection by browser', + 'location' => 'Europe/Paris', + 'autologin_key' => 'modifiedContactAutologinKey', + 'authentication_source' => 'Centreon', + 'admin' => 0, + 'reach_API' => 0, + 'acl_groups' => '', + 'address1' => '7@localhost', + 'address2' => '8@localhost', + 'address3' => '9@localhost', + 'address4' => '10@localhost', + 'address5' => '11@localhost', + 'address6' => '12@localhost', + 'enabled' => 1, + 'comments' => 'modifiedContactComments' ); /** @@ -54,17 +123,111 @@ public function iUpdateContactProperties() */ public function theContactPropertiesAreUpdated() { - $this->currentPage = new ContactConfigurationListingPage($this); - $this->currentPage = $this->currentPage->inspect($this->updatedProperties['alias']); - $object = $this->currentPage->getProperties(); - $tableau = array(); - foreach ($this->updatedProperties as $key => $value) { - if ($value != $object[$key]) { - $tableau[] = $key; - } + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new ContactConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->updatedProperties['alias']); + $object = $this->currentPage->getProperties(); + foreach ($this->updatedProperties as $key => $value) { + if ($key != 'password' && $key != 'password2') { + if ($key != 'password' && $key != 'password2' && $value != $object[$key]) { + $this->tableau[] = $key; + } + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); } - if (count($tableau) > 0) { - throw new \Exception("Some properties are not being updated : " . implode(',', $tableau)); + } + + /** + * @When I duplicate a contact + */ + public function iDuplicateAContact() + { + $this->currentPage = new ContactConfigurationListingPage($this); + $object = $this->currentPage->getEntry($this->initialProperties['alias']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Duplicate'); + } + + /** + * @Then the new contact has the same properties + */ + public function theNewContactHasTheSameProperties() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new ContactConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['alias'] . '_1'); + $object = $this->currentPage->getProperties(); + foreach ($this->initialProperties as $key => $value) { + if ($key != 'password' && $key != 'password2') { + if ($key != 'name' && $key != 'alias' && $value != $object[$key]) { + if (is_array($value)) { + $value = implode(' ', $value); + } + if ($value != $object[$key]) { + $this->tableau[] = $key; + + } + } + if (($key == 'name' || $key == 'alias') && $value . '_1' != $object[$key]) { + $this->tableau[] = $key; + } + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); } } + + /** + * @When I delete a contact + */ + public function iDeleteAContact() + { + $this->currentPage = new ContactConfigurationListingPage($this); + $object = $this->currentPage->getEntry($this->initialProperties['alias']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Delete'); + } + + /** + * @Then the deleted contact is not displayed in the list + */ + public function theDeletedContactIsNotDisplayedInTheList() + { + $this->spin( + function ($context) { + $this->currentPage = new ContactConfigurationListingPage($this); + $object = $this->currentPage->getEntries(); + $bool = true; + foreach ($object as $value) { + $bool = $bool && $value['name'] != $this->initialProperties['name']; + } + return $bool; + }, + "The service is not being deleted.", + 5 + ); + } } From 09ca80c3f48b5f538185438c0ccc93b0fd190eca Mon Sep 17 00:00:00 2001 From: mariegallardo Date: Tue, 8 Aug 2017 17:50:36 +0200 Subject: [PATCH 140/207] Feature service configuration (#5482) * New Features began * File updated" * File finished' * File updated * * #5497 duplicate acl --- behat.yml | 20 +- features/ServiceConfiguration.feature | 20 + .../bootstrap/ServiceConfigurationContext.php | 447 ++++++++++++++++++ 3 files changed, 482 insertions(+), 5 deletions(-) create mode 100644 features/ServiceConfiguration.feature create mode 100644 features/bootstrap/ServiceConfigurationContext.php diff --git a/behat.yml b/behat.yml index ea126e8a0cb..48d2aea639a 100644 --- a/behat.yml +++ b/behat.yml @@ -179,11 +179,6 @@ default: contexts: - ContactConfigurationContext - contact_group_configuration: - paths: [ %paths.base%/features/ContactGroupConfiguration.feature ] - contexts: - - ContactGroupConfigurationContext - host_configuration: paths: [ %paths.base%/features/HostConfiguration.feature ] contexts: @@ -199,6 +194,16 @@ default: contexts: - HostGroupConfigurationContext + contact_group_configuration: + paths: [ %paths.base%/features/ContactGroupConfiguration.feature ] + contexts: + - ContactGroupConfigurationContext + + contact_group_creation_duplication: + paths: [ %paths.base%/features/ContactGroupCreationDuplication.feature ] + contexts: + - ContactGroupCreationDuplicationContext + ldap_configuration: paths: [ %paths.base%/features/LdapConfiguration.feature ] contexts: @@ -279,6 +284,11 @@ default: contexts: - ServiceGroupConfigurationContext + service_configuration: + paths: [ %paths.base%/features/ServiceConfiguration.feature ] + contexts: + - ServiceConfigurationContext + host_group_service_configuration: paths: [ %paths.base%/features/HostGroupServiceConfiguration.feature ] contexts: diff --git a/features/ServiceConfiguration.feature b/features/ServiceConfiguration.feature new file mode 100644 index 00000000000..35187ad4890 --- /dev/null +++ b/features/ServiceConfiguration.feature @@ -0,0 +1,20 @@ +Feature: Edit a service + As a Centreon user + I want to manipulate a service + To see if all simples manipulations work + + Background: + Given I am logged in a Centreon server + And a service is configured + + Scenario: Change the properties of a service + When I change the properties of a service + Then the properties are updated + + Scenario: Duplicate one existing service + When I duplicate a service + Then the new service has the same properties + + Scenario: Delete one existing service + When I delete a service + Then the deleted service is not displayed in the service list diff --git a/features/bootstrap/ServiceConfigurationContext.php b/features/bootstrap/ServiceConfigurationContext.php new file mode 100644 index 00000000000..2e399bfdd0c --- /dev/null +++ b/features/bootstrap/ServiceConfigurationContext.php @@ -0,0 +1,447 @@ + 'hostName', + 'alias' => 'hostAlias', + 'address' => 'host@localhost' + ); + + protected $serviceCategory1 = array( + 'name' => 'serviceCategory1Name', + 'description' => 'serviceCategory1Description', + 'severity' => 1, + 'level' => 3, + 'icon' => ' centreon (png)' + ); + + protected $serviceCategory2 = array( + 'name' => 'serviceCategory2Name', + 'description' => 'serviceCategory2Description', + 'severity' => 1, + 'level' => 2, + 'icon' => ' centreon (png)' + ); + + protected $serviceGroup1 = array( + 'name' => 'serviceGroup1Name', + 'description' => 'serviceGroup1Description' + ); + + protected $serviceGroup2 = array( + 'name' => 'serviceGroup2Name', + 'description' => 'serviceGroup2Description' + ); + + protected $initialProperties = array( + 'hosts' => 'Centreon-Server', + 'description' => 'serviceDescription', + 'templates' => 'generic-service', + 'check_command' => 'check_http', + 'macros' => array( + 'MACRONAME' => 22 + ), + 'check_period' => 'workhours', + 'max_check_attempts' => 15, + 'normal_check_interval' => 7, + 'retry_check_interval' => 9, + 'active_checks_enabled' => 2, + 'passive_checks_enabled' => 1, + 'is_volatile' => 0, + 'notifications_enabled' => 2, + 'inherits_contacts_groups' => 0, + 'contacts' => 'Guest', + 'contact_additive_inheritance' => 1, + 'contact_groups' => 'Supervisors', + 'contact_group_additive_inheritance' => 1, + 'notification_interval' => 23, + 'notify_on_none' => 1, + 'notify_on_warning' => 0, + 'notify_on_unknown' => 0, + 'notify_on_critical' => 0, + 'notify_on_recovery' => 0, + 'notify_on_flapping' => 0, + 'notify_on_downtime_scheduled' => 0, + 'first_notification_delay' => 4, + 'recovery_notification_delay' => 3, + 'service_groups' => 'serviceGroup1Name', + 'trap_relations' => 'Generic - coldStart', + 'obsess_over_service' => 2, + 'acknowledgement_timeout' => 34, + 'check_freshness' => 1, + 'freshness_threshold' => 22, + 'flap_detection_enabled' => 0, + 'low_flap_threshold' => 15, + 'high_flap_threshold' => 18, + 'retain_status_information' => 2, + 'retain_non_status_information' => 1, + 'stalking_on_ok' => 1, + 'stalking_on_warning' => 1, + 'stalking_on_unknown' => 0, + 'stalking_on_critical' => 0, + 'event_handler_enabled' => 0, + 'event_handler' => 'check_https', + 'event_handler_arguments' => 'eventHandlerArgument', + 'graph_template' => 'CPU', + 'service_categories' => 'Disk', + 'url' => 'serviceUrl', + 'notes' => 'serviceNotes', + 'action_url' => 'serviceActionUrl', + 'icon' => ' centreon (png)', + 'alt_icon' => 'serviceAltIcon', + 'severity' => 'serviceCategory2Name (2)', + 'geo_coordinates' => 'Paris', + 'status' => 1, + 'comments' => 'serviceComments' + ); + + protected $duplicatedProperties = array( + 'hosts' => 'Centreon-Server', + 'description' => 'serviceDescription_1', + 'templates' => 'generic-service', + 'check_command' => 'check_http', + 'macros' => array( + 'MACRONAME' => 22 + ), + 'check_period' => 'workhours', + 'max_check_attempts' => 15, + 'normal_check_interval' => 7, + 'retry_check_interval' => 9, + 'active_checks_enabled' => 2, + 'passive_checks_enabled' => 1, + 'is_volatile' => 0, + 'notifications_enabled' => 2, + 'inherits_contacts_groups' => 0, + 'contacts' => 'Guest', + 'contact_additive_inheritance' => 1, + 'contact_groups' => 'Supervisors', + 'contact_group_additive_inheritance' => 1, + 'notification_interval' => 23, + 'notify_on_none' => 1, + 'notify_on_warning' => 0, + 'notify_on_unknown' => 0, + 'notify_on_critical' => 0, + 'notify_on_recovery' => 0, + 'notify_on_flapping' => 0, + 'notify_on_downtime_scheduled' => 0, + 'first_notification_delay' => 4, + 'recovery_notification_delay' => 3, + 'service_groups' => 'serviceGroup1Name', + 'trap_relations' => 'coldStart', + 'obsess_over_service' => 2, + 'acknowledgement_timeout' => 34, + 'check_freshness' => 1, + 'freshness_threshold' => 22, + 'flap_detection_enabled' => 0, + 'low_flap_threshold' => 15, + 'high_flap_threshold' => 18, + 'retain_status_information' => 2, + 'retain_non_status_information' => 1, + 'stalking_on_ok' => 1, + 'stalking_on_warning' => 1, + 'stalking_on_unknown' => 0, + 'stalking_on_critical' => 0, + 'event_handler_enabled' => 0, + 'event_handler' => 'check_https', + 'event_handler_arguments' => 'eventHandlerArgument', + 'graph_template' => 'CPU', + 'service_categories' => 'Disk', + 'url' => 'serviceUrl', + 'notes' => 'serviceNotes', + 'action_url' => 'serviceActionUrl', + 'icon' => ' centreon (png)', + 'alt_icon' => 'serviceAltIcon', + 'severity' => 'serviceCategory2Name (2)', + 'geo_coordinates' => 'Paris', + 'status' => 1, + 'comments' => 'serviceComments' + ); + + protected $update = array( + 'hosts' => 'hostName', + 'description' => 'serviceDescriptionChanged', + 'templates' => 'Ping-WAN', + 'check_command' => 'check_https', + 'macros' => array( + 'MACRONAMECHANGED' => 11 + ), + 'check_period' => 'none', + 'max_check_attempts' => 32, + 'normal_check_interval' => 81, + 'retry_check_interval' => 12, + 'active_checks_enabled' => 0, + 'passive_checks_enabled' => 2, + 'is_volatile' => 1, + 'notifications_enabled' => 0, + 'inherits_contacts_groups' => 1, + 'notification_interval' => 14, + 'notify_on_none' => 0, + 'notify_on_warning' => 1, + 'notify_on_unknown' => 1, + 'notify_on_critical' => 1, + 'notify_on_recovery' => 1, + 'notify_on_flapping' => 1, + 'notify_on_downtime_scheduled' => 1, + 'first_notification_delay' => 8, + 'recovery_notification_delay' => 9, + 'service_groups' => 'serviceGroup2Name', + 'trap_relations' => 'HP - snTrapL4GslbRemoteControllerUp', + 'obsess_over_service' => 0, + 'acknowledgement_timeout' => 28, + 'check_freshness' => 2, + 'freshness_threshold' => 31, + 'flap_detection_enabled' => 1, + 'low_flap_threshold' => 42, + 'high_flap_threshold' => 79, + 'retain_status_information' => 1, + 'retain_non_status_information' => 0, + 'stalking_on_ok' => 0, + 'stalking_on_warning' => 0, + 'stalking_on_unknown' => 1, + 'stalking_on_critical' => 1, + 'event_handler_enabled' => 1, + 'event_handler' => 'check_http', + 'event_handler_arguments' => 'eventHandlerArgumentChanged', + 'graph_template' => 'Storage', + 'service_categories' => 'Memory', + 'url' => 'serviceUrlChanged', + 'notes' => 'serviceNotesChanged', + 'action_url' => 'serviceActionUrlChanged', + 'icon' => '', + 'alt_icon' => 'Empty', + 'severity' => 'serviceCategory1Name (3)', + 'geo_coordinates' => '1.2.3.4', + 'status' => 1, + 'comments' => 'serviceCommentsChanged' + ); + + protected $updatedProperties = array( + 'hosts' => 'hostName', + 'description' => 'serviceDescriptionChanged', + 'templates' => 'Ping-WAN', + 'check_command' => 'check_https', + 'macros' => array( + 'MACRONAMECHANGED' => 11, + 'MACRONAME' => 22 + ), + 'check_period' => 'none', + 'max_check_attempts' => 32, + 'normal_check_interval' => 81, + 'retry_check_interval' => 12, + 'active_checks_enabled' => 0, + 'passive_checks_enabled' => 2, + 'is_volatile' => 1, + 'notifications_enabled' => 0, + 'inherits_contacts_groups' => 1, + 'contacts' => '', + 'contact_additive_inheritance' => 0, + 'contact_groups' => '', + 'contact_group_additive_inheritance' => 0, + 'notification_interval' => 14, + 'notify_on_none' => 0, + 'notify_on_warning' => 1, + 'notify_on_unknown' => 1, + 'notify_on_critical' => 1, + 'notify_on_recovery' => 1, + 'notify_on_flapping' => 1, + 'notify_on_downtime_scheduled' => 1, + 'first_notification_delay' => 8, + 'recovery_notification_delay' => 9, + 'service_groups' => 'serviceGroup2Name', + 'trap_relations' => array( + 'snTrapL4GslbRemoteControllerUp' + ), + 'obsess_over_service' => 0, + 'acknowledgement_timeout' => 28, + 'check_freshness' => 2, + 'freshness_threshold' => 31, + 'flap_detection_enabled' => 1, + 'low_flap_threshold' => 42, + 'high_flap_threshold' => 79, + 'retain_status_information' => 1, + 'retain_non_status_information' => 0, + 'stalking_on_ok' => 0, + 'stalking_on_warning' => 0, + 'stalking_on_unknown' => 1, + 'stalking_on_critical' => 1, + 'event_handler_enabled' => 1, + 'event_handler' => 'check_http', + 'event_handler_arguments' => 'eventHandlerArgumentChanged', + 'graph_template' => 'Storage', + 'service_categories' => 'Memory', + 'url' => 'serviceUrlChanged', + 'notes' => 'serviceNotesChanged', + 'action_url' => 'serviceActionUrlChanged', + 'icon' => '', + 'alt_icon' => 'Empty', + 'severity' => 'serviceCategory1Name (3)', + 'geo_coordinates' => '1.2.3.4', + 'status' => 1, + 'comments' => 'serviceCommentsChanged' + ); + + /** + * @Given a service is configured + */ + public function aServiceIsConfigured() + { + $this->currentPage = new HostConfigurationPage($this); + $this->currentPage->setProperties($this->host); + $this->currentPage->save(); + $this->currentPage = new ServiceCategoryConfigurationPage($this); + $this->currentPage->setProperties($this->serviceCategory1); + $this->currentPage->save(); + $this->currentPage = new ServiceCategoryConfigurationPage($this); + $this->currentPage->setProperties($this->serviceCategory2); + $this->currentPage->save(); + $this->currentPage = new ServiceGroupConfigurationPage($this); + $this->currentPage->setProperties($this->serviceGroup1); + $this->currentPage->save(); + $this->currentPage = new ServiceGroupConfigurationPage($this); + $this->currentPage->setProperties($this->serviceGroup2); + $this->currentPage->save(); + $this->currentPage = new ServiceConfigurationPage($this); + $this->currentPage->setProperties($this->initialProperties); + $this->currentPage->save(); + } + + /** + * @When I change the properties of a service + */ + public function iChangeThePropertiesOfAService() + { + $this->currentPage = new ServiceConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['description']); + $this->currentPage->setProperties($this->update); + $this->currentPage->save(); + } + + /** + * @Then the properties are updated + */ + public function thePropertiesAreUpdated() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new ServiceConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->updatedProperties['description']); + $object = $this->currentPage->getProperties(); + foreach ($this->updatedProperties as $key => $value) { + if ($value != $object[$key]) { + if (is_array($value)) { + $value = implode(' ', $value); + } + if ($value != $object[$key]) { + $this->tableau[] = $key; + } + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I duplicate a service + */ + public function iDuplicateAService() + { + $this->currentPage = new ServiceConfigurationListingPage($this); + $object = $this->currentPage->getEntry(array( + 'service' => $this->initialProperties['description'], + 'host' => $this->initialProperties['hosts'] + )); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Duplicate'); + } + + /** + * @Then the new service has the same properties + */ + public function theNewServiceHasTheSameProperties() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new ServiceConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->duplicatedProperties['description']); + $object = $this->currentPage->getProperties(); + foreach ($this->duplicatedProperties as $key => $value) { + if ($value != $object[$key]) { + if (is_array($value)) { + $value = implode(' ', $value); + } + if ($value != $object[$key]) { + $this->tableau[] = $key; + } + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I delete a service + */ + public function iDeleteAService() + { + $this->currentPage = new ServiceConfigurationListingPage($this); + $object = $this->currentPage->getEntry(array( + 'service' => $this->initialProperties['description'], + 'host' => $this->initialProperties['hosts'] + )); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Delete'); + } + + /** + * @Then the deleted service is not displayed in the service list + */ + public function theDeletedServiceIsNotDisplayedInTheServiceList() + { + $this->spin( + function ($context) { + $this->currentPage = new ServiceConfigurationListingPage($this); + $object = $this->currentPage->getEntries(); + $bool = true; + foreach ($object as $host => $service) { + foreach ($service as $value) { + $bool = $bool && $value['service'] != $this->initialProperties['description']; + } + } + return $bool; + }, + "The service is not being deleted.", + 5 + ); + } +} From 7bd9c7bd8575d9ec7417ff5c009f5177a6dfb707 Mon Sep 17 00:00:00 2001 From: Kevin Duret Date: Wed, 9 Aug 2017 09:58:20 +0200 Subject: [PATCH 141/207] fix search in service template select2 --- www/api/class/centreon_configuration_servicetemplate.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/api/class/centreon_configuration_servicetemplate.class.php b/www/api/class/centreon_configuration_servicetemplate.class.php index bc6eb7e6f44..807a8850421 100644 --- a/www/api/class/centreon_configuration_servicetemplate.class.php +++ b/www/api/class/centreon_configuration_servicetemplate.class.php @@ -139,7 +139,7 @@ private function listWithHostTemplate($q = '', $range = array()) 'AND hsr.service_service_id = s.service_id ' . 'AND h.host_register = "0" ' . 'AND s.service_register = "0" ' . - 'AND s.service_description LIKE :description ' . + 'AND CONCAT(h.host_name, " - ", s.service_description) LIKE :description ' . 'ORDER BY h.host_name '; if (isset($range) && !empty($range)) { $queryService .= 'LIMIT :offset, :limit'; From 2ea1a2b1e8e0bbad52f07672b7e9443f170d6aee Mon Sep 17 00:00:00 2001 From: Kevin Duret Date: Wed, 9 Aug 2017 10:11:04 +0200 Subject: [PATCH 142/207] fix search in trap select2 --- www/api/class/centreon_configuration_trap.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/api/class/centreon_configuration_trap.class.php b/www/api/class/centreon_configuration_trap.class.php index 2810ebf026f..882159e6287 100644 --- a/www/api/class/centreon_configuration_trap.class.php +++ b/www/api/class/centreon_configuration_trap.class.php @@ -69,7 +69,7 @@ public function getList() $queryTraps = 'SELECT SQL_CALC_FOUND_ROWS DISTINCT t.traps_name, t.traps_id, m.name ' . 'FROM traps t, traps_vendor m ' . 'WHERE t.manufacturer_id = m.id ' . - 'AND (t.traps_name LIKE :name OR m.name LIKE :name) ' . + 'AND CONCAT(m.name, " -", t.traps_name) LIKE :name ' . 'ORDER BY m.name, t.traps_name '; if (isset($this->arguments['page_limit']) && isset($this->arguments['page'])) { $offset = ($this->arguments['page'] - 1) * $this->arguments['page_limit']; From f50df7bd233e098e101c5e37df7c95cb50183eca Mon Sep 17 00:00:00 2001 From: Matthieu Mandoula Date: Wed, 9 Aug 2017 11:57:31 +0200 Subject: [PATCH 143/207] Service submit result (#5485) * put clipboard on app head and remove old lib tool.js * ServiceSubmitResult acceptance test initialized * "then" step missing * last step to complete * last method completed * attribute's name changed and getPropertyFromAHostAndService function name changed --- behat.yml | 11 +++ features/ServiceSubmitResult.feature | 14 ++++ .../bootstrap/ServiceSubmitResultContext.php | 73 +++++++++++++++++++ 3 files changed, 98 insertions(+) create mode 100644 features/ServiceSubmitResult.feature create mode 100644 features/bootstrap/ServiceSubmitResultContext.php diff --git a/behat.yml b/behat.yml index 48d2aea639a..70e9cc7c4a8 100644 --- a/behat.yml +++ b/behat.yml @@ -199,6 +199,11 @@ default: contexts: - ContactGroupConfigurationContext + host_duplication_check: + paths: [ %paths.base%/features/HostDuplicationCheck.feature ] + contexts: + - HostDuplicationCheckContext + contact_group_creation_duplication: paths: [ %paths.base%/features/ContactGroupCreationDuplication.feature ] contexts: @@ -313,3 +318,9 @@ default: paths: [ %paths.base%/features/MetaServiceConfiguration.feature ] contexts: - MetaServiceConfigurationContext + + + service_submit_result: + paths: [ %paths.base%/features/ServiceSubmitResult.feature ] + contexts: + - ServiceSubmitResultContext \ No newline at end of file diff --git a/features/ServiceSubmitResult.feature b/features/ServiceSubmitResult.feature new file mode 100644 index 00000000000..83cc08fc539 --- /dev/null +++ b/features/ServiceSubmitResult.feature @@ -0,0 +1,14 @@ +Feature: Submit A Result To A Passive Service + As a Centreon user + I want to force the status and output of a passive service + To launch a specific event + + Background: + Given I am logged in a Centreon server + + Scenario: Submit result to a passive service + Given one passive service has been configured using arguments status and output exists + When I submit some result to this service + Then the values are set as wanted in Monitoring > Status details page + + diff --git a/features/bootstrap/ServiceSubmitResultContext.php b/features/bootstrap/ServiceSubmitResultContext.php new file mode 100644 index 00000000000..006a4929325 --- /dev/null +++ b/features/bootstrap/ServiceSubmitResultContext.php @@ -0,0 +1,73 @@ + $this->hostname, + 'alias' => $this->hostname, + 'address' => 'localhost', + 'max_check_attempts' => 1, + 'normal_check_interval' => 1, + 'retry_check_interval' => 1, + 'active_checks_enabled' => "0", + 'passive_checks_enabled' => "1" + ); + $hostConfig->setProperties($hostProperties); + $hostConfig->save(); + + // Create service. + $serviceConfig = new ServiceConfigurationPage($this); + $serviceProperties = array( + 'description' => $this->hostservice, + 'hosts' => $this->hostname, + 'templates' => 'generic-service', + 'check_command' => 'check_centreon_dummy', + 'check_period' => '24x7', + 'active_checks_enabled' => "0", + 'passive_checks_enabled' => "1" + ); + $serviceConfig->setProperties($serviceProperties); + $serviceConfig->save(); + + // Ensure service is monitored. + $this->restartAllPollers(); + } + + /** + * @When I submit some result to this service + */ + public function iSubmitSomeResultToThisService() + { + $this->submitServiceResult($this->hostname, $this->hostservice, 2, $this->checkoutput); + } + + /** + * @Then the values are set as wanted in Monitoring > Status details page + */ + public function theValuesAreSetAsWantedInMonitoringStatusDetailsPage() + { + $this->page = new MonitoringServicesPage($this); + $result = $this->page->getPropertyFromAHostAndService($this->hostname, $this->hostservice, 'status_information'); + if ($result != $this->checkoutput) { + throw new Exception('The result submitted is not set as wanted'); + } + } +} From 1618fadc7fed906872119e92bde5a0bb5f80bbb6 Mon Sep 17 00:00:00 2001 From: mariegallardo Date: Wed, 9 Aug 2017 13:24:27 +0200 Subject: [PATCH 144/207] New feature HostDependencyConfiguration (#5526) --- behat.yml | 6 +- features/HostDependencyConfiguration.feature | 20 ++ .../HostDependencyConfigurationContext.php | 209 ++++++++++++++++++ 3 files changed, 234 insertions(+), 1 deletion(-) create mode 100644 features/HostDependencyConfiguration.feature create mode 100644 features/bootstrap/HostDependencyConfigurationContext.php diff --git a/behat.yml b/behat.yml index 70e9cc7c4a8..78fdb40159f 100644 --- a/behat.yml +++ b/behat.yml @@ -323,4 +323,8 @@ default: service_submit_result: paths: [ %paths.base%/features/ServiceSubmitResult.feature ] contexts: - - ServiceSubmitResultContext \ No newline at end of file + - ServiceSubmitResultContext + host_dependency_configuration: + paths: [ %paths.base%/features/HostDependencyConfiguration.feature ] + contexts: + - HostDependencyConfigurationContext diff --git a/features/HostDependencyConfiguration.feature b/features/HostDependencyConfiguration.feature new file mode 100644 index 00000000000..3b8e08f6250 --- /dev/null +++ b/features/HostDependencyConfiguration.feature @@ -0,0 +1,20 @@ +Feature: Edit a service + As a Centreon user + I want to manipulate a host dependency + To see if all simples manipulations work + + Background: + Given I am logged in a Centreon server + And a host dependency is configured + + Scenario: Change the properties of a host dependency + When I change the properties of a host dependency + Then the properties are updated + + Scenario: Duplicate one existing host dependency + When I duplicate a host dependency + Then the new host dependency has the same properties + + Scenario: Delete one existing service + When I delete a host dependency + Then the deleted host dependency is not displayed in the list diff --git a/features/bootstrap/HostDependencyConfigurationContext.php b/features/bootstrap/HostDependencyConfigurationContext.php new file mode 100644 index 00000000000..13cd7ddafb6 --- /dev/null +++ b/features/bootstrap/HostDependencyConfigurationContext.php @@ -0,0 +1,209 @@ + 'host1Name', + 'alias' => 'host1Alias', + 'address' => 'host1@localhost' + ); + + protected $host2 = array( + 'name' => 'host2Name', + 'alias' => 'host2Alias', + 'address' => 'host2@localhost' + ); + + protected $host3 = array( + 'name' => 'host3Name', + 'alias' => 'host3Alias', + 'address' => 'host3@localhost' + ); + + protected $initialProperties = array( + 'name' => 'hostDependencyName', + 'description' => 'hostDependencyDescription', + 'parent_relationship' => 0, + 'execution_fails_on_none' => 1, + 'execution_fails_on_up' => 0, + 'execution_fails_on_down' => 0, + 'execution_fails_on_unreachable' => 0, + 'execution_fails_on_pending' => 0, + 'notification_fails_on_ok' => 1, + 'notification_fails_on_down' => 1, + 'notification_fails_on_unreachable' => 1, + 'notification_fails_on_pending' => 1, + 'notification_fails_on_none' => 0, + 'hosts' => 'Centreon-Server', + 'dependent_hosts' => 'host1Name', + 'dependent_services' => 'Centreon-Server - Memory', + 'comment' => 'hostDependencyComment' + ); + + protected $updatedProperties = array( + 'name' => 'hostDependencyNameChanged', + 'description' => 'hostDependencyDescriptionChanged', + 'parent_relationship' => 1, + 'execution_fails_on_up' => 1, + 'execution_fails_on_down' => 1, + 'execution_fails_on_unreachable' => 1, + 'execution_fails_on_pending' => 1, + 'execution_fails_on_none' => 0, + 'notification_fails_on_none' => 1, + 'notification_fails_on_ok' => 0, + 'notification_fails_on_down' => 0, + 'notification_fails_on_unreachable' => 0, + 'notification_fails_on_pending' => 0, + 'hosts' => 'host2Name', + 'dependent_hosts' => 'host3Name', + 'dependent_services' => 'Centreon-Server - Load', + 'comment' => 'hostDependencyCommentChanged' + ); + + /** + * @Given a host dependency is configured + */ + public function aHostDependencyIsConfigured() + { + $this->currentPage = new HostConfigurationPage($this); + $this->currentPage->setProperties($this->host1); + $this->currentPage->save(); + $this->currentPage = new HostConfigurationPage($this); + $this->currentPage->setProperties($this->host2); + $this->currentPage->save(); + $this->currentPage = new HostConfigurationPage($this); + $this->currentPage->setProperties($this->host3); + $this->currentPage->save(); + $this->currentPage = new HostDependencyConfigurationPage($this); + $this->currentPage->setProperties($this->initialProperties); + $this->currentPage->save(); + } + + /** + * @When I change the properties of a host dependency + */ + public function iChangeThePropertiesOfAHostDependency() + { + $this->currentPage = new HostDependencyConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['name']); + $this->currentPage->setProperties($this->updatedProperties); + $this->currentPage->save(); + } + + /** + * @Then the properties are updated + */ + public function thePropertiesAreUpdated() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new HostDependencyConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->updatedProperties['name']); + $object = $this->currentPage->getProperties(); + foreach ($this->updatedProperties as $key => $value) { + if ($value != $object[$key]) { + if (is_array($value)) { + $value = implode(' ', $value); + } + if ($value != $object[$key]) { + $this->tableau[] = $key; + } + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I duplicate a host dependency + */ + public function iDuplicateAHostDependency() + { + $this->currentPage = new HostDependencyConfigurationListingPage($this); + $object = $this->currentPage->getEntry($this->initialProperties['name']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Duplicate'); + } + + /** + * @Then the new host dependency has the same properties + */ + public function theNewHostDependencyHasTheSameProperties() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new HostDependencyConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['name'] . '_1'); + $object = $this->currentPage->getProperties(); + foreach ($this->initialProperties as $key => $value) { + if ($key != 'name' && $value != $object[$key]) { + if (is_array($value)) { + $value = implode(' ', $value); + } + if ($value != $object[$key]) { + $this->tableau[] = $key; + } + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I delete a host dependency + */ + public function iDeleteAHostDependency() + { + $this->currentPage = new HostDependencyConfigurationListingPage($this); + $object = $this->currentPage->getEntry($this->initialProperties['name']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Delete'); + } + + /** + * @Then the deleted host dependency is not displayed in the list + */ + public function theDeletedHostDependencyIsNotDisplayedInTheList() + { + $this->spin( + function ($context) { + $this->currentPage = new HostDependencyConfigurationListingPage($this); + $object = $this->currentPage->getEntries(); + $bool = true; + foreach ($object as $value) { + $bool = $bool && $value['name'] != $this->initialProperties['name']; + } + return $bool; + }, + "The service is not being deleted.", + 5 + ); + } +} From abadc538e8010e6372a9928dd3f999b12959c0a2 Mon Sep 17 00:00:00 2001 From: loiclau Date: Wed, 9 Aug 2017 15:00:29 +0200 Subject: [PATCH 145/207] * clean behat --- behat.yml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/behat.yml b/behat.yml index 78fdb40159f..c7680ac0529 100644 --- a/behat.yml +++ b/behat.yml @@ -199,16 +199,6 @@ default: contexts: - ContactGroupConfigurationContext - host_duplication_check: - paths: [ %paths.base%/features/HostDuplicationCheck.feature ] - contexts: - - HostDuplicationCheckContext - - contact_group_creation_duplication: - paths: [ %paths.base%/features/ContactGroupCreationDuplication.feature ] - contexts: - - ContactGroupCreationDuplicationContext - ldap_configuration: paths: [ %paths.base%/features/LdapConfiguration.feature ] contexts: From d83344e41017b45ed3c02f3493ef40040f7c35e4 Mon Sep 17 00:00:00 2001 From: Kevin Duret Date: Wed, 9 Aug 2017 16:53:30 +0200 Subject: [PATCH 146/207] fix select2 for trap --- www/api/class/centreon_configuration_trap.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/api/class/centreon_configuration_trap.class.php b/www/api/class/centreon_configuration_trap.class.php index 882159e6287..babb733f562 100644 --- a/www/api/class/centreon_configuration_trap.class.php +++ b/www/api/class/centreon_configuration_trap.class.php @@ -69,7 +69,7 @@ public function getList() $queryTraps = 'SELECT SQL_CALC_FOUND_ROWS DISTINCT t.traps_name, t.traps_id, m.name ' . 'FROM traps t, traps_vendor m ' . 'WHERE t.manufacturer_id = m.id ' . - 'AND CONCAT(m.name, " -", t.traps_name) LIKE :name ' . + 'AND CONCAT(m.name, " - ", t.traps_name) LIKE :name ' . 'ORDER BY m.name, t.traps_name '; if (isset($this->arguments['page_limit']) && isset($this->arguments['page'])) { $offset = ($this->arguments['page'] - 1) * $this->arguments['page_limit']; From e66be4cb20b571784e2a5f8545431de99d3a61e3 Mon Sep 17 00:00:00 2001 From: Kevin Duret Date: Thu, 10 Aug 2017 10:30:23 +0200 Subject: [PATCH 147/207] fix typo in servicegroup dependency form --- .../servicegroup_dependency/formServiceGroupDependency.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/include/configuration/configObject/servicegroup_dependency/formServiceGroupDependency.php b/www/include/configuration/configObject/servicegroup_dependency/formServiceGroupDependency.php index e4946d76957..ceebe0f8a15 100644 --- a/www/include/configuration/configObject/servicegroup_dependency/formServiceGroupDependency.php +++ b/www/include/configuration/configObject/servicegroup_dependency/formServiceGroupDependency.php @@ -204,7 +204,7 @@ $attrServicegroups, array('defaultDatasetRoute' => $query) ); -$form->addElement('select2', 'dep_sgParents', _("Linked with Servicegroups"), array(), $attrServicegroup1); +$form->addElement('select2', 'dep_sgParents', _("Servicegroups"), array(), $attrServicegroup1); $route = './include/common/webServices/rest/internal.php?object=centreon_configuration_servicegroup' . '&action=defaultValues&target=dependency&field=dep_sgChilds&id=' . $dep_id; @@ -212,7 +212,7 @@ $attrServicegroups, array('defaultDatasetRoute' => $route) ); -$form->addElement('select2', 'dep_sgChilds', _("Linked with Servicegroups"), array(), $attrServicegroup2); +$form->addElement('select2', 'dep_sgChilds', _("Dependent Servicegroups"), array(), $attrServicegroup2); $form->addElement('textarea', 'dep_comment', _("Comments"), $attrsTextarea); From 948d03bbda7f0cd58f53b91c2ab66a5f60a34c59 Mon Sep 17 00:00:00 2001 From: mariegallardo Date: Thu, 10 Aug 2017 12:43:56 +0200 Subject: [PATCH 148/207] Feature host group dependency (#5530) * Select2 fixed * New feature HostGroupDependency --- behat.yml | 6 + .../HostGroupDependencyConfiguration.feature | 20 ++ ...ostGroupDependencyConfigurationContext.php | 179 ++++++++++++++++++ .../MassiveChangeServicesContext.php | 5 +- .../ServiceGroupConfigurationContext.php | 36 +--- 5 files changed, 210 insertions(+), 36 deletions(-) create mode 100644 features/HostGroupDependencyConfiguration.feature create mode 100644 features/bootstrap/HostGroupDependencyConfigurationContext.php diff --git a/behat.yml b/behat.yml index c7680ac0529..a580f9aeee6 100644 --- a/behat.yml +++ b/behat.yml @@ -310,10 +310,16 @@ default: - MetaServiceConfigurationContext + host_group_dependency_configuration: + paths: [ %paths.base%/features/HostGroupDependencyConfiguration.feature ] + contexts: + - HostGroupDependencyConfigurationContext + service_submit_result: paths: [ %paths.base%/features/ServiceSubmitResult.feature ] contexts: - ServiceSubmitResultContext + host_dependency_configuration: paths: [ %paths.base%/features/HostDependencyConfiguration.feature ] contexts: diff --git a/features/HostGroupDependencyConfiguration.feature b/features/HostGroupDependencyConfiguration.feature new file mode 100644 index 00000000000..21b81509cc5 --- /dev/null +++ b/features/HostGroupDependencyConfiguration.feature @@ -0,0 +1,20 @@ +Feature: Edit a host group dependency + As a Centreon user + I want to manipulate a host group dependency + To see if all simples manipulations work + + Background: + Given I am logged in a Centreon server + And a host group dependency is configured + + Scenario: Change the properties of a host group dependency + When I change the properties of a host group dependency + Then the properties are updated + + Scenario: Duplicate one existing host group dependency + When I duplicate a host group dependency + Then the new object has the same properties + + Scenario: Delete one existing host group dependency + When I delete a host group dependency + Then the deleted object is not displayed in the list diff --git a/features/bootstrap/HostGroupDependencyConfigurationContext.php b/features/bootstrap/HostGroupDependencyConfigurationContext.php new file mode 100644 index 00000000000..576343050fe --- /dev/null +++ b/features/bootstrap/HostGroupDependencyConfigurationContext.php @@ -0,0 +1,179 @@ + 'hostGroupDependencyName', + 'description' => 'hostGroupDependencyAlias', + 'parent_relationship' => 0, + 'execution_fails_on_none' => 1, + 'execution_fails_on_ok' => 0, + 'execution_fails_on_down' => 0, + 'execution_fails_on_unreachable' => 0, + 'execution_fails_on_pending' => 0, + 'notification_fails_on_ok' => 1, + 'notification_fails_on_down' => 1, + 'notification_fails_on_unreachable' => 1, + 'notification_fails_on_pending' => 1, + 'notification_fails_on_none' => 0, + 'host_groups' => 'Firewall', + 'dependent_host_groups' => 'Windows-Servers', + 'comment' => 'hostGroupDependencyComment' + ); + + protected $updatedProperties = array( + 'name' => 'hostGroupDependencyNameChanged', + 'description' => 'hostGroupDependencyDescriptionChanged', + 'parent_relationship' => 1, + 'execution_fails_on_ok' => 1, + 'execution_fails_on_down' => 1, + 'execution_fails_on_unreachable' => 1, + 'execution_fails_on_pending' => 1, + 'execution_fails_on_none' => 0, + 'notification_fails_on_none' => 1, + 'notification_fails_on_ok' => 0, + 'notification_fails_on_down' => 0, + 'notification_fails_on_unreachable' => 0, + 'notification_fails_on_pending' => 0, + 'host_groups' => 'Unix-Servers', + 'dependent_host_groups' => 'Routers', + 'comment' => 'hostGroupDependencyCommentChanged' + ); + + /** + * @Given a host group dependency is configured + */ + public function aHostGroupDependencyIsConfigured() + { + $this->currentPage = new HostGroupDependencyConfigurationPage($this); + $this->currentPage->setProperties($this->initialProperties); + $this->currentPage->save(); + } + + /** + * @When I change the properties of a host group dependency + */ + public function iChangeThePropertiesOfAHostGroupDependency() + { + $this->currentPage = new HostGroupDependencyConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['name']); + $this->currentPage->setProperties($this->updatedProperties); + $this->currentPage->save(); + } + + /** + * @Then the properties are updated + */ + public function thePropertiesAreUpdated() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new HostGroupDependencyConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->updatedProperties['name']); + $object = $this->currentPage->getProperties(); + foreach ($this->updatedProperties as $key => $value) { + if ($value != $object[$key]) { + if (is_array($value)) { + $value = implode(' ', $value); + } + if ($value != $object[$key]) { + $this->tableau[] = $key; + } + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I duplicate a host group dependency + */ + public function iDuplicateAHostGroupDependency() + { + $this->currentPage = new HostGroupDependencyConfigurationListingPage($this); + $object = $this->currentPage->getEntry($this->initialProperties['name']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Duplicate'); + } + + /** + * @Then the new object has the same properties + */ + public function theNewObjectHasTheSameProperties() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new HostGroupDependencyConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['name'] . '_1'); + $object = $this->currentPage->getProperties(); + foreach ($this->initialProperties as $key => $value) { + if ($key != 'name' && $value != $object[$key]) { + if (is_array($value)) { + $value = implode(' ', $value); + } + if ($value != $object[$key]) { + $this->tableau[] = $key; + } + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I delete a host group dependency + */ + public function iDeleteAHostGroupDependency() + { + $this->currentPage = new HostGroupDependencyConfigurationListingPage($this); + $object = $this->currentPage->getEntry($this->initialProperties['name']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Delete'); + } + + /** + * @Then the deleted object is not displayed in the list + */ + public function theDeletedObjectIsNotDisplayedInTheList() + { + $this->spin( + function ($context) { + $this->currentPage = new HostGroupDependencyConfigurationListingPage($this); + $object = $this->currentPage->getEntries(); + $bool = true; + foreach ($object as $value) { + $bool = $bool && $value['name'] != $this->initialProperties['name']; + } + return $bool; + }, + "The service is not being deleted.", + 5 + ); + } +} diff --git a/features/bootstrap/MassiveChangeServicesContext.php b/features/bootstrap/MassiveChangeServicesContext.php index 48f5eb8d738..31c00f2111e 100644 --- a/features/bootstrap/MassiveChangeServicesContext.php +++ b/features/bootstrap/MassiveChangeServicesContext.php @@ -115,10 +115,7 @@ class MassiveChangeServicesContext extends CentreonContext 'update_mode_sgs' => 0, 'service_groups' => 'serviceGroupName', 'update_mode_traps' => 1, - 'trap_relations' => array( - 'Generic', - 'Generic - trapName' - ), + 'trap_relations' => 'Generic - trapName', 'obsess_over_service' => 2, 'acknowledgement_timeout' => 7, 'check_freshness' => 1, diff --git a/features/bootstrap/ServiceGroupConfigurationContext.php b/features/bootstrap/ServiceGroupConfigurationContext.php index cae9e02e250..13411d2ba51 100644 --- a/features/bootstrap/ServiceGroupConfigurationContext.php +++ b/features/bootstrap/ServiceGroupConfigurationContext.php @@ -26,40 +26,12 @@ class ServiceGroupConfigurationContext extends CentreonContext 'description' => 'serviceGroupDescription', 'hosts' => 'Centreon-Server - Memory', 'host_groups' => 'Windows-Servers - hostGroupServiceDescription1', - 'service_templates' => array( - 'Ping-LAN', - 'generic-host - Ping-LAN' - ), - 'geo_coordinates' => '1.2.3.4', - 'enabled' => 1, - 'comments' => 'serviceGroupComments' - ); - - protected $duplicatedProperties = array( - 'name' => 'serviceGroupName_1', - 'description' => 'serviceGroupDescription', - 'hosts' => 'Centreon-Server - Memory', - 'host_groups' => 'Windows-Servers - hostGroupServiceDescription1', 'service_templates' => 'generic-host - Ping-LAN', 'geo_coordinates' => '1.2.3.4', 'enabled' => 1, 'comments' => 'serviceGroupComments' ); - protected $update = array( - 'name' => 'serviceGroupNameChanged', - 'description' => 'serviceGroupDescriptionChanged', - 'hosts' => 'Centreon-Server - Load', - 'host_groups' => 'Firewall - hostGroupServiceDescription2', - 'service_templates' => array( - 'SNMP-Linux-Swap', - 'Servers-Linux - SNMP-Linux-Swap' - ), - 'geo_coordinates' => 'Paris', - 'enabled' => 1, - 'comments' => 'serviceGroupCommentsChanged' - ); - protected $updatedProperties = array( 'name' => 'serviceGroupNameChanged', 'description' => 'serviceGroupDescriptionChanged', @@ -94,7 +66,7 @@ public function iChangeThePropertiesOfAServiceGroup() { $this->currentPage = new ServiceGroupConfigurationListingPage($this); $this->currentPage = $this->currentPage->inspect($this->initialProperties['name']); - $this->currentPage->setProperties($this->update); + $this->currentPage->setProperties($this->updatedProperties); $this->currentPage->save(); } @@ -148,10 +120,10 @@ public function theNewServiceGroupHasTheSameProperties() $this->spin( function ($context) { $this->currentPage = new ServiceGroupConfigurationListingPage($this); - $this->currentPage = $this->currentPage->inspect($this->duplicatedProperties['name']); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['name'] . '_1'); $object = $this->currentPage->getProperties(); - foreach ($this->duplicatedProperties as $key => $value) { - if ($value != $object[$key]) { + foreach ($this->initialProperties as $key => $value) { + if ($key != 'name' && $value != $object[$key]) { $this->tableau[] = $key; } } From be30043a8da77e9a58ec86700b908019f1cb0278 Mon Sep 17 00:00:00 2001 From: mariegallardo Date: Thu, 10 Aug 2017 15:50:54 +0200 Subject: [PATCH 149/207] New feature serviceGroupDependency (#5537) * New feature serviceGroup * behat added * Feature corrected --- behat.yml | 5 + ...erviceGroupDependencyConfiguration.feature | 20 ++ ...iceGroupDependencyConfigurationContext.php | 238 ++++++++++++++++++ 3 files changed, 263 insertions(+) create mode 100644 features/ServiceGroupDependencyConfiguration.feature create mode 100644 features/bootstrap/ServiceGroupDependencyConfigurationContext.php diff --git a/behat.yml b/behat.yml index a580f9aeee6..c07ff8e5bd6 100644 --- a/behat.yml +++ b/behat.yml @@ -324,3 +324,8 @@ default: paths: [ %paths.base%/features/HostDependencyConfiguration.feature ] contexts: - HostDependencyConfigurationContext + + service_group_dependency_configuration: + paths: [ %paths.base%/features/ServiceGroupDependencyConfiguration.feature ] + contexts: + - ServiceGroupDependencyConfigurationContext diff --git a/features/ServiceGroupDependencyConfiguration.feature b/features/ServiceGroupDependencyConfiguration.feature new file mode 100644 index 00000000000..46ec7ba8841 --- /dev/null +++ b/features/ServiceGroupDependencyConfiguration.feature @@ -0,0 +1,20 @@ +Feature: Edit a service group dependency + As a Centreon user + I want to manipulate a service group dependency + To see if all simples manipulations work + + Background: + Given I am logged in a Centreon server + And a service group dependency + + Scenario: Change the properties of a service group dependency + When I change the properties of a service group dependency + Then the properties are updated + + Scenario: Duplicate one existing service group dependency + When I duplicate a service group dependency + Then the new object has the same properties + + Scenario: Delete one existing service group dependency + When I delete a service group dependency + Then the deleted object is not displayed in the list diff --git a/features/bootstrap/ServiceGroupDependencyConfigurationContext.php b/features/bootstrap/ServiceGroupDependencyConfigurationContext.php new file mode 100644 index 00000000000..71c5ee23010 --- /dev/null +++ b/features/bootstrap/ServiceGroupDependencyConfigurationContext.php @@ -0,0 +1,238 @@ + 'serviceGroup1Name', + 'description' => 'serviceGroup1Description' + ); + + protected $serviceGroup2 = array( + 'name' => 'serviceGroup2Name', + 'description' => 'serviceGroup2Description' + ); + + protected $serviceGroup3 = array( + 'name' => 'serviceGroup3Name', + 'description' => 'serviceGroup3Description' + ); + + protected $serviceGroup4 = array( + 'name' => 'serviceGroup4Name', + 'description' => 'serviceGroup4Description' + ); + + protected $serviceGroup5 = array( + 'name' => 'serviceGroup5Name', + 'description' => 'serviceGroup5Description' + ); + + protected $serviceGroup6 = array( + 'name' => 'serviceGroup6Name', + 'description' => 'serviceGroup6Description' + ); + + protected $initialProperties = array( + 'name' => 'serviceGroupDependencyName', + 'description' => 'serviceGroupDependencyDescription', + 'parent_relationship' => 0, + 'execution_fails_on_none' => 1, + 'execution_fails_on_ok' => 0, + 'execution_fails_on_warning' => 0, + 'execution_fails_on_unknown' => 0, + 'execution_fails_on_critical' => 0, + 'execution_fails_on_pending' => 0, + 'notification_fails_on_ok' => 1, + 'notification_fails_on_warning' => 1, + 'notification_fails_on_unknown' => 1, + 'notification_fails_on_critical' => 1, + 'notification_fails_on_pending' => 1, + 'notification_fails_on_none' => 0, + 'service_groups' => 'serviceGroup1Name', + 'dependent_service_groups' => 'serviceGroup2Name', + 'comment' => 'serviceGroupDependencyComment' + ); + + protected $updatedProperties = array( + 'name' => 'serviceGroupDependencyNameChanged', + 'description' => 'serviceGroupDependencyDescriptionChanged', + 'parent_relationship' => 1, + 'execution_fails_on_ok' => 1, + 'execution_fails_on_warning' => 1, + 'execution_fails_on_unknown' => 1, + 'execution_fails_on_critical' => 1, + 'execution_fails_on_pending' => 1, + 'execution_fails_on_none' => 0, + 'notification_fails_on_none' => 1, + 'notification_fails_on_ok' => 0, + 'notification_fails_on_warning' => 0, + 'notification_fails_on_unknown' => 0, + 'notification_fails_on_critical' => 0, + 'notification_fails_on_pending' => 0, + 'service_groups' => array( + 'serviceGroup3Name', + 'serviceGroup4Name' + ), + 'dependent_service_groups' => array( + 'serviceGroup5Name', + 'serviceGroup6Name' + ), + 'comment' => 'serviceGroupDependencyCommentChanged' + ); + + /** + * @Given a service group dependency + */ + public function aServiceGroupDependency() + { + $this->currentPage = new ServiceGroupConfigurationPage($this); + $this->currentPage->setProperties($this->serviceGroup1); + $this->currentPage->save(); + $this->currentPage = new ServiceGroupConfigurationPage($this); + $this->currentPage->setProperties($this->serviceGroup2); + $this->currentPage->save(); + $this->currentPage = new ServiceGroupConfigurationPage($this); + $this->currentPage->setProperties($this->serviceGroup3); + $this->currentPage->save(); + $this->currentPage = new ServiceGroupConfigurationPage($this); + $this->currentPage->setProperties($this->serviceGroup4); + $this->currentPage->save(); + $this->currentPage = new ServiceGroupConfigurationPage($this); + $this->currentPage->setProperties($this->serviceGroup5); + $this->currentPage->save(); + $this->currentPage = new ServiceGroupConfigurationPage($this); + $this->currentPage->setProperties($this->serviceGroup6); + $this->currentPage->save(); + $this->currentPage = new ServiceGroupDependencyConfigurationPage($this); + $this->currentPage->setProperties($this->initialProperties); + $this->currentPage->save(); + } + + /** + * @When I change the properties of a service group dependency + */ + public function iChangeThePropertiesOfAServiceGroupDependency() + { + $this->currentPage = new ServiceGroupDependencyConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['name']); + $this->currentPage->setProperties($this->updatedProperties); + $this->currentPage->save(); + } + + /** + * @Then the properties are updated + */ + public function thePropertiesAreUpdated() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new ServiceGroupDependencyConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->updatedProperties['name']); + $object = $this->currentPage->getProperties(); + foreach ($this->updatedProperties as $key => $value) { + if ($value != $object[$key]) { + if (is_array($value)) { + $value = implode(' ', $value); + } + if ($value != $object[$key]) { + $this->tableau[] = $key; + } + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I duplicate a service group dependency + */ + public function iDuplicateAServiceGroupDependency() + { + $this->currentPage = new ServiceGroupDependencyConfigurationListingPage($this); + $object = $this->currentPage->getEntry($this->initialProperties['name']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Duplicate'); + } + + /** + * @Then the new object has the same properties + */ + public function theNewObjectHasTheSameProperties() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new ServiceGroupDependencyConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['name'] . '_1'); + $object = $this->currentPage->getProperties(); + foreach ($this->initialProperties as $key => $value) { + if ($key != 'name' && $value != $object[$key]) { + if (is_array($value)) { + $value = implode(' ', $value); + } + if ($value != $object[$key]) { + $this->tableau[] = $key; + } + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I delete a service group dependency + */ + public function iDeleteAServiceGroupDependency() + { + $this->currentPage = new ServiceGroupDependencyConfigurationListingPage($this); + $object = $this->currentPage->getEntry($this->initialProperties['name']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Delete'); + } + + /** + * @Then the deleted object is not displayed in the list + */ + public function theDeletedObjectIsNotDisplayedInTheList() + { + $this->spin( + function ($context) { + $this->currentPage = new ServiceGroupDependencyConfigurationListingPage($this); + $object = $this->currentPage->getEntries(); + $bool = true; + foreach ($object as $value) { + $bool = $bool && $value['name'] != $this->initialProperties['name']; + } + return $bool; + }, + "The service is not being deleted.", + 5 + ); + } +} From d54f6025f74e4b802475e0a35943482440f9270d Mon Sep 17 00:00:00 2001 From: mariegallardo Date: Thu, 10 Aug 2017 17:19:24 +0200 Subject: [PATCH 150/207] Connectors configuration (#5515) * New feature: ConnectorConfiguration * Feature en attente * Feature updated * File fixed * File fixed * Feature finished * Feature fixed * Behat fixed * MassiveChangeService fixed --- behat.yml | 8 +- features/ConnectorConfiguration.feature | 20 +++ .../ConnectorConfigurationContext.php | 165 ++++++++++++++++++ 3 files changed, 191 insertions(+), 2 deletions(-) create mode 100644 features/ConnectorConfiguration.feature create mode 100644 features/bootstrap/ConnectorConfigurationContext.php diff --git a/behat.yml b/behat.yml index c07ff8e5bd6..6aff962f41e 100644 --- a/behat.yml +++ b/behat.yml @@ -309,7 +309,6 @@ default: contexts: - MetaServiceConfigurationContext - host_group_dependency_configuration: paths: [ %paths.base%/features/HostGroupDependencyConfiguration.feature ] contexts: @@ -319,7 +318,7 @@ default: paths: [ %paths.base%/features/ServiceSubmitResult.feature ] contexts: - ServiceSubmitResultContext - + host_dependency_configuration: paths: [ %paths.base%/features/HostDependencyConfiguration.feature ] contexts: @@ -329,3 +328,8 @@ default: paths: [ %paths.base%/features/ServiceGroupDependencyConfiguration.feature ] contexts: - ServiceGroupDependencyConfigurationContext + + connector_configuration: + paths: [ %paths.base%/features/ConnectorConfiguration.feature ] + contexts: + - ConnectorConfigurationContext diff --git a/features/ConnectorConfiguration.feature b/features/ConnectorConfiguration.feature new file mode 100644 index 00000000000..24100cb12d0 --- /dev/null +++ b/features/ConnectorConfiguration.feature @@ -0,0 +1,20 @@ +Feature: Edit a connector + As a Centreon user + I want to manipulate a connector + To see if all simples manipulations work + + Background: + Given I am logged in a Centreon server + And a connector is configured + + Scenario: Change the properties of a connector + When I change the properties of a connector + Then the properties are updated + + Scenario: Duplicate one existing connector + When I duplicate a connector + Then the new connector has the same properties + + Scenario: Delete one existing connector + When I delete a connector + Then the deleted connector is not displayed in the list diff --git a/features/bootstrap/ConnectorConfigurationContext.php b/features/bootstrap/ConnectorConfigurationContext.php new file mode 100644 index 00000000000..e6c438eb444 --- /dev/null +++ b/features/bootstrap/ConnectorConfigurationContext.php @@ -0,0 +1,165 @@ + 'connectorName', + 'description' => 'connectorDescription', + 'command_line' => 'connectorCommandLine', + 'command' => 'service-notify-by-email', + 'enabled' => 1 + ); + + protected $duplicatedProperties = array( + 'name' => 'connectorName_1', + 'description' => 'connectorDescription', + 'command_line' => 'connectorCommandLine', + 'command' => '', + 'enabled' => 1 + ); + + protected $updatedProperties = array( + 'name' => 'connectorNameChanged', + 'description' => 'connectorDescriptionChanged', + 'command_line' => 'connectorCommandLineChanged', + 'command' => 'service-notify-by-epager', + 'enabled' => 1 + ); + + /** + * @Given a connector is configured + */ + public function aConnectorIsConfigured() + { + $this->currentPage = new ConnectorConfigurationPage($this); + $this->currentPage->setProperties($this->initialProperties); + $this->currentPage->save(); + } + + /** + * @When I change the properties of a connector + */ + public function iChangeThePropertiesOfAConnector() + { + $this->currentPage = new ConnectorConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['name']); + $this->currentPage->setProperties($this->updatedProperties); + $this->currentPage->save(); + } + + /** + * @Then the properties are updated + */ + public function thePropertiesAreUpdated() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new ConnectorConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->updatedProperties['name']); + $object = $this->currentPage->getProperties(); + foreach ($this->updatedProperties as $key => $value) { + if ($value != $object[$key]) { + if (is_array($value)) { + $value = implode(' ', $value); + } + if ($value != $object[$key]) { + $this->tableau[] = $key; + } + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I duplicate a connector + */ + public function iDuplicateAConnector() + { + $this->currentPage = new ConnectorConfigurationListingPage($this); + $object = $this->currentPage->getEntry($this->initialProperties['name']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Duplicate'); + } + + /** + * @Then the new connector has the same properties + */ + public function theNewConnectorHasTheSameProperties() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new ConnectorConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->duplicatedProperties['name']); + $object = $this->currentPage->getProperties(); + foreach ($this->duplicatedProperties as $key => $value) { + if ($value != $object[$key]) { + if (is_array($value)) { + $value = implode(' ', $value); + } + if ($value != $object[$key]) { + $this->tableau[] = $key; + } + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I delete a connector + */ + public function iDeleteAConnector() + { + $this->currentPage = new ConnectorConfigurationListingPage($this); + $object = $this->currentPage->getEntry($this->initialProperties['name']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Delete'); + } + + /** + * @Then the deleted connector is not displayed in the list + */ + public function theDeletedConnectorIsNotDisplayedInTheList() + { + $this->spin( + function ($context) { + $this->currentPage = new ConnectorConfigurationListingPage($this); + $object = $this->currentPage->getEntries(); + $bool = true; + foreach ($object as $value) { + $bool = $bool && $value['name'] != $this->initialProperties['name']; + } + return $bool; + }, + "The connector is not being deleted.", + 5 + ); + } +} From c2d19a0307a3b337dc5b2d318618741eb205333d Mon Sep 17 00:00:00 2001 From: mariegallardo Date: Fri, 11 Aug 2017 09:23:19 +0200 Subject: [PATCH 151/207] new feature VendorConfiguration (#5540) --- behat.yml | 5 + features/VendorConfiguration.feature | 20 +++ .../bootstrap/VendorConfigurationContext.php | 153 ++++++++++++++++++ 3 files changed, 178 insertions(+) create mode 100644 features/VendorConfiguration.feature create mode 100644 features/bootstrap/VendorConfigurationContext.php diff --git a/behat.yml b/behat.yml index 6aff962f41e..57ff17b7038 100644 --- a/behat.yml +++ b/behat.yml @@ -333,3 +333,8 @@ default: paths: [ %paths.base%/features/ConnectorConfiguration.feature ] contexts: - ConnectorConfigurationContext + + vendor_configuration: + paths: [ %paths.base%/features/VendorConfiguration.feature ] + contexts: + - VendorConfigurationContext diff --git a/features/VendorConfiguration.feature b/features/VendorConfiguration.feature new file mode 100644 index 00000000000..adf471ca8dc --- /dev/null +++ b/features/VendorConfiguration.feature @@ -0,0 +1,20 @@ +Feature: Edit a vendor + As a Centreon user + I want to manipulate a vendor + To see if all simples manipulations work + + Background: + Given I am logged in a Centreon server + And a vendor is configured + + Scenario: Change the properties of a vendor + When I change the properties of a vendor + Then the properties are updated + + Scenario: Duplicate one existing vendor + When I duplicate a vendor + Then the new vendor has the same properties + + Scenario: Delete one existing vendor + When I delete a vendor + Then the deleted object is not displayed in the list diff --git a/features/bootstrap/VendorConfigurationContext.php b/features/bootstrap/VendorConfigurationContext.php new file mode 100644 index 00000000000..d3b64a564d5 --- /dev/null +++ b/features/bootstrap/VendorConfigurationContext.php @@ -0,0 +1,153 @@ + 'vendorName', + 'alias' => 'vendorAlias', + 'description' => 'vendorDescription' + ); + + protected $updatedProperties = array( + 'name' => 'vendorNameChanged', + 'alias' => 'vendorAliasChanged', + 'description' => 'vendorDescriptionChanged' + ); + + /** + * @Given a vendor is configured + */ + public function aVendorIsConfigured() + { + $this->currentPage = new VendorConfigurationPage($this); + $this->currentPage->setProperties($this->initialProperties); + $this->currentPage->save(); + } + + /** + * @When I change the properties of a vendor + */ + public function iChangeThePropertiesOfAVendor() + { + $this->currentPage = new VendorConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['name']); + $this->currentPage->setProperties($this->updatedProperties); + $this->currentPage->save(); + } + + /** + * @Then the properties are updated + */ + public function thePropertiesAreUpdated() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new VendorConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->updatedProperties['name']); + $object = $this->currentPage->getProperties(); + foreach ($this->updatedProperties as $key => $value) { + if ($value != $object[$key]) { + if (is_array($value)) { + $value = implode(' ', $value); + } + if ($value != $object[$key]) { + $this->tableau[] = $key; + } + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I duplicate a vendor + */ + public function iDuplicateAVendor() + { + $this->currentPage = new VendorConfigurationListingPage($this); + $object = $this->currentPage->getEntry($this->initialProperties['name']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Duplicate'); + } + + /** + * @Then the new vendor has the same properties + */ + public function theNewVendorHasTheSameProperties() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new VendorConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['name'] . '_1'); + $object = $this->currentPage->getProperties(); + foreach ($this->initialProperties as $key => $value) { + if ($key != 'name' && $value != $object[$key]) { + if (is_array($value)) { + $value = implode(' ', $value); + } + if ($value != $object[$key]) { + $this->tableau[] = $key; + } + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I delete a vendor + */ + public function iDeleteAVendor() + { + $this->currentPage = new VendorConfigurationListingPage($this); + $object = $this->currentPage->getEntry($this->initialProperties['name']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Delete'); + } + + /** + * @Then the deleted object is not displayed in the list + */ + public function theDeletedObjectIsNotDisplayedInTheList() + { + $this->spin( + function ($context) { + $this->currentPage = new VendorConfigurationListingPage($this); + $object = $this->currentPage->getEntries(); + $bool = true; + foreach ($object as $value) { + $bool = $bool && $value['name'] != $this->initialProperties['name']; + } + return $bool; + }, + "The service is not being deleted.", + 5 + ); + } +} From 578df44c0b61f2e5fbbff23ff81f45b0542914b7 Mon Sep 17 00:00:00 2001 From: loiclau Date: Fri, 11 Aug 2017 10:25:54 +0200 Subject: [PATCH 152/207] * duplicate host dependency #5531 --- .../configObject/service_dependency/DB-Func.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/www/include/configuration/configObject/service_dependency/DB-Func.php b/www/include/configuration/configObject/service_dependency/DB-Func.php index d979b319934..5fd0b7911c8 100644 --- a/www/include/configuration/configObject/service_dependency/DB-Func.php +++ b/www/include/configuration/configObject/service_dependency/DB-Func.php @@ -124,6 +124,18 @@ function multipleServiceDependencyInDB($dependencies = array(), $nbrDup = array( $DBRESULT = $pearDB->query("SELECT MAX(dep_id) FROM dependency"); $maxId = $DBRESULT->fetchRow(); if (isset($maxId["MAX(dep_id)"])) { + + $query = "SELECT * FROM dependency_hostChild_relation WHERE dependency_dep_id = '".$key."'"; + $dbResult = $pearDB->query($query); + $fields["dep_hostPar"] = ""; + while ($host = $dbResult->fetchRow()) { + $query = "INSERT INTO dependency_hostChild_relation VALUES ('', '".$maxId["MAX(dep_id)"]. + "', '".$host["host_host_id"]."')"; + $pearDB->query($query); + $fields["dep_hostPar"] .= $host["host_host_id"] . ","; + } + $fields["dep_hostPar"] = trim($fields["dep_hostPar"], ","); + $query = "SELECT * FROM dependency_serviceParent_relation WHERE dependency_dep_id = '" . $key . "'"; $DBRESULT = $pearDB->query($query); $fields["dep_hSvPar"] = ""; From dd3e1a492fc4294ec21132fb048705e4f582fb57 Mon Sep 17 00:00:00 2001 From: loiclau Date: Fri, 11 Aug 2017 11:02:49 +0200 Subject: [PATCH 153/207] * fix style --- .../configuration/configGenerate/DB-Func.php | 211 +++++++++++------- .../configGenerate/formGenerateFiles.php | 104 +++++---- .../configGenerate/generateFiles.php | 40 ++-- .../configuration/configGenerate/help.php | 16 +- .../configGenerate/xml/restartPollers.php | 2 +- .../service_dependency/DB-Func.php | 6 +- 6 files changed, 217 insertions(+), 162 deletions(-) diff --git a/www/include/configuration/configGenerate/DB-Func.php b/www/include/configuration/configGenerate/DB-Func.php index ca7ea65ac8e..6b34af3eb93 100644 --- a/www/include/configuration/configGenerate/DB-Func.php +++ b/www/include/configuration/configGenerate/DB-Func.php @@ -33,22 +33,22 @@ * */ - /** - * Get The resolved criticality for a specific host - * - * @param CentreonDB $DB - * @param int $pollerId - * @return array - */ +/** + * Get The resolved criticality for a specific host + * + * @param CentreonDB $DB + * @param int $pollerId + * @return array + */ function getMyHostTemplateCriticality($host_id) { global $pearDB, $critHTpl; - + if (!$host_id) { return null; } - - $rq = "SELECT host_tpl_id FROM host_template_relation WHERE host_host_id = '".$host_id."' ORDER BY `order`"; + + $rq = "SELECT host_tpl_id FROM host_template_relation WHERE host_host_id = '" . $host_id . "' ORDER BY `order`"; $DBRESULT = $pearDB->query($rq); while ($row = $DBRESULT->fetchRow()) { if (isset($critHTpl[$row['host_tpl_id']]) && $critHTpl[$row['host_tpl_id']]) { @@ -72,45 +72,60 @@ function getMyHostTemplateCriticality($host_id) function intCmdParam($DB, $pollerId) { $cache = array('tpl' => array(), 'svc' => array()); - + $commands = array(); $DBRESULT = $DB->query("SELECT command_id, command_name FROM command"); while ($data = $DBRESULT->fetchRow()) { $commands[$data["command_id"]] = $data["command_name"]; } $DBRESULT->closeCursor(); - + $i = 0; - $DBRESULT = $DB->query("SELECT service_id, service_register, service_template_model_stm_id, command_command_id, command_command_id_arg + $DBRESULT = $DB->query("SELECT service_id, service_register, service_template_model_stm_id, + command_command_id, command_command_id_arg FROM service s, host_service_relation hsr, ns_host_relation nhr WHERE s.service_id = hsr.service_service_id AND hsr.host_host_id = nhr.host_host_id - AND nhr.nagios_server_id = ".$DB->escape($pollerId)." + AND nhr.nagios_server_id = " . $DB->escape($pollerId) . " UNION - SELECT service_id, service_register, service_template_model_stm_id, command_command_id, command_command_id_arg + SELECT service_id, service_register, service_template_model_stm_id, + command_command_id, command_command_id_arg FROM service s, host_service_relation hsr, ns_host_relation nhr, hostgroup_relation hgr WHERE s.service_id = hsr.service_service_id AND hsr.hostgroup_hg_id = hgr.hostgroup_hg_id AND hgr.host_host_id = nhr.host_host_id - AND nhr.nagios_server_id = ".$DB->escape($pollerId)." + AND nhr.nagios_server_id = " . $DB->escape($pollerId) . " UNION - SELECT service_id, service_register, service_template_model_stm_id, command_command_id, command_command_id_arg + SELECT service_id, service_register, service_template_model_stm_id, + command_command_id, command_command_id_arg FROM service s WHERE service_register = '0' ORDER BY service_register, service_template_model_stm_id"); while ($data = $DBRESULT->fetchRow()) { if ($data["service_register"] == 1) { if ($data["command_command_id_arg"] && !$data["command_command_id"]) { - $cache["svc"][$data["service_id"]] = db2str(getInfoInSvcTpl($data["service_template_model_stm_id"], "cmd", $cache)).db2str($data["command_command_id_arg"]); + $cache["svc"][$data["service_id"]] = + db2str(getInfoInSvcTpl($data["service_template_model_stm_id"], "cmd", $cache)) . + db2str($data["command_command_id_arg"]); } elseif ($data["command_command_id"] && !$data["command_command_id_arg"]) { - $cache["svc"][$data["service_id"]] = $commands[$data["command_command_id"]].db2str(getInfoInSvcTpl($data["service_template_model_stm_id"], "arg", $cache)); + $cache["svc"][$data["service_id"]] = $commands[$data["command_command_id"]] . + db2str(getInfoInSvcTpl( + $data["service_template_model_stm_id"], + "arg", + $cache + )); } elseif ($data["command_command_id"] && $data["command_command_id_arg"]) { - $cache["svc"][$data["service_id"]] = $commands[$data["command_command_id"]].db2str($data["command_command_id_arg"]); + $cache["svc"][$data["service_id"]] = $commands[$data["command_command_id"]] . + db2str($data["command_command_id_arg"]); } else { $cache["svc"][$data["service_id"]] = null; } } else { - $cache["tpl"][$data["service_id"]] = array('arg' => $data["command_command_id_arg"], 'cmd' => $data["command_command_id"] != null ? $commands[$data["command_command_id"]] : null, 'tpl' => $data["service_template_model_stm_id"]); + $cache["tpl"][$data["service_id"]] = array( + 'arg' => $data["command_command_id_arg"], + 'cmd' => $data["command_command_id"] != null ? $commands[$data["command_command_id"]] : null, + 'tpl' => $data["service_template_model_stm_id"] + ); } $i++; } @@ -160,7 +175,7 @@ function getMyServiceTPInCache($service_id = null, $cache) if (!$service_id) { return; } - + $tab = array(); while (1) { if (isset($cache[$service_id]["tp"])) { @@ -206,7 +221,7 @@ function myHour($hour) return "00"; } if ($hour < 10) { - return "0".$hour; + return "0" . $hour; } return $hour; } @@ -217,7 +232,7 @@ function myMinute($min) return "00"; } if ($min < 10 && $min > 0) { - return "0".$min; + return "0" . $min; } return $min; } @@ -245,34 +260,41 @@ function ComputeGMTTime($day, $daybefore, $dayafter, $gmt, $conf) if ($PeriodBefore[$daybefore] != "") { $PeriodBefore[$daybefore] .= ","; } - $PeriodBefore[$daybefore] .= $value.":".$tabValue[2]."-".(24 + $tabValue[3]).":".myMinute($tabValue[4]); + $PeriodBefore[$daybefore] .= $value . ":" . $tabValue[2] . "-" . (24 + $tabValue[3]) . + ":" . myMinute($tabValue[4]); } elseif ($tabValue[1] < 0 && $tabValue[3] > 0) { $value = ((24 + $tabValue[3]) % 24); if ($Period[$day] != "") { $Period[$day] .= ","; } - $Period[$day] .= "00:00-".myHour($value).":".(($tabValue[4] < 10 && $tabValue[4] > 0) ? "0".$tabValue[4] : $tabValue[4]); + $Period[$day] .= "00:00-" . myHour($value) . ":" . (($tabValue[4] < 10 && $tabValue[4] > 0) + ? "0" . $tabValue[4] + : $tabValue[4]); if ($PeriodBefore[$daybefore] != "") { $PeriodBefore[$daybefore] .= ","; } - $PeriodBefore[$daybefore] .= (24 + $tabValue[1]).":".myMinute($tabValue[2])."-24:00"; + $PeriodBefore[$daybefore] .= (24 + $tabValue[1]) . ":" . myMinute($tabValue[2]) . "-24:00"; } elseif ($tabValue[1] < 0 && $tabValue[3] == 0) { $value = ((24 + $tabValue[3]) % 24); if ($Period[$day] != "") { $Period[$day] .= ","; } - $Period[$day] .= "00:00-".myHour($value).":".(($tabValue[4] < 10 && $tabValue[4] > 0) ? "0".$tabValue[4] : $tabValue[4]); + $Period[$day] .= "00:00-" . myHour($value) . ":" . (($tabValue[4] < 10 && $tabValue[4] > 0) + ? "0" . $tabValue[4] + : $tabValue[4]); if ($PeriodBefore[$daybefore] != "") { $PeriodBefore[$daybefore] .= ","; } - $PeriodBefore[$daybefore] .= (24 + $tabValue[1]).":".myMinute($tabValue[2])."-24:00"; + $PeriodBefore[$daybefore] .= (24 + $tabValue[1]) . ":" . myMinute($tabValue[2]) . "-24:00"; } else { $value = ($tabValue[1] < 0 ? 24 + $tabValue[1] : $tabValue[1]); if ($Period[$day] != "") { $Period[$day] .= ","; } $tabValue[3] = ($tabValue[3] < 0 ? 24 + $tabValue[3] : $tabValue[3]); - $Period[$day] .= myHour($value).":".myMinute($tabValue[2])."-".(($tabValue[3] < 10 && $tabValue[3] > 0) ? "0".$tabValue[3] : $tabValue[3]).":".myMinute($tabValue[4]); + $Period[$day] .= myHour($value) . ":" . myMinute($tabValue[2]) . "-" . + (($tabValue[3] < 10 && $tabValue[3] > 0) ? "0" . $tabValue[3] : $tabValue[3]) . + ":" . myMinute($tabValue[4]); } } elseif ($gmt > 0) { $tabValue[1] += $gmt; @@ -281,40 +303,42 @@ function ComputeGMTTime($day, $daybefore, $dayafter, $gmt, $conf) if ($PeriodAfter[$dayafter] != "") { $PeriodAfter[$dayafter] .= ","; } - $PeriodAfter[$dayafter] .= ($tabValue[1] % 24).":".myMinute($tabValue[2])."-".($tabValue[3] % 24).":".myMinute($tabValue[4]).""; + $PeriodAfter[$dayafter] .= ($tabValue[1] % 24) . ":" . myMinute($tabValue[2]) . "-" . + ($tabValue[3] % 24) . ":" . myMinute($tabValue[4]) . ""; } elseif ($tabValue[1] < 24 && $tabValue[3] > 24) { if ($Period[$day] != "") { $Period[$day] .= ","; } - $Period[$day] .= myMinute($tabValue[1]).":".$tabValue[2]."-"."24:00"; + $Period[$day] .= myMinute($tabValue[1]) . ":" . $tabValue[2] . "-" . "24:00"; $tabValue[3] = $tabValue[3] % 24; if ($PeriodAfter[$dayafter] != "") { $PeriodAfter[$dayafter] .= ","; } - $PeriodAfter[$dayafter] .= "00:00-".myHour($tabValue[3]) .":".myMinute($tabValue[4]).""; + $PeriodAfter[$dayafter] .= "00:00-" . myHour($tabValue[3]) . ":" . myMinute($tabValue[4]) . ""; } elseif ($tabValue[1] == 24 && $tabValue[3] == 24) { if ($PeriodAfter[$dayafter] != "") { $PeriodAfter[$dayafter] .= ","; } - $PeriodAfter[$dayafter] .= "00:".myMinute($tabValue[2])."-00:".myMinute($tabValue[4]); + $PeriodAfter[$dayafter] .= "00:" . myMinute($tabValue[2]) . "-00:" . myMinute($tabValue[4]); } else { if (($tabValue[3] == 24 && $tabValue[4] > 0)) { if ($PeriodAfter[$dayafter] != "") { $PeriodAfter[$dayafter] .= ","; } - $PeriodAfter[$dayafter] .= "00:00-00:".myMinute($tabValue[4]); + $PeriodAfter[$dayafter] .= "00:00-00:" . myMinute($tabValue[4]); $tabValue[4] = "00"; } if ($Period[$day] != "") { $Period[$day] .= ","; } - $Period[$day] .= myMinute($tabValue[1]).":".myMinute($tabValue[2])."-".myMinute($tabValue[3]).":".myMinute($tabValue[4]); + $Period[$day] .= myMinute($tabValue[1]) . ":" . myMinute($tabValue[2]) . + "-" . myMinute($tabValue[3]) . ":" . myMinute($tabValue[4]); } } elseif ($gmt == 0) { if ($Period[$day] != "") { $Period[$day] .= ","; } - $Period[$day] .= $tabValue[1].":".$tabValue[2]."-".$tabValue[3].":".$tabValue[4]; + $Period[$day] .= $tabValue[1] . ":" . $tabValue[2] . "-" . $tabValue[3] . ":" . $tabValue[4]; } } } @@ -323,8 +347,9 @@ function ComputeGMTTime($day, $daybefore, $dayafter, $gmt, $conf) function isHostOnThisInstance($host_id, $instance_id) { global $pearDB; - - $DBRESULT_relation = $pearDB->query("SELECT * FROM ns_host_relation WHERE host_host_id = '".$host_id."' AND nagios_server_id = '".$instance_id."'"); + $query = "SELECT * FROM ns_host_relation WHERE host_host_id = '" . $host_id . + "' AND nagios_server_id = '" . $instance_id . "'"; + $DBRESULT_relation = $pearDB->query($query); if ($DBRESULT_relation->rowCount()) { return 1; } else { @@ -335,8 +360,8 @@ function isHostOnThisInstance($host_id, $instance_id) function isLocalInstance($instance_id) { global $pearDB; - - $DBRESULT_relation = $pearDB->query("SELECT localhost FROM nagios_server WHERE id = '".$instance_id."'"); + + $DBRESULT_relation = $pearDB->query("SELECT localhost FROM nagios_server WHERE id = '" . $instance_id . "'"); $data = $DBRESULT_relation->fetchRow(); return $data["localhost"]; } @@ -344,19 +369,19 @@ function isLocalInstance($instance_id) function manageDependencies($ret = array()) { global $pearDB, $form; - + /* * Init Dependancies table */ $gbArr = array(); $gbArr = checkDependenciesStrong(); - + return ($gbArr); } function checkDependenciesStrong() { - global $pearDB, $oreon; + global $pearDB, $oreon; $cctEnb = array(); $cgEnb = array(); $hostEnb = array(); @@ -364,7 +389,15 @@ function checkDependenciesStrong() $svEnb = array(); $sgEnb = array(); $omsEnb = array(); - $gbEnb = array(0 => &$cctEnb, 1 => &$cgEnb, 2 => &$hostEnb, 3 => &$hgEnb, 4 => &$svEnb, 5 => &$sgEnb, 7 => &$omsEnb); + $gbEnb = array( + 0 => &$cctEnb, + 1 => &$cgEnb, + 2 => &$hostEnb, + 3 => &$hgEnb, + 4 => &$svEnb, + 5 => &$sgEnb, + 7 => &$omsEnb + ); /* * Contact @@ -408,8 +441,8 @@ function checkDependenciesStrong() /* * Host Template Model */ - $host = array(); - $DBRESULT = $pearDB->query("SELECT host_id, host_name FROM host WHERE host.host_register = '0' AND host.host_activate = '1'"); + $query = "SELECT host_id, host_name FROM host WHERE host.host_register = '0' AND host.host_activate = '1'"; + $DBRESULT = $pearDB->query($query); while ($host = $DBRESULT->fetchRow()) { $hostEnb[$host["host_id"]] = $host["host_name"]; } @@ -423,14 +456,17 @@ function checkDependenciesStrong() * Create template buffer */ $hostTemplate = array(); - $DBRESULT = $pearDB->query("SELECT htr.host_tpl_id, host.host_id FROM host_template_relation htr, host WHERE host.host_id = htr.host_host_id"); + $query = "SELECT htr.host_tpl_id, host.host_id FROM host_template_relation htr, host " . + "WHERE host.host_id = htr.host_host_id"; + $DBRESULT = $pearDB->query($query); while ($htpl = $DBRESULT->fetchRow()) { - $hostTemplate[$htpl["host_id"]] = $htpl["host_tpl_id"]; + $hostTemplate[$htpl["host_id"]] = $htpl["host_tpl_id"]; } - $host = array(); - $DBRESULT = $pearDB->query("SELECT host.host_id, host.host_name FROM host WHERE host.host_register = '1' AND host.host_activate = '1'"); - while ($host = $DBRESULT->fetchRow()) { + $query = "SELECT host.host_id, host.host_name FROM host " . + "WHERE host.host_register = '1' AND host.host_activate = '1'"; + $DBRESULT = $pearDB->query(); + while ($host = $DBRESULT->fetchRow($query)) { /* * If the Host is link to a Template, we think that the dependencies are manage in the template */ @@ -441,8 +477,9 @@ function checkDependenciesStrong() /* * Contactgroup dependancy */ - - $DBRESULT2 = $pearDB->query("SELECT DISTINCT cghr.contactgroup_cg_id FROM contactgroup_host_relation cghr WHERE cghr.host_host_id = '".$host["host_id"]."'"); + $query = "SELECT DISTINCT cghr.contactgroup_cg_id FROM contactgroup_host_relation cghr " . + "WHERE cghr.host_host_id = '" . $host["host_id"] . "'"; + $DBRESULT2 = $pearDB->query($query); while ($valid = $DBRESULT2->fetchRow()) { isset($cgEnb[$valid["contactgroup_cg_id"]]) ? $hostEnb[$host["host_id"]] = $host["host_name"] : null; } @@ -452,8 +489,9 @@ function checkDependenciesStrong() /* * Contact dependancy */ - - $DBRESULT2 = $pearDB->query("SELECT DISTINCT chr.contact_id FROM contact_host_relation chr WHERE chr.host_host_id = '".$host["host_id"]."'"); + $query = "SELECT DISTINCT chr.contact_id FROM contact_host_relation chr " . + "WHERE chr.host_host_id = '" . $host["host_id"] . "'"; + $DBRESULT2 = $pearDB->query($query); while ($valid = $DBRESULT2->fetchRow()) { isset($cctEnb[$valid["contact_id"]]) ? $hostEnb[$host["host_id"]] = $host["host_name"] : null; } @@ -470,7 +508,9 @@ function checkDependenciesStrong() $hostGroup = array(); $DBRESULT = $pearDB->query("SELECT DISTINCT hg.hg_id FROM hostgroup hg WHERE hg.hg_activate = '1'"); while ($hostGroup = $DBRESULT->fetchRow()) { - $DBRESULT2 = $pearDB->query("SELECT DISTINCT hgr.host_host_id, hgr.hostgroup_hg_id FROM hostgroup_relation hgr WHERE hgr.hostgroup_hg_id = '".$hostGroup["hg_id"]."'"); + $query = "SELECT DISTINCT hgr.host_host_id, hgr.hostgroup_hg_id FROM hostgroup_relation hgr " . + "WHERE hgr.hostgroup_hg_id = '" . $hostGroup["hg_id"] . "'"; + $DBRESULT2 = $pearDB->query($query); while ($hostGroup = $DBRESULT2->fetchRow()) { if (isset($hostEnb[$hostGroup["host_host_id"]])) { $hgEnb[$hostGroup["hostgroup_hg_id"]] = 1; @@ -485,8 +525,8 @@ function checkDependenciesStrong() /* * Service Template Model */ - $service = array(); - $DBRESULT = $pearDB->query("SELECT DISTINCT sv.service_id FROM service sv WHERE sv.service_activate = '1' AND service_register = '0'"); + $query = "SELECT DISTINCT sv.service_id FROM service sv WHERE sv.service_activate = '1' AND service_register = '0'"; + $DBRESULT = $pearDB->query($query); while ($service = $DBRESULT->fetchRow()) { $svEnb[$service["service_id"]] = 1; } @@ -498,9 +538,9 @@ function checkDependenciesStrong() $service = array(); $DBRESULT = $pearDB->query("SELECT DISTINCT service_id, service_description, service_template_model_stm_id " . - "FROM service " . - "WHERE service_activate = '1' " . - "AND service_register = '1'"); + "FROM service " . + "WHERE service_activate = '1' " . + "AND service_register = '1'"); while ($service = $DBRESULT->fetchRow()) { /* * If the Service is link to a Template, we think that @@ -511,8 +551,9 @@ function checkDependenciesStrong() } else { $h = false; $hg = false; - - $DBRESULT2 = $pearDB->query("SELECT DISTINCT hsr.host_host_id, hsr.hostgroup_hg_id FROM host_service_relation hsr WHERE hsr.service_service_id = '".$pearDB->escape($service["service_id"])."'"); + $query = "SELECT DISTINCT hsr.host_host_id, hsr.hostgroup_hg_id FROM host_service_relation hsr " . + "WHERE hsr.service_service_id = '" . $pearDB->escape($service["service_id"]) . "'"; + $DBRESULT2 = $pearDB->query($query); while ($valid = $DBRESULT2->fetchRow()) { isset($hostEnb[$valid["host_host_id"]]) ? $h = true : null; isset($hgEnb[$valid["hostgroup_hg_id"]]) ? $hg = true : null; @@ -535,7 +576,9 @@ function checkDependenciesStrong() $serviceGroup = array(); $DBRESULT = $pearDB->query("SELECT sg_id, sg_name FROM servicegroup sg WHERE sg.sg_activate = '1'"); while ($serviceGroup = $DBRESULT->fetchRow()) { - $DBRESULT2 = $pearDB->query("SELECT sgr.service_service_id FROM servicegroup_relation sgr WHERE sgr.servicegroup_sg_id = '".$serviceGroup["sg_id"]."'"); + $query = "SELECT sgr.service_service_id FROM servicegroup_relation sgr " . + "WHERE sgr.servicegroup_sg_id = '" . $serviceGroup["sg_id"] . "'"; + $DBRESULT2 = $pearDB->query($query); while ($valid = $DBRESULT2->fetchRow()) { if (isset($svEnb[$valid["service_service_id"]])) { $sgEnb[$serviceGroup["sg_id"]] = $serviceGroup["sg_name"]; @@ -564,7 +607,7 @@ function print_header($handle, $name) { $time = date("F j, Y, g:i a"); $by = $name; - $str = "###################################################################\n"; + $str = "###################################################################\n"; $len = strlen($str); // Get line lenght $str .= "# #\n"; $str .= "# GENERATED BY CENTREON #\n"; @@ -584,7 +627,7 @@ function print_header($handle, $name) // Add space to put text on center for ($i = 0; $i != $DBRESULT; $i++) { - $str .= " "; + $str .= " "; } $str .= "#\n"; @@ -594,7 +637,7 @@ function print_header($handle, $name) // Add space to put text on center for ($i = 0; $i != $DBRESULT; $i++) { - $str .= " "; + $str .= " "; } $str .= "#\n"; $str .= "# #\n"; @@ -711,7 +754,7 @@ function readINIfile($filename, $commentchar) foreach ($array1 as $filedata) { $dataline = trim($filedata); $firstchar = substr($dataline, 0, 1); - if ($firstchar!=$commentchar && $dataline!='') { + if ($firstchar != $commentchar && $dataline != '') { //It's an entry (not a comment and not a blank line) if ($firstchar == '[' && substr($dataline, -1, 1) == ']') { //It's a section @@ -729,7 +772,7 @@ function readINIfile($filename, $commentchar) $array2[$section][$key] = stripcslashes($value); } else { //...without a value - $array2[$section][strtoupper(trim($dataline))]=''; + $array2[$section][strtoupper(trim($dataline))] = ''; } } } else { @@ -742,11 +785,11 @@ function readINIfile($filename, $commentchar) function writeINIfile($filename, $array1, $commentchar, $commenttext) { $handle = fopen($filename, 'wb'); - if ($commenttext!='') { - $comtext = $commentchar. + if ($commenttext != '') { + $comtext = $commentchar . str_replace( $commentchar, - "\r\n".$commentchar, + "\r\n" . $commentchar, str_replace( "\r", $commentchar, @@ -761,10 +804,10 @@ function writeINIfile($filename, $array1, $commentchar, $commenttext) ) ) ); - if (substr($comtext, -1, 1)==$commentchar && substr($comtext, -1, 1)!=$commentchar) { + if (substr($comtext, -1, 1) == $commentchar && substr($comtext, -1, 1) != $commentchar) { $comtext = substr($comtext, 0, -1); } - fwrite($handle, $comtext."\r\n"); + fwrite($handle, $comtext . "\r\n"); } foreach ($array1 as $sections => $items) { //Write the section @@ -773,16 +816,16 @@ function writeINIfile($filename, $array1, $commentchar, $commenttext) } //$section = ucfirst(preg_replace('/[\0-\37]|[\177-\377]/', "-", $sections)); $section = strtoupper(preg_replace('/[\0-\37]|\177/', "-", $sections)); - fwrite($handle, "[".$section."]\r\n"); + fwrite($handle, "[" . $section . "]\r\n"); foreach ($items as $keys => $values) { //Write the key/value pairs $key = strtoupper(preg_replace('/[\0-\37]|=|\177/', "-", $keys)); - if (substr($key, 0, 1)==$commentchar) { - $key = '-'.substr($key, 1); + if (substr($key, 0, 1) == $commentchar) { + $key = '-' . substr($key, 1); } // if (substr($values, 0, 1) == '"' && substr($values, -1, 1) == '"') { $values = substr($values, 1, -1); } $value = ucfirst(addcslashes($values, '')); - fwrite($handle, ' '.$key.'='.$value."\r\n"); + fwrite($handle, ' ' . $key . '=' . $value . "\r\n"); } } fclose($handle); @@ -850,7 +893,7 @@ function getListIndexData() } $listRelation = array(); while ($row = $res->fetchRow()) { - $id = $row['host_id'].';'.$row['service_id']; + $id = $row['host_id'] . ';' . $row['service_id']; $listRelation[$id] = true; } return $listRelation; @@ -900,10 +943,10 @@ function getChildren($infos) while ($row = $res->fetchRow()) { if (!isset($children[$row['config_key']])) { $children[$row['config_key']] = array( - 'key' => $row['config_key'], - 'children' => getChildren($row), - 'values' => $row['config_value'] - ); + 'key' => $row['config_key'], + 'children' => getChildren($row), + 'values' => $row['config_value'] + ); } else { if (!is_array($children[$row['config_key']]['values'])) { $children[$row['config_key']]['values'] = array($children[$row['config_key']]['values']); diff --git a/www/include/configuration/configGenerate/formGenerateFiles.php b/www/include/configuration/configGenerate/formGenerateFiles.php index 06f27b201d1..d4078b470f3 100644 --- a/www/include/configuration/configGenerate/formGenerateFiles.php +++ b/www/include/configuration/configGenerate/formGenerateFiles.php @@ -41,10 +41,12 @@ * Get Poller List */ $acl = $centreon->user->access; -$tab_nagios_server = $acl->getPollerAclConf(array('get_row' => 'name', - 'order' => array('name'), - 'keys' => array('id'), - 'conditions' => array('ns_activate' => 1))); +$tab_nagios_server = $acl->getPollerAclConf(array( + 'get_row' => 'name', + 'order' => array('name'), + 'keys' => array('id'), + 'conditions' => array('ns_activate' => 1) +)); /* Sort the list of poller server */ $pollersId = explode(',', $_GET['poller']); $selectedPollers = array(); @@ -67,14 +69,21 @@ $form->addElement('checkbox', 'move', _("Move Export Files"), null, array('id' => 'nmove')); $form->addElement('checkbox', 'restart', _("Restart Monitoring Engine"), null, array('id' => 'nrestart')); $form->addElement('checkbox', 'postcmd', _('Post generation command'), null, array('id' => 'npostcmd')); -$form->addElement('select', 'restart_mode', _("Method"), array(2 => _("Restart"), 1 => _("Reload")), array('id' => 'nrestart_mode', 'style' => 'width: 220px;')); +$form->addElement( + 'select', + 'restart_mode', + _("Method"), + array(2 => _("Restart"), 1 => _("Reload")), + array('id' => 'nrestart_mode', 'style' => 'width: 220px;') +); $form->setDefaults(array('debug' => '1', 'gen' => '1', 'restart_mode' => '1')); /* Add multiselect for pollers */ +$route = './include/common/webServices/rest/internal.php?object=centreon_configuration_poller&action=list'; $attrPoller = array( 'datasourceOrigin' => 'ajax', 'allowClear' => true, - 'availableDatasetRoute' => './include/common/webServices/rest/internal.php?object=centreon_configuration_poller&action=list', + 'availableDatasetRoute' => $route, 'multiple' => true ); $form->addElement('select2', 'nhost', _("Pollers"), array("class" => "required"), $attrPoller); @@ -89,14 +98,24 @@ $tpl = new Smarty(); $tpl = initSmartyTpl($path, $tpl); -$sub = $form->addElement('button', 'submit', _("Export"), array('id' => 'exportBtn', 'onClick' => 'generationProcess();', 'class' => 'btc bt_success')); +$sub = $form->addElement( + 'button', + 'submit', + _("Export"), + array('id' => 'exportBtn', 'onClick' => 'generationProcess();', 'class' => 'btc bt_success') +); $msg = null; $stdout = null; $tpl->assign("noPollerSelectedLabel", _("Compulsory Poller")); $tpl->assign("consoleLabel", _("Console")); $tpl->assign("progressLabel", _("Progress")); -$tpl->assign("helpattr", 'TITLE, "' . _("Help") . '", CLOSEBTN, true, FIX, [this, 0, 5], BGCOLOR, "#ffff99", BORDERCOLOR, "orange", TITLEFONTCOLOR, "black", TITLEBGCOLOR, "orange", CLOSEBTNCOLORS, ["","black", "white", "red"], WIDTH, -300, SHADOW, true, TEXTALIGN, "justify"'); +$tpl->assign( + "helpattr", + 'TITLE, "' . _("Help") . '", CLOSEBTN, true, FIX, [this, 0, 5], BGCOLOR, "#ffff99", BORDERCOLOR, ' . + '"orange", TITLEFONTCOLOR, "black", TITLEBGCOLOR, "orange", CLOSEBTNCOLORS, ["","black", "white", "red"], ' . + 'WIDTH, -300, SHADOW, true, TEXTALIGN, "justify"' +); include_once("help.php"); @@ -118,7 +137,8 @@ $tpl->display("formGenerateFiles.ihtml"); -?> + + Date: Fri, 11 Aug 2017 11:24:57 +0200 Subject: [PATCH 155/207] * fix style header --- www/include/core/header/header.php | 40 ++++++++------- www/include/core/header/htmlHeader.php | 67 ++++++++++++++++---------- 2 files changed, 63 insertions(+), 44 deletions(-) diff --git a/www/include/core/header/header.php b/www/include/core/header/header.php index dc9a04bda9b..592c8f59798 100644 --- a/www/include/core/header/header.php +++ b/www/include/core/header/header.php @@ -60,15 +60,15 @@ function microtime_float() require_once "$classdir/centreonLang.class.php"; require_once "$classdir/centreonSession.class.php"; require_once "$classdir/centreon.class.php"; -require_once SMARTY_DIR."Smarty.class.php"; +require_once SMARTY_DIR . "Smarty.class.php"; /* * Create DB Connection * - centreon * - centstorage */ -$pearDB = new CentreonDB(); -$pearDBO = new CentreonDB("centstorage"); +$pearDB = new CentreonDB(); +$pearDBO = new CentreonDB("centstorage"); ini_set("session.gc_maxlifetime", "31536000"); @@ -84,7 +84,7 @@ function microtime_float() } $time_limit = time() - ($session_expire["value"] * 60); -$DBRESULT = $pearDB->query("DELETE FROM `session` WHERE `last_reload` < '".$time_limit."'"); +$DBRESULT = $pearDB->query("DELETE FROM `session` WHERE `last_reload` < '" . $time_limit . "'"); $args = "&redirect='"; @@ -94,16 +94,16 @@ function microtime_float() $args .= '&'; } $args .= "$key=$value"; - $a++; + $a++; } $args .= "'"; /* * Get session and Check if session is not expired */ -$DBRESULT = $pearDB->query("SELECT `user_id` FROM `session` WHERE `session_id` = '".session_id()."'"); +$DBRESULT = $pearDB->query("SELECT `user_id` FROM `session` WHERE `session_id` = '" . session_id() . "'"); if (!$DBRESULT->fetchColumn()) { - header("Location: index.php?disconnect=2".$args); + header("Location: index.php?disconnect=2" . $args); } /* @@ -121,13 +121,13 @@ function microtime_float() $a++; } $args .= "'"; - header("Location: index.php?disconnect=1".$args); + header("Location: index.php?disconnect=1" . $args); } else { $args = null; foreach ($_GET as $key => $value) { - $args ? $args .= "&".$key."=".$value : $args = $key."=".$value; + $args ? $args .= "&" . $key . "=" . $value : $args = $key . "=" . $value; } - header("Location: index.php?".$args.""); + header("Location: index.php?" . $args . ""); } } @@ -174,7 +174,7 @@ function microtime_float() $level4 = null; switch (strlen($p)) { case 1: - $level1= $p; + $level1 = $p; break; case 3: $level1 = substr($p, 0, 1); @@ -198,7 +198,7 @@ function microtime_float() $level4 = substr($p, 5, 2); break; default: - $level1= $p; + $level1 = $p; break; } @@ -208,29 +208,33 @@ function microtime_float() $tab_file_css = array(); $i = 0; -if ($handle = @opendir("./Themes/Centreon-2/Color")) { +if ($handle = @opendir("./Themes/Centreon-2/Color")) { while ($file = @readdir($handle)) { - if (is_file("./Themes/Centreon-2/Color"."/$file")) { + if (is_file("./Themes/Centreon-2/Color" . "/$file")) { $tab_file_css[$i++] = $file; } } @closedir($handle); } -$colorfile = "Color/". $tab_file_css[0]; +$colorfile = "Color/" . $tab_file_css[0]; /* * Get CSS Order and color */ -$DBRESULT = $pearDB->query("SELECT `css_name` FROM `css_color_menu` WHERE `menu_nb` = '".$level1."'"); +$DBRESULT = $pearDB->query("SELECT `css_name` FROM `css_color_menu` WHERE `menu_nb` = '" . $level1 . "'"); if ($DBRESULT->fetchColumn() && ($elem = $DBRESULT->fetch())) { - $colorfile = "Color/".$elem["css_name"]; + $colorfile = "Color/" . $elem["css_name"]; } /* * Update Session Table For last_reload and current_page row */ -$DBRESULT = $pearDB->query("UPDATE `session` SET `current_page` = '".$level1.$level2.$level3.$level4."', `last_reload` = '".time()."', `ip_address` = '".$_SERVER["REMOTE_ADDR"]."' WHERE CONVERT(`session_id` USING utf8) = '".session_id()."' AND `user_id` = '".$centreon->user->user_id."'"); +$query = "UPDATE `session` SET `current_page` = '" . $level1 . $level2 . $level3 . $level4 . + "', `last_reload` = '" . time() . "', `ip_address` = '" . $_SERVER["REMOTE_ADDR"] . + "' WHERE CONVERT(`session_id` USING utf8) = '" . session_id() . "' AND `user_id` = '" . + $centreon->user->user_id . "'"; +$DBRESULT = $pearDB->query($query); /* * Init Language diff --git a/www/include/core/header/htmlHeader.php b/www/include/core/header/htmlHeader.php index 49eb448ace7..f9b105f7eea 100644 --- a/www/include/core/header/htmlHeader.php +++ b/www/include/core/header/htmlHeader.php @@ -53,14 +53,16 @@ - - - + + + - - + + @@ -68,31 +70,39 @@ // == Declare CSS for modules foreach ($centreon->modules as $module_name => $infos) { - if (file_exists(_CENTREON_PATH_."www/modules/".$module_name."/static/css/styles.css")) { - print "\n"; + if (file_exists(_CENTREON_PATH_ . "www/modules/" . $module_name . "/static/css/styles.css")) { + print "\n"; } } ?> - + - - - + + + - + - - + + @@ -114,12 +124,14 @@ if ($centreon->user->access->admin == 0) { $tabActionACL = $centreon->user->access->getActions(); if ($min != 1 && (isset($tabActionACL["top_counter"]) || isset($tabActionACL["poller_stats"]))) { - print "\n"; + print "\n"; } unset($tabActionACL); } else { if ($min != 1) { - print "\n"; + print "\n"; } } @@ -127,34 +139,35 @@ $searchStr = ""; if (isset($_GET["search"])) { - $searchStr .= "search_host=".htmlentities($_GET["search"], ENT_QUOTES, "UTF-8"); + $searchStr .= "search_host=" . htmlentities($_GET["search"], ENT_QUOTES, "UTF-8"); } if (isset($centreon->historySearch[$url]) && !isset($_GET["search"])) { - $searchStr .= "search_host=".$centreon->historySearch[$url]; + $searchStr .= "search_host=" . $centreon->historySearch[$url]; } $searchStrSVC = ""; if (isset($_GET["search_service"])) { - $searchStrSVC = "search_service=".htmlentities($_GET["search_service"], ENT_QUOTES, "UTF-8"); + $searchStrSVC = "search_service=" . htmlentities($_GET["search_service"], ENT_QUOTES, "UTF-8"); if ($searchStr == "") { - $searchStrSVC = "&".$searchStrSVC; + $searchStrSVC = "&" . $searchStrSVC; } $search_service = htmlentities($_GET["search_service"], ENT_QUOTES, "UTF-8"); } elseif (isset($centreon->historySearchService[$url]) && !isset($_GET["search_service"])) { $search_service = $centreon->historySearchService[$url]; - $searchStr .= "search_service=".$centreon->historySearchService[$url]; + $searchStr .= "search_service=" . $centreon->historySearchService[$url]; } /* * include javascript */ $res = null; - $sth= $pearDB->prepare("SELECT DISTINCT PathName_js, init FROM topology_JS WHERE id_page = ? AND (o = ? OR o IS NULL)"); + $query = "SELECT DISTINCT PathName_js, init FROM topology_JS WHERE id_page = ? AND (o = ? OR o IS NULL)"; + $sth = $pearDB->prepare($query); $sth->execute(array($p, $o)); while ($topology_js = $sth->fetch()) { if ($topology_js['PathName_js'] != "./include/common/javascript/ajaxMonitoring.js") { if ($topology_js['PathName_js'] != "") { - echo "\n"; + echo "\n"; } } } @@ -190,7 +203,9 @@ } $res = null; - $DBRESULT = $pearDB->query("SELECT DISTINCT PathName_js, init FROM topology_JS WHERE id_page = '".$p."' AND (o = '" . $o . "' OR o IS NULL)"); + $query = "SELECT DISTINCT PathName_js, init FROM topology_JS WHERE id_page = '" . + $p . "' AND (o = '" . $o . "' OR o IS NULL)"; + $DBRESULT = $pearDB->query($query); while ($topology_js = $DBRESULT->fetch()) { if ($topology_js['init'] == "initM") { if ($o != "hd" && $o != "svcd") { @@ -204,8 +219,8 @@ print "\tsetTimeout('initM($tM, \"$sid\", \"$obis\")', 0);"; } } elseif ($topology_js['init']) { - echo "if (typeof ".$topology_js['init']." == 'function') {"; - echo $topology_js['init'] ."();"; + echo "if (typeof " . $topology_js['init'] . " == 'function') {"; + echo $topology_js['init'] . "();"; echo "}"; } } From 76e675abe680bc6ceca6032fd8ea71afb9b19a61 Mon Sep 17 00:00:00 2001 From: loiclau Date: Fri, 11 Aug 2017 11:30:21 +0200 Subject: [PATCH 156/207] * fix style login --- www/include/core/login/login.php | 18 +++++------ www/include/core/login/processLogin.php | 43 ++++++++++++++++++------- 2 files changed, 41 insertions(+), 20 deletions(-) diff --git a/www/include/core/login/login.php b/www/include/core/login/login.php index 8dcd546b8e0..2a34b603db8 100644 --- a/www/include/core/login/login.php +++ b/www/include/core/login/login.php @@ -73,19 +73,19 @@ } elseif (isset($_POST["centreon_token"])) { $loginMessages[] = _('Your credentials are incorrect.'); } - + if (isset($_GET["disconnect"]) && $_GET["disconnect"] == 2) { $loginMessages[] = _('Your session is expired.'); } - + if ($file_install_acces) { $loginMessages[] = $error_msg; } - + if (isset($msg) && $msg) { $loginMessages[] = $msg; } - + /** * Adding hidden value */ @@ -93,7 +93,7 @@ $pageElement = $form->addElement('hidden', 'p'); $pageElement->setValue($_GET['p']); } - + /** * Adding validation rule */ @@ -109,16 +109,16 @@ if ($file_install_acces) { $submitLogin->freeze(); } - + /* * Smarty template Init */ $tpl = new Smarty(); -$tpl = initSmartyTpl($path.'/include/core/login/template/', $tpl); +$tpl = initSmartyTpl($path . '/include/core/login/template/', $tpl); // Initializing variables $tpl->assign('loginMessages', $loginMessages); -$tpl->assign('centreonVersion', 'v. '.$release['value']); +$tpl->assign('centreonVersion', 'v. ' . $release['value']); $tpl->assign('currentDate', date("d/m/Y")); // Redirect User @@ -126,7 +126,7 @@ INPUT_GET, 'redirect', FILTER_SANITIZE_STRING, - array('options' => array('default'=> '')) + array('options' => array('default' => '')) ); $tpl->assign('redirect', $redirect); diff --git a/www/include/core/login/processLogin.php b/www/include/core/login/processLogin.php index 634ec238a09..cc148e12f40 100644 --- a/www/include/core/login/processLogin.php +++ b/www/include/core/login/processLogin.php @@ -32,10 +32,17 @@ * For more information : contact@centreon.com * */ - + if (isset($_POST["centreon_token"]) - || (isset($_GET["autologin"]) && $_GET["autologin"] && $_GET["autologin"] && isset($generalOptions["enable_autologin"]) && $generalOptions["enable_autologin"]) - || (isset($_POST["autologin"]) && $_POST["autologin"] && isset($generalOptions["enable_autologin"]) && $generalOptions["enable_autologin"]) + || (isset($_GET["autologin"]) && + $_GET["autologin"] && + $_GET["autologin"] && + isset($generalOptions["enable_autologin"]) && + $generalOptions["enable_autologin"]) + || (isset($_POST["autologin"]) && + $_POST["autologin"] && + isset($generalOptions["enable_autologin"]) && + $generalOptions["enable_autologin"]) || (!isset($generalOptions['sso_enable']) || $generalOptions['sso_enable'] == 1)) { /* * Init log class @@ -52,7 +59,7 @@ isset($_GET["autologin"]) ? $autologin = $_GET["autologin"] : $autologin = 0; isset($_GET["useralias"]) ? $useraliasG = $_GET["useralias"] : $useraliasG = null; isset($_GET["password"]) ? $passwordG = $_GET["password"] : $passwordG = null; - + $useraliasP = null; $passwordP = null; if ($loginValidate) { @@ -72,18 +79,32 @@ $encryptType = 1; } - $centreonAuth = new CentreonAuthSSO($useralias, $password, $autologin, $pearDB, $CentreonLog, $encryptType, $token, $generalOptions); + $centreonAuth = new CentreonAuthSSO( + $useralias, + $password, + $autologin, + $pearDB, + $CentreonLog, + $encryptType, + $token, + $generalOptions + ); if ($centreonAuth->passwdOk == 1) { $centreon = new Centreon($centreonAuth->userInfos); $_SESSION["centreon"] = $centreon; - $DBRESULT = $pearDB->prepare("INSERT INTO `session` (`session_id` , `user_id` , `current_page` , `last_reload`, `ip_address`) VALUES (?, ?, ?, ?, ?)"); - $pearDB->execute($DBRESULT, array(session_id(), $centreon->user->user_id, '1', time(), $_SERVER["REMOTE_ADDR"])); + $query = "INSERT INTO `session` (`session_id` , `user_id` , `current_page` , `last_reload`, `ip_address`) " . + "VALUES (?, ?, ?, ?, ?)"; + $DBRESULT = $pearDB->prepare($query); + $pearDB->execute( + $DBRESULT, + array(session_id(), $centreon->user->user_id, '1', time(), $_SERVER["REMOTE_ADDR"]) + ); if (!isset($_POST["submit"])) { - if (isset ($_GET["p"]) && $_GET["p"] != '') { - header('Location: main.php?p='.$_GET["p"]); - } else if (isset($centreon->user->default_page) && $centreon->user->default_page != '') { - header('Location: main.php?p='.$centreon->user->default_page); + if (isset($_GET["p"]) && $_GET["p"] != '') { + header('Location: main.php?p=' . $_GET["p"]); + } elseif (isset($centreon->user->default_page) && $centreon->user->default_page != '') { + header('Location: main.php?p=' . $centreon->user->default_page); } else { header('Location: main.php'); } From 69720e610734ce48038bfd7c83b52e7fd93dc4cc Mon Sep 17 00:00:00 2001 From: loiclau Date: Fri, 11 Aug 2017 11:56:19 +0200 Subject: [PATCH 157/207] * fix style external cmd --- www/include/monitoring/external_cmd/cmd.php | 24 +-- .../monitoring/external_cmd/functions.php | 202 ++++++++++++++---- .../external_cmd/functionsPopup.php | 30 +-- .../external_cmd/popup/massive_ack.php | 29 ++- .../external_cmd/popup/massive_downtime.php | 55 +++-- .../monitoring/external_cmd/popup/popup.php | 2 +- 6 files changed, 247 insertions(+), 95 deletions(-) diff --git a/www/include/monitoring/external_cmd/cmd.php b/www/include/monitoring/external_cmd/cmd.php index 1088ac7a88d..8c4b1ac569f 100644 --- a/www/include/monitoring/external_cmd/cmd.php +++ b/www/include/monitoring/external_cmd/cmd.php @@ -32,7 +32,7 @@ * For more information : contact@centreon.com * */ - + if (!isset($centreon)) { exit(); } @@ -84,7 +84,7 @@ case 7: svc_check($key, $en); break; - + /* * Notifications */ @@ -97,7 +97,7 @@ case 10: svc_notifications($key, $en); break; - + /* Auto Notification */ case 80: autoNotificationServiceStart($key); @@ -111,7 +111,7 @@ case 83: autoNotificationHostStop($key); break; - + /* Auto Check */ case 90: autoCheckServiceStart($key); @@ -133,7 +133,7 @@ case 95: schedule_host_checks($key, 1); break; - + /* * Acknowledge status */ @@ -143,7 +143,7 @@ case 15: acknowledgeService($param); break; - + /* * Configure nagios Core */ @@ -216,7 +216,7 @@ case 42: send_cmd("DISABLE_PERFORMANCE_DATA", ""); break; - + /* * End Configuration Nagios Core */ @@ -232,7 +232,7 @@ case 46: svc_event_handler($key, $en); break; - + case 49: host_flap_detection($key, 1); break; @@ -245,7 +245,7 @@ case 52: host_event_handler($key, 0); break; - + case 59: add_hostgroup_downtime($param["dtm"]); break; @@ -273,7 +273,7 @@ case 67: schedule_svc_check($key, 1, 1); break; - + /* Auto Aknowledge */ case 70: autoAcknowledgeServiceStart($key); @@ -287,7 +287,7 @@ case 73: autoAcknowledgeHostStop($key); break; - + /* Auto Notification */ case 80: autoNotificationServiceStart($key); @@ -301,7 +301,7 @@ case 83: autoNotificationHostStop($key); break; - + /* Auto Check */ case 90: autoCheckServiceStart($key); diff --git a/www/include/monitoring/external_cmd/functions.php b/www/include/monitoring/external_cmd/functions.php index d23f30763c0..b676280ce09 100644 --- a/www/include/monitoring/external_cmd/functions.php +++ b/www/include/monitoring/external_cmd/functions.php @@ -49,11 +49,11 @@ function write_command($cmd, $poller) * Destination is centcore pipe path */ if (defined("_CENTREON_VARLIB_")) { - $destination = _CENTREON_VARLIB_."/centcore.cmd"; + $destination = _CENTREON_VARLIB_ . "/centcore.cmd"; } else { $destination = "/var/lib/centreon/centcore.cmd"; } - + $cmd = str_replace("`", "`", $cmd); $cmd = str_replace("\n", "
", $cmd); $informations = preg_split("/\;/", $key); @@ -63,7 +63,7 @@ function write_command($cmd, $poller) } setlocale(LC_CTYPE, 'en_US.UTF-8'); - $str = "echo ". escapeshellarg("EXTERNALCMD:$poller:[" . time() . "]" . $cmd . "\n") . " >> " . $destination; + $str = "echo " . escapeshellarg("EXTERNALCMD:$poller:[" . time() . "]" . $cmd . "\n") . " >> " . $destination; return passthru($str); } @@ -88,7 +88,10 @@ function schedule_host_svc_checks($arg, $forced) if ($actions == true || $is_admin) { $tab_forced = array("0" => "", "1" => "_FORCED"); - $flg = send_cmd(" SCHEDULE" . $tab_forced[$forced] . "_HOST_SVC_CHECKS;" . $arg . ";" . time(), GetMyHostPoller($pearDB, $arg)); + $flg = send_cmd( + " SCHEDULE" . $tab_forced[$forced] . "_HOST_SVC_CHECKS;" . $arg . ";" . time(), + GetMyHostPoller($pearDB, $arg) + ); return $flg; } return null; @@ -106,11 +109,15 @@ function schedule_svc_checks($arg, $forced) if ($forced == "1") { $actions = $centreon->user->access->checkAction("service_schedule_forced_check"); } - + if ($actions == true || $is_admin) { $tab_forced = array("0" => "", "1" => "_FORCED"); $tab_data = preg_split("/\;/", $arg); - $flg = send_cmd(" SCHEDULE" . $tab_forced[$forced] . "_SVC_CHECK;" . urldecode($tab_data[0]) . ";" . urldecode($tab_data[1]) . ";" . time(), GetMyHostPoller($pearDB, urldecode($tab_data[0]))); + $flg = send_cmd( + " SCHEDULE" . $tab_forced[$forced] . "_SVC_CHECK;" . urldecode($tab_data[0]) . + ";" . urldecode($tab_data[1]) . ";" . time(), + GetMyHostPoller($pearDB, urldecode($tab_data[0])) + ); return $flg; } return null; @@ -131,7 +138,10 @@ function schedule_host_checks($arg, $forced) if ($actions == true || $is_admin) { $tab_forced = array("0" => "", "1" => "_FORCED"); $tab_data = preg_split("/\;/", $arg); - $flg = send_cmd(" SCHEDULE" . $tab_forced[$forced] . "_HOST_CHECK;" . urldecode($tab_data[0]) . ";" . time(), GetMyHostPoller($pearDB, urldecode($tab_data[0]))); + $flg = send_cmd( + " SCHEDULE" . $tab_forced[$forced] . "_HOST_CHECK;" . urldecode($tab_data[0]) . ";" . time(), + GetMyHostPoller($pearDB, urldecode($tab_data[0])) + ); return $flg; } return null; @@ -148,7 +158,10 @@ function host_check($arg, $type) $actions = $centreon->user->access->checkAction("host_checks"); if ($actions == true || $is_admin) { - $flg = send_cmd(" " . $tab[$type] . "_HOST_CHECK;" . urldecode($arg), GetMyHostPoller($pearDB, urldecode($arg))); + $flg = send_cmd( + " " . $tab[$type] . "_HOST_CHECK;" . urldecode($arg), + GetMyHostPoller($pearDB, urldecode($arg)) + ); return $flg; } @@ -166,7 +179,10 @@ function host_notification($arg, $type) $actions = $centreon->user->access->checkAction("host_notifications"); if ($actions == true || $is_admin) { - $flg = send_cmd(" " . $tab[$type] . "_HOST_NOTIFICATIONS;" . urldecode($arg), GetMyHostPoller($pearDB, urldecode($arg))); + $flg = send_cmd( + " " . $tab[$type] . "_HOST_NOTIFICATIONS;" . urldecode($arg), + GetMyHostPoller($pearDB, urldecode($arg)) + ); return $flg; } return null; @@ -183,7 +199,10 @@ function host_svc_notifications($arg, $type) $actions = $centreon->user->access->checkAction("host_notifications_for_services"); if ($actions == true || $is_admin) { - $flg = send_cmd(" " . $tab[$type] . "_HOST_SVC_NOTIFICATIONS;" . urldecode($arg), GetMyHostPoller($pearDB, urldecode($arg))); + $flg = send_cmd( + " " . $tab[$type] . "_HOST_SVC_NOTIFICATIONS;" . urldecode($arg), + GetMyHostPoller($pearDB, urldecode($arg)) + ); return $flg; } return null; @@ -200,7 +219,10 @@ function host_svc_checks($arg, $type) $actions = $centreon->user->access->checkAction("host_checks_for_services"); if ($actions == true || $is_admin) { - $flg = send_cmd(" " . $tab[$type] . "_HOST_SVC_CHECKS;" . urldecode($arg) . ";" . time(), GetMyHostPoller($pearDB, urldecode($arg))); + $flg = send_cmd( + " " . $tab[$type] . "_HOST_SVC_CHECKS;" . urldecode($arg) . ";" . time(), + GetMyHostPoller($pearDB, urldecode($arg)) + ); return $flg; } return null; @@ -218,7 +240,10 @@ function svc_check($arg, $type) if ($actions == true || $is_admin) { $tab_data = preg_split("/\;/", $arg); - $flg = send_cmd(" " . $tab[$type] . "_SVC_CHECK;" . urldecode($tab_data["0"]) . ";" . urldecode($tab_data["1"]), GetMyHostPoller($pearDB, urldecode($tab_data["0"]))); + $flg = send_cmd( + " " . $tab[$type] . "_SVC_CHECK;" . urldecode($tab_data["0"]) . ";" . urldecode($tab_data["1"]), + GetMyHostPoller($pearDB, urldecode($tab_data["0"])) + ); return $flg; } return null; @@ -236,7 +261,10 @@ function passive_svc_check($arg, $type) if ($actions == true || $is_admin) { $tab_data = preg_split("/\;/", $arg); - $flg = send_cmd(" " . $tab[$type] . "_PASSIVE_SVC_CHECKS;" . urldecode($tab_data[0]) . ";" . urldecode($tab_data[1]), GetMyHostPoller($pearDB, urldecode($tab_data["0"]))); + $flg = send_cmd( + " " . $tab[$type] . "_PASSIVE_SVC_CHECKS;" . urldecode($tab_data[0]) . ";" . urldecode($tab_data[1]), + GetMyHostPoller($pearDB, urldecode($tab_data["0"])) + ); return $flg; } return null; @@ -254,7 +282,10 @@ function svc_notifications($arg, $type) if ($actions == true || $is_admin) { $tab_data = preg_split("/\;/", $arg); - $flg = send_cmd(" " . $tab[$type] . "_SVC_NOTIFICATIONS;" . urldecode($tab_data[0]) . ";" . urldecode($tab_data[1]), GetMyHostPoller($pearDB, urldecode($tab_data["0"]))); + $flg = send_cmd( + " " . $tab[$type] . "_SVC_NOTIFICATIONS;" . urldecode($tab_data[0]) . ";" . urldecode($tab_data[1]), + GetMyHostPoller($pearDB, urldecode($tab_data["0"])) + ); return $flg; } return null; @@ -272,7 +303,10 @@ function svc_event_handler($arg, $type) if ($actions == true || $is_admin) { $tab_data = preg_split("/\;/", $arg); - $flg = send_cmd(" " . $tab[$type] . "_SVC_EVENT_HANDLER;" . urldecode($tab_data[0]) . ";" . urldecode($tab_data[1]), GetMyHostPoller($pearDB, urldecode($tab_data["0"]))); + $flg = send_cmd( + " " . $tab[$type] . "_SVC_EVENT_HANDLER;" . urldecode($tab_data[0]) . ";" . urldecode($tab_data[1]), + GetMyHostPoller($pearDB, urldecode($tab_data["0"])) + ); return $flg; } return null; @@ -290,7 +324,10 @@ function host_event_handler($arg, $type) if ($actions == true || $is_admin) { $tab_data = preg_split("/\;/", $arg); - $flg = send_cmd(" " . $tab[$type] . "_HOST_EVENT_HANDLER;" . urldecode($arg), GetMyHostPoller($pearDB, urldecode($arg))); + $flg = send_cmd( + " " . $tab[$type] . "_HOST_EVENT_HANDLER;" . urldecode($arg), + GetMyHostPoller($pearDB, urldecode($arg)) + ); return $flg; } return null; @@ -308,7 +345,10 @@ function svc_flapping_enable($arg, $type) if ($actions == true || $is_admin) { $tab_data = preg_split("/\;/", $arg); - $flg = send_cmd(" " . $tab[$type] . "_SVC_FLAP_DETECTION;" . urldecode($tab_data[0]) . ";" . urldecode($tab_data[1]), GetMyHostPoller($pearDB, urldecode($tab_data[0]))); + $flg = send_cmd( + " " . $tab[$type] . "_SVC_FLAP_DETECTION;" . urldecode($tab_data[0]) . ";" . urldecode($tab_data[1]), + GetMyHostPoller($pearDB, urldecode($tab_data[0])) + ); return $flg; } return null; @@ -326,7 +366,10 @@ function host_flapping_enable($arg, $type) if ($actions == true || $is_admin) { $tab_data = preg_split("/\;/", $arg); - $flg = send_cmd(" " . $tab[$type] . "_HOST_FLAP_DETECTION;" . urldecode($arg), GetMyHostPoller($pearDB, urldecode($arg))); + $flg = send_cmd( + " " . $tab[$type] . "_HOST_FLAP_DETECTION;" . urldecode($arg), + GetMyHostPoller($pearDB, urldecode($arg)) + ); return $flg; } return null; @@ -340,7 +383,10 @@ function notifi_host_hostgroup($arg, $type) { global $pearDB, $tab, $is_admin; $tab_data = preg_split("/\;/", $arg); - $flg = send_cmd(" " . $tab[$type] . "_HOST_NOTIFICATIONS;" . urldecode($tab_data[0]), GetMyHostPoller($pearDB, urldecode($tab_data[0]))); + $flg = send_cmd( + " " . $tab[$type] . "_HOST_NOTIFICATIONS;" . urldecode($tab_data[0]), + GetMyHostPoller($pearDB, urldecode($tab_data[0])) + ); return $flg; } @@ -359,13 +405,28 @@ function acknowledgeHost($param) $key = $param["host_name"]; isset($param['sticky']) && $param['sticky'] == "1" ? $sticky = "2" : $sticky = "1"; $host_poller = GetMyHostPoller($pearDB, htmlentities($param["host_name"], ENT_QUOTES, "UTF-8")); - $flg = write_command(" ACKNOWLEDGE_HOST_PROBLEM;" . urldecode($param["host_name"]) . ";$sticky;" . htmlentities($param["notify"], ENT_QUOTES, "UTF-8") . ";" . htmlentities($param["persistent"], ENT_QUOTES, "UTF-8") . ";" . htmlentities($param["author"], ENT_QUOTES, "UTF-8") . ";" . htmlentities($param["comment"], ENT_QUOTES, "UTF-8"), urldecode($host_poller)); + $flg = write_command( + " ACKNOWLEDGE_HOST_PROBLEM;" . urldecode($param["host_name"]) . + ";$sticky;" . htmlentities($param["notify"], ENT_QUOTES, "UTF-8") . ";" . + htmlentities($param["persistent"], ENT_QUOTES, "UTF-8") . ";" . + htmlentities($param["author"], ENT_QUOTES, "UTF-8") . ";" . + htmlentities($param["comment"], ENT_QUOTES, "UTF-8"), + urldecode($host_poller) + ); if (isset($param['ackhostservice']) && $param['ackhostservice'] == 1) { $svc_tab = getMyHostServices(getMyHostID(htmlentities($param["host_name"], ENT_QUOTES, "UTF-8"))); if (count($svc_tab)) { foreach ($svc_tab as $key2 => $value) { - write_command(" ACKNOWLEDGE_SVC_PROBLEM;" . htmlentities(urldecode($param["host_name"]), ENT_QUOTES, "UTF-8") . ";" . $value . ";" . $sticky . ";" . htmlentities($param["notify"], ENT_QUOTES, "UTF-8") . ";" . htmlentities($param["persistent"], ENT_QUOTES, "UTF-8") . ";" . htmlentities($param["author"], ENT_QUOTES, "UTF-8") . ";" . htmlentities($param["comment"], ENT_QUOTES, "UTF-8"), urldecode($host_poller)); + write_command( + " ACKNOWLEDGE_SVC_PROBLEM;" . + htmlentities(urldecode($param["host_name"]), ENT_QUOTES, "UTF-8") . + ";" . $value . ";" . $sticky . ";" . htmlentities($param["notify"], ENT_QUOTES, "UTF-8") . ";" . + htmlentities($param["persistent"], ENT_QUOTES, "UTF-8") . ";" . + htmlentities($param["author"], ENT_QUOTES, "UTF-8") . ";" . + htmlentities($param["comment"], ENT_QUOTES, "UTF-8"), + urldecode($host_poller) + ); } } } @@ -389,7 +450,10 @@ function acknowledgeHostDisable() $actions = $centreon->user->access->checkAction("host_disacknowledgement"); if ($actions == true || $is_admin) { - $flg = send_cmd(" REMOVE_HOST_ACKNOWLEDGEMENT;" . urldecode($_GET["host_name"]), GetMyHostPoller($pearDB, urldecode($_GET["host_name"]))); + $flg = send_cmd( + " REMOVE_HOST_ACKNOWLEDGEMENT;" . urldecode($_GET["host_name"]), + GetMyHostPoller($pearDB, urldecode($_GET["host_name"])) + ); return $flg; } @@ -407,7 +471,11 @@ function acknowledgeServiceDisable() $actions = $centreon->user->access->checkAction("service_disacknowledgement"); if ($actions == true || $is_admin) { - $flg = send_cmd(" REMOVE_SVC_ACKNOWLEDGEMENT;" . urldecode($_GET["host_name"]) . ";" . urldecode($_GET["service_description"]), GetMyHostPoller($pearDB, urldecode($_GET["host_name"]))); + $flg = send_cmd( + " REMOVE_SVC_ACKNOWLEDGEMENT;" . urldecode($_GET["host_name"]) . ";" . + urldecode($_GET["service_description"]), + GetMyHostPoller($pearDB, urldecode($_GET["host_name"])) + ); return $flg; } return null; @@ -428,10 +496,19 @@ function acknowledgeService($param) $param["comment"] = $param["comment"]; $param["comment"] = str_replace('\'', ' ', $param["comment"]); isset($param['sticky']) && $param['sticky'] == "1" ? $sticky = "2" : $sticky = "1"; - $flg = send_cmd(" ACKNOWLEDGE_SVC_PROBLEM;" . urldecode($param["host_name"]) . ";" . urldecode($param["service_description"]) . ";" . $sticky . ";" . $param["notify"] . ";" . $param["persistent"] . ";" . $param["author"] . ";" . $param["comment"], GetMyHostPoller($pearDB, urldecode($param["host_name"]))); + $flg = send_cmd( + " ACKNOWLEDGE_SVC_PROBLEM;" . urldecode($param["host_name"]) . ";" . + urldecode($param["service_description"]) . ";" . $sticky . ";" . $param["notify"] . + ";" . $param["persistent"] . ";" . $param["author"] . ";" . $param["comment"], + GetMyHostPoller($pearDB, urldecode($param["host_name"])) + ); isset($param['force_check']) && $param['force_check'] ? $force_check = 1 : $force_check = 0; if ($force_check == 1 && $centreon->user->access->checkAction("service_schedule_forced_check") == true) { - send_cmd(" SCHEDULE_FORCED_SVC_CHECK;" . urldecode($param["host_name"]) . ";" . urldecode($param["service_description"]) . ";" . time(), GetMyHostPoller($pearDB, urldecode($param["host_name"]))); + send_cmd( + " SCHEDULE_FORCED_SVC_CHECK;" . urldecode($param["host_name"]) . ";" . + urldecode($param["service_description"]) . ";" . time(), + GetMyHostPoller($pearDB, urldecode($param["host_name"])) + ); } set_user_param($centreon->user->user_id, $pearDB, "ack_sticky", $param["sticky"]); set_user_param($centreon->user->user_id, $pearDB, "ack_notify", $param["notify"]); @@ -450,7 +527,12 @@ function submitPassiveCheck() if ($actions == true || $is_admin) { $key = $_GET["host_name"]; - $flg = send_cmd(" PROCESS_SERVICE_CHECK_RESULT;" . urldecode($_GET["host_name"]) . ";" . urldecode($_GET["service_description"]) . ";" . $_GET["return_code"] . ";" . $_GET["output"] . "|" . $_GET["dataPerform"], GetMyHostPoller($pearDB, urldecode($_GET["host_name"]))); + $flg = send_cmd( + " PROCESS_SERVICE_CHECK_RESULT;" . urldecode($_GET["host_name"]) . ";" . + urldecode($_GET["service_description"]) . ";" . $_GET["return_code"] . ";" . $_GET["output"] . "|" . + $_GET["dataPerform"], + GetMyHostPoller($pearDB, urldecode($_GET["host_name"])) + ); return $flg; } return null; @@ -464,7 +546,11 @@ function submitHostPassiveCheck() if ($actions == true || $is_admin) { $key = $_GET["host_name"]; - $flg = send_cmd(" PROCESS_HOST_CHECK_RESULT;" . urldecode($_GET["host_name"]) . ";" . $_GET["return_code"] . ";" . $_GET["output"] . "|" . $_GET["dataPerform"], GetMyHostPoller($pearDB, urldecode($_GET["host_name"]))); + $flg = send_cmd( + " PROCESS_HOST_CHECK_RESULT;" . urldecode($_GET["host_name"]) . ";" . + $_GET["return_code"] . ";" . $_GET["output"] . "|" . $_GET["dataPerform"], + GetMyHostPoller($pearDB, urldecode($_GET["host_name"])) + ); return $flg; } return null; @@ -510,7 +596,11 @@ function autoAcknowledgeServiceStart($key) if ($actions == true || $is_admin) { $comment = "Service Auto Acknowledge by " . $centreon->user->alias . "\n"; $ressource = preg_split("/\;/", $key); - $flg = send_cmd(" ACKNOWLEDGE_SVC_PROBLEM;" . urldecode($ressource[0]) . ";" . urldecode($ressource[1]) . ";1;1;1;" . $centreon->user->alias . ";" . $comment, GetMyHostPoller($pearDB, urldecode($ressource[0]))); + $flg = send_cmd( + " ACKNOWLEDGE_SVC_PROBLEM;" . urldecode($ressource[0]) . ";" . urldecode($ressource[1]) . + ";1;1;1;" . $centreon->user->alias . ";" . $comment, + GetMyHostPoller($pearDB, urldecode($ressource[0])) + ); return $flg; } } @@ -524,7 +614,10 @@ function autoAcknowledgeServiceStop($key) if ($actions == true || $is_admin) { $comment = "Service Auto Acknowledge by " . $centreon->user->alias . "\n"; $ressource = preg_split("/\;/", $key); - $flg = send_cmd(" REMOVE_SVC_ACKNOWLEDGEMENT;" . urldecode($ressource[0]) . ";" . urldecode($ressource[1]), GetMyHostPoller($pearDB, urldecode($ressource[0]))); + $flg = send_cmd( + " REMOVE_SVC_ACKNOWLEDGEMENT;" . urldecode($ressource[0]) . ";" . urldecode($ressource[1]), + GetMyHostPoller($pearDB, urldecode($ressource[0])) + ); return $flg; } } @@ -542,7 +635,11 @@ function autoAcknowledgeHostStart($key) if ($actions == true || $is_admin) { $comment = "Host Auto Acknowledge by " . $centreon->user->alias . "\n"; $ressource = preg_split("/\;/", $key); - $flg = send_cmd(" ACKNOWLEDGE_HOST_PROBLEM;" . urldecode($ressource[0]) . ";1;1;1;" . $centreon->user->alias . ";" . $comment, GetMyHostPoller($pearDB, urldecode($ressource[0]))); + $flg = send_cmd( + " ACKNOWLEDGE_HOST_PROBLEM;" . urldecode($ressource[0]) . + ";1;1;1;" . $centreon->user->alias . ";" . $comment, + GetMyHostPoller($pearDB, urldecode($ressource[0])) + ); return $flg; } } @@ -556,7 +653,10 @@ function autoAcknowledgeHostStop($key) if ($actions == true || $is_admin) { $comment = "Host Auto Acknowledge by " . $centreon->user->alias . "\n"; $ressource = preg_split("/\;/", $key); - $flg = send_cmd(" REMOVE_HOST_ACKNOWLEDGEMENT;" . urldecode($ressource[0]), GetMyHostPoller($pearDB, urldecode($ressource[0]))); + $flg = send_cmd( + " REMOVE_HOST_ACKNOWLEDGEMENT;" . urldecode($ressource[0]), + GetMyHostPoller($pearDB, urldecode($ressource[0])) + ); return $flg; } } @@ -573,7 +673,10 @@ function autoNotificationServiceStart($key) if ($actions == true || $is_admin) { $ressource = preg_split("/\;/", $key); - $flg = send_cmd(" ENABLE_SVC_NOTIFICATIONS;" . urldecode($ressource[0]) . ";" . urldecode($ressource[1]), GetMyHostPoller($pearDB, urldecode($ressource[0]))); + $flg = send_cmd( + " ENABLE_SVC_NOTIFICATIONS;" . urldecode($ressource[0]) . ";" . urldecode($ressource[1]), + GetMyHostPoller($pearDB, urldecode($ressource[0])) + ); return $flg; } } @@ -586,7 +689,10 @@ function autoNotificationServiceStop($key) if ($actions == true || $is_admin) { $ressource = preg_split("/\;/", $key); - $flg = send_cmd(" DISABLE_SVC_NOTIFICATIONS;" . urldecode($ressource[0]) . ";" . urldecode($ressource[1]), GetMyHostPoller($pearDB, urldecode($ressource[0]))); + $flg = send_cmd( + " DISABLE_SVC_NOTIFICATIONS;" . urldecode($ressource[0]) . ";" . urldecode($ressource[1]), + GetMyHostPoller($pearDB, urldecode($ressource[0])) + ); return $flg; } } @@ -603,7 +709,10 @@ function autoNotificationHostStart($key) if ($actions == true || $is_admin) { $ressource = preg_split("/\;/", $key); - $flg = send_cmd(" ENABLE_HOST_NOTIFICATIONS;" . urldecode($ressource[0]), GetMyHostPoller($pearDB, urldecode($ressource[0]))); + $flg = send_cmd( + " ENABLE_HOST_NOTIFICATIONS;" . urldecode($ressource[0]), + GetMyHostPoller($pearDB, urldecode($ressource[0])) + ); return $flg; } } @@ -616,7 +725,10 @@ function autoNotificationHostStop($key) if ($actions == true || $is_admin) { $ressource = preg_split("/\;/", $key); - $flg = send_cmd(" DISABLE_HOST_NOTIFICATIONS;" . urldecode($ressource[0]), GetMyHostPoller($pearDB, urldecode($ressource[0]))); + $flg = send_cmd( + " DISABLE_HOST_NOTIFICATIONS;" . urldecode($ressource[0]), + GetMyHostPoller($pearDB, urldecode($ressource[0])) + ); return $flg; } } @@ -633,7 +745,10 @@ function autoCheckServiceStart($key) if ($actions == true || $is_admin) { $ressource = preg_split("/\;/", $key); - $flg = send_cmd(" ENABLE_SVC_CHECK;" . urldecode($ressource[0]) . ";" . urldecode($ressource[1]), GetMyHostPoller($pearDB, urldecode($ressource[0]))); + $flg = send_cmd( + " ENABLE_SVC_CHECK;" . urldecode($ressource[0]) . ";" . urldecode($ressource[1]), + GetMyHostPoller($pearDB, urldecode($ressource[0])) + ); return $flg; } } @@ -646,7 +761,10 @@ function autoCheckServiceStop($key) if ($actions == true || $is_admin) { $ressource = preg_split("/\;/", $key); - $flg = send_cmd(" DISABLE_SVC_CHECK;" . urldecode($ressource[0]) . ";" . urldecode($ressource[1]), GetMyHostPoller($pearDB, urldecode($ressource[0]))); + $flg = send_cmd( + " DISABLE_SVC_CHECK;" . urldecode($ressource[0]) . ";" . urldecode($ressource[1]), + GetMyHostPoller($pearDB, urldecode($ressource[0])) + ); return $flg; } } @@ -663,7 +781,10 @@ function autoCheckHostStart($key) if ($actions == true || $is_admin) { $ressource = preg_split("/\;/", $key); - $flg = send_cmd(" ENABLE_HOST_CHECK;" . urldecode($ressource[0]), GetMyHostPoller($pearDB, urldecode($ressource[0]))); + $flg = send_cmd( + " ENABLE_HOST_CHECK;" . urldecode($ressource[0]), + GetMyHostPoller($pearDB, urldecode($ressource[0])) + ); return $flg; } } @@ -678,7 +799,10 @@ function autoCheckHostStop($key) if ($actions == true || $is_admin) { global $pearDB, $tab, $is_admin; $ressource = preg_split("/\;/", $key); - $flg = send_cmd(" DISABLE_HOST_CHECK;" . urldecode($ressource[0]), GetMyHostPoller($pearDB, urldecode($ressource[0]))); + $flg = send_cmd( + " DISABLE_HOST_CHECK;" . urldecode($ressource[0]), + GetMyHostPoller($pearDB, urldecode($ressource[0])) + ); return $flg; } } diff --git a/www/include/monitoring/external_cmd/functionsPopup.php b/www/include/monitoring/external_cmd/functionsPopup.php index 354577a5843..ed434940810 100644 --- a/www/include/monitoring/external_cmd/functionsPopup.php +++ b/www/include/monitoring/external_cmd/functionsPopup.php @@ -68,7 +68,7 @@ function massiveHostAck($key) $processedHosts[$hostName] = true; $persistent = isset($_GET['persistent']) && $_GET['persistent'] == "true" ? "1" : "0"; - $notify = isset($_GET['notify']) && $_GET['notify'] == "true" ? "1" :"0"; + $notify = isset($_GET['notify']) && $_GET['notify'] == "true" ? "1" : "0"; $sticky = isset($_GET['sticky']) && $_GET['sticky'] == "true" ? "2" : "1"; $force_check = isset($_GET['force_check']) && $_GET['force_check'] == "true" ? "1" : "0"; @@ -95,7 +95,7 @@ function massiveHostAck($key) $actions = $centreon->user->access->checkAction("service_acknowledgement"); if (($actions == true || $is_admin) && isset($_GET['ackhostservice']) && $_GET['ackhostservice'] == "true") { - $DBRES = $pearDB->query("SELECT host_id FROM `host` WHERE host_name = '".$hostName."' LIMIT 1"); + $DBRES = $pearDB->query("SELECT host_id FROM `host` WHERE host_name = '" . $hostName . "' LIMIT 1"); $row = $DBRES->fetchRow(); $svc_tab = getMyHostServices($row['host_id']); if (count($svc_tab)) { @@ -216,7 +216,7 @@ function massiveHostDowntime($key) if (!isset($tmp[0])) { throw new Exception('No host found'); } - + $host_name = $tmp[0]; if (isset($processedHosts[$host_name])) { return null; @@ -227,10 +227,14 @@ function massiveHostDowntime($key) $end = isset($_GET['end']) && $_GET['end'] ? $_GET['end'] : time(); $comment = isset($_GET['comment']) && $_GET['comment'] ? sanitizeShellString($_GET["comment"]) : ""; $fixed = isset($_GET['fixed']) && $_GET['fixed'] == "true" ? $fixed = 1 : $fixed = 0; - $duration = isset($_GET['duration']) && $_GET['duration'] && is_numeric($_GET['duration']) ? $duration = $_GET['duration'] : $duration = 0; - $duration_scale = isset($_GET['duration_scale']) && $_GET['duration_scale'] ? $duration_scale = $_GET['duration_scale'] : $duration_scale = "s"; + $duration = isset($_GET['duration']) && $_GET['duration'] && is_numeric($_GET['duration']) + ? $duration = $_GET['duration'] + : $duration = 0; + $duration_scale = isset($_GET['duration_scale']) && $_GET['duration_scale'] + ? $duration_scale = $_GET['duration_scale'] + : $duration_scale = "s"; $hostTime = isset($_GET['host_or_centreon_time']) && $_GET['host_or_centreon_time'] == "true" ? "1" : "0"; - + if ($duration > 0) { switch ($duration_scale) { default: @@ -248,19 +252,19 @@ function massiveHostDowntime($key) break; } } - + $host = getMyHostID($host_name); - + $with_services = false; if (($centreon->user->access->checkAction("service_schedule_downtime") == true) && isset($_GET['downtimehostservice']) && $_GET['downtimehostservice'] == "true") { $with_services = true; } - + $extCmdObj = new CentreonExternalCommand($centreon); $extCmdObj->addHostDowntime($host, $comment, $start, $end, $fixed, $duration, $with_services, $hostTime); } - + return null; } @@ -296,7 +300,7 @@ function massiveServiceDowntime($key) $_GET['duration'] : 0; $duration_scale = isset($_GET['duration_scale']) && $_GET['duration_scale'] ? $_GET['duration_scale'] : "s"; $hostTime = isset($_GET['host_or_centreon_time']) && $_GET['host_or_centreon_time'] == "true" ? "1" : "0"; - + if ($duration > 0) { switch ($duration_scale) { default: @@ -317,10 +321,10 @@ function massiveServiceDowntime($key) break; } } - + $host = getMyHostID($host_name); $service = getMyServiceID($svc_description, $host); - + $extCmdObj = new CentreonExternalCommand($centreon); $extCmdObj->addSvcDowntime($host, $service, $comment, $start, $end, $fixed, $duration, $hostTime); } diff --git a/www/include/monitoring/external_cmd/popup/massive_ack.php b/www/include/monitoring/external_cmd/popup/massive_ack.php index fed883da0f2..8cd2494db1f 100644 --- a/www/include/monitoring/external_cmd/popup/massive_ack.php +++ b/www/include/monitoring/external_cmd/popup/massive_ack.php @@ -49,7 +49,7 @@ } } -$path = _CENTREON_PATH_."/www/include/monitoring/external_cmd/popup/"; +$path = _CENTREON_PATH_ . "/www/include/monitoring/external_cmd/popup/"; /* * Smarty template Init @@ -98,40 +98,51 @@ $tpl->assign('authorlabel', _("Alias")); $tpl->assign('authoralias', $centreon->user->get_alias()); -$form->addElement('textarea', 'comment', _("Comment"), array("rows"=>"5", "cols"=>"85", "id"=>"popupComment")); +$form->addElement('textarea', 'comment', _("Comment"), array("rows" => "5", "cols" => "85", "id" => "popupComment")); $form->setDefaults(array("comment" => sprintf(_("Acknowledged by %s"), $centreon->user->alias))); -$chckbox[] = $form->addElement('checkbox', 'persistent', _("Persistent"), "", array("id"=>"persistent")); +$chckbox[] = $form->addElement('checkbox', 'persistent', _("Persistent"), "", array("id" => "persistent")); if (isset($centreon->optGen['monitoring_ack_persistent']) && $centreon->optGen['monitoring_ack_persistent']) { $chckbox[0]->setChecked(true); } -$chckbox2[] = $form->addElement('checkbox', 'ackhostservice', _("Acknowledge services attached to hosts"), "", array("id"=>"ackhostservice")); +$chckbox2[] = $form->addElement( + 'checkbox', + 'ackhostservice', + _("Acknowledge services attached to hosts"), + "", + array("id" => "ackhostservice") +); if (isset($centreon->optGen['monitoring_ack_svc']) && $centreon->optGen['monitoring_ack_svc']) { $chckbox2[0]->setChecked(true); } -$chckbox3[] = $form->addElement('checkbox', 'sticky', _("Sticky"), "", array("id"=>"sticky")); +$chckbox3[] = $form->addElement('checkbox', 'sticky', _("Sticky"), "", array("id" => "sticky")); if (isset($centreon->optGen['monitoring_ack_sticky']) && $centreon->optGen['monitoring_ack_sticky']) { $chckbox3[0]->setChecked(true); } -$chckbox4[] = $form->addElement('checkbox', 'force_check', _("Force active checks"), "", array("id"=>"force_check")); +$chckbox4[] = $form->addElement('checkbox', 'force_check', _("Force active checks"), "", array("id" => "force_check")); if (isset($centreon->optGen['monitoring_ack_active_checks']) && $centreon->optGen['monitoring_ack_active_checks']) { $chckbox4[0]->setChecked(true); } -$chckbox5[] = $form->addElement('checkbox', 'notify', _("Notify"), "", array("id"=>"notify")); +$chckbox5[] = $form->addElement('checkbox', 'notify', _("Notify"), "", array("id" => "notify")); if (isset($centreon->optGen['monitoring_ack_notify']) && $centreon->optGen['monitoring_ack_notify']) { $chckbox5[0]->setChecked(true); } -$form->addElement('hidden', 'author', $centreon->user->get_alias(), array("id"=>"author")); +$form->addElement('hidden', 'author', $centreon->user->get_alias(), array("id" => "author")); $form->addRule('comment', _("Comment is required"), 'required', '', 'client'); $form->setJsWarnings(_("Invalid information entered"), _("Please correct these fields")); -$form->addElement('button', 'submit', _("Acknowledge selected problems"), array("onClick" => "send_the_command();", "class" => "btc bt_info")); +$form->addElement( + 'button', + 'submit', + _("Acknowledge selected problems"), + array("onClick" => "send_the_command();", "class" => "btc bt_info") +); $form->addElement('reset', 'reset', _("Reset"), array("class" => "btc bt_default")); $renderer = new HTML_QuickForm_Renderer_ArraySmarty($tpl); diff --git a/www/include/monitoring/external_cmd/popup/massive_downtime.php b/www/include/monitoring/external_cmd/popup/massive_downtime.php index 388650a462f..1eada542e59 100644 --- a/www/include/monitoring/external_cmd/popup/massive_downtime.php +++ b/www/include/monitoring/external_cmd/popup/massive_downtime.php @@ -49,7 +49,7 @@ } } -$path = _CENTREON_PATH_."/www/include/monitoring/external_cmd/popup/"; +$path = _CENTREON_PATH_ . "/www/include/monitoring/external_cmd/popup/"; /* * Init GMT @@ -76,17 +76,17 @@ $tpl->assign('authorlabel', _("Alias")); $tpl->assign('authoralias', $centreon->user->get_alias()); -$form->addElement('textarea', 'comment', _("Comment"), array("rows"=>"5", "cols"=>"70", "id"=>"popupComment")); +$form->addElement('textarea', 'comment', _("Comment"), array("rows" => "5", "cols" => "70", "id" => "popupComment")); $form->setDefaults(array("comment" => sprintf(_("Downtime set by %s"), $centreon->user->alias))); -$form->addElement('text', 'start', _('Start Time'), array('id'=>'start', 'size'=>10, 'class'=>'datepicker')); -$form->addElement('text', 'end', _('End Time'), array('id'=>'end', 'size'=>10, 'class'=>'datepicker')); - -$form->addElement('text', 'start_time', '', array('id'=>'start_time', 'size' => 5, 'class' => 'timepicker')); -$form->addElement('text', 'end_time', '', array('id'=>'end_time', 'size' => 5, 'class' => 'timepicker')); +$form->addElement('text', 'start', _('Start Time'), array('id' => 'start', 'size' => 10, 'class' => 'datepicker')); +$form->addElement('text', 'end', _('End Time'), array('id' => 'end', 'size' => 10, 'class' => 'datepicker')); + +$form->addElement('text', 'start_time', '', array('id' => 'start_time', 'size' => 5, 'class' => 'timepicker')); +$form->addElement('text', 'end_time', '', array('id' => 'end_time', 'size' => 5, 'class' => 'timepicker')); + +$form->addElement('text', 'timezone_warning', _("*The timezone used is configured on your user settings")); -$form->addElement('text','timezone_warning', _("*The timezone used is configured on your user settings")); - $form->setDefaults( array( "start" => $centreonGMT->getDate("Y/m/d", time()), @@ -96,42 +96,55 @@ ) ); /* -$host_or_centreon_time[] = HTML_QuickForm::createElement('radio', 'host_or_centreon_time', null, _("Centreon Time"), '0'); +$host_or_centreon_time[] = +HTML_QuickForm::createElement('radio', 'host_or_centreon_time', null, _("Centreon Time"), '0'); $host_or_centreon_time[] = HTML_QuickForm::createElement('radio', 'host_or_centreon_time', null, _("Host Time"), '1'); $form->addGroup($host_or_centreon_time, 'host_or_centreon_time', _("Select Host or Centreon Time"), ' '); $form->setDefaults(array('host_or_centreon_time' => '0')); */ -$form->addElement('text', 'duration', _('Duration'), array('id'=>'duration', 'width'=>'30', 'disabled'=>'true')); +$form->addElement('text', 'duration', _('Duration'), array('id' => 'duration', 'width' => '30', 'disabled' => 'true')); $defaultDuration = 3600; if (isset($centreon->optGen['monitoring_dwt_duration']) && $centreon->optGen['monitoring_dwt_duration']) { $defaultDuration = $centreon->optGen['monitoring_dwt_duration']; } $form->setDefaults(array('duration' => $defaultDuration)); -$scaleChoices = array("s" => _("Seconds"), - "m" => _("Minutes"), - "h" => _("Hours"), - "d" => _("Days") - ); -$form->addElement('select', 'duration_scale', _("Scale of time"), $scaleChoices, array('id'=>'duration_scale')); +$scaleChoices = array( + "s" => _("Seconds"), + "m" => _("Minutes"), + "h" => _("Hours"), + "d" => _("Days") +); +$form->addElement('select', 'duration_scale', _("Scale of time"), $scaleChoices, array('id' => 'duration_scale')); $defaultScale = 's'; if (isset($centreon->optGen['monitoring_dwt_duration_scale']) && $centreon->optGen['monitoring_dwt_duration_scale']) { $defaultScale = $centreon->optGen['monitoring_dwt_duration_scale']; } $form->setDefaults(array('duration_scale' => $defaultScale)); -$chckbox[] = $form->addElement('checkbox', 'fixed', _("Fixed"), "", array("id"=>"fixed")); +$chckbox[] = $form->addElement('checkbox', 'fixed', _("Fixed"), "", array("id" => "fixed")); $chckbox[0]->setChecked(true); -$chckbox2[] = $form->addElement('checkbox', 'downtimehostservice', _("Set downtimes on services attached to hosts"), "", array("id"=>"downtimehostservice")); +$chckbox2[] = $form->addElement( + 'checkbox', + 'downtimehostservice', + _("Set downtimes on services attached to hosts"), + "", + array("id" => "downtimehostservice") +); $chckbox2[0]->setChecked(true); -$form->addElement('hidden', 'author', $centreon->user->get_alias(), array("id"=>"author")); +$form->addElement('hidden', 'author', $centreon->user->get_alias(), array("id" => "author")); $form->addRule('comment', _("Comment is required"), 'required', '', 'client'); $form->setJsWarnings(_("Invalid information entered"), _("Please correct these fields")); -$form->addElement('button', 'submit', _("Set downtime"), array("onClick" => "send_the_command();", "class" => "btc bt_info")); +$form->addElement( + 'button', + 'submit', + _("Set downtime"), + array("onClick" => "send_the_command();", "class" => "btc bt_info") +); $form->addElement('reset', 'reset', _("Reset"), array("class" => "btc bt_default")); $renderer = new HTML_QuickForm_Renderer_ArraySmarty($tpl); diff --git a/www/include/monitoring/external_cmd/popup/popup.php b/www/include/monitoring/external_cmd/popup/popup.php index 1b881571df8..e0bb61e4a67 100644 --- a/www/include/monitoring/external_cmd/popup/popup.php +++ b/www/include/monitoring/external_cmd/popup/popup.php @@ -56,7 +56,7 @@ } $sid = session_id(); if (isset($sid)) { - $res = $pearDB->query("SELECT * FROM session WHERE session_id = '".$sid."'"); + $res = $pearDB->query("SELECT * FROM session WHERE session_id = '" . $sid . "'"); if (!$session = $res->fetchRow()) { exit(); } From 8f3f535092711f1f2137c08af38854a239809720 Mon Sep 17 00:00:00 2001 From: loiclau Date: Fri, 11 Aug 2017 14:45:53 +0200 Subject: [PATCH 158/207] * fix style centreon-conf --- .../centreon-config/centreonMainCfg.class.php | 57 ++++++++++++------- 1 file changed, 36 insertions(+), 21 deletions(-) diff --git a/www/class/centreon-config/centreonMainCfg.class.php b/www/class/centreon-config/centreonMainCfg.class.php index f386ed41a02..eb2da7bfebe 100644 --- a/www/class/centreon-config/centreonMainCfg.class.php +++ b/www/class/centreon-config/centreonMainCfg.class.php @@ -188,9 +188,11 @@ public function insertBrokerDefaultDirectives($iId, $source) return false; } - $DBRESULT = $this->DB->query("SELECT bk_mod_id FROM `cfg_nagios_broker_module` WHERE cfg_nagios_id = '" . $iId . "'"); + $query = "SELECT bk_mod_id FROM `cfg_nagios_broker_module` WHERE cfg_nagios_id = '" . $iId . "'"; + $DBRESULT = $this->DB->query($query); if ($DBRESULT->rowCount() == 0) { - $sQuery = "INSERT INTO cfg_nagios_broker_module (`broker_module`, `cfg_nagios_id`) VALUES ('" . $this->aDefaultBrokerDirective[$source] . "', " . $iId . ")"; + $sQuery = "INSERT INTO cfg_nagios_broker_module (`broker_module`, `cfg_nagios_id`) VALUES ('" . + $this->aDefaultBrokerDirective[$source] . "', " . $iId . ")"; try { $res = $this->DB->query($sQuery); } catch (\PDOException $e) { @@ -221,23 +223,35 @@ public function insertServerInCfgNagios($source, $iId, $sName) $baseValues = $res->fetchRow(); } - $rq = "INSERT INTO `cfg_nagios` (`nagios_name`, `nagios_server_id`, `log_file`, `cfg_dir`, `temp_file`, `status_file`, - `status_update_interval`, `nagios_user`, `nagios_group`, `enable_notifications`, `execute_service_checks`, `accept_passive_service_checks`, `execute_host_checks`, - `accept_passive_host_checks`, `enable_event_handlers`, `log_rotation_method`, `log_archive_path`, `check_external_commands`, `external_command_buffer_slots`, - `command_check_interval`, `command_file`, `lock_file`, `retain_state_information`, `state_retention_file`,`retention_update_interval`, `use_retained_program_state`, - `use_retained_scheduling_info`, `use_syslog`, `log_notifications`, `log_service_retries`, `log_host_retries`, `log_event_handlers`, - `log_external_commands`, `log_passive_checks`, `sleep_time`, `service_inter_check_delay_method`, `host_inter_check_delay_method`, `service_interleave_factor`, - `max_concurrent_checks`, `max_service_check_spread`, `max_host_check_spread`, `check_result_reaper_frequency`, `max_check_result_reaper_time`, `interval_length`, - `auto_reschedule_checks`, `use_aggressive_host_checking`, `enable_flap_detection`, `low_service_flap_threshold`, `high_service_flap_threshold`, `low_host_flap_threshold`, - `high_host_flap_threshold`, `soft_state_dependencies`, `service_check_timeout`, `host_check_timeout`, `event_handler_timeout`, `notification_timeout`, `ocsp_timeout`, - `ochp_timeout`, `perfdata_timeout`, `obsess_over_services`, `obsess_over_hosts`, `process_performance_data`, `host_perfdata_file_mode`, `service_perfdata_file_mode`, - `check_for_orphaned_services`, `check_for_orphaned_hosts`, `check_service_freshness`, `check_host_freshness`, `date_format`, `illegal_object_name_chars`, - `illegal_macro_output_chars`, `use_regexp_matching`, `use_true_regexp_matching`, `admin_email`, `admin_pager`, `nagios_comment`, `nagios_activate`, - `event_broker_options`, `translate_passive_host_checks`, `enable_predictive_host_dependency_checks`, `enable_predictive_service_dependency_checks`, `passive_host_checks_are_soft`, - `use_large_installation_tweaks`, `enable_environment_macros`, `use_setpgid`, - `debug_file`, `debug_level`, `debug_level_opt`, `debug_verbosity`, `max_debug_file_size`, `daemon_dumps_core`, `cfg_file`, `use_check_result_path`) "; - $rq .= "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?," . - "?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; + $rq = "INSERT INTO `cfg_nagios` (`nagios_name`, `nagios_server_id`, `log_file`, `cfg_dir`, `temp_file`, " . + "`status_file`, `status_update_interval`, `nagios_user`, `nagios_group`, `enable_notifications`, " . + "`execute_service_checks`, `accept_passive_service_checks`, `execute_host_checks`, " . + "`accept_passive_host_checks`, `enable_event_handlers`, `log_rotation_method`, `log_archive_path`, " . + "`check_external_commands`, `external_command_buffer_slots`, `command_check_interval`, `command_file`, " . + "`lock_file`, `retain_state_information`, `state_retention_file`,`retention_update_interval`, " . + "`use_retained_program_state`, `use_retained_scheduling_info`, `use_syslog`, `log_notifications`, " . + "`log_service_retries`, `log_host_retries`, `log_event_handlers`, `log_external_commands`, " . + "`log_passive_checks`, `sleep_time`, `service_inter_check_delay_method`, " . + "`host_inter_check_delay_method`, `service_interleave_factor`, `max_concurrent_checks`, " . + "`max_service_check_spread`, `max_host_check_spread`, `check_result_reaper_frequency`, " . + "`max_check_result_reaper_time`, `interval_length`, `auto_reschedule_checks`, " . + "`use_aggressive_host_checking`, `enable_flap_detection`, `low_service_flap_threshold`, " . + "`high_service_flap_threshold`, `low_host_flap_threshold`, `high_host_flap_threshold`, " . + "`soft_state_dependencies`, `service_check_timeout`, `host_check_timeout`, `event_handler_timeout`, " . + "`notification_timeout`, `ocsp_timeout`, `ochp_timeout`, `perfdata_timeout`, `obsess_over_services`, " . + "`obsess_over_hosts`, `process_performance_data`, `host_perfdata_file_mode`, " . + "`service_perfdata_file_mode`, `check_for_orphaned_services`, `check_for_orphaned_hosts`, " . + "`check_service_freshness`, `check_host_freshness`, `date_format`, `illegal_object_name_chars`, " . + "`illegal_macro_output_chars`, `use_regexp_matching`, `use_true_regexp_matching`, `admin_email`, " . + "`admin_pager`, `nagios_comment`, `nagios_activate`, `event_broker_options`, " . + "`translate_passive_host_checks`, `enable_predictive_host_dependency_checks`, " . + "`enable_predictive_service_dependency_checks`, `passive_host_checks_are_soft`, " . + "`use_large_installation_tweaks`, `enable_environment_macros`, `use_setpgid`, " . + "`debug_file`, `debug_level`, `debug_level_opt`, `debug_verbosity`, `max_debug_file_size`, " . + "`daemon_dumps_core`, `cfg_file`, `use_check_result_path`) "; + $rq .= "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, " . + "?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, " . + "?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; $params = array( 'Centreon Engine ' . $sName, @@ -338,8 +352,9 @@ public function insertServerInCfgNagios($source, $iId, $sName) $baseValues['use_check_result_path'] ); foreach ($params as &$param) { - if (empty($param)) + if (empty($param)) { $param = null; + } } try { @@ -364,4 +379,4 @@ public function getBrokerModules($id) $DBRESULT->closeCursor(); return $entries; } -} \ No newline at end of file +} From 538536faca8eb4c9e4a297e14f1df1b024f879b0 Mon Sep 17 00:00:00 2001 From: Christophe WEILAND Date: Fri, 11 Aug 2017 14:58:12 +0200 Subject: [PATCH 159/207] [FIX] ERROR: Can't find MySQL datadir (#5484) --- cron/centreon-backup-mysql.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cron/centreon-backup-mysql.sh b/cron/centreon-backup-mysql.sh index e62495831cc..6213b958af0 100644 --- a/cron/centreon-backup-mysql.sh +++ b/cron/centreon-backup-mysql.sh @@ -82,6 +82,10 @@ output_log() { ### if [ -n "$process" ] ; then datadir=$(echo "$process" | awk '{ for (i = 1; i < NF; i++) { if (match($i, "--datadir")) { print $i } } }' | awk -F\= '{ print $2 }') + ### New version CentOS7/MariaDB : datadir not present in ps + if [ -z "$datadir" ] ; then + datadir=$(mysqld --verbose --help 2> /dev/null | egrep "^datadir" | awk -F' ' '{print $2}') + fi started=1 fi if [ -z "$datadir" ] ; then From 68bee09d746c190d390c5ecd7529218d8de18fe2 Mon Sep 17 00:00:00 2001 From: loiclau Date: Fri, 11 Aug 2017 15:02:37 +0200 Subject: [PATCH 160/207] * fix style performance --- .../Administration/performance/manageData.php | 4 +- .../Administration/performance/viewData.php | 154 +++++++++++------- .../performance/viewMetrics.php | 81 +++++---- 3 files changed, 142 insertions(+), 97 deletions(-) diff --git a/www/include/Administration/performance/manageData.php b/www/include/Administration/performance/manageData.php index 1beb4514b59..3ca339de32c 100644 --- a/www/include/Administration/performance/manageData.php +++ b/www/include/Administration/performance/manageData.php @@ -64,9 +64,9 @@ switch ($o) { case "msvc": - require_once($path."viewMetrics.php"); + require_once($path . "viewMetrics.php"); break; default: - require_once($path."viewData.php"); + require_once($path . "viewData.php"); break; } diff --git a/www/include/Administration/performance/viewData.php b/www/include/Administration/performance/viewData.php index 957561b4e7f..7385029a8ab 100644 --- a/www/include/Administration/performance/viewData.php +++ b/www/include/Administration/performance/viewData.php @@ -81,7 +81,7 @@ 'o2' => FILTER_SANITIZE_STRING, 'select' => array( 'filter' => FILTER_SANITIZE_STRING, - 'flags' => FILTER_REQUIRE_ARRAY + 'flags' => FILTER_REQUIRE_ARRAY ), 'id' => FILTER_SANITIZE_STRING ); @@ -142,69 +142,78 @@ if ($inputs["o"] == "rg" && isset($inputs["select"])) { $selected = $inputs["select"]; foreach ($selected as $key => $value) { - $DBRESULT = $pearDBO->query("UPDATE index_data SET `must_be_rebuild` = '1' WHERE id = '".$key."'"); + $DBRESULT = $pearDBO->query("UPDATE index_data SET `must_be_rebuild` = '1' WHERE id = '" . $key . "'"); } $brk->reload(); } elseif ($inputs["o"] == "nrg" && isset($inputs["select"])) { $selected = $inputs["select"]; foreach ($selected as $key => $value) { - $DBRESULT = $pearDBO->query("UPDATE index_data SET `must_be_rebuild` = '0' WHERE id = '".$key."' AND `must_be_rebuild` = '1'"); + $query = "UPDATE index_data SET `must_be_rebuild` = '0' WHERE id = '" . + $key . "' AND `must_be_rebuild` = '1'"; + $pearDBO->query($query); } } elseif ($inputs["o"] == "ed" && isset($inputs["select"])) { $selected = $inputs["select"]; $listMetricsToDelete = array(); foreach ($selected as $key => $value) { - $DBRESULT = $pearDBO->query("SELECT metric_id FROM metrics WHERE `index_id` = '".$key."'"); + $DBRESULT = $pearDBO->query("SELECT metric_id FROM metrics WHERE `index_id` = '" . $key . "'"); while ($metrics = $DBRESULT->fetchRow()) { $listMetricsToDelete[] = $metrics['metric_id']; } } $listMetricsToDelete = array_unique($listMetricsToDelete); if (count($listMetricsToDelete) > 0) { - $pearDBO->query("UPDATE metrics SET to_delete = 1 WHERE metric_id IN (" . join(', ', $listMetricsToDelete) . ")"); - $pearDBO->query("UPDATE index_data SET to_delete = 1 WHERE id IN (" . join(', ', array_keys($selected)) . ")"); - $pearDB->query("DELETE FROM ods_view_details WHERE metric_id IN (" . join(', ', $listMetricsToDelete) . ")"); + $query = "UPDATE metrics SET to_delete = 1 WHERE metric_id IN (" . join(', ', $listMetricsToDelete) . ")"; + $pearDBO->query($query); + $query = "UPDATE index_data SET to_delete = 1 WHERE id IN (" . join(', ', array_keys($selected)) . ")"; + $pearDBO->query($query); + $query = "DELETE FROM ods_view_details WHERE metric_id IN (" . join(', ', $listMetricsToDelete) . ")"; + $pearDB->query($query); $brk->reload(); } } elseif ($inputs["o"] == "hg" && isset($inputs["select"])) { $selected = $inputs["select"]; foreach ($selected as $key => $value) { - $DBRESULT = $pearDBO->query("UPDATE index_data SET `hidden` = '1' WHERE id = '".$key."'"); + $DBRESULT = $pearDBO->query("UPDATE index_data SET `hidden` = '1' WHERE id = '" . $key . "'"); } } elseif ($inputs["o"] == "nhg" && isset($inputs["select"])) { $selected = $inputs["select"]; foreach ($selected as $key => $value) { - $DBRESULT = $pearDBO->query("UPDATE index_data SET `hidden` = '0' WHERE id = '".$key."'"); + $DBRESULT = $pearDBO->query("UPDATE index_data SET `hidden` = '0' WHERE id = '" . $key . "'"); } } elseif ($inputs["o"] == "lk" && isset($inputs["select"])) { $selected = $inputs["select"]; foreach ($selected as $key => $value) { - $DBRESULT = $pearDBO->query("UPDATE index_data SET `locked` = '1' WHERE id = '".$key."'"); + $DBRESULT = $pearDBO->query("UPDATE index_data SET `locked` = '1' WHERE id = '" . $key . "'"); } } elseif ($inputs["o"] == "nlk" && isset($inputs["select"])) { $selected = $inputs["select"]; foreach ($selected as $key => $value) { - $DBRESULT = $pearDBO->query("UPDATE index_data SET `locked` = '0' WHERE id = '".$key."'"); + $DBRESULT = $pearDBO->query("UPDATE index_data SET `locked` = '0' WHERE id = '" . $key . "'"); } } } if (isset($inputs["o"]) && $inputs["o"] == "d" && isset($inputs["id"])) { - $DBRESULT = $pearDBO->query("UPDATE index_data SET `trashed` = '1' WHERE id = '".htmlentities($inputs["id"], ENT_QUOTES, 'UTF-8')."'"); + $query = "UPDATE index_data SET `trashed` = '1' WHERE id = '" . + htmlentities($inputs["id"], ENT_QUOTES, 'UTF-8') . "'"; + $pearDBO->query($query); } if (isset($inputs["o"]) && $inputs["o"] == "rb" && isset($inputs["id"])) { - $DBRESULT = $pearDBO->query("UPDATE index_data SET `must_be_rebuild` = '1' WHERE id = '".htmlentities($inputs["id"], ENT_QUOTES, 'UTF-8')."'"); + $query = "UPDATE index_data SET `must_be_rebuild` = '1' WHERE id = '" . + htmlentities($inputs["id"], ENT_QUOTES, 'UTF-8') . "'"; + $pearDBO->query($query); } $search_string = ""; $extTables = ""; if ($searchH != "" || $searchS != "" || $searchP != "") { if ($searchH != "") { - $search_string .= " AND i.host_name LIKE '%".htmlentities($searchH, ENT_QUOTES, 'UTF-8')."%' "; + $search_string .= " AND i.host_name LIKE '%" . htmlentities($searchH, ENT_QUOTES, 'UTF-8') . "%' "; } if ($searchS != "") { - $search_string .= " AND i.service_description LIKE '%".htmlentities($searchS, ENT_QUOTES, 'UTF-8')."%' "; + $search_string .= " AND i.service_description LIKE '%" . htmlentities($searchS, ENT_QUOTES, 'UTF-8') . "%' "; } if ($searchP != "") { /* Centron Broker */ @@ -218,11 +227,15 @@ $yesOrNo = array(0 => "No", 1 => "Yes", 2 => "Rebuilding"); $data = array(); -$DBRESULT = $pearDBO->query("SELECT SQL_CALC_FOUND_ROWS DISTINCT i.* FROM index_data i, metrics m" . $extTables . " WHERE i.id = m.index_id $search_string ORDER BY host_name, service_description LIMIT ".$num * $limit.", $limit"); +$query = "SELECT SQL_CALC_FOUND_ROWS DISTINCT i.* FROM index_data i, metrics m" . $extTables . + " WHERE i.id = m.index_id $search_string ORDER BY host_name, service_description LIMIT " . $num * $limit . + ", $limit"; +$DBRESULT = $pearDBO->query($query); $rows = $pearDBO->numberRows(); for ($i = 0; $index_data = $DBRESULT->fetchRow(); $i++) { - $DBRESULT2 = $pearDBO->query("SELECT * FROM metrics WHERE index_id = '".$index_data["id"]."' ORDER BY metric_name"); + $query = "SELECT * FROM metrics WHERE index_id = '" . $index_data["id"] . "' ORDER BY metric_name"; + $DBRESULT2 = $pearDBO->query($query); $metric = ""; for ($im = 0; $metrics = $DBRESULT2->fetchRow(); $im++) { if ($im) { @@ -230,11 +243,12 @@ } $metric .= $metrics["metric_name"]; if (isset($metrics["unit_name"]) && $metrics["unit_name"]) { - $metric .= "(".$metrics["unit_name"].")"; + $metric .= "(" . $metrics["unit_name"] . ")"; } } $index_data["metrics_name"] = $metric; - $index_data["service_description"] = "".$index_data["service_description"].""; + $index_data["service_description"] = "" . + $index_data["service_description"] . ""; $index_data["storage_type"] = $storage_type[$index_data["storage_type"]]; $index_data["must_be_rebuild"] = $yesOrNo[$index_data["must_be_rebuild"]]; @@ -271,53 +285,75 @@ $tpl = new Smarty(); $tpl = initSmartyTpl($path, $tpl); -$form = new HTML_QuickForm('form', 'POST', "?p=".$p); +$form = new HTML_QuickForm('form', 'POST', "?p=" . $p); ?> - + "javascript: " . - "if (this.form.elements['o1'].selectedIndex == 1) {" . - " setO(this.form.elements['o1'].value); submit();} " . - "else if (this.form.elements['o1'].selectedIndex == 2) {" . - " setO(this.form.elements['o1'].value); submit();} " . - "else if (this.form.elements['o1'].selectedIndex == 3 && confirm('"._('Do you confirm the deletion ?')."')) {" . - " setO(this.form.elements['o1'].value); submit();} " . - "else if (this.form.elements['o1'].selectedIndex == 4) {" . - " setO(this.form.elements['o1'].value); submit();} " . - "else if (this.form.elements['o1'].selectedIndex == 5) {" . - " setO(this.form.elements['o1'].value); submit();} " . - "else if (this.form.elements['o1'].selectedIndex == 6) {" . - " setO(this.form.elements['o1'].value); submit();} " . - "else if (this.form.elements['o1'].selectedIndex == 7) {" . - " setO(this.form.elements['o1'].value); submit();} " . - ""); -$form->addElement('select', 'o1', null, array(null=>_("More actions..."), "rg"=>_("Rebuild RRD Database"), "nrg"=>_("Stop rebuilding RRD Databases"), "ed"=>_("Delete graphs"), "hg"=>_("Hide graphs of selected Services"), "nhg"=>_("Stop hiding graphs of selected Services"), "lk"=>_("Lock Services"), "nlk"=>_("Unlock Services")), $attrs1); + 'onchange' => "javascript: " . + "if (this.form.elements['o1'].selectedIndex == 1) {" . + " setO(this.form.elements['o1'].value); submit();} " . + "else if (this.form.elements['o1'].selectedIndex == 2) {" . + " setO(this.form.elements['o1'].value); submit();} " . + "else if (this.form.elements['o1'].selectedIndex == 3 && confirm('" . + _('Do you confirm the deletion ?') . "')) {" . + " setO(this.form.elements['o1'].value); submit();} " . + "else if (this.form.elements['o1'].selectedIndex == 4) {" . + " setO(this.form.elements['o1'].value); submit();} " . + "else if (this.form.elements['o1'].selectedIndex == 5) {" . + " setO(this.form.elements['o1'].value); submit();} " . + "else if (this.form.elements['o1'].selectedIndex == 6) {" . + " setO(this.form.elements['o1'].value); submit();} " . + "else if (this.form.elements['o1'].selectedIndex == 7) {" . + " setO(this.form.elements['o1'].value); submit();} " . + "" +); +$form->addElement('select', 'o1', null, array( + null => _("More actions..."), + "rg" => _("Rebuild RRD Database"), + "nrg" => _("Stop rebuilding RRD Databases"), + "ed" => _("Delete graphs"), + "hg" => _("Hide graphs of selected Services"), + "nhg" => _("Stop hiding graphs of selected Services"), + "lk" => _("Lock Services"), + "nlk" => _("Unlock Services") +), $attrs1); $form->setDefaults(array('o1' => null)); $attrs2 = array( - 'onchange'=>"javascript: " . - "if (this.form.elements['o2'].selectedIndex == 1) {" . - " setO(this.form.elements['o2'].value); submit();} " . - "else if (this.form.elements['o2'].selectedIndex == 2) {" . - " setO(this.form.elements['o2'].value); submit();} " . - "else if (this.form.elements['o2'].selectedIndex == 3 && confirm('"._('Do you confirm the deletion ?')."')) {" . - " setO(this.form.elements['o2'].value); submit();} " . - "else if (this.form.elements['o2'].selectedIndex == 4) {" . - " setO(this.form.elements['o2'].value); submit();} " . - "else if (this.form.elements['o2'].selectedIndex == 5) {" . - " setO(this.form.elements['o2'].value); submit();} " . - "else if (this.form.elements['o2'].selectedIndex == 6) {" . - " setO(this.form.elements['o2'].value); submit();} " . - "else if (this.form.elements['o2'].selectedIndex == 7) {" . - " setO(this.form.elements['o2'].value); submit();} " . - ""); -$form->addElement('select', 'o2', null, array(null=>_("More actions..."), "rg"=>_("Rebuild RRD Database"), "nrg"=>_("Stop rebuilding RRD Databases"), "ed"=>_("Delete graphs"), "hg"=>_("Hide graphs of selected Services"), "nhg"=>_("Stop hiding graphs of selected Services"), "lk"=>_("Lock Services"), "nlk"=>_("Unlock Services")), $attrs2); + 'onchange' => "javascript: " . + "if (this.form.elements['o2'].selectedIndex == 1) {" . + " setO(this.form.elements['o2'].value); submit();} " . + "else if (this.form.elements['o2'].selectedIndex == 2) {" . + " setO(this.form.elements['o2'].value); submit();} " . + "else if (this.form.elements['o2'].selectedIndex == 3 && confirm('" . + _('Do you confirm the deletion ?') . "')) {" . + " setO(this.form.elements['o2'].value); submit();} " . + "else if (this.form.elements['o2'].selectedIndex == 4) {" . + " setO(this.form.elements['o2'].value); submit();} " . + "else if (this.form.elements['o2'].selectedIndex == 5) {" . + " setO(this.form.elements['o2'].value); submit();} " . + "else if (this.form.elements['o2'].selectedIndex == 6) {" . + " setO(this.form.elements['o2'].value); submit();} " . + "else if (this.form.elements['o2'].selectedIndex == 7) {" . + " setO(this.form.elements['o2'].value); submit();} " . + "" +); +$form->addElement('select', 'o2', null, array( + null => _("More actions..."), + "rg" => _("Rebuild RRD Database"), + "nrg" => _("Stop rebuilding RRD Databases"), + "ed" => _("Delete graphs"), + "hg" => _("Hide graphs of selected Services"), + "nhg" => _("Stop hiding graphs of selected Services"), + "lk" => _("Lock Services"), + "nlk" => _("Unlock Services") +), $attrs2); $form->setDefaults(array('o2' => null)); $o1 = $form->getElement('o1'); diff --git a/www/include/Administration/performance/viewMetrics.php b/www/include/Administration/performance/viewMetrics.php index 9f8713a57ee..10e4859a68b 100644 --- a/www/include/Administration/performance/viewMetrics.php +++ b/www/include/Administration/performance/viewMetrics.php @@ -38,7 +38,7 @@ } require_once './class/centreonBroker.class.php'; - + if ((isset($_POST["o1"]) && $_POST["o1"]) || (isset($_POST["o2"]) && $_POST["o2"])) { if ($_POST["o1"] == "ed" || $_POST["o2"] == "ed") { $selected = $_POST["select"]; @@ -52,42 +52,42 @@ } elseif ($_POST["o1"] == "hg" || $_POST["o2"] == "hg") { $selected = $_POST["select"]; foreach ($selected as $key => $value) { - $DBRESULT = $pearDBO->query("UPDATE metrics SET `hidden` = '1' WHERE `metric_id` = '".$key."'"); + $pearDBO->query("UPDATE metrics SET `hidden` = '1' WHERE `metric_id` = '" . $key . "'"); } } elseif ($_POST["o1"] == "nhg" || $_POST["o2"] == "nhg") { $selected = $_POST["select"]; foreach ($selected as $key => $value) { - $DBRESULT = $pearDBO->query("UPDATE metrics SET `hidden` = '0' WHERE `metric_id` = '".$key."'"); + $pearDBO->query("UPDATE metrics SET `hidden` = '0' WHERE `metric_id` = '" . $key . "'"); } } elseif ($_POST["o1"] == "lk" || $_POST["o2"] == "lk") { $selected = $_POST["select"]; foreach ($selected as $key => $value) { - $DBRESULT = $pearDBO->query("UPDATE metrics SET `locked` = '1' WHERE `metric_id` = '".$key."'"); + $pearDBO->query("UPDATE metrics SET `locked` = '1' WHERE `metric_id` = '" . $key . "'"); } } elseif ($_POST["o1"] == "nlk" || $_POST["o2"] == "nlk") { $selected = $_POST["select"]; foreach ($selected as $key => $value) { - $DBRESULT = $pearDBO->query("UPDATE metrics SET `locked` = '0' WHERE `metric_id` = '".$key."'"); + $pearDBO->query("UPDATE metrics SET `locked` = '0' WHERE `metric_id` = '" . $key . "'"); } } elseif ($_POST["o1"] == "dst_g" || $_POST["o2"] == "dst_g") { $selected = $_POST["select"]; foreach ($selected as $key => $value) { - $DBRESULT = $pearDBO->query("UPDATE metrics SET `data_source_type` = '0' WHERE `metric_id` = '".$key."'"); + $pearDBO->query("UPDATE metrics SET `data_source_type` = '0' WHERE `metric_id` = '" . $key . "'"); } } elseif ($_POST["o1"] == "dst_c" || $_POST["o2"] == "dst_c") { $selected = $_POST["select"]; foreach ($selected as $key => $value) { - $DBRESULT = $pearDBO->query("UPDATE metrics SET `data_source_type` = '1' WHERE `metric_id` = '".$key."'"); + $pearDBO->query("UPDATE metrics SET `data_source_type` = '1' WHERE `metric_id` = '" . $key . "'"); } } elseif ($_POST["o1"] == "dst_d" || $_POST["o2"] == "dst_d") { $selected = $_POST["select"]; foreach ($selected as $key => $value) { - $DBRESULT = $pearDBO->query("UPDATE metrics SET `data_source_type` = '2' WHERE `metric_id` = '".$key."'"); + $pearDBO->query("UPDATE metrics SET `data_source_type` = '2' WHERE `metric_id` = '" . $key . "'"); } } elseif ($_POST["o1"] == "dst_a" || $_POST["o2"] == "dst_a") { $selected = $_POST["select"]; foreach ($selected as $key => $value) { - $DBRESULT = $pearDBO->query("UPDATE metrics SET `data_source_type` = '3' WHERE `metric_id` = '".$key."'"); + $pearDBO->query("UPDATE metrics SET `data_source_type` = '3' WHERE `metric_id` = '" . $key . "'"); } } } @@ -97,7 +97,8 @@ $search_string = " WHERE `host_name` LIKE '%$search%' OR `service_description` LIKE '%$search%'"; } -$DBRESULT = $pearDBO->query("SELECT COUNT(*) FROM metrics WHERE to_delete = 0 AND index_id = '".$_GET["index_id"]."'"); +$query = "SELECT COUNT(*) FROM metrics WHERE to_delete = 0 AND index_id = '" . $_GET["index_id"] . "'"; +$DBRESULT = $pearDBO->query($query); $tmp = $DBRESULT->fetchRow(); $rows = $tmp["COUNT(*)"]; @@ -106,7 +107,8 @@ $yesOrNo = array(null => "No", 0 => "No", 1 => "Yes", 2 => "Rebuilding"); $rrd_dst = array(0 => "GAUGE", 1 => "COUNTER", 2 => "DERIVE", 3 => "ABSOLUTE"); -$DBRESULT2 = $pearDBO->query("SELECT * FROM metrics WHERE to_delete = 0 AND index_id = '".$_GET["index_id"]."' ORDER BY metric_name"); +$query = "SELECT * FROM metrics WHERE to_delete = 0 AND index_id = '" . $_GET["index_id"] . "' ORDER BY metric_name"; +$DBRESULT2 = $pearDBO->query($query); unset($data); for ($im = 0; $metrics = $DBRESULT2->fetchRow(); $im++) { $metric = array(); @@ -116,7 +118,10 @@ $metric["metric_name"] = str_replace("#S#", "/", $metric["metric_name"]); $metric["metric_name"] = str_replace("#BS#", "\\", $metric["metric_name"]); $metric["unit_name"] = $metrics["unit_name"]; - if (!isset($metrics["data_source_type"]) || isset($metrics["data_source_type"]) && $metrics["data_source_type"] == null) { + if (!isset($metrics["data_source_type"]) || + isset($metrics["data_source_type"]) && + $metrics["data_source_type"] == null + ) { $metric["data_source_type"] = $rrd_dst["0"]; } else { $metric["data_source_type"] = $rrd_dst[$metrics["data_source_type"]]; @@ -128,7 +133,7 @@ $metric["warn"] = $metrics["warn"]; $metric["crit"] = $metrics["crit"]; - $metric["path"] = _CENTREON_VARLIB_.'/metrics/'.$metric["metric_id"].".rrd"; + $metric["path"] = _CENTREON_VARLIB_ . '/metrics/' . $metric["metric_id"] . ".rrd"; $data[$im] = $metric; unset($metric); @@ -142,35 +147,39 @@ $tpl = new Smarty(); $tpl = initSmartyTpl($path, $tpl); -$form = new HTML_QuickForm('form', 'POST', "?p=".$p); +$form = new HTML_QuickForm('form', 'POST', "?p=" . $p); /* * Toolbar select */ ?> - + function on_action_change(id) { + var selected_id = this.form.elements[id].selectedIndex - 1; + + if (selected_id in confirm_messages && !confirm(confirm_messages[selected_id])) { + return; + } + setO(this.form.elements[id].value); + document.forms['form'].submit(); + } + _("More actions..."), From a173052e5d940a247ffd6aefa07fa4664625c40b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Duret?= Date: Fri, 11 Aug 2017 15:06:34 +0200 Subject: [PATCH 161/207] Increase perfs on EventLogs for non admin user (#5480) --- www/include/eventLogs/xml/data.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/include/eventLogs/xml/data.php b/www/include/eventLogs/xml/data.php index abf7077c848..79653546bc0 100644 --- a/www/include/eventLogs/xml/data.php +++ b/www/include/eventLogs/xml/data.php @@ -510,8 +510,8 @@ logs.instance_name FROM logs ".$innerJoinEngineLog. ((!$is_admin) ? - " inner join centreon_acl acl on ((logs.host_id = acl.host_id AND logs.service_id IS NULL) OR " - . " (logs.host_id = acl.host_id AND acl.service_id = logs.service_id)) " + " inner join centreon_acl acl on (logs.host_id = acl.host_id AND (acl.service_id IS NULL OR " + . " acl.service_id = logs.service_id)) " . " WHERE acl.group_id IN (".$access->getAccessGroupsString().") AND " : "WHERE ") . " logs.ctime > '$start' AND logs.ctime <= '$end' $whereOutput $msg_req"; From d2080a0807dd70f21e5b3775a96ec1c79c7a81d5 Mon Sep 17 00:00:00 2001 From: loiclau Date: Fri, 11 Aug 2017 15:25:04 +0200 Subject: [PATCH 162/207] * fix style virtualmetrics --- www/include/views/virtualMetrics/DB-Func.php | 124 ++++++++------ .../virtualMetrics/formVirtualMetrics.php | 98 ++++++++---- .../virtualMetrics/listVirtualMetrics.php | 151 +++++++++++------- .../views/virtualMetrics/virtualMetrics.php | 20 +-- 4 files changed, 250 insertions(+), 143 deletions(-) diff --git a/www/include/views/virtualMetrics/DB-Func.php b/www/include/views/virtualMetrics/DB-Func.php index 879fc46c315..8c371480b25 100644 --- a/www/include/views/virtualMetrics/DB-Func.php +++ b/www/include/views/virtualMetrics/DB-Func.php @@ -46,8 +46,8 @@ function _TestRPNInfinityLoop() if (isset($form)) { $gsvs = $form->getSubmitValues(); } - - if ($gsvs["vmetric_name"] != null && preg_match("/".$gsvs["vmetric_name"]."/i", $gsvs["rpn_function"])) { + + if ($gsvs["vmetric_name"] != null && preg_match("/" . $gsvs["vmetric_name"] . "/i", $gsvs["rpn_function"])) { return false; } else { return true; @@ -62,26 +62,26 @@ function NameTestExistence($vmetric_name = null, $index_id = null) if (isset($form)) { $gsvs = $form->getSubmitValues(); } - + $sql = "SELECT vmetric_id FROM virtual_metrics WHERE "; - $sql .= "vmetric_name = '".($vmetric_name == null ? $gsvs["vmetric_name"] : $vmetric_name)."' "; - $sql .= "AND index_id = '".($index_id == null ? $gsvs["index_id"] : $index_id)."'"; + $sql .= "vmetric_name = '" . ($vmetric_name == null ? $gsvs["vmetric_name"] : $vmetric_name) . "' "; + $sql .= "AND index_id = '" . ($index_id == null ? $gsvs["index_id"] : $index_id) . "'"; try { $DBRESULT = $pearDB->query($sql); } catch (\PDOException $e) { - print "DB Error : ".$e->getMessage(); + print "DB Error : " . $e->getMessage(); } $vmetric = $DBRESULT->fetchRow(); $nR = $DBRESULT->rowCount(); $DBRESULT->closeCursor(); $sql = "SELECT metric_id FROM metrics WHERE "; - $sql .= "metric_name = '".($vmetric_name == null ? $gsvs["vmetric_name"] : $vmetric_name)."' "; - $sql .= "AND index_id = '".($index_id == null ? $gsvs["index_id"] : $index_id)."'"; + $sql .= "metric_name = '" . ($vmetric_name == null ? $gsvs["vmetric_name"] : $vmetric_name) . "' "; + $sql .= "AND index_id = '" . ($index_id == null ? $gsvs["index_id"] : $index_id) . "'"; try { $DBRESULT = $pearDBO->query($sql); } catch (\PDOException $e) { - print "DB Error : ".$e->getMessage(); + print "DB Error : " . $e->getMessage(); } $metric = $DBRESULT->fetchRow(); $nR = $nR + $DBRESULT->rowCount(); @@ -101,7 +101,7 @@ function deleteVirtualMetricInDB($vmetrics = array()) try { $DBRESULT = $pearDB->query("DELETE FROM virtual_metrics WHERE vmetric_id = '" . $key . "'"); } catch (\PDOException $e) { - print "DB Error : ".$e->getMessage(); + print "DB Error : " . $e->getMessage(); } } } @@ -113,7 +113,7 @@ function multipleVirtualMetricInDB($vmetrics = array(), $nbrDup = array()) try { $DBRESULT = $pearDB->query("SELECT * FROM virtual_metrics WHERE vmetric_id = '" . $key . "' LIMIT 1"); } catch (\PDOException $e) { - print "DB Error : ".$e->getMessage(); + print "DB Error : " . $e->getMessage(); } $row = $DBRESULT->fetchRow(); $row["vmetric_id"] = ''; @@ -123,20 +123,22 @@ function multipleVirtualMetricInDB($vmetrics = array(), $nbrDup = array()) $key2 == "index_id" ? $i_id = $value2 : null; if ($key2 == "vmetric_name") { $count = 1; - $v_name = $value2."_".$count; + $v_name = $value2 . "_" . $count; while (!NameTestExistence($v_name, $i_id)) { $count++; - $v_name = $value2."_".$count; + $v_name = $value2 . "_" . $count; } $value2 = $v_name; } - $val ? $val .= ($value2!=null?(", '".$value2."'"):", NULL") : $val .= ($value2!=null?("'".$value2."'"):"NULL"); + $val + ? $val .= ($value2 != null ? (", '" . $value2 . "'") : ", NULL") + : $val .= ($value2 != null ? ("'" . $value2 . "'") : "NULL"); } - $val ? $rq = "INSERT INTO virtual_metrics VALUES (".$val.")" : $rq = null; + $val ? $rq = "INSERT INTO virtual_metrics VALUES (" . $val . ")" : $rq = null; try { $DBRESULT2 = $pearDB->query($rq); } catch (\PDOException $e) { - print "DB Error : ".$e->getMessage(); + print "DB Error : " . $e->getMessage(); } } } @@ -163,8 +165,9 @@ function insertVirtualMetric() $s_id = null; $ret = array(); $ret = $form->getSubmitValues(); - - $rq = "INSERT INTO `virtual_metrics` ( `vmetric_id` , `index_id`, `vmetric_name`, `def_type` , `rpn_function`, `unit_name` , `warn`, `crit`, `hidden` , `comment` , `vmetric_activate`, `ck_state`) "; + + $rq = "INSERT INTO `virtual_metrics` ( `vmetric_id` , `index_id`, `vmetric_name`, `def_type` , `rpn_function`, " . + "`unit_name` , `warn`, `crit`, `hidden` , `comment` , `vmetric_activate`, `ck_state`) "; $rq .= "VALUES ( NULL, "; if (isset($ret["host_id"]) && preg_match('/\d+\-\d+/', $ret["host_id"])) { @@ -183,19 +186,25 @@ function insertVirtualMetric() } else { $rq .= "NULL, "; } - isset($ret["vmetric_name"]) && $ret["vmetric_name"] != null ? $rq .= "'".htmlentities($ret["vmetric_name"], ENT_QUOTES, "UTF-8")."', ": $rq .= "NULL, "; - isset($ret["def_type"]) && $ret["def_type"] != null ? $rq .= "'".$ret["def_type"]."', ": $rq .= "NULL, "; - isset($ret["rpn_function"]) && $ret["rpn_function"] != null ? $rq .= "'".$ret["rpn_function"]."', ": $rq .= "NULL, "; - isset($ret["unit_name"]) && $ret["unit_name"] != null ? $rq .= "'".$ret["unit_name"]."', ": $rq .= "NULL, "; - isset($ret["warn"]) && $ret["warn"] != null ? $rq .= "'".$ret["warn"]."', ": $rq .= "NULL, "; - isset($ret["crit"]) && $ret["crit"] != null ? $rq .= "'".$ret["crit"]."', ": $rq .= "NULL, "; - isset($ret["vhidden"]) && $ret["vhidden"] != null ? $rq .= "'".$ret["vhidden"]."', ": $rq .= "NULL, "; - isset($ret["comment"]) && $ret["comment"] != null ? $rq .= "'".htmlentities($ret["comment"], ENT_QUOTES, "UTF-8")."', ": $rq .= "NULL, "; + isset($ret["vmetric_name"]) && $ret["vmetric_name"] != null + ? $rq .= "'" . htmlentities($ret["vmetric_name"], ENT_QUOTES, "UTF-8") . "', " + : $rq .= "NULL, "; + isset($ret["def_type"]) && $ret["def_type"] != null ? $rq .= "'" . $ret["def_type"] . "', " : $rq .= "NULL, "; + isset($ret["rpn_function"]) && $ret["rpn_function"] != null + ? $rq .= "'" . $ret["rpn_function"] . "', " + : $rq .= "NULL, "; + isset($ret["unit_name"]) && $ret["unit_name"] != null ? $rq .= "'" . $ret["unit_name"] . "', " : $rq .= "NULL, "; + isset($ret["warn"]) && $ret["warn"] != null ? $rq .= "'" . $ret["warn"] . "', " : $rq .= "NULL, "; + isset($ret["crit"]) && $ret["crit"] != null ? $rq .= "'" . $ret["crit"] . "', " : $rq .= "NULL, "; + isset($ret["vhidden"]) && $ret["vhidden"] != null ? $rq .= "'" . $ret["vhidden"] . "', " : $rq .= "NULL, "; + isset($ret["comment"]) && $ret["comment"] != null + ? $rq .= "'" . htmlentities($ret["comment"], ENT_QUOTES, "UTF-8") . "', " + : $rq .= "NULL, "; $rq .= "NULL, NULL"; $rq .= ")"; if ($centreon->optGen["debug_rrdtool"] == "1") { $debug_path = realpath($centreon->optGen["debug_path"]); - error_log("[" . date("d/m/Y H:s") ."] VIRTUAL METRIC : $rq \n", 3, $debug_path . "/rrdtool.log"); + error_log("[" . date("d/m/Y H:s") . "] VIRTUAL METRIC : $rq \n", 3, $debug_path . "/rrdtool.log"); } $DBRESULT = $pearDB->query($rq); $DBRESULT = $pearDB->query("SELECT MAX(vmetric_id) FROM virtual_metrics"); @@ -230,24 +239,32 @@ function updateVirtualMetric($vmetric_id = null) } else { $rq .= "NULL, "; } - $rq .= "vmetric_name = "; - isset($ret["vmetric_name"]) && $ret["vmetric_name"] != null ? $rq .= "'".htmlentities($ret["vmetric_name"], ENT_QUOTES, "UTF-8")."', ": $rq .= "NULL, "; - $rq .= "def_type = "; - isset($ret["def_type"]) && $ret["def_type"] != null ? $rq .= "'".$ret["def_type"]."', ": $rq .= "NULL, "; - $rq .= "rpn_function = "; - isset($ret["rpn_function"]) && $ret["rpn_function"] != null ? $rq .= "'".$ret["rpn_function"]."', ": $rq .= "NULL, "; - $rq .= "unit_name = "; - isset($ret["unit_name"]) && $ret["unit_name"] != null ? $rq .= "'".$ret["unit_name"]."', ": $rq .= "NULL, "; - $rq .= "warn = "; - isset($ret["warn"]) && $ret["warn"] != null ? $rq .= "'".$ret["warn"]."', ": $rq .= "NULL, "; - $rq .= "crit = "; - isset($ret["crit"]) && $ret["crit"] != null ? $rq .= "'".$ret["crit"]."', ": $rq .= "NULL, "; - $rq .= "hidden = "; - isset($ret["vhidden"]) && $ret["vhidden"] != null ? $rq .= "'".$ret["vhidden"]."', ": $rq .= "NULL, "; - $rq .= "comment = "; - isset($ret["comment"]) && $ret["comment"] != null ? $rq .= "'".htmlentities($ret["comment"], ENT_QUOTES, "UTF-8")."', ": $rq .= "NULL, "; + $rq .= "vmetric_name = "; + isset($ret["vmetric_name"]) && $ret["vmetric_name"] != null + ? $rq .= "'" . htmlentities($ret["vmetric_name"], ENT_QUOTES, "UTF-8") . "', " + : $rq .= "NULL, "; + $rq .= "def_type = "; + isset($ret["def_type"]) && $ret["def_type"] != null ? $rq .= "'" . $ret["def_type"] . "', " : $rq .= "NULL, "; + $rq .= "rpn_function = "; + isset($ret["rpn_function"]) && $ret["rpn_function"] != null + ? $rq .= "'" . $ret["rpn_function"] . "', " + : $rq .= "NULL, "; + $rq .= "unit_name = "; + isset($ret["unit_name"]) && $ret["unit_name"] != null ? $rq .= "'" . $ret["unit_name"] . "', " : $rq .= "NULL, "; + $rq .= "warn = "; + isset($ret["warn"]) && $ret["warn"] != null ? $rq .= "'" . $ret["warn"] . "', " : $rq .= "NULL, "; + $rq .= "crit = "; + isset($ret["crit"]) && $ret["crit"] != null ? $rq .= "'" . $ret["crit"] . "', " : $rq .= "NULL, "; + $rq .= "hidden = "; + isset($ret["vhidden"]) && $ret["vhidden"] != null + ? $rq .= "'" . $ret["vhidden"] . "', " + : $rq .= "NULL, "; + $rq .= "comment = "; + isset($ret["comment"]) && $ret["comment"] != null + ? $rq .= "'" . htmlentities($ret["comment"], ENT_QUOTES, "UTF-8") . "', " + : $rq .= "NULL, "; $rq .= "vmetric_activate = NULL, ck_state = NULL "; - $rq .= "WHERE vmetric_id = '".$vmetric_id."'"; + $rq .= "WHERE vmetric_id = '" . $vmetric_id . "'"; $DBRESULT = $pearDB->query($rq); if (!enableVirtualMetricInDB($vmetric_id)) { @@ -261,7 +278,7 @@ function disableVirtualMetricInDB($vmetric_id = null, $force = 0) return 0; } global $pearDB; - + $v_dis = disableVirtualMetric($vmetric_id, $force); if (!count($v_dis)) { return 0; @@ -276,7 +293,7 @@ function &disableVirtualMetric($v_id = null, $force = 0) { global $pearDB; $v_dis = array(); - + $repA = array("*", "+", "-", "?", "^", "$"); $repB = array("\\\\*", "\\\\+", "\\\\-", "\\\\?", "\\\\^", "\\\\$"); $l_where = ($force == 0) ? " AND `vmetric_activate` = '1'" : ""; @@ -284,7 +301,10 @@ function &disableVirtualMetric($v_id = null, $force = 0) if ($l_pqy->rowCount() == 1) { $vmetric = $l_pqy->fetchRow(); $l_pqy->closeCursor(); - $l_pqy = $pearDB->query("SELECT vmetric_id FROM `virtual_metrics` WHERE `index_id`='".$vmetric["index_id"]."' AND `vmetric_activate` = '1' AND `rpn_function` REGEXP '(^|,)".str_replace($repA, $repB, $vmetric["vmetric_name"])."(,|$)';"); + $query = "SELECT vmetric_id FROM `virtual_metrics` WHERE `index_id`='" . $vmetric["index_id"] . + "' AND `vmetric_activate` = '1' " . + "AND `rpn_function` REGEXP '(^|,)" . str_replace($repA, $repB, $vmetric["vmetric_name"]) . "(,|$)';"; + $l_pqy = $pearDB->query($query); while ($d_vmetric = $l_pqy->fetchRow()) { $lv_dis = disableVirtualMetric($d_vmetric["vmetric_id"]); if (is_array($lv_dis)) { @@ -334,7 +354,9 @@ function enableVirtualMetric($v_id, $v_name = null, $index_id = null) $l_where = "vmetric_name = '$v_name' AND index_id ='$index_id'"; } - $l_pqy = $pearDB->query("SELECT vmetric_id, index_id, rpn_function FROM virtual_metrics WHERE $l_where AND (vmetric_activate = '0' OR vmetric_activate IS NULL);"); + $query = "SELECT vmetric_id, index_id, rpn_function FROM virtual_metrics " . + "WHERE $l_where AND (vmetric_activate = '0' OR vmetric_activate IS NULL);"; + $l_pqy = $pearDB->query($query); if ($l_pqy->rowCount() == 1) { $p_vmetric = $l_pqy->fetchRow(); $l_mlist = preg_split("/\,/", $p_vmetric["rpn_function"]); @@ -360,12 +382,14 @@ function checkRRDGraphData($v_id = null, $force = 0) } /* Check if already Valid */ - $l_pqy = $pearDB->query("SELECT vmetric_id, def_type FROM virtual_metrics WHERE vmetric_id = '$v_id' AND ( ck_state <> '1' OR ck_state IS NULL );"); + $query = "SELECT vmetric_id, def_type FROM virtual_metrics " . + "WHERE vmetric_id = '$v_id' AND ( ck_state <> '1' OR ck_state IS NULL );"; + $l_pqy = $pearDB->query($query); if ($l_pqy->rowCount() == 1) { /** * Create XML Request Objects */ - $centreon = & $_SESSION["centreon"]; + $centreon = &$_SESSION["centreon"]; $obj = new CentreonGraph($centreon->user->get_id(), null, 0, 1); /** diff --git a/www/include/views/virtualMetrics/formVirtualMetrics.php b/www/include/views/virtualMetrics/formVirtualMetrics.php index 14d9574784c..ba6fb3e29c8 100644 --- a/www/include/views/virtualMetrics/formVirtualMetrics.php +++ b/www/include/views/virtualMetrics/formVirtualMetrics.php @@ -49,7 +49,8 @@ $o = "c"; } if (($o == "c" || $o == "w") && $vmetric_id) { - $p_qy = $pearDB->query("SELECT *, hidden vhidden FROM virtual_metrics WHERE vmetric_id = '".$vmetric_id."' LIMIT 1"); + $query = "SELECT *, hidden vhidden FROM virtual_metrics WHERE vmetric_id = '" . $vmetric_id . "' LIMIT 1"; + $p_qy = $pearDB->query($query); // Set base value $vmetric = array_map("myDecode", $p_qy->fetchRow()); $p_qy->closeCursor(); @@ -59,16 +60,16 @@ * * Existing Data Index List comes from DBO -> Store in $indds Array */ -$indds = array(""=> sprintf("%s%s", _("Host list"), "   ")); +$indds = array("" => sprintf("%s%s", _("Host list"), "   ")); $mx_l = strlen($indds[""]); try { $dbindd = $pearDBO->query("SELECT DISTINCT host_id, host_name FROM index_data;"); } catch (\PDOException $e) { - print "DB Error : ".$e->getMessage()."
"; + print "DB Error : " . $e->getMessage() . "
"; } while ($indd = $dbindd->fetchRow()) { - $indds[$indd["host_id"]] = $indd["host_name"]."   "; + $indds[$indd["host_id"]] = $indd["host_name"] . "   "; $hn_l = strlen($indd["host_name"]); if ($hn_l > $mx_l) { $mx_l = $hn_l; @@ -79,19 +80,23 @@ /* * End of "database-retrieved" information */ - + /* * Var information to format the element */ -$attrsText = array("size"=>"30"); -$attrsText2 = array("size"=>"10"); +$attrsText = array("size" => "30"); +$attrsText2 = array("size" => "10"); $attrsAdvSelect = array("style" => "width: 200px; height: 100px;"); -$attrsTextarea = array("rows"=>"4", "cols"=>"60"); +$attrsTextarea = array("rows" => "4", "cols" => "60"); + +$availableRoute = './include/common/webServices/rest/internal.php?object=centreon_configuration_service&action=list'; +$defaultRoute = './include/common/webServices/rest/internal.php?object=centreon_configuration_graphvirtualmetric' . + '&action=defaultValues&target=graphVirtualMetric&field=host_id&id=' . $vmetric_id; $attrServices = array( 'datasourceOrigin' => 'ajax', - 'availableDatasetRoute' => './include/common/webServices/rest/internal.php?object=centreon_configuration_service&action=list', - 'defaultDatasetRoute' => './include/common/webServices/rest/internal.php?object=centreon_configuration_graphvirtualmetric&action=defaultValues&target=graphVirtualMetric&field=host_id&id=' . $vmetric_id, + 'availableDatasetRoute' => $availableRoute, + 'defaultDatasetRoute' => $defaultRoute, 'linkedObject' => 'centreonService', 'multiple' => false ); @@ -99,7 +104,7 @@ /* * Form begin */ -$form = new HTML_QuickForm('Form', 'post', "?p=".$p); +$form = new HTML_QuickForm('Form', 'post', "?p=" . $p); if ($o == "a") { $form->addElement('header', 'ftitle', _("Add a Virtual Metric")); } elseif ($o == "c") { @@ -121,10 +126,22 @@ $form->addElement('static', 'hsr_text', _("Choose a service if you want a specific virtual metric for it.")); $form->addElement('select2', 'host_id', _("Linked Host Services"), array(), $attrServices); -$form->addElement('select', 'def_type', _("DEF Type"), array(0=>"CDEF   ",1=>"VDEF   "), "onChange=manageVDEF();"); +$form->addElement( + 'select', + 'def_type', + _("DEF Type"), + array(0 => "CDEF   ", 1 => "VDEF   "), + "onChange=manageVDEF();" +); // RPN Function $form->addElement('textarea', 'rpn_function', _("RPN (Reverse Polish Notation) Function"), $attrsTextarea); -$form->addElement('static', 'rpn_text', _("
Notes :
   - Do not mix metrics of different sources.
   - Only aggregation functions work in VDEF rpn expressions.")); +$form->addElement( + 'static', + 'rpn_text', + _("
Notes :
   - " . + "Do not mix metrics of different sources.
   - " . + "Only aggregation functions work in VDEF rpn expressions.") +); #$form->addElement('select', 'real_metrics', null, $rmetrics); $form->addElement('text', 'unit_name', _("Metric Unit"), $attrsText2); $form->addElement('text', 'warn', _("Warning Threshold"), $attrsText2); @@ -150,9 +167,15 @@ $form->registerRule('existName', 'callback', 'NameTestExistence'); $form->registerRule('RPNInfinityLoop', 'callback', '_TestRPNInfinityLoop'); $form->addRule('vmetric_name', _("Name already in use for this Host/Service"), 'existName'); -$form->addRule('rpn_function', _("Can't Use This Virtual Metric '".(isset($_POST["vmetric_name"]) ? htmlentities($_POST["vmetric_name"], ENT_QUOTES, "UTF-8") : '')."' In This RPN Function"), 'RPNInfinityLoop'); +$form->addRule( + 'rpn_function', + _("Can't Use This Virtual Metric '" . (isset($_POST["vmetric_name"]) + ? htmlentities($_POST["vmetric_name"], ENT_QUOTES, "UTF-8") + : '') . "' In This RPN Function"), + 'RPNInfinityLoop' +); -$form->setRequiredNote("*". _(" Required fields")); +$form->setRequiredNote("*" . _(" Required fields")); /* * End of form definition @@ -164,22 +187,35 @@ if ($o == "w") { // Just watch - $form->addElement("button", "change", _("Modify"), array("onClick"=>"javascript:window.location.href='?p=".$p."&o=c&vmetric_id=".$vmetric_id."'")); + $form->addElement( + "button", + "change", + _("Modify"), + array("onClick" => "javascript:window.location.href='?p=" . $p . "&o=c&vmetric_id=" . $vmetric_id . "'") + ); $form->setDefaults($vmetric); $form->freeze(); } elseif ($o == "c") { // Modify $subC = $form->addElement('submit', 'submitC', _("Save"), array("class" => "btc bt_success")); - $res = $form->addElement('reset', 'reset', _("Reset"), array("onClick"=>"javascript:resetLists(".$vmetric["host_id"].",".$vmetric["index_id"].");", "class" => "btc bt_default")); + $res = $form->addElement('reset', 'reset', _("Reset"), array( + "onClick" => "javascript:resetLists(" . $vmetric["host_id"] . "," . $vmetric["index_id"] . ");", + "class" => "btc bt_default" + )); $form->setDefaults($vmetric); } elseif ($o == "a") { // Add $subA = $form->addElement('submit', 'submitA', _("Save"), array("class" => "btc bt_success")); - $res = $form->addElement('reset', 'reset', _("Reset"), array("onClick"=>"javascript:resetLists(0,0)", "class" => "btc bt_default")); + $res = $form->addElement( + 'reset', + 'reset', + _("Reset"), + array("onClick" => "javascript:resetLists(0,0)", "class" => "btc bt_default") + ); } if ($o == "c" || $o == "a") { -?> + ?> -assign('msg', array ("changeL"=>"?p=".$p."&o=c&vmetric_id=".$vmetric_id, "changeT"=>_("Modify"))); +$tpl->assign('msg', array("changeL" => "?p=" . $p . "&o=c&vmetric_id=" . $vmetric_id, "changeT" => _("Modify"))); $tpl->assign("sort1", _("Properties")); $tpl->assign("sort2", _("Graphs")); @@ -227,7 +263,7 @@ function manageVDEF() { $helptext = ""; include_once("help.php"); foreach ($help as $key => $text) { - $helptext .= ''."\n"; + $helptext .= '' . "\n"; } $tpl->assign("helptext", $helptext); @@ -255,7 +291,7 @@ function manageVDEF() { "button", "change", _("Modify"), - array("onClick"=>"javascript:window.location.href='?p=$p&o=c&vmetric_id=".$vmetricObj->getValue()."'") + array("onClick" => "javascript:window.location.href='?p=$p&o=c&vmetric_id=" . $vmetricObj->getValue() . "'") ); $form->freeze(); $valid = true; @@ -277,19 +313,23 @@ function manageVDEF() { $tpl->assign('o', $o); $tpl->display("formVirtualMetrics.ihtml"); } -$vdef=1; /* Display VDEF too */ +$vdef = 1; /* Display VDEF too */ include_once("./include/views/graphs/common/makeJS_formMetricsList.php"); if ($o == "c" || $o == "w") { - isset($_POST["host_id"]) && $_POST["host_id"] != null ? $host_service_id=$_POST["host_id"]: $host_service_id=$vmetric["host_id"]; + isset($_POST["host_id"]) && $_POST["host_id"] != null + ? $host_service_id = $_POST["host_id"] + : $host_service_id = $vmetric["host_id"]; } elseif ($o == "a") { - isset($_POST["host_id"]) && $_POST["host_id"] != null ? $host_service_id=$_POST["host_id"]: $host_service_id=0; + isset($_POST["host_id"]) && $_POST["host_id"] != null + ? $host_service_id = $_POST["host_id"] + : $host_service_id = 0; } ?> diff --git a/www/include/views/virtualMetrics/listVirtualMetrics.php b/www/include/views/virtualMetrics/listVirtualMetrics.php index bfb4f012a2e..3ca06253ede 100644 --- a/www/include/views/virtualMetrics/listVirtualMetrics.php +++ b/www/include/views/virtualMetrics/listVirtualMetrics.php @@ -32,7 +32,7 @@ * For more information : contact@centreon.com * */ - + if (!isset($oreon)) { exit; } @@ -43,13 +43,13 @@ $search = ''; if (isset($_POST['searchVM']) && $_POST['searchVM']) { $search = $_POST['searchVM']; - $SearchTool = " WHERE vmetric_name LIKE '%".$search."%'"; + $SearchTool = " WHERE vmetric_name LIKE '%" . $search . "%'"; } try { $DBRESULT = $pearDB->query("SELECT COUNT(*) FROM virtual_metrics" . $SearchTool); } catch (\PDOException $e) { - print "DB Error : ".$e->getMessage(); + print "DB Error : " . $e->getMessage(); } $tmp = $DBRESULT->fetchRow(); @@ -73,14 +73,15 @@ $tpl->assign("headerMenu_hidden", _("Hidden")); $tpl->assign("headerMenu_status", _("Status")); $tpl->assign("headerMenu_options", _("Options")); -$rq = "SELECT * FROM virtual_metrics $SearchTool ORDER BY index_id,vmetric_name LIMIT ".$num * $limit.", ".$limit; +$rq = "SELECT * FROM virtual_metrics $SearchTool ORDER BY index_id,vmetric_name LIMIT " . + $num * $limit . ", " . $limit; try { $DBRESULT = $pearDB->query($rq); } catch (\PDOException $e) { - print "Mysql Error : ".$e->getMessage(); + print "Mysql Error : " . $e->getMessage(); } - -$form = new HTML_QuickForm('select_form', 'POST', "?p=".$p); + +$form = new HTML_QuickForm('select_form', 'POST', "?p=" . $p); /* * Different style between each lines @@ -94,24 +95,42 @@ $yesOrNo = array(null => "No", 0 => "No", 1 => "Yes"); $elemArr = array(); for ($i = 0; $vmetric = $DBRESULT->fetchRow(); $i++) { - $selectedElements = $form->addElement('checkbox', "select[".$vmetric['vmetric_id']."]"); + $selectedElements = $form->addElement('checkbox', "select[" . $vmetric['vmetric_id'] . "]"); if ($vmetric["vmetric_activate"]) { - $moptions = ""._("Disabled").""; + $moptions = "" . _("Disabled") . ""; } else { - $moptions = ""._("Enabled").""; + $moptions = "" . _("Enabled") . " "; } - $moptions .= "  31 && (event.keyCode < 45 || event.keyCode > 57)) event.returnValue = false; if(event.which > 31 && (event.which < 45 || event.which > 57)) return false;\" maxlength=\"3\" size=\"3\" value='1' style=\"margin-bottom:0px;\" name='dupNbr[".$vmetric['vmetric_id']."]'>"; + $moptions .= " & nbsp; 31 && (event.keyCode < 45 || event.keyCode > 57)) " . + "event.returnValue = false; if(event.which > 31 && (event.which < 45 || event.which > 57)) return false;" . + "\" maxlength=\"3\" size=\"3\" value='1' style=\"margin-bottom:0px;\" name='dupNbr[" . + $vmetric['vmetric_id'] . "]' />"; + try { - $dbindd = $pearDBO->query("SELECT id,host_id,service_id FROM index_data WHERE id = '" . $vmetric['index_id'] . "'"); + $query = "SELECT id,host_id,service_id FROM index_data WHERE id = '" . $vmetric['index_id'] . "'"; + $dbindd = $pearDBO->query($query); } catch (\PDOException $e) { - print "DB Error : ".$e->getMessage()."
"; + print "DB Error : " . $e->getMessage() . "
"; } $indd = $dbindd->fetchRow(); $dbindd->closeCursor(); try { - $dbhsrname = $pearDB->query("(SELECT concat(h.host_name,' > ',s.service_description) full_name FROM host_service_relation AS hsr, host AS h, service AS s WHERE hsr.host_host_id = h.host_id AND hsr.service_service_id = s.service_id AND h.host_id = '" . $indd["host_id"] . "' AND s.service_id = '" . $indd["service_id"] . "') UNION (SELECT concat(h.host_name,' > ',s.service_description) full_name FROM host_service_relation AS hsr, host AS h, service AS s, hostgroup_relation AS hr WHERE hsr.hostgroup_hg_id = hr.hostgroup_hg_id AND hr.host_host_id = h.host_id AND hsr.service_service_id = s.Service_id AND h.host_id = '" . $indd["host_id"] . "' AND s.service_id = '" . $indd["service_id"] . "') ORDER BY full_name"); + $query = "(SELECT concat(h.host_name,' > ',s.service_description) full_name " . + "FROM host_service_relation AS hsr, host AS h, service AS s WHERE hsr.host_host_id = h.host_id " . + "AND hsr.service_service_id = s.service_id AND h.host_id = '" . $indd["host_id"] . + "' AND s.service_id = '" . $indd["service_id"] . "') UNION " . + "(SELECT concat(h.host_name,' > ',s.service_description) full_name " . + "FROM host_service_relation AS hsr, host AS h, service AS s, hostgroup_relation AS hr " . + "WHERE hsr.hostgroup_hg_id = hr.hostgroup_hg_id AND hr.host_host_id = h.host_id " . + "AND hsr.service_service_id = s.Service_id AND h.host_id = '" . $indd["host_id"] . + "' AND s.service_id = '" . $indd["service_id"] . "') ORDER BY full_name"; + $dbhsrname = $pearDB->query($query); } catch (\PDOException $e) { - print "DB Error : ".$e->getMessage()."
"; + print "DB Error : " . $e->getMessage() . "
"; } $hsrname = $dbhsrname->fetchRow(); $dbhsrname->closeCursor(); @@ -119,19 +138,21 @@ $hsrname["full_name"] = str_replace('#BS#', "\\", $hsrname["full_name"]); ### TODO : data_count - $elemArr[$i] = array("MenuClass"=>"list_".$style, - "title"=>$hsrname["full_name"], - "RowMenu_select"=>$selectedElements->toHtml(), - "RowMenu_ckstate"=>$vmetric["ck_state"], - "RowMenu_name"=>$vmetric["vmetric_name"], - "RowMenu_link"=>"?p=".$p."&o=c&vmetric_id=".$vmetric['vmetric_id'], - "RowMenu_unit"=>$vmetric["unit_name"], - "RowMenu_rpnfunc"=>$vmetric["rpn_function"], - "RowMenu_count"=>"-", - "RowMenu_dtype"=>$deftype[$vmetric["def_type"]], - "RowMenu_hidden"=>$yesOrNo[$vmetric["hidden"]], - "RowMenu_status"=>$vmetric["vmetric_activate"] ? _("Enabled") : _("Disabled"), - "RowMenu_options"=>$moptions); + $elemArr[$i] = array( + "MenuClass" => "list_" . $style, + "title" => $hsrname["full_name"], + "RowMenu_select" => $selectedElements->toHtml(), + "RowMenu_ckstate" => $vmetric["ck_state"], + "RowMenu_name" => $vmetric["vmetric_name"], + "RowMenu_link" => "?p=" . $p . "&o=c&vmetric_id=" . $vmetric['vmetric_id'], + "RowMenu_unit" => $vmetric["unit_name"], + "RowMenu_rpnfunc" => $vmetric["rpn_function"], + "RowMenu_count" => "-", + "RowMenu_dtype" => $deftype[$vmetric["def_type"]], + "RowMenu_hidden" => $yesOrNo[$vmetric["hidden"]], + "RowMenu_status" => $vmetric["vmetric_activate"] ? _("Enabled") : _("Disabled"), + "RowMenu_options" => $moptions + ); $style != "two" ? $style = "two" : $style = "one"; } $tpl->assign("elemArr", $elemArr); @@ -140,44 +161,66 @@ /* * Different messages we put in the template */ -$tpl->assign('msg', array ("addL"=>"?p=".$p."&o=a", "addT"=>_("Add"), "delConfirm"=>_("Do you confirm the deletion ?"))); +$tpl->assign( + 'msg', + array("addL" => "?p=" . $p . "&o=a", "addT" => _("Add"), "delConfirm" => _("Do you confirm the deletion ?")) +); /* - * Toolbar select + * Toolbar select */ ?> - + "javascript: " . - "if (this.form.elements['o1'].selectedIndex == 1 && confirm('"._("Do you confirm the duplication ?")."')) {" . - " setO(this.form.elements['o1'].value); submit();} " . - "else if (this.form.elements['o1'].selectedIndex == 2 && confirm('"._("Do you confirm the deletion ?")."')) {" . - " setO(this.form.elements['o1'].value); submit();} " . - "else if (this.form.elements['o1'].selectedIndex == 3) {" . - " setO(this.form.elements['o1'].value); submit();} " . - ""); - - $form->addElement('select', 'o1', null, array(null=>_("More actions..."), "m"=>_("Duplicate"), "d"=>_("Delete")), $attrs1); + 'onchange' => "javascript: " . + "if (this.form.elements['o1'].selectedIndex == 1 && confirm('" . + _("Do you confirm the duplication ?") . "')) {" . + " setO(this.form.elements['o1'].value); submit();} " . + "else if (this.form.elements['o1'].selectedIndex == 2 && confirm('" . + _("Do you confirm the deletion ?") . "')) {" . + " setO(this.form.elements['o1'].value); submit();} " . + "else if (this.form.elements['o1'].selectedIndex == 3) {" . + " setO(this.form.elements['o1'].value); submit();} " . + "" +); + +$form->addElement( + 'select', + 'o1', + null, + array(null => _("More actions..."), "m" => _("Duplicate"), "d" => _("Delete")), + $attrs1 +); + $form->setDefaults(array('o1' => null)); $o1 = $form->getElement('o1'); $o1->setValue(null); $attrs = array( - 'onchange'=>"javascript: " . - "if (this.form.elements['o2'].selectedIndex == 1 && confirm('"._("Do you confirm the duplication ?")."')) {" . - " setO(this.form.elements['o2'].value); submit();} " . - "else if (this.form.elements['o2'].selectedIndex == 2 && confirm('"._("Do you confirm the deletion ?")."')) {" . - " setO(this.form.elements['o2'].value); submit();} " . - "else if (this.form.elements['o2'].selectedIndex == 3) {" . - " setO(this.form.elements['o2'].value); submit();} " . - ""); -$form->addElement('select', 'o2', null, array(null=>_("More actions..."), "m"=>_("Duplicate"), "d"=>_("Delete")), $attrs); + 'onchange' => "javascript: " . + "if (this.form.elements['o2'].selectedIndex == 1 && confirm('" . + _("Do you confirm the duplication ?") . "')) {" . + " setO(this.form.elements['o2'].value); submit();} " . + "else if (this.form.elements['o2'].selectedIndex == 2 && confirm('" . + _("Do you confirm the deletion ?") . "')) {" . + " setO(this.form.elements['o2'].value); submit();} " . + "else if (this.form.elements['o2'].selectedIndex == 3) {" . + " setO(this.form.elements['o2'].value); submit();} " . + "" +); +$form->addElement( + 'select', + 'o2', + null, + array(null => _("More actions..."), "m" => _("Duplicate"), "d" => _("Delete")), + $attrs +); $form->setDefaults(array('o2' => null)); $o2 = $form->getElement('o2'); diff --git a/www/include/views/virtualMetrics/virtualMetrics.php b/www/include/views/virtualMetrics/virtualMetrics.php index 7b73f1d3de6..ae22f096970 100644 --- a/www/include/views/virtualMetrics/virtualMetrics.php +++ b/www/include/views/virtualMetrics/virtualMetrics.php @@ -34,7 +34,7 @@ */ if (!isset($centreon)) { - exit(); + exit(); } isset($_GET["vmetric_id"]) ? $cG = $_GET["vmetric_id"] : $cG = null; @@ -64,36 +64,36 @@ /* * PHP functions */ -require_once $path."DB-Func.php"; +require_once $path . "DB-Func.php"; require_once "./include/common/common-Func.php"; switch ($o) { case "a": - require_once $path."formVirtualMetrics.php"; + require_once $path . "formVirtualMetrics.php"; break; #Add a Virtual Metrics case "w": - require_once $path."formVirtualMetrics.php"; + require_once $path . "formVirtualMetrics.php"; break; #Watch a Virtual Metrics case "c": - require_once $path."formVirtualMetrics.php" ; + require_once $path . "formVirtualMetrics.php"; break; #Modify a Virtual Metrics case "s": enableVirtualMetricInDB($vmetric_id); - require_once $path."listVirtualMetrics.php"; + require_once $path . "listVirtualMetrics.php"; break; #Activate a Virtual Metrics case "u": disableVirtualMetricInDB($vmetric_id); - require_once $path."listVirtualMetrics.php"; + require_once $path . "listVirtualMetrics.php"; break; #Desactivate a Virtual Metrics... case "m": multipleVirtualMetricInDB(isset($select) ? $select : array(), $dupNbr); - require_once $path."listVirtualMetrics.php"; + require_once $path . "listVirtualMetrics.php"; break; #Duplicate n Virtual Metrics case "d": deleteVirtualMetricInDB(isset($select) ? $select : array()); - require_once $path."listVirtualMetrics.php"; + require_once $path . "listVirtualMetrics.php"; break; #Delete n Virtual Metrics default: - require_once $path."listVirtualMetrics.php"; + require_once $path . "listVirtualMetrics.php"; break; } From f43317d98150e777ebaa1e9c9ed05ebcb4154dd7 Mon Sep 17 00:00:00 2001 From: Kevin Duret Date: Wed, 16 Aug 2017 09:04:18 +0200 Subject: [PATCH 163/207] avoid php warning on config generation --- www/class/config-generate/service.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/class/config-generate/service.class.php b/www/class/config-generate/service.class.php index 58547b6ca52..b45f019c5f7 100644 --- a/www/class/config-generate/service.class.php +++ b/www/class/config-generate/service.class.php @@ -150,13 +150,13 @@ private function browseContactsInStpl($service_id) break; } - if (!is_null($services_tpl[$service_tpl_id]['contacts']) && + if (isset($services_tpl[$service_tpl_id]['contacts']) && $services_tpl[$service_tpl_id]['contacts'] != '' ) { $services_tpl[$service_tpl_top_id]['has_tpl_contacts'] = 1; } - if (!is_null($services_tpl[$service_tpl_id]['contact_groups']) && + if (isset($services_tpl[$service_tpl_id]['contact_groups']) && $services_tpl[$service_tpl_id]['contact_groups'] != '' ) { $services_tpl[$service_tpl_top_id]['has_tpl_contact_groups'] = 1; From 417b10de61fcadb39e81779a9082613473016dc8 Mon Sep 17 00:00:00 2001 From: mariegallardo Date: Wed, 16 Aug 2017 09:56:04 +0200 Subject: [PATCH 164/207] New feature MetaServiceDependencyConfiguration (#5539) --- behat.yml | 10 + ...MetaServiceDependencyConfiguration.feature | 20 ++ ...aServiceDependencyConfigurationContext.php | 238 ++++++++++++++++++ 3 files changed, 268 insertions(+) create mode 100644 features/MetaServiceDependencyConfiguration.feature create mode 100644 features/bootstrap/MetaServiceDependencyConfigurationContext.php diff --git a/behat.yml b/behat.yml index 57ff17b7038..0b090c5a611 100644 --- a/behat.yml +++ b/behat.yml @@ -338,3 +338,13 @@ default: paths: [ %paths.base%/features/VendorConfiguration.feature ] contexts: - VendorConfigurationContext + + first_notification_delay: + paths: [ %paths.base%/features/FirstNotificationDelay.feature ] + contexts: + - FirstNotificationDelayContext + + meta_service_dependency_configuration: + paths: [ %paths.base%/features/MetaServiceDependencyConfiguration.feature ] + contexts: + - MetaServiceDependencyConfigurationContext \ No newline at end of file diff --git a/features/MetaServiceDependencyConfiguration.feature b/features/MetaServiceDependencyConfiguration.feature new file mode 100644 index 00000000000..cd4c0bda38d --- /dev/null +++ b/features/MetaServiceDependencyConfiguration.feature @@ -0,0 +1,20 @@ +Feature: Edit a meta service dependency + As a Centreon user + I want to manipulate a meta service dependency + To see if all simples manipulations work + + Background: + Given I am logged in a Centreon server + And a meta service dependency + + Scenario: Change the properties of a meta service dependency + When I change the properties of a meta service dependency + Then the properties are updated + + Scenario: Duplicate one existing meta service dependency + When I duplicate a meta service dependency + Then the new object has the same properties + + Scenario: Delete one existing meta service dependency + When I delete a meta service dependency + Then the deleted object is not displayed in the list diff --git a/features/bootstrap/MetaServiceDependencyConfigurationContext.php b/features/bootstrap/MetaServiceDependencyConfigurationContext.php new file mode 100644 index 00000000000..6aa16b60432 --- /dev/null +++ b/features/bootstrap/MetaServiceDependencyConfigurationContext.php @@ -0,0 +1,238 @@ + 'metaService1Name', + 'max_check_attempts' => 12 + ); + + protected $metaService2 = array( + 'name' => 'metaService2Name', + 'max_check_attempts' => 3 + ); + + protected $metaService3 = array( + 'name' => 'metaService3Name', + 'max_check_attempts' => 40 + ); + + protected $metaService4 = array( + 'name' => 'metaService4Name', + 'max_check_attempts' => 9 + ); + + protected $metaService5 = array( + 'name' => 'metaService5Name', + 'max_check_attempts' => 21 + ); + + protected $metaService6 = array( + 'name' => 'metaService6Name', + 'max_check_attempts' => 4 + ); + + protected $initialProperties = array( + 'name' => 'metaServiceDependencyName', + 'description' => 'metaServiceDependencyDescription', + 'parent_relationship' => 0, + 'execution_fails_on_ok' => 1, + 'execution_fails_on_warning' => 1, + 'execution_fails_on_unknown' => 1, + 'execution_fails_on_critical' => 1, + 'execution_fails_on_pending' => 1, + 'execution_fails_on_none' => 0, + 'notification_fails_on_none' => 1, + 'notification_fails_on_ok' => 0, + 'notification_fails_on_warning' => 0, + 'notification_fails_on_unknown' => 0, + 'notification_fails_on_critical' => 0, + 'notification_fails_on_pending' => 0, + 'meta_services' => array( + 'metaService1Name', + 'metaService2Name' + ), + 'dependent_meta_services' => 'metaService3Name', + 'comment' => 'metaServiceDependencyComment' + ); + + protected $updatedProperties = array( + 'name' => 'metaServiceDependencyNameChanged', + 'description' => 'metaServiceDependencyDescriptionChanged', + 'parent_relationship' => 1, + 'execution_fails_on_pending' => 0, + 'execution_fails_on_none' => 1, + 'execution_fails_on_ok' => 0, + 'execution_fails_on_warning' => 0, + 'execution_fails_on_unknown' => 0, + 'execution_fails_on_critical' => 0, + 'notification_fails_on_ok' => 1, + 'notification_fails_on_warning' => 1, + 'notification_fails_on_unknown' => 1, + 'notification_fails_on_critical' => 1, + 'notification_fails_on_pending' => 1, + 'notification_fails_on_none' => 0, + 'meta_services' => 'metaService4Name', + 'dependent_meta_services' => array( + 'metaService5Name', + 'metaService6Name' + ), + 'comment' => 'metaServiceDependencyCommentChanged' + ); + + /** + * @Given a meta service dependency + */ + public function aMetaServiceDependency() + { + $this->currentPage = new MetaServiceConfigurationPage($this); + $this->currentPage->setProperties($this->metaService1); + $this->currentPage->save(); + $this->currentPage = new MetaServiceConfigurationPage($this); + $this->currentPage->setProperties($this->metaService2); + $this->currentPage->save(); + $this->currentPage = new MetaServiceConfigurationPage($this); + $this->currentPage->setProperties($this->metaService3); + $this->currentPage->save(); + $this->currentPage = new MetaServiceConfigurationPage($this); + $this->currentPage->setProperties($this->metaService4); + $this->currentPage->save(); + $this->currentPage = new MetaServiceConfigurationPage($this); + $this->currentPage->setProperties($this->metaService5); + $this->currentPage->save(); + $this->currentPage = new MetaServiceConfigurationPage($this); + $this->currentPage->setProperties($this->metaService6); + $this->currentPage->save(); + $this->currentPage = new MetaServiceDependencyConfigurationPage($this); + $this->currentPage->setProperties($this->initialProperties); + $this->currentPage->save(); + } + + /** + * @When I change the properties of a meta service dependency + */ + public function iChangeThePropertiesOfAMetaServiceDependency() + { + $this->currentPage = new MetaServiceDependencyConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['name']); + $this->currentPage->setProperties($this->updatedProperties); + $this->currentPage->save(); + } + + /** + * @Then the properties are updated + */ + public function thePropertiesAreUpdated() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new MetaServiceDependencyConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->updatedProperties['name']); + $object = $this->currentPage->getProperties(); + foreach ($this->updatedProperties as $key => $value) { + if ($value != $object[$key]) { + if (is_array($value)) { + $value = implode(' ', $value); + } + if ($value != $object[$key]) { + $this->tableau[] = $key; + } + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I duplicate a meta service dependency + */ + public function iDuplicateAMetaServiceDependency() + { + $this->currentPage = new MetaServiceDependencyConfigurationListingPage($this); + $object = $this->currentPage->getEntry($this->initialProperties['name']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Duplicate'); + } + + /** + * @Then the new object has the same properties + */ + public function theNewObjectHasTheSameProperties() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new MetaServiceDependencyConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['name'] . '_1'); + $object = $this->currentPage->getProperties(); + foreach ($this->initialProperties as $key => $value) { + if ($key != 'name' && $value != $object[$key]) { + if (is_array($value)) { + $value = implode(' ', $value); + } + if ($value != $object[$key]) { + $this->tableau[] = $key; + } + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I delete a meta service dependency + */ + public function iDeleteAMetaServiceDependency() + { + $this->currentPage = new MetaServiceDependencyConfigurationListingPage($this); + $object = $this->currentPage->getEntry($this->initialProperties['name']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Delete'); + } + + /** + * @Then the deleted object is not displayed in the list + */ + public function theDeletedObjectIsNotDisplayedInTheList() + { + $this->spin( + function ($context) { + $this->currentPage = new MetaServiceDependencyConfigurationListingPage($this); + $object = $this->currentPage->getEntries(); + $bool = true; + foreach ($object as $value) { + $bool = $bool && $value['name'] != $this->initialProperties['name']; + } + return $bool; + }, + "The service is not being deleted.", + 5 + ); + } +} From b428fe6b0ca16c6d736eddf18027dec4af7536aa Mon Sep 17 00:00:00 2001 From: David Boucher Date: Fri, 11 Aug 2017 18:12:38 +0200 Subject: [PATCH 165/207] FirstNotificationDelay: New tests First notification delay works on hosts and services and we have new tests to validate the feature. --- behat.yml | 2 +- features/FirstNotificationDelay.feature | 44 ++++ .../FirstNotificationDelayContext.php | 227 ++++++++++++++++++ 3 files changed, 272 insertions(+), 1 deletion(-) create mode 100644 features/FirstNotificationDelay.feature create mode 100644 features/bootstrap/FirstNotificationDelayContext.php diff --git a/behat.yml b/behat.yml index 0b090c5a611..4411a6f1352 100644 --- a/behat.yml +++ b/behat.yml @@ -347,4 +347,4 @@ default: meta_service_dependency_configuration: paths: [ %paths.base%/features/MetaServiceDependencyConfiguration.feature ] contexts: - - MetaServiceDependencyConfigurationContext \ No newline at end of file + - MetaServiceDependencyConfigurationContext diff --git a/features/FirstNotificationDelay.feature b/features/FirstNotificationDelay.feature new file mode 100644 index 00000000000..38276575d6f --- /dev/null +++ b/features/FirstNotificationDelay.feature @@ -0,0 +1,44 @@ +Feature: Recovery notification delay + As a Centreon user + I want to discard notifications of nodes that did not stay long enough in a non-OK state + So that I am not polluted with non-important notifications + + Background: + Given I am logged in a Centreon server + + Scenario: Host first notification disabled before delay + Given a host configured with first notification delay + And the host is not UP + When the host is still not UP before the first notification delay + Then no notification is sent + + Scenario: Service first notification disabled before delay + Given a service configured with first notification delay + And the host is UP + And the service is not OK + When the service is still not OK before the first notification delay + Then no notification is sent + + Scenario: Host first notification enabled after delay + Given a host configured with first notification delay + And the host is not UP + When the host is still not UP after the first notification delay + Then a notification is sent + When the host is UP + Then a notification is sent + When the host is not UP + And the host is still not UP before the first notification delay + Then no notification is sent + + Scenario: Service first notification enabled after delay + Given a service configured with first notification delay + And the host is UP + And the service is not OK + When the service is still not OK after the first notification delay + Then a notification is sent + When the service is OK + Then a notification is sent + When the service is not OK + And the service is still not OK before the first notification delay + Then no notification is sent + diff --git a/features/bootstrap/FirstNotificationDelayContext.php b/features/bootstrap/FirstNotificationDelayContext.php new file mode 100644 index 00000000000..c4679b698f0 --- /dev/null +++ b/features/bootstrap/FirstNotificationDelayContext.php @@ -0,0 +1,227 @@ +hostName = 'FirstNotificationDelayTestHost'; + $this->serviceName = 'FirstNotificationDelayTestService'; + } + + /** + * @Given a host configured with first notification delay + */ + public function aHostConfiguredWithFirstNotificationDelay() + { + // Create notification command. + $this->createNotificationCommand(); + + // Update notifications on admin contact + $this->updateContactNotification(); + + // Create host. + $this->createHostWithFirstNotificationDelay(); + + // Restart all pollers. + $this->reloadAllPollers(); + } + + /** + * @Given a service configured with first notification delay + */ + public function aServiceConfiguredWithFirstNotificationDelay() + { + // Create notification command. + $this->createNotificationCommand(); + + // Update notifications on admin contact + $this->updateContactNotification(); + + // Create service. + $this->createHostWithFirstNotificationDelay(); + $this->createServiceWithFirstNotificationDelay(); + + // Restart all pollers. + $this->reloadAllPollers(); + } + + /** + * @Given the host is UP + */ + public function theHostIsUp() + { + $this->execute('rm -f /tmp/acceptance_notification.tmp', 'web', false); + $this->submitHostResult($this->hostName, 0, __FUNCTION__); + } + + /** + * @Given the host is not UP + */ + public function theHostIsNotUp() + { + $this->execute('rm -f /tmp/acceptance_notification.tmp', 'web', false); + $this->submitHostResult($this->hostName, 1, __FUNCTION__); + } + + /** + * @Given the service is OK + */ + public function theServiceIsOK() + { + $this->execute('rm -f /tmp/acceptance_notification.tmp', 'web', false); + $this->submitServiceResult($this->hostName, $this->serviceName, 0, __FUNCTION__); + } + + /** + * @Given the service is not OK + */ + public function theServiceIsNotOK() + { + $this->execute('rm -f /tmp/acceptance_notification.tmp', 'web', false); + $this->submitServiceResult($this->hostName, $this->serviceName, 2, __FUNCTION__); + } + + /** + * @When the host is still not UP before the first notification delay + */ + public function theHostIsStillNotUPBeforeFirstNotificationDelay() + { + sleep(25); + $this->submitHostResult($this->hostName, 1, __FUNCTION__); + } + + /** + * @When the host is still not UP after the first notification delay + */ + public function theHostIsStillNotUPAfterFirstNotificationDelay() + { + sleep(65); + $this->submitHostResult($this->hostName, 1, __FUNCTION__); + } + + /** + * @When the service is still not OK before the first notification delay + */ + public function theServiceIsStillNotOKBeforeTheFirstNotificationDelay() + { + sleep(25); + $this->submitServiceResult($this->hostName, $this->serviceName, 2, __FUNCTION__); + } + + /** + * @When the service is still not OK after the first notification delay + */ + public function theServiceIsStillNotOKAfterTheFirstNotificationDelay() + { + sleep(65); + $this->submitServiceResult($this->hostName, $this->serviceName, 2, __FUNCTION__); + } + + /** + * @Then no notification is sent + */ + public function noNotificationIsSent() + { + sleep(10); + $retval = $this->execute('ls /tmp/acceptance_notification.tmp 2>/dev/null', 'web', false); + if ($retval['exit_code'] == 0) { + throw new \Exception('Notification was sent out.'); + } + } + + /** + * @Then a notification is sent + */ + public function aNotificationIsSent() + { + $this->spin( + function ($context) { + $retval = $context->execute('ls /tmp/acceptance_notification.tmp 2>/dev/null', 'web', false); + return ($retval['exit_code'] == 0); + }, + 'error: No notification was sent out.', + 10 + ); + } + + private function createNotificationCommand() + { + $page = new CommandConfigurationPage($this, true, 1); + $page->setProperties(array( + 'command_name' => 'acceptance_notification_command', + 'command_line' => 'touch /tmp/acceptance_notification.tmp' + )); + $page->save(); + } + + private function updateContactNotification() + { + $page = new ContactConfigurationListingPage($this); + $contact = $page->inspect('admin'); + $contact->setProperties(array( + 'notifications_enabled' => 1, + 'host_notify_on_recovery' => 1, + 'host_notify_on_down' => 1, + 'host_notification_command' => 'acceptance_notification_command', + 'service_notify_on_recovery' => 1, + 'service_notify_on_critical' => 1, + 'service_notification_command' => 'acceptance_notification_command' + )); + $contact->save(); + } + + public function createHostWithFirstNotificationDelay() + { + $page = new HostConfigurationPage($this); + $page->setProperties(array( + 'name' => $this->hostName, + 'alias' => $this->hostName, + 'address' => 'localhost', + 'max_check_attempts' => 1, + 'normal_check_interval' => 1, + 'retry_check_interval' => 1, + 'active_checks_enabled' => 0, + 'passive_checks_enabled' => 1, + 'notifications_enabled' => 1, + 'notify_on_recovery' => 1, + 'notify_on_down' => 1, + 'first_notification_delay' => 1, + 'cs' => 'admin_admin' + )); + $page->save(); + } + + public function createServiceWithFirstNotificationDelay() + { + $page = new ServiceConfigurationPage($this); + $page->setProperties(array( + 'hosts' => $this->hostName, + 'description' => $this->serviceName, + 'templates' => 'generic-service', + 'check_command' => 'check_centreon_dummy', + 'check_period' => '24x7', + 'max_check_attempts' => 1, + 'normal_check_interval' => 1, + 'retry_check_interval' => 1, + 'active_checks_enabled' => 0, + 'passive_checks_enabled' => 1, + 'notifications_enabled' => 1, + 'notify_on_recovery' => 1, + 'notify_on_critical' => 1, + 'first_notification_delay' => 1, + 'recovery_notification_delay' => 0, + 'cs' => 'admin_admin' + )); + $page->save(); + } +} From dc62abe38de64e14bd80a00a4729e4032b0aed17 Mon Sep 17 00:00:00 2001 From: loiclau Date: Wed, 16 Aug 2017 15:43:37 +0200 Subject: [PATCH 166/207] * add delete errors msg #5502 --- .../centreon-knowledge/wikiApi.class.php | 20 +++++++++++-------- .../configKnowledge/templates/display.ihtml | 11 +++++++++- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/www/class/centreon-knowledge/wikiApi.class.php b/www/class/centreon-knowledge/wikiApi.class.php index fdeca93d553..c9c6976dfed 100644 --- a/www/class/centreon-knowledge/wikiApi.class.php +++ b/www/class/centreon-knowledge/wikiApi.class.php @@ -240,16 +240,20 @@ public function deletePage($title = '') $token = $this->getMethodToken('delete', $title); - $postfields = array( - 'action' => 'delete', - 'title' => $title, - 'token' => $token - ); + if($token){ + $postfields = array( + 'action' => 'delete', + 'title' => $title, + 'token' => $token + ); - curl_setopt($this->curl, CURLOPT_POSTFIELDS, $postfields); - curl_exec($this->curl); + curl_setopt($this->curl, CURLOPT_POSTFIELDS, $postfields); + curl_exec($this->curl); - return true; + return true; + } else { + return false; + } } public function getAllPages() diff --git a/www/include/configuration/configKnowledge/templates/display.ihtml b/www/include/configuration/configKnowledge/templates/display.ihtml index 42dcbf21851..1a163913e5b 100644 --- a/www/include/configuration/configKnowledge/templates/display.ihtml +++ b/www/include/configuration/configKnowledge/templates/display.ihtml @@ -1,4 +1,5 @@ +
@@ -241,7 +242,15 @@ title: title }), success: function (data) { - location.reload() + if(data.result){ + location.reload() + } else { + var msg = "Deletion failed, please check your wiki configuration and your wiki user rights."; + var $popin = jQuery("#errorMsg"); + $popin.html(msg); + jQuery($popin).css('display', 'block'); + $popin.centreonPopin("open"); + } } }); } From 8921440bcbb3b5b7a2c5239c84056b675150d315 Mon Sep 17 00:00:00 2001 From: Laurent Pinsivy Date: Wed, 16 Aug 2017 16:59:42 +0200 Subject: [PATCH 167/207] #5410 #5287 - Fix sort and order in real time services monitoring (#5517) Move include to get correct values for $sort_type and $order --- www/include/monitoring/status/Services/service.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/www/include/monitoring/status/Services/service.php b/www/include/monitoring/status/Services/service.php index 96d28ad9c44..1edee84e4b9 100644 --- a/www/include/monitoring/status/Services/service.php +++ b/www/include/monitoring/status/Services/service.php @@ -168,11 +168,6 @@ $global_sort_order = $centreon->optGen["global_sort_order"]; } -include_once("./include/monitoring/status/Common/default_poller.php"); -include_once("./include/monitoring/status/Common/default_hostgroups.php"); -include_once("./include/monitoring/status/Common/default_servicegroups.php"); -include_once($svc_path . "/serviceJS.php"); - if ($o == "svcpb" || $o == "svc_unhandled" || empty($o)) { if (!empty($filters["sort_type"])) { $sort_type = $filters["sort_type"]; @@ -203,6 +198,10 @@ } } +include_once("./include/monitoring/status/Common/default_poller.php"); +include_once("./include/monitoring/status/Common/default_hostgroups.php"); +include_once("./include/monitoring/status/Common/default_servicegroups.php"); +include_once($svc_path . "/serviceJS.php"); /* * Smarty template Init From 64f308b3e7d79c50861fd53852077916bce9b049 Mon Sep 17 00:00:00 2001 From: mariegallardo Date: Wed, 16 Aug 2017 17:12:08 +0200 Subject: [PATCH 168/207] Feature service dependency configuration page (#5532) * Select2 fixed * New feature: serviceDependencyConfiguration * feature updated --- behat.yml | 5 + .../ServiceDependencyConfiguration.feature | 20 ++ .../ServiceDependencyConfigurationContext.php | 195 ++++++++++++++++++ 3 files changed, 220 insertions(+) create mode 100644 features/ServiceDependencyConfiguration.feature create mode 100644 features/bootstrap/ServiceDependencyConfigurationContext.php diff --git a/behat.yml b/behat.yml index 4411a6f1352..9d60670f015 100644 --- a/behat.yml +++ b/behat.yml @@ -324,6 +324,11 @@ default: contexts: - HostDependencyConfigurationContext + service_dependency_configuration: + paths: [ %paths.base%/features/ServiceDependencyConfiguration.feature ] + contexts: + - ServiceDependencyConfigurationContext + service_group_dependency_configuration: paths: [ %paths.base%/features/ServiceGroupDependencyConfiguration.feature ] contexts: diff --git a/features/ServiceDependencyConfiguration.feature b/features/ServiceDependencyConfiguration.feature new file mode 100644 index 00000000000..9b4bdbcef32 --- /dev/null +++ b/features/ServiceDependencyConfiguration.feature @@ -0,0 +1,20 @@ +Feature: Edit a service dependency + As a Centreon user + I want to manipulate a service dependency + To see if all simples manipulations work + + Background: + Given I am logged in a Centreon server + And a service dependency is configured + + Scenario: Change the properties of a service dependency + When I change the properties of a service dependency + Then the properties are updated + + Scenario: Duplicate one existing service dependency + When I duplicate a service dependency + Then the new object has the same properties + + Scenario: Delete one existing service dependency + When I delete a service dependency + Then the deleted object is not displayed in the list diff --git a/features/bootstrap/ServiceDependencyConfigurationContext.php b/features/bootstrap/ServiceDependencyConfigurationContext.php new file mode 100644 index 00000000000..cb5d52bbbfc --- /dev/null +++ b/features/bootstrap/ServiceDependencyConfigurationContext.php @@ -0,0 +1,195 @@ + 'hostName', + 'alias' => 'hostAlias', + 'address' => 'host@localhost' + ); + + protected $initialProperties = array( + 'name' => 'serviceDependencyName', + 'description' => 'serviceDependencyDescription', + 'parent_relationship' => 0, + 'execution_fails_on_none' => 1, + 'execution_fails_on_ok' => 0, + 'execution_fails_on_warning' => 0, + 'execution_fails_on_unknown' => 0, + 'execution_fails_on_critical' => 0, + 'execution_fails_on_pending' => 0, + 'notification_fails_on_ok' => 1, + 'notification_fails_on_warning' => 1, + 'notification_fails_on_unknown' => 1, + 'notification_fails_on_critical' => 1, + 'notification_fails_on_pending' => 1, + 'notification_fails_on_none' => 0, + 'services' => 'Centreon-Server - Load', + 'dependent_services' => 'Centreon-Server - Memory', + 'dependent_hosts' => 'Centreon-Server', + 'comment' => 'serviceDependingComment' + ); + + protected $updatedProperties = array( + 'name' => 'serviceDependentNameChanged', + 'description' => 'serviceDependentDescriptionChanged', + 'parent_relationship' => 1, + 'execution_fails_on_ok' => 1, + 'execution_fails_on_warning' => 1, + 'execution_fails_on_unknown' => 1, + 'execution_fails_on_critical' => 1, + 'execution_fails_on_pending' => 1, + 'execution_fails_on_none' => 0, + 'notification_fails_on_none' => 1, + 'notification_fails_on_ok' => 0, + 'notification_fails_on_warning' => 0, + 'notification_fails_on_unknown' => 0, + 'notification_fails_on_critical' => 0, + 'notification_fails_on_pending' => 0, + 'services' => 'Centreon-Server - Ping', + 'dependent_services' => 'Centreon-Server - Disk-/home', + 'dependent_hosts' => 'hostName', + 'comment' => 'serviceDependingCommentChanged' + ); + + /** + * @Given a service dependency is configured + */ + public function aServiceDependencyIsConfigured() + { + $this->currentPage = new HostConfigurationPage($this); + $this->currentPage->setProperties($this->host); + $this->currentPage->save(); + $this->currentPage = new ServiceDependencyConfigurationPage($this); + $this->currentPage->setProperties($this->initialProperties); + $this->currentPage->save(); + } + + /** + * @When I change the properties of a service dependency + */ + public function iChangeThePropertiesOfAServiceDependency() + { + $this->currentPage = new ServiceDependencyConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['name']); + $this->currentPage->setProperties($this->updatedProperties); + $this->currentPage->save(); + } + + /** + * @Then the properties are updated + */ + public function thePropertiesAreUpdated() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new ServiceDependencyConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->updatedProperties['name']); + $object = $this->currentPage->getProperties(); + foreach ($this->updatedProperties as $key => $value) { + if ($value != $object[$key]) { + if (is_array($value)) { + $value = implode(' ', $value); + } + if ($value != $object[$key]) { + $this->tableau[] = $key; + } + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I duplicate a service dependency + */ + public function iDuplicateAServiceDependency() + { + $this->currentPage = new ServiceDependencyConfigurationListingPage($this); + $object = $this->currentPage->getEntry($this->initialProperties['name']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Duplicate'); + } + + /** + * @Then the new object has the same properties + */ + public function theNewObjectHasTheSameProperties() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new ServiceDependencyConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['name'] . '_1'); + $object = $this->currentPage->getProperties(); + foreach ($this->initialProperties as $key => $value) { + if ($key != 'name' && $value != $object[$key]) { + if (is_array($value)) { + $value = implode(' ', $value); + } + if ($value != $object[$key]) { + $this->tableau[] = $key; + } + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I delete a service dependency + */ + public function iDeleteAServiceDependency() + { + $this->currentPage = new ServiceDependencyConfigurationListingPage($this); + $object = $this->currentPage->getEntry($this->initialProperties['name']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Delete'); + } + + /** + * @Then the deleted object is not displayed in the list + */ + public function theDeletedObjectIsNotDisplayedInTheList() + { + $this->spin( + function ($context) { + $this->currentPage = new ServiceDependencyConfigurationListingPage($this); + $object = $this->currentPage->getEntries(); + $bool = true; + foreach ($object as $value) { + $bool = $bool && $value['name'] != $this->initialProperties['name']; + } + return $bool; + }, + "The service is not being deleted.", + 5 + ); + } +} From ab2ab01e7d9cceab6708d4038e50a6de6246dd20 Mon Sep 17 00:00:00 2001 From: Laurent Pinsivy Date: Wed, 16 Aug 2017 17:36:45 +0200 Subject: [PATCH 169/207] Update DB-Func.php "revert" commit 76e677d326c16a119cdf263d1fb68dad7ad633af but specify table to delete and add WHERE in SQL request. Conflicts: www/include/options/accessLists/groupsACL/DB-Func.php --- www/include/options/accessLists/groupsACL/DB-Func.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/www/include/options/accessLists/groupsACL/DB-Func.php b/www/include/options/accessLists/groupsACL/DB-Func.php index 5c2142e5933..4ec9d4e21c6 100644 --- a/www/include/options/accessLists/groupsACL/DB-Func.php +++ b/www/include/options/accessLists/groupsACL/DB-Func.php @@ -383,10 +383,10 @@ function updateGroupResources($acl_group_id, $ret = array()) return; } - $query = 'DELETE ' - . 'FROM acl_res_group_relations USING acl_res_group_relations ' - . 'JOIN acl_resources ar ON acl_res_group_relations.acl_res_id = ar.acl_res_id ' - . 'AND acl_res_group_relations.acl_group_id = ' . $acl_group_id . ' ' + $query = 'DELETE argr ' + . 'FROM acl_res_group_relations argr ' + . 'JOIN acl_resources ar ON argr.acl_res_id = ar.acl_res_id ' + . 'WHERE argr.acl_group_id = ' . $acl_group_id . ' ' . 'AND ar.locked = 0 '; $pearDB->query($query); if (isset($_POST["resourceAccess"])) { From 5d6c2befca99c54ecc9082cdafe3a6e3e44bf548 Mon Sep 17 00:00:00 2001 From: Laurent Pinsivy Date: Thu, 17 Aug 2017 09:07:34 +0200 Subject: [PATCH 170/207] #5402 - order by status then by service description (#5552) --- .../status/ServicesHostGroups/xml/serviceGridByHGXML.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/include/monitoring/status/ServicesHostGroups/xml/serviceGridByHGXML.php b/www/include/monitoring/status/ServicesHostGroups/xml/serviceGridByHGXML.php index e02ee236ae5..52ab743536c 100644 --- a/www/include/monitoring/status/ServicesHostGroups/xml/serviceGridByHGXML.php +++ b/www/include/monitoring/status/ServicesHostGroups/xml/serviceGridByHGXML.php @@ -179,7 +179,7 @@ $rq1 .= " AND h.instance_id = ".$instance; } //$rq1 .= " ORDER BY s.description"; - $rq1 .= " order by tri asc"; + $rq1 .= " order by tri asc, s.description asc"; $tabService = array(); $tabHost = array(); From 2e39a54759ba815e78fc7b3d452f786fc754efff Mon Sep 17 00:00:00 2001 From: Lionel Assepo Date: Wed, 16 Aug 2017 17:29:24 +0200 Subject: [PATCH 171/207] * Add sql upgrade file for 2.8.12 --- www/install/sql/centreon/Update-DB-2.8.11_to_2.8.12.sql | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 www/install/sql/centreon/Update-DB-2.8.11_to_2.8.12.sql diff --git a/www/install/sql/centreon/Update-DB-2.8.11_to_2.8.12.sql b/www/install/sql/centreon/Update-DB-2.8.11_to_2.8.12.sql new file mode 100644 index 00000000000..fd464ba9bb4 --- /dev/null +++ b/www/install/sql/centreon/Update-DB-2.8.11_to_2.8.12.sql @@ -0,0 +1,2 @@ +-- Change version of Centreon +UPDATE `informations` SET `value` = '2.8.12' WHERE CONVERT( `informations`.`key` USING utf8 ) = 'version' AND CONVERT ( `informations`.`value` USING utf8 ) = '2.8.11' LIMIT 1; From 0c576ccce6207bf58e95f34cd3847e68761d092b Mon Sep 17 00:00:00 2001 From: Lionel Assepo Date: Thu, 17 Aug 2017 10:27:12 +0200 Subject: [PATCH 172/207] * Add upgrade from 2.8.12 to 2.9.0 --- ...ate-DB-2.8.11_to_2.9.0.sql => Update-DB-2.8.12_to_2.9.0.sql} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename www/install/sql/centreon/{Update-DB-2.8.11_to_2.9.0.sql => Update-DB-2.8.12_to_2.9.0.sql} (97%) diff --git a/www/install/sql/centreon/Update-DB-2.8.11_to_2.9.0.sql b/www/install/sql/centreon/Update-DB-2.8.12_to_2.9.0.sql similarity index 97% rename from www/install/sql/centreon/Update-DB-2.8.11_to_2.9.0.sql rename to www/install/sql/centreon/Update-DB-2.8.12_to_2.9.0.sql index fde40c2de02..34ae0c2a5e5 100644 --- a/www/install/sql/centreon/Update-DB-2.8.11_to_2.9.0.sql +++ b/www/install/sql/centreon/Update-DB-2.8.12_to_2.9.0.sql @@ -1,5 +1,5 @@ -- Change version of Centreon -UPDATE `informations` SET `value` = '2.9.0' WHERE CONVERT( `informations`.`key` USING utf8 ) = 'version' AND CONVERT ( `informations`.`value` USING utf8 ) = '2.8.10' LIMIT 1; +UPDATE `informations` SET `value` = '2.9.0' WHERE CONVERT( `informations`.`key` USING utf8 ) = 'version' AND CONVERT ( `informations`.`value` USING utf8 ) = '2.8.12' LIMIT 1; ALTER TABLE `extended_host_information` DROP FOREIGN KEY `extended_host_information_ibfk_3`; ALTER TABLE `extended_host_information` DROP COLUMN `ehi_vrml_image`; From dbfdb903af74140280ab5135df6f1db92e4469f9 Mon Sep 17 00:00:00 2001 From: Kevin Duret Date: Thu, 17 Aug 2017 11:04:32 +0200 Subject: [PATCH 173/207] fix syntax error in config generate --- www/include/configuration/configGenerate/formGenerateFiles.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/include/configuration/configGenerate/formGenerateFiles.php b/www/include/configuration/configGenerate/formGenerateFiles.php index d4078b470f3..fc19a946d14 100644 --- a/www/include/configuration/configGenerate/formGenerateFiles.php +++ b/www/include/configuration/configGenerate/formGenerateFiles.php @@ -486,7 +486,7 @@ function displayPhpErrorMsg(action, responseXML) { trEl.appendChild(tdEl1); var tdEl2 = document.createElement('td'); tdEl2.setAttribute('class', 'FormRowValue'); - tdEl2.innerHTML = ''. + tdEl2.innerHTML = '' + '[ + ]'; trEl.appendChild(tdEl2); var divErrors = document.createElement('div'); From 91328d2a27d0cd95f13d402124db10095948a402 Mon Sep 17 00:00:00 2001 From: cgagnaire Date: Thu, 17 Aug 2017 11:49:15 +0200 Subject: [PATCH 174/207] replacing contact_name by contact_alias (#5546) This class works like centreonService.class.php, and we pass the alias (i.e. the login) when setting contacts to a service template. --- www/class/centreon-clapi/centreonServiceTemplate.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/www/class/centreon-clapi/centreonServiceTemplate.class.php b/www/class/centreon-clapi/centreonServiceTemplate.class.php index 0aabe65aad9..a8151b734b5 100644 --- a/www/class/centreon-clapi/centreonServiceTemplate.class.php +++ b/www/class/centreon-clapi/centreonServiceTemplate.class.php @@ -742,7 +742,7 @@ public function __call($name, $arg) $relationTable = array(); foreach ($relations as $rel) { if ($matches[2] == "contact") { - $tab = $obj->getIdByParameter("contact_name", array($rel)); + $tab = $obj->getIdByParameter("contact_alias", array($rel)); } else { $tab = $obj->getIdByParameter($obj->getUniqueLabelField(), array($rel)); } @@ -960,7 +960,7 @@ public function export($filters=null) $filters_contactRel['service_id'] = $filters['service_id']; } $elements = $contactRel->getMergedParameters( - array("contact_name", "contact_id"), + array("contact_alias", "contact_id"), array('service_description'), -1, 0, @@ -974,7 +974,7 @@ public function export($filters=null) echo $this->action . $this->delim . "addcontact" . $this->delim . $element['service_description'] . $this->delim - . $element['contact_name'] . "\n"; + . $element['contact_alias'] . "\n"; } // macros From e398bd08086947f787eded697b21b4343eb59d7d Mon Sep 17 00:00:00 2001 From: Laurent Pinsivy Date: Thu, 17 Aug 2017 11:50:32 +0200 Subject: [PATCH 175/207] #5534 - remove padding to align field with others (#5553) --- .../views/componentTemplates/formComponentTemplate.ihtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/include/views/componentTemplates/formComponentTemplate.ihtml b/www/include/views/componentTemplates/formComponentTemplate.ihtml index e93676f8ff8..99e306b16d5 100644 --- a/www/include/views/componentTemplates/formComponentTemplate.ihtml +++ b/www/include/views/componentTemplates/formComponentTemplate.ihtml @@ -30,7 +30,7 @@
{$form.ds_name.label} - + {if $o == "a" || $o == "c"} 3z+lzZN%Hd4&6wojSz)8s1{Wdhg>YU~2Y}1H14}HQZ{SR55aZ zAR~MXxr=>S37W+`AQKds?Y;c3g?16umm9ssUUI^0invk2a|icaY?Dry5gb{$yWeN+Fk8*$npzgLV#K zg<0BaakFycsrI+u@}3 z8Kigk+_B3Rg|XTX+vPUM$b^3Y6U>+9d<4DSm?~36^A|bFCluJVvRYItC5lUTLjQ4br|q>f+;C!S_IODG(_dW zrhPl)eiaY;j!FOOL;l>9M%jd1JmtNr?!9oDH7)%ejHTO7iL$t$dJj%6i2`wf9+d>| z3XM5NT3ug&PFUe@%QXXv?>q2LGMK#RxZ>-9`VW^e(g#)R*ReXELi;Rw*DE&|3WM$i zl-_BWal*=Z^XYY;+UtD!5jzu9IvLWJ<1dA-@DobI^Lqqh!2eVub}OrF(1-0s8IPY0 z0x7fqh|T_B??;&a9TA)yLlyV}y2~dN#x;ld%&vegC4VlxY`ICmb^?<~=hGfeR><{T zOa9*ysCF0bc z*f84*6|##Zcw(U1Auy&oy8SS&I-W|Fk*RPCZ)Bn#(Kc-`xMU&fQu1lqy+*8GKA703 zZ|MddBdF7K($o|!#98d`IT+fpV!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49<9h@&|A>j;hv9d zbw@jW2>BbnM?y<`(q{N~izEy#atrvxd@Igsr2esEr&eS$E>x6-S<4t`Eyp!NMGu35 zu?20D8ufe1+YWVu()YE79xzWnxM5PN4(JC<)f2qe$sC1W+Qg^@G3jt9wt7<;>L3;iAM)f>? zi!P1ir?}EonSk|1Jc2t>gVEGvh4|INjpZxk- zQ)5#i{pjLP!j(qxAt?fp{3=5qTaR-fdxvJNyOGleAM(PQOOGe(En&F@t!CgL6dqX1n&BilI7`wG{_jIJ_Hl7^v?Kr7g#IJ(@s~ z59&nVZMQJGG6qM+R?i%#Po2YSa5CSXgTR=@vWTaiz|26KU@JW|X1Xgt8;E~n05Z=# zwvkDXc2G;kVg5{ATVgTU(S)Cw%T&Ev-z2sBu|{K^9Y0;ywE-ror04>exx6Que%J4IEpsn<;kjPcN`iY5z- zvXkel6yyZ2BTdAau8ijkkkt@vJhhi{Pgc9sQg<0j0tQ@bT2gNX{wltRNp&?^^lN(3 zPptw)z@?B6At$Klgbj)}CTf0e`Zb@iMrH2heQo3!r~1g~dyhgMJfgX}y86gkQ|;Gfv-QFM@b?f!g<5yt-Wd0L z%$Ao`5yMq(emE5}X@jX1*`@4VQA4fuL(&z(XJSAFCb&V5W5}P3LL<_{mZN+7%npbY zJ8W#~;$FVLph6hlb?)GB#KQ^%ramk;`=93HbMODo2mk6f- openssl req -x509 -newkey rsa:2048 -nodes -keyout ca.key -out ca.crt -days 365 + + +Now we can generate certificates using the CA key. + +:: + + $> openssl req -new -newkey rsa:2048 -nodes -keyout central.key -out central.csr -days 365 + $> openssl req -new -newkey rsa:2048 -nodes -keyout poller.key -out poller.csr -days 365 + $> openssl x509 -req -in central.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out central.crt -days 365 -sha256 + $> openssl x509 -req -in poller.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out poller.crt -days 365 -sha256 + + +Place *central.key*, *central.crt* and *ca.crt* on the Centreon central server +(in **/etc/centreon-broker** for example) and *poller.key*, *poller.crt* and +*ca.crt* on your poller. + +Now we need to configure Centreon Broker to use these files. Go to +**Configuration ==> Pollers ==> Broker configuration**. For +*central-broker-master*, in the *Input* tab, you need to set the following +parameters for *central-broker-master-input*. + +- Enable TLS encryption = Yes +- Private key file = /etc/centreon-broker/central.key +- Public certificate = /etc/centreon-broker/central.crt +- Trusted CA's certificate = /etc/centreon-broker/ca.crt + +.. image:: /_static/images/configuration/broker_certificates.png + :align: center + +Similarly for your poller, you will need to modify it's TCP output in the Output +tab with the following parameters. + +- Enable TLS encryption = Yes +- Private key file = /etc/centreon-broker/poller.key +- Public certificate = /etc/centreon-broker/poller.crt +- Trusted CA's certificate = /etc/centreon-broker/ca.crt + +Regenerate the configuration of the affected pollers +(**Configuration ==> Pollers**) and you're good. + + Centreontrapd Configuration =========================== diff --git a/doc/fr/_static/images/configuration/broker_certificates.png b/doc/fr/_static/images/configuration/broker_certificates.png new file mode 100644 index 0000000000000000000000000000000000000000..badb0b463d62013d0ff082a1d4b6942f99457636 GIT binary patch literal 56433 zcmbrl1ymhdwgn0y0RjYfPYCYr5E3K_7Tn$8;O@a4f;$9vcXxMpJ-EBeFYax*?{~j` zJ^nu#r*bIWRlD|@bImn(zz+$LcW}6H5D*aWzI_#xhJbjb0(`Szp@B6IYLwW(f6&^Z zB7zXlFaLfw;_}=OIuIF{;y)BT5V0U2h#|fS3dlOlA1t}s$k;X?KN~1V zWWO~fF=eDxY)5y_P-W@C@#VT9>G$VF4NEVF)R7a;Z2_ zH8?!Hoceflv|hEGDrxu5)z#Hf5cq6}hG(Ms10M=dz(1D$?J+N_{<{3@W(p9&AxTQZ zqtS9m%A7!#GW(g-eeUt-)6sWAMHg~gk5i(WrqkHP3Vm(}k16}|n=9wq?Ue9mLcPmw zJ8c~fiIE0L>-+WXo3Gblz*Ukuy-UEq=T}U1GprF6Ht-3o`U)Elb>M`^Bi+wC zWL0AsFVgpE^9hT1@q~`pR{8j!;lg!Xvq?C;UC87G>l_be4?e`4zh8 ziP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+6_BW@85gy49<9h@&|A>j;hv9d zbw@jW2>BbnM?y<`(q{N~izEy#atrvxd@Igsr2esEr&eS$E>x6-S<4t`Eyp!NMGu35 zu?20D8ufe1+YWVu()YE79xzWnxM5PN4(JC<)f2qe$sC1W+Qg^@G3jt9wt7<;>L3;iAM)f>? zi!P1ir?}EonSk|1Jc2t>gVEGvh4|INjpZxk- zQ)5#i{pjLP!j(qxAt?fp{3=5qTaR-fdxvJNyOGleAM(PQOOGe(En&F@t!CgL6dqX1n&BilI7`wG{_jIJ_Hl7^v?Kr7g#IJ(@s~ z59&nVZMQJGG6qM+R?i%#Po2YSa5CSXgTR=@vWTaiz|26KU@JW|X1Xgt8;E~n05Z=# zwvkDXc2G;kVg5{ATVgTU(S)Cw%T&Ev-z2sBu|{K^9Y0;ywE-ror04>exx6Que%J4IEpsn<;kjPcN`iY5z- zvXkel6yyZ2BTdAau8ijkkkt@vJhhi{Pgc9sQg<0j0tQ@bT2gNX{wltRNp&?^^lN(3 zPptw)z@?B6At$Klgbj)}CTf0e`Zb@iMrH2heQo3!r~1g~dyhgMJfgX}y86gkQ|;Gfv-QFM@b?f!g<5yt-Wd0L z%$Ao`5yMq(emE5}X@jX1*`@4VQA4fuL(&z(XJSAFCb&V5W5}P3LL<_{mZN+7%npbY zJ8W#~;$FVLph6hlb?)GB#KQ^%ramk;`=93HbMODo2mk6f- openssl req -x509 -newkey rsa:2048 -nodes -keyout ca.key -out ca.crt -days 365 + + +Nous pouvons maintenant générer les certificats en utilisant la clé de la CA. + +:: + + $> openssl req -new -newkey rsa:2048 -nodes -keyout central.key -out central.csr -days 365 + $> openssl req -new -newkey rsa:2048 -nodes -keyout poller.key -out poller.csr -days 365 + $> openssl x509 -req -in central.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out central.crt -days 365 -sha256 + $> openssl x509 -req -in poller.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out poller.crt -days 365 -sha256 + + +Placez *central.key*, *central.crt* et *ca.crt* sur le serveur Centreon +central (dans **/etc/centreon-broker** par exemple) et *poller.key*, +*poller.crt* et *ca.crt* sur votre poller. + +Nous devons maintenant configurer Centreon Broker pour utiliser ces +fichiers. Allez dans **Configuration ==> Pollers ==> Broker configuration**. +Pour *central-broker-master*, dans l'onglet *Input*, vous devez remplir les +paramètres suivants pour *central-broker-master-input*. + +- Enable TLS encryption = Yes +- Private key file = /etc/centreon-broker/central.key +- Public certificate = /etc/centreon-broker/central.crt +- Trusted CA's certificate = /etc/centreon-broker/ca.crt + +.. image:: /_static/images/configuration/broker_certificates.png + :align: center + +De manière similaire pour le poller, vous devez modifier les paramètres +de la connexion TCP dans l'onglet Output. + +- Enable TLS encryption = Yes +- Private key file = /etc/centreon-broker/poller.key +- Public certificate = /etc/centreon-broker/poller.crt +- Trusted CA's certificate = /etc/centreon-broker/ca.crt + +Regénérez la configuration des pollers affectés par ces changements +(**Configuration ==> Pollers**) et la mise en place de +l'authentification est terminée. + + Configuration de Centreontrapd ============================== @@ -78,7 +136,7 @@ Sur le serveur central : :: $ ssh-keygen - + 3. Puis exportez votre clé SSH vers le serveur satellite : ::
{$form.ds_name.html}{$form.ds_name.html}    From 3992a9861b3900031012d4ba2775a6e9bf1480e8 Mon Sep 17 00:00:00 2001 From: loiclau Date: Thu, 17 Aug 2017 13:46:18 +0200 Subject: [PATCH 176/207] * fix style context --- .../bootstrap/ContactConfigurationContext.php | 7 ++++--- .../FirstNotificationDelayContext.php | 4 ++-- .../bootstrap/HostConfigurationContext.php | 4 ++-- .../bootstrap/LdapConfigurationContext.php | 7 ------- .../MetaServiceConfigurationContext.php | 6 +++--- features/bootstrap/MetaServicesApiContext.php | 3 --- .../bootstrap/ServiceConfigurationContext.php | 12 ++++++------ .../bootstrap/ServiceSubmitResultContext.php | 6 +++++- .../bootstrap/VirtualMetricHandleContext.php | 18 +++++++++--------- 9 files changed, 31 insertions(+), 36 deletions(-) diff --git a/features/bootstrap/ContactConfigurationContext.php b/features/bootstrap/ContactConfigurationContext.php index 90c9c8f61dc..0d6797c8768 100644 --- a/features/bootstrap/ContactConfigurationContext.php +++ b/features/bootstrap/ContactConfigurationContext.php @@ -1,4 +1,5 @@ tableau[] = $key; - + } } if (($key == 'name' || $key == 'alias') && $value . '_1' != $object[$key]) { diff --git a/features/bootstrap/FirstNotificationDelayContext.php b/features/bootstrap/FirstNotificationDelayContext.php index c4679b698f0..ee532149b09 100644 --- a/features/bootstrap/FirstNotificationDelayContext.php +++ b/features/bootstrap/FirstNotificationDelayContext.php @@ -146,8 +146,8 @@ public function aNotificationIsSent() { $this->spin( function ($context) { - $retval = $context->execute('ls /tmp/acceptance_notification.tmp 2>/dev/null', 'web', false); - return ($retval['exit_code'] == 0); + $retval = $context->execute('ls /tmp/acceptance_notification.tmp 2>/dev/null', 'web', false); + return ($retval['exit_code'] == 0); }, 'error: No notification was sent out.', 10 diff --git a/features/bootstrap/HostConfigurationContext.php b/features/bootstrap/HostConfigurationContext.php index 2d3c3daf108..feeb5202f9d 100644 --- a/features/bootstrap/HostConfigurationContext.php +++ b/features/bootstrap/HostConfigurationContext.php @@ -194,7 +194,7 @@ class HostConfigurationContext extends CentreonContext 'address' => 'hostChanged@localhost', 'snmp_community' => 'hostSnmpCommunitychanged', 'snmp_version' => '3', - 'macros' => array( + 'macros' => array( 'HOSTMACROCHANGED' => 5 ), 'location' => 'Europe/Paris', @@ -222,7 +222,7 @@ class HostConfigurationContext extends CentreonContext 'notify_on_downtime_scheduled' => 0, 'notification_interval' => 34, 'notification_period' => 'workhours', - 'first_notification_delay' => 7, + 'first_notification_delay' => 7, 'recovery_notification_delay' => 4, 'parent_host_groups' => 'hostGroupName2', 'parent_host_categories' => 'hostCategoryName3', diff --git a/features/bootstrap/LdapConfigurationContext.php b/features/bootstrap/LdapConfigurationContext.php index 2dbb049f789..ea5e35d5c26 100644 --- a/features/bootstrap/LdapConfigurationContext.php +++ b/features/bootstrap/LdapConfigurationContext.php @@ -23,7 +23,6 @@ public function iAddANewLdapConfiguration() 'enable_authentication' => 1, 'template' => 'Posix' )); - } @@ -46,7 +45,6 @@ public function iModifySomePropertiesOfAnExistingLdapConfiguration() $this->page = $this->page->inspect($this->configuration_name); $this->page->setProperties(array('configuration_name' => $this->newConfigurationName)); $this->page->save(); - } /** @@ -54,15 +52,12 @@ public function iModifySomePropertiesOfAnExistingLdapConfiguration() */ public function allChangesAreSaved() { - $this->page = new LdapConfigurationListingPage($this); $object = $this->page->getEntry($this->newConfigurationName); if ($object['configuration_name'] != $this->newConfigurationName) { - throw new \Exception('the Configuration has not changed.'); } - } /** @@ -77,7 +72,6 @@ public function iHaveDeletedOneExistingLdapConfiguration() $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); $this->setConfirmBox(true); $this->selectInList('select[name="o1"]', 'Delete'); - } /** @@ -89,7 +83,6 @@ public function thisConfigurationHasDisappearedFromTheLdapConfigurationList() $object = $this->page->getEntries(); if (isset($object[$this->configuration_name])) { - throw new \Exception('the Configuration is not deleted.'); } } diff --git a/features/bootstrap/MetaServiceConfigurationContext.php b/features/bootstrap/MetaServiceConfigurationContext.php index 31ba533720b..c7c909a9e17 100644 --- a/features/bootstrap/MetaServiceConfigurationContext.php +++ b/features/bootstrap/MetaServiceConfigurationContext.php @@ -17,7 +17,7 @@ class MetaServiceConfigurationContext extends CentreonContext 'data_source_type' => 'ABSOLUTE', 'selection_mode' => 2, 'sql_like_clause_expression' => 'metaServiceExpression', - 'metric' => '', + 'metric' => '', 'check_period' => 'workhours', 'max_check_attempts' => 10, 'normal_check_interval' => 15, @@ -154,8 +154,8 @@ function ($context) { if ($value != $object[$key]) { $this->tableau[] = $key; } - } - if ($key == 'name'&& $value . '_1' != $object[$key]) { + } + if ($key == 'name' && $value . '_1' != $object[$key]) { $this->tableau[] = $key; } } diff --git a/features/bootstrap/MetaServicesApiContext.php b/features/bootstrap/MetaServicesApiContext.php index 1ba1ddd38f3..01437f3959a 100644 --- a/features/bootstrap/MetaServicesApiContext.php +++ b/features/bootstrap/MetaServicesApiContext.php @@ -40,7 +40,6 @@ public function aCallToApiConfigurationServicesWithParameterAll() { $param = 'all'; $this->jsonreturn = $this->callToApiConfigurationServices($param); - } @@ -51,7 +50,6 @@ public function aCallToApiConfigurationServicesWithParameterS() { $param = 's'; $this->jsonreturn = $this->callToApiConfigurationServices($param); - } @@ -62,7 +60,6 @@ public function aCallToApiConfigurationServicesWithParameterM() { $param = 'm'; $this->jsonreturn = $this->callToApiConfigurationServices($param); - } diff --git a/features/bootstrap/ServiceConfigurationContext.php b/features/bootstrap/ServiceConfigurationContext.php index 2e399bfdd0c..12f935f6460 100644 --- a/features/bootstrap/ServiceConfigurationContext.php +++ b/features/bootstrap/ServiceConfigurationContext.php @@ -103,7 +103,7 @@ class ServiceConfigurationContext extends CentreonContext 'severity' => 'serviceCategory2Name (2)', 'geo_coordinates' => 'Paris', 'status' => 1, - 'comments' => 'serviceComments' + 'comments' => 'serviceComments' ); protected $duplicatedProperties = array( @@ -111,7 +111,7 @@ class ServiceConfigurationContext extends CentreonContext 'description' => 'serviceDescription_1', 'templates' => 'generic-service', 'check_command' => 'check_http', - 'macros' => array( + 'macros' => array( 'MACRONAME' => 22 ), 'check_period' => 'workhours', @@ -121,21 +121,21 @@ class ServiceConfigurationContext extends CentreonContext 'active_checks_enabled' => 2, 'passive_checks_enabled' => 1, 'is_volatile' => 0, - 'notifications_enabled' => 2, + 'notifications_enabled' => 2, 'inherits_contacts_groups' => 0, 'contacts' => 'Guest', 'contact_additive_inheritance' => 1, 'contact_groups' => 'Supervisors', 'contact_group_additive_inheritance' => 1, 'notification_interval' => 23, - 'notify_on_none' => 1, + 'notify_on_none' => 1, 'notify_on_warning' => 0, 'notify_on_unknown' => 0, 'notify_on_critical' => 0, 'notify_on_recovery' => 0, 'notify_on_flapping' => 0, 'notify_on_downtime_scheduled' => 0, - 'first_notification_delay' => 4, + 'first_notification_delay' => 4, 'recovery_notification_delay' => 3, 'service_groups' => 'serviceGroup1Name', 'trap_relations' => 'coldStart', @@ -173,7 +173,7 @@ class ServiceConfigurationContext extends CentreonContext 'description' => 'serviceDescriptionChanged', 'templates' => 'Ping-WAN', 'check_command' => 'check_https', - 'macros' => array( + 'macros' => array( 'MACRONAMECHANGED' => 11 ), 'check_period' => 'none', diff --git a/features/bootstrap/ServiceSubmitResultContext.php b/features/bootstrap/ServiceSubmitResultContext.php index 006a4929325..feeccee6afb 100644 --- a/features/bootstrap/ServiceSubmitResultContext.php +++ b/features/bootstrap/ServiceSubmitResultContext.php @@ -65,7 +65,11 @@ public function iSubmitSomeResultToThisService() public function theValuesAreSetAsWantedInMonitoringStatusDetailsPage() { $this->page = new MonitoringServicesPage($this); - $result = $this->page->getPropertyFromAHostAndService($this->hostname, $this->hostservice, 'status_information'); + $result = $this->page->getPropertyFromAHostAndService( + $this->hostname, + $this->hostservice, + 'status_information' + ); if ($result != $this->checkoutput) { throw new Exception('The result submitted is not set as wanted'); } diff --git a/features/bootstrap/VirtualMetricHandleContext.php b/features/bootstrap/VirtualMetricHandleContext.php index 1414b15459b..da509c00ced 100644 --- a/features/bootstrap/VirtualMetricHandleContext.php +++ b/features/bootstrap/VirtualMetricHandleContext.php @@ -9,7 +9,7 @@ class VirtualMetricHandleContext extends CentreonContext protected $page; protected $vmName = 'vmtestname'; protected $host = 'MetricTestHostname'; - protected $functionRPN ='test10'; + protected $functionRPN = 'test10'; protected $hostService = 'MetricTestService'; protected $duplicatedVmName = 'vmtestname_1'; @@ -27,7 +27,7 @@ public function iAddAVirtualMetric() 'linked-host_services' => $this->host . ' - ' . $this->hostService )); $this->page->setProperties(array('function' => $this->functionRPN)); - $this->page->save(); + $this->page->save(); } /** @@ -35,11 +35,11 @@ public function iAddAVirtualMetric() */ public function allPropertiesAreSaved() { - $this->page = new MetricsConfigurationListingPage($this); - $data = $this->page->getEntry($this->vmName); - if ($data['name'] != $this->vmName || $data['function'] != $this->functionRPN) { - throw new \Exception('Some properties have not been saved'); - } + $this->page = new MetricsConfigurationListingPage($this); + $data = $this->page->getEntry($this->vmName); + if ($data['name'] != $this->vmName || $data['function'] != $this->functionRPN) { + throw new \Exception('Some properties have not been saved'); + } } /** @@ -69,8 +69,8 @@ public function allPropertiesAreCopiedExceptTheName() if (key_exists($this->duplicatedVmName, $objects)) { if ($objects[$this->duplicatedVmName]['function'] != $objects[$this->vmName]['function'] || $objects[$this->duplicatedVmName]['def_type'] != $objects[$this->vmName]['def_type']) { - - throw new \Exception( 'Some properties of ' . $this->duplicatedVmName . ' virtual Metric have not ' + + throw new \Exception('Some properties of ' . $this->duplicatedVmName . ' virtual Metric have not ' . 'been duplicated'); } } else { From c70069c66e17ad2217c42741f149edad1c947b9d Mon Sep 17 00:00:00 2001 From: loiclau Date: Thu, 17 Aug 2017 14:05:20 +0200 Subject: [PATCH 177/207] * fix style clapi --- .../centreon-clapi/centreonCommand.class.php | 2 +- .../centreonHostGroupService.class.php | 2 +- .../centreonServiceCategory.class.php | 9 +++++- .../centreonServiceGroup.class.php | 32 +++++++++++-------- .../centreonServiceTemplate.class.php | 2 +- 5 files changed, 30 insertions(+), 17 deletions(-) diff --git a/www/class/centreon-clapi/centreonCommand.class.php b/www/class/centreon-clapi/centreonCommand.class.php index 10d74e70902..82495ea8ced 100644 --- a/www/class/centreon-clapi/centreonCommand.class.php +++ b/www/class/centreon-clapi/centreonCommand.class.php @@ -214,7 +214,7 @@ public function getId($commandName) * @return void */ - public function export($filters=null) + public function export($filters = null) { $elements = $this->object->getList("*", -1, 0, null, null, $filters); foreach ($elements as $element) { diff --git a/www/class/centreon-clapi/centreonHostGroupService.class.php b/www/class/centreon-clapi/centreonHostGroupService.class.php index 20d6d64ef8a..9f64fcdaddb 100644 --- a/www/class/centreon-clapi/centreonHostGroupService.class.php +++ b/www/class/centreon-clapi/centreonHostGroupService.class.php @@ -920,7 +920,7 @@ public function __call($name, $arg) * * @return void */ - public function export($filters=null) + public function export($filters = null) { $filters["service_register"] = $this->register; diff --git a/www/class/centreon-clapi/centreonServiceCategory.class.php b/www/class/centreon-clapi/centreonServiceCategory.class.php index c9e5faf87c1..ccbd5f99a1c 100644 --- a/www/class/centreon-clapi/centreonServiceCategory.class.php +++ b/www/class/centreon-clapi/centreonServiceCategory.class.php @@ -401,7 +401,14 @@ private function setServiceTemplate($args, $relobj, $obj, $categoryId) */ public function export($filters = null) { - $scs = $this->object->getList(array($this->object->getPrimaryKey(), $this->object->getUniqueLabelField()), -1, 0, null, null, $filters); + $scs = $this->object->getList( + array($this->object->getPrimaryKey(), $this->object->getUniqueLabelField()), + -1, + 0, + null, + null, + $filters + ); $relobj = new \Centreon_Object_Relation_Service_Category_Service(); $hostServiceRel = new \Centreon_Object_Relation_Host_Service(); $svcObj = new \Centreon_Object_Service(); diff --git a/www/class/centreon-clapi/centreonServiceGroup.class.php b/www/class/centreon-clapi/centreonServiceGroup.class.php index a9737969f17..7dfbde8febf 100644 --- a/www/class/centreon-clapi/centreonServiceGroup.class.php +++ b/www/class/centreon-clapi/centreonServiceGroup.class.php @@ -50,8 +50,8 @@ */ class CentreonServiceGroup extends CentreonObject { - const ORDER_UNIQUENAME = 0; - const ORDER_ALIAS = 1; + const ORDER_UNIQUENAME = 0; + const ORDER_ALIAS = 1; public static $aDepends = array( 'HOST', @@ -84,7 +84,7 @@ public function show($parameters = null) { $filters = array(); if (isset($parameters)) { - $filters = array($this->object->getUniqueLabelField() => "%".$parameters."%"); + $filters = array($this->object->getUniqueLabelField() => "%" . $parameters . "%"); } $params = array('sg_id', 'sg_name', 'sg_alias'); $paramString = str_replace("sg_", "", implode($this->delim, $params)); @@ -131,12 +131,12 @@ public function setparam($parameters) } if (($objectId = $this->getObjectId($params[self::ORDER_UNIQUENAME])) != 0) { if (!preg_match("/^sg_/", $params[1])) { - $params[1] = "sg_".$params[1]; + $params[1] = "sg_" . $params[1]; } $updateParams = array($params[1] => $params[2]); parent::setparam($objectId, $updateParams); } else { - throw new CentreonClapiException(self::OBJECT_NOT_FOUND.":".$params[self::ORDER_UNIQUENAME]); + throw new CentreonClapiException(self::OBJECT_NOT_FOUND . ":" . $params[self::ORDER_UNIQUENAME]); } } @@ -160,7 +160,7 @@ public function __call($name, $arg) $args = explode($this->delim, $arg[0]); $sgIds = $this->object->getIdByParameter($this->object->getUniqueLabelField(), array($args[0])); if (!count($sgIds)) { - throw new CentreonClapiException(self::OBJECT_NOT_FOUND .":".$args[0]); + throw new CentreonClapiException(self::OBJECT_NOT_FOUND . ":" . $args[0]); } $sgId = $sgIds[0]; @@ -198,7 +198,7 @@ public function __call($name, $arg) "ASC", array( "service_id" => $val['service_id'], - "host_id" => $val['host_id'] + "host_id" => $val['host_id'] ), "AND" ); @@ -218,7 +218,7 @@ public function __call($name, $arg) "ASC", array( "service_id" => $val['service_id'], - "hg_id" => $val['hostgroup_id'] + "hg_id" => $val['hostgroup_id'] ), "AND" ); @@ -258,7 +258,7 @@ public function __call($name, $arg) "AND" ); if (!count($elements)) { - throw new CentreonClapiException(self::OBJECT_NOT_FOUND . ":". $tmp[0]."/".$tmp[1]); + throw new CentreonClapiException(self::OBJECT_NOT_FOUND . ":" . $tmp[0] . "/" . $tmp[1]); } $relationTable[$i]['host_id'] = $elements[0]['host_id']; $relationTable[$i]['service_id'] = $elements[0]['service_id']; @@ -277,7 +277,7 @@ public function __call($name, $arg) "AND" ); if (!count($elements)) { - throw new CentreonClapiException(self::OBJECT_NOT_FOUND . ":". $tmp[0]."/".$tmp[1]); + throw new CentreonClapiException(self::OBJECT_NOT_FOUND . ":" . $tmp[0] . "/" . $tmp[1]); } $relationTable[$i]['hostgroup_id'] = $elements[0]['hg_id']; $relationTable[$i]['service_id'] = $elements[0]['service_id']; @@ -297,7 +297,7 @@ public function __call($name, $arg) $insert = true; foreach ($existingRelationIds as $existrel) { if (($existrel[$hstring] == $relation[$hstring]) && - $existrel['service_id'] == $relation['service_id']) { + $existrel['service_id'] == $relation['service_id']) { $insert = false; break; } @@ -322,8 +322,14 @@ public function __call($name, $arg) */ public function export($filters = null) { - - $sgs = $this->object->getList(array($this->object->getPrimaryKey(), $this->object->getUniqueLabelField()), -1, 0, null, null, $filters); + $sgs = $this->object->getList( + array($this->object->getPrimaryKey(), $this->object->getUniqueLabelField()), + -1, + 0, + null, + null, + $filters + ); $relobjSvc = new \Centreon_Object_Relation_Service_Group_Service(); $objSvc = new \Centreon_Object_Relation_Host_Service(); $relobjHgSvc = new \Centreon_Object_Relation_Service_Group_Host_Group_Service(); diff --git a/www/class/centreon-clapi/centreonServiceTemplate.class.php b/www/class/centreon-clapi/centreonServiceTemplate.class.php index a8151b734b5..b23d774bccf 100644 --- a/www/class/centreon-clapi/centreonServiceTemplate.class.php +++ b/www/class/centreon-clapi/centreonServiceTemplate.class.php @@ -907,7 +907,7 @@ protected function parseTemplateTree($tree, $filter_id = null) * * @return void */ - public function export($filters=null) + public function export($filters = null) { $filters["service_register"] = $this->register; $elements = $this->object->getList( From eeacab591f458018853dd4ec75c3dda1397fd8f1 Mon Sep 17 00:00:00 2001 From: loiclau Date: Thu, 17 Aug 2017 14:41:01 +0200 Subject: [PATCH 178/207] * fix style img_gantt --- .../configObject/escalation/img_gantt.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/www/include/configuration/configObject/escalation/img_gantt.php b/www/include/configuration/configObject/escalation/img_gantt.php index 4b2487700dd..0fbebb04733 100644 --- a/www/include/configuration/configObject/escalation/img_gantt.php +++ b/www/include/configuration/configObject/escalation/img_gantt.php @@ -273,14 +273,10 @@ # init IMAGE $largeur = ($max_notif > 50) ? 1024 : 800; //$hauteur = ($nb_esc > 5) ? 768 : 400; -$hauteur = - ($nb_esc_tot * 35) + ( - ( - $max_contact_service == 0 - ? $nb_esc - : $max_contact_service - ) * 35 - ) + 70; + +$hauteurData = ($max_contact_service == 0) ? $nb_esc : $max_contact_service; +$hauteur = ($nb_esc_tot * 35) + (($hauteurData) * 35) + 70; + $marge_left = ($max_contact_length) ? $max_contact_length * 13 : 10 * 13; $marge_legende = 20; $marge_bottom = 50 + $marge_legende; From 477b4712213167afed981ebc4bc98c0a445256d2 Mon Sep 17 00:00:00 2001 From: Kevin Duret Date: Thu, 17 Aug 2017 15:20:44 +0200 Subject: [PATCH 179/207] fix rest api acceptance tests --- tests/rest_api/rest_api.postman_collection.json | 10 +++++----- www/class/centreon-clapi/centreonAPI.class.php | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/rest_api/rest_api.postman_collection.json b/tests/rest_api/rest_api.postman_collection.json index 6d30404eae3..bb93c007eb5 100644 --- a/tests/rest_api/rest_api.postman_collection.json +++ b/tests/rest_api/rest_api.postman_collection.json @@ -33918,7 +33918,7 @@ ], "body": { "mode": "raw", - "raw": "{\n \"action\": \"addcontact\",\n \"object\": \"stpl\",\n \"values\": \"{{stpl_description}};{{contact_name}}\"\n}" + "raw": "{\n \"action\": \"addcontact\",\n \"object\": \"stpl\",\n \"values\": \"{{stpl_description}};{{contact_alias}}\"\n}" }, "description": "" }, @@ -33980,7 +33980,7 @@ ], "body": { "mode": "raw", - "raw": "{\n \"action\": \"delcontact\",\n \"object\": \"stpl\",\n \"values\": \"{{stpl_description}};{{contact_name}}\"\n}" + "raw": "{\n \"action\": \"delcontact\",\n \"object\": \"stpl\",\n \"values\": \"{{stpl_description}};{{contact_alias}}\"\n}" }, "description": "" }, @@ -34042,7 +34042,7 @@ ], "body": { "mode": "raw", - "raw": "{\n \"action\": \"setcontact\",\n \"object\": \"stpl\",\n \"values\": \"{{stpl_description}};{{contact_name}}|{{contact_name2}}\"\n}" + "raw": "{\n \"action\": \"setcontact\",\n \"object\": \"stpl\",\n \"values\": \"{{stpl_description}};{{contact_alias}}|{{contact_alias2}}\"\n}" }, "description": "" }, @@ -34063,8 +34063,8 @@ " tests[\"Body contains list of contacts\"] = contactData;", " var i = 0;", " while (i < contactData.length) {", - " if (postman.getEnvironmentVariable(\"contact_alias\") == contactData[i].name){", - " tests[\"Body contains added contact_alias\"] = postman.getEnvironmentVariable(\"contact_alias\") == contactData[i].name;", + " if (postman.getEnvironmentVariable(\"contact_alias\") == contactData[i].alias){", + " tests[\"Body contains added contact_alias\"] = postman.getEnvironmentVariable(\"contact_alias\") == contactData[i].alias;", " break;", " }", " i++;", diff --git a/www/class/centreon-clapi/centreonAPI.class.php b/www/class/centreon-clapi/centreonAPI.class.php index 3e705772287..167bd08654c 100644 --- a/www/class/centreon-clapi/centreonAPI.class.php +++ b/www/class/centreon-clapi/centreonAPI.class.php @@ -398,7 +398,7 @@ protected function requireLibs($object) if ($object != "") { if (isset($this->relationObject[$object]['class']) && isset($this->relationObject[$object]['module']) - && !class_exists("Centreon" . $this->relationObject[$object]) + && !class_exists("Centreon" . $this->relationObject[$object]['class']) ) { if ($this->relationObject[$object]['module'] == 'core') { require_once "centreon" . $this->relationObject[$object]['class'] . ".class.php"; From 4604f2a169ca7d5f22331e1dcc7b38af62f292d1 Mon Sep 17 00:00:00 2001 From: mariegallardo Date: Thu, 17 Aug 2017 15:33:57 +0200 Subject: [PATCH 180/207] Feature host template configuration (#5476) * New Feature * File updated' * Waiting to fix a bug * New Features HostTemplateBasicsOperations * File cleaned * File upgraded * Feature fixed * * #5472 fix severity in category * * fix acceptance --- behat.yml | 7 +- features/HostTemplateBasicsOperations.feature | 20 + .../HostTemplateBasicsOperationsContext.php | 445 ++++++++++++++++++ www/class/centreonHost.class.php | 2 +- 4 files changed, 472 insertions(+), 2 deletions(-) create mode 100644 features/HostTemplateBasicsOperations.feature create mode 100644 features/bootstrap/HostTemplateBasicsOperationsContext.php diff --git a/behat.yml b/behat.yml index 9d60670f015..0334a39c43c 100644 --- a/behat.yml +++ b/behat.yml @@ -199,6 +199,11 @@ default: contexts: - ContactGroupConfigurationContext + host_template_basics_operations: + paths: [ %paths.base%/features/HostTemplateBasicsOperations.feature ] + contexts: + - HostTemplateBasicsOperationsContext + ldap_configuration: paths: [ %paths.base%/features/LdapConfiguration.feature ] contexts: @@ -263,7 +268,7 @@ default: paths: [ %paths.base%/features/MassiveChangeServices.feature ] contexts: - MassiveChangeServicesContext - + virtual_metric_handle: paths: [ %paths.base%/features/VirtualMetricHandle.feature ] contexts: diff --git a/features/HostTemplateBasicsOperations.feature b/features/HostTemplateBasicsOperations.feature new file mode 100644 index 00000000000..7a12c0e274a --- /dev/null +++ b/features/HostTemplateBasicsOperations.feature @@ -0,0 +1,20 @@ +Feature: HostTemplateBasicsOperations + As a Centreon admin + I want to manipulate a host template + To see if all simples manipulations work + + Background: + Given I am logged in a Centreon server + And a host template is configured + + Scenario: I test the modification of a host template properties + When I change the properties of a host template + Then the properties are updated + + Scenario: I test the duplication of a host template + When I duplicate a host template + Then the new host template has the same properties + + Scenario: I test the deletion of a host template + When I delete a host template + Then the deleted host is not displayed in the host list diff --git a/features/bootstrap/HostTemplateBasicsOperationsContext.php b/features/bootstrap/HostTemplateBasicsOperationsContext.php new file mode 100644 index 00000000000..ecbe6eef326 --- /dev/null +++ b/features/bootstrap/HostTemplateBasicsOperationsContext.php @@ -0,0 +1,445 @@ + 'hostCategory1Name', + 'alias' => 'hostCategory1Alias', + 'severity' => 1, + 'severity_level' => 2, + 'severity_icon' => ' centreon (png)' + ); + + protected $hostCategory2 = array( + 'name' => 'hostCategory2Name', + 'alias' => 'hostCategory2Alias', + 'severity' => 1, + 'severity_level' => 13, + 'severity_icon' => ' centreon (png)' + ); + + protected $hostCategory3 = array( + 'name' => 'hostCategory3Name', + 'alias' => 'hostCategory3Alias' + ); + + protected $hostCategory4 = array( + 'name' => 'hostCategory4Name', + 'alias' => 'hostCategory4Alias' + ); + + protected $initialProperties = array( + 'name' => 'hostTemplateName', + 'alias' => 'hostTemplateAlias', + 'address' => 'hostTemplate@localhost', + 'snmp_community' => 'snmp', + 'snmp_version' => '2c', + 'location' => 'Europe/Paris', + 'templates' => array( + 'generic-host' + ), + 'check_command' => 'check_http', + 'command_arguments' => 'hostTemplateCommandArgument', + 'macros' => array( + 'HOSTTEMPLATEMACRONAME' => '22' + ), + 'check_period' => 'workhours', + 'max_check_attempts' => 34, + 'normal_check_interval' => 5, + 'retry_check_interval' => 10, + 'active_checks_enabled' => 2, + 'passive_checks_enabled' => 0, + 'notifications_enabled' => 1, + 'contact_additive_inheritance' => 1, + 'contacts' => 'Guest', + 'contact_group_additive_inheritance' => 0, + 'contact_groups' => 'Supervisors', + 'notify_on_down' => 1, + 'notify_on_unreachable' => 1, + 'notify_on_recovery' => 1, + 'notify_on_flapping' => 1, + 'notify_on_downtime_scheduled' => 1, + 'notify_on_none' => 0, + 'notification_interval' => 17, + 'notification_period' => 'none', + 'first_notification_delay' => 4, + 'recovery_notification_delay' => 3, + 'service_templates' => 'generic-service', + 'parent_host_categories' => 'hostCategory3Name', + 'obsess_over_host' => 2, + 'acknowledgement_timeout' => 2, + 'check_freshness' => 0, + 'freshness_threshold' => 34, + 'flap_detection_enabled' => 1, + 'low_flap_threshold' => 67, + 'high_flap_threshold' => 85, + 'retain_status_information' => 2, + 'retain_non_status_information' => 0, + 'stalking_option_on_up' => 1, + 'stalking_option_on_down' => 0, + 'stalking_option_on_unreachable' => 1, + 'event_handler_enabled' => 2, + 'event_handler' => 'check_https', + 'event_handler_arguments' => 'event_handler_arguments', + 'url' => 'hostTemplateChangeUrl', + 'notes' => 'hostTemplateChangeNotes', + 'action_url' => 'hostTemplateChangeActionUrl', + 'icon' => ' centreon (png)', + 'alt_icon' => 'hostTemplateChangeIcon', + 'status_map_image' => '', + '2d_coords' => '15,84', + '3d_coords' => '15,84,76', + 'severity_level' => 'hostCategory1Name (2)', + 'enabled' => 1, + 'comments' => 'hostTemplateChangeComments' + ); + + protected $duplicatedProperties = array( + 'name' => 'hostTemplateName_1', + 'alias' => 'hostTemplateAlias', + 'address' => 'hostTemplate@localhost', + 'snmp_community' => 'snmp', + 'snmp_version' => '2c', + 'location' => 'Europe/Paris', + 'templates' => array( + 'generic-host' + ), + 'check_command' => 'check_http', + 'command_arguments' => 'hostTemplateCommandArgument', + 'macros' => array( + 'HOSTTEMPLATEMACRONAME' => '22' + ), + 'check_period' => 'workhours', + 'max_check_attempts' => 34, + 'normal_check_interval' => 5, + 'retry_check_interval' => 10, + 'active_checks_enabled' => 2, + 'passive_checks_enabled' => 0, + 'notifications_enabled' => 1, + 'contact_additive_inheritance' => 1, + 'contacts' => 'Guest', + 'contact_group_additive_inheritance' => 0, + 'contact_groups' => 'Supervisors', + 'notify_on_down' => 1, + 'notify_on_unreachable' => 1, + 'notify_on_recovery' => 1, + 'notify_on_flapping' => 1, + 'notify_on_downtime_scheduled' => 1, + 'notify_on_none' => 0, + 'notification_interval' => 17, + 'notification_period' => 'none', + 'first_notification_delay' => 4, + 'recovery_notification_delay' => 3, + 'service_templates' => 'generic-service', + 'parent_host_categories' => 'hostCategory3Name', + 'obsess_over_host' => 2, + 'acknowledgement_timeout' => 2, + 'check_freshness' => 0, + 'freshness_threshold' => 34, + 'flap_detection_enabled' => 1, + 'low_flap_threshold' => 67, + 'high_flap_threshold' => 85, + 'retain_status_information' => 2, + 'retain_non_status_information' => 0, + 'stalking_option_on_up' => 1, + 'stalking_option_on_down' => 0, + 'stalking_option_on_unreachable' => 1, + 'event_handler_enabled' => 2, + 'event_handler' => 'check_https', + 'event_handler_arguments' => 'event_handler_arguments', + 'url' => 'hostTemplateChangeUrl', + 'notes' => 'hostTemplateChangeNotes', + 'action_url' => 'hostTemplateChangeActionUrl', + 'icon' => ' centreon (png)', + 'alt_icon' => 'hostTemplateChangeIcon', + 'status_map_image' => '', + '2d_coords' => '15,84', + '3d_coords' => '15,84,76', + 'severity_level' => 'hostCategory1Name (2)', + 'enabled' => 1, + 'comments' => 'hostTemplateChangeComments' + ); + + protected $update = array( + 'name' => 'hostTemplateNameChanged', + 'alias' => 'hostTemplateAliasChanged', + 'address' => 'hostTemplate@localhostChanged', + 'snmp_community' => 'snmpChanged', + 'snmp_version' => '3', + 'location' => 'Europe/Paris', + 'templates' => array( + 'Printers' + ), + 'check_command' => 'check_https', + 'command_arguments' => 'hostTemplateCommandArgumentChanged', + 'macros' => array( + 'HOSTTEMPLATEMACRONAMECHANGED' => '11' + ), + 'check_period' => 'nonworkhours', + 'max_check_attempts' => 34, + 'normal_check_interval' => 9, + 'retry_check_interval' => 4, + 'active_checks_enabled' => 1, + 'passive_checks_enabled' => 1, + 'notifications_enabled' => 0, + 'contact_additive_inheritance' => 0, + 'contacts' => 'User', + 'contact_group_additive_inheritance' => 1, + 'contact_groups' => 'Guest', + 'notify_on_down' => 0, + 'notify_on_unreachable' => 0, + 'notify_on_recovery' => 0, + 'notify_on_flapping' => 0, + 'notify_on_downtime_scheduled' => 0, + 'notify_on_none' => 0, + 'notification_interval' => 49, + 'notification_period' => 'workhours', + 'first_notification_delay' => 7, + 'recovery_notification_delay' => 8, + 'service_templates' => 'Ping-LAN', + 'parent_host_categories' => 'hostCategory4Name', + 'obsess_over_host' => 1, + 'acknowledgement_timeout' => 0, + 'check_freshness' => 1, + 'freshness_threshold' => 15, + 'flap_detection_enabled' => 0, + 'low_flap_threshold' => 25, + 'high_flap_threshold' => 34, + 'retain_status_information' => 1, + 'retain_non_status_information' => 1, + 'stalking_option_on_up' => 0, + 'stalking_option_on_down' => 1, + 'stalking_option_on_unreachable' => 0, + 'event_handler_enabled' => 1, + 'event_handler' => 'check_http', + 'event_handler_arguments' => 'event_handler_argumentsChanged', + 'url' => 'hostTemplateChangeUrlChanged', + 'notes' => 'hostTemplateChangeNotesChanged', + 'action_url' => 'hostTemplateChangeActionUrlChanged', + 'icon' => '', + 'alt_icon' => 'hostTemplateChangeIconChanged', + 'status_map_image' => ' centreon (png)', + '2d_coords' => '48,29', + '3d_coords' => '09,25,27', + 'severity_level' => 'hostCategory2Name (13)', + 'enabled' => 1, + 'comments' => 'hostTemplateChangeCommentsChanged' + ); + + protected $updatedProperties = array( + 'name' => 'hostTemplateNameChanged', + 'alias' => 'hostTemplateAliasChanged', + 'address' => 'hostTemplate@localhostChanged', + 'snmp_community' => 'snmpChanged', + 'snmp_version' => '3', + 'location' => 'Europe/Paris', + 'templates' => array( + 'Printers' + ), + 'check_command' => 'check_https', + 'command_arguments' => 'hostTemplateCommandArgumentChanged', + 'macros' => array( + 'HOSTTEMPLATEMACRONAME' => '22', + 'HOSTTEMPLATEMACRONAMECHANGED' => '11' + ), + 'check_period' => 'nonworkhours', + 'max_check_attempts' => 34, + 'normal_check_interval' => 9, + 'retry_check_interval' => 4, + 'active_checks_enabled' => 1, + 'passive_checks_enabled' => 1, + 'notifications_enabled' => 0, + 'contact_additive_inheritance' => 0, + 'contacts' => 'User', + 'contact_group_additive_inheritance' => 1, + 'contact_groups' => 'Guest', + 'notify_on_down' => 0, + 'notify_on_unreachable' => 0, + 'notify_on_recovery' => 0, + 'notify_on_flapping' => 0, + 'notify_on_downtime_scheduled' => 0, + 'notify_on_none' => 0, + 'notification_interval' => 49, + 'notification_period' => 'workhours', + 'first_notification_delay' => 7, + 'recovery_notification_delay' => 8, + 'service_templates' => 'Ping-LAN', + 'parent_host_categories' => 'hostCategory4Name', + 'obsess_over_host' => 1, + 'acknowledgement_timeout' => 0, + 'check_freshness' => 1, + 'freshness_threshold' => 15, + 'flap_detection_enabled' => 0, + 'low_flap_threshold' => 25, + 'high_flap_threshold' => 34, + 'retain_status_information' => 1, + 'retain_non_status_information' => 1, + 'stalking_option_on_up' => 0, + 'stalking_option_on_down' => 1, + 'stalking_option_on_unreachable' => 0, + 'event_handler_enabled' => 1, + 'event_handler' => 'check_http', + 'event_handler_arguments' => 'event_handler_argumentsChanged', + 'url' => 'hostTemplateChangeUrlChanged', + 'notes' => 'hostTemplateChangeNotesChanged', + 'action_url' => 'hostTemplateChangeActionUrlChanged', + 'icon' => '', + 'alt_icon' => 'hostTemplateChangeIconChanged', + 'status_map_image' => ' centreon (png)', + '2d_coords' => '48,29', + '3d_coords' => '09,25,27', + 'severity_level' => 'hostCategory2Name (13)', + 'enabled' => 1, + 'comments' => 'hostTemplateChangeCommentsChanged' + ); + + /** + * @Given a host template is configured + */ + public function aHostTemplateIsConfigured() + { + $this->currentPage = new HostCategoryConfigurationPage($this); + $this->currentPage->setProperties($this->hostCategory1); + $this->currentPage->save(); + $this->currentPage = new HostCategoryConfigurationPage($this); + $this->currentPage->setProperties($this->hostCategory2); + $this->currentPage->save(); + $this->currentPage = new HostCategoryConfigurationPage($this); + $this->currentPage->setProperties($this->hostCategory3); + $this->currentPage->save(); + $this->currentPage = new HostCategoryConfigurationPage($this); + $this->currentPage->setProperties($this->hostCategory4); + $this->currentPage->save(); + $this->currentPage = new HostTemplateConfigurationPage($this); + $this->currentPage->setProperties($this->initialProperties); + $this->currentPage->save(); + } + + /** + * @When I change the properties of a host template + */ + public function iChangeThePropertiesOfAHostTemplate() + { + $this->currentPage = new HostTemplateConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->initialProperties['name']); + $this->currentPage->setProperties($this->update); + $this->currentPage->save(); + } + + /** + * @Then the properties are updated + */ + public function thePropertiesAreUpdated() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new HostTemplateConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->updatedProperties['name']); + $object = $this->currentPage->getProperties(); + foreach ($this->updatedProperties as $key => $value) { + if ($value != $object[$key]) { + if (is_array($value)) { + $value = implode(' ', $value); + } + if ($value != $object[$key]) { + $this->tableau[] = $key; + } + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I duplicate a host template + */ + public function iDuplicateAHostTemplate() + { + $this->currentPage = new HostTemplateConfigurationListingPage($this); + $object = $this->currentPage->getEntry($this->initialProperties['name']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Duplicate'); + } + + /** + * @Then the new host template has the same properties + */ + public function theNewHostTemplateHasTheSameProperties() + { + $this->tableau = array(); + try { + $this->spin( + function ($context) { + $this->currentPage = new HostTemplateConfigurationListingPage($this); + $this->currentPage = $this->currentPage->inspect($this->duplicatedProperties['name']); + $object = $this->currentPage->getProperties(); + foreach ($this->duplicatedProperties as $key => $value) { + if ($value != $object[$key]) { + if (is_array($value)) { + $value = implode(' ', $value); + } + if ($value != $object[$key]) { + $this->tableau[] = $key; + } + } + } + return count($this->tableau) == 0; + }, + "Some properties are not being updated : ", + 5 + ); + } catch (\Exception $e) { + $this->tableau = array_unique($this->tableau); + throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau)); + } + } + + /** + * @When I delete a host template + */ + public function iDeleteAHostTemplate() + { + $this->currentPage = new HostTemplateConfigurationListingPage($this); + $object = $this->currentPage->getEntry($this->initialProperties['name']); + $this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check(); + $this->setConfirmBox(true); + $this->selectInList('select[name="o1"]', 'Delete'); + } + + /** + * @Then the deleted host is not displayed in the host list + */ + public function theDeletedHostIsNotDisplayedInTheHostList() + { + $this->spin( + function ($context) { + $this->currentPage = new HostTemplateConfigurationListingPage($this); + $object = $this->currentPage->getEntries(); + $bool = true; + foreach ($object as $value) { + $bool = $bool && $value['name'] != $this->initialProperties['name']; + } + return $bool; + }, + "The host category is not being deleted.", + 5 + ); + } +} diff --git a/www/class/centreonHost.class.php b/www/class/centreonHost.class.php index 49bb3a4ae37..4e1ec2713ee 100755 --- a/www/class/centreonHost.class.php +++ b/www/class/centreonHost.class.php @@ -1727,11 +1727,11 @@ public static function getDefaultValuesParameters($field) break; case 'host_hcs': $parameters['type'] = 'relation'; - $parameters['externalObject']['object'] = 'centreonHostcategories'; $parameters['externalObject']['table'] = 'hostcategories'; $parameters['externalObject']['id'] = 'hc_id'; $parameters['externalObject']['name'] = 'hc_name'; $parameters['externalObject']['comparator'] = 'hc_id'; + $parameters['externalObject']['additionalComparator'] = array('level' => null); $parameters['relationObject']['table'] = 'hostcategories_relation'; $parameters['relationObject']['field'] = 'hostcategories_hc_id'; $parameters['relationObject']['comparator'] = 'host_host_id'; From 7de00a9a04926880f4b6b3fb866d3f2af9e6b2e5 Mon Sep 17 00:00:00 2001 From: loiclau Date: Thu, 17 Aug 2017 16:25:33 +0200 Subject: [PATCH 181/207] * fix style menu --- www/include/core/menu/menu.php | 141 ++++++++++++------ www/include/core/menu/menuJS.php | 21 ++- .../core/menu/userFullScreenPreferences.php | 12 +- www/include/core/menu/userMenuPreferences.php | 16 +- www/include/core/menu/xml/menuXML.php | 52 ++++--- 5 files changed, 155 insertions(+), 87 deletions(-) diff --git a/www/include/core/menu/menu.php b/www/include/core/menu/menu.php index 806bf75ee80..487822508e0 100644 --- a/www/include/core/menu/menu.php +++ b/www/include/core/menu/menu.php @@ -96,7 +96,10 @@ $tpl->assign("Documentation", _("Documentation")); $tpl->assign("p", $p); $tpl->assign("sound_status", isset($_SESSION['disable_sound']) ? 'off' : 'on'); -$tpl->assign("sound_action", isset($_SESSION['disable_sound']) ? 'jQuery().centreon_notify_start();' : 'jQuery().centreon_notify_stop();'); +$tpl->assign( + "sound_action", + isset($_SESSION['disable_sound']) ? 'jQuery().centreon_notify_start();' : 'jQuery().centreon_notify_stop();' +); $tpl->assign("date_time_format_status", _("d/m/Y H:i:s")); /* @@ -109,7 +112,7 @@ */ $lcaSTR = ""; if (!$is_admin) { - $lcaSTR = "AND topology_page IN (".$centreon->user->access->getTopologyString().")"; + $lcaSTR = "AND topology_page IN (" . $centreon->user->access->getTopologyString() . ")"; } /* @@ -120,13 +123,19 @@ for ($i = 0; $DBRESULT->rowCount() && ($elem = $DBRESULT->fetchRow()); $i++) { $pageAccess = $centreon->user->access->page($elem["topology_page"]); if (($pageAccess == "1") || ($pageAccess == "2")) { - $elemArr[1][$i] = array("Menu1ClassImg" => $level1 == $elem["topology_page"] ? "menu1_bgimg" : "id_".$elem["topology_id"], - "Menu1Page" => $elem["topology_page"] , - "Menu1Url" => "main.php?p=".$elem["topology_page"].$elem["topology_url_opt"], - "Menu1UrlPopup" => $elem["topology_popup"], - "Menu1UrlPopupOpen" => $elem["topology_url"], - "Menu1Name" => $centreonMenu->translate($elem['topology_modules'], $elem['topology_url'], $elem["topology_name"]), - "Menu1Popup" => $elem["topology_popup"] ? true : false); + $elemArr[1][$i] = array( + "Menu1ClassImg" => $level1 == $elem["topology_page"] ? "menu1_bgimg" : "id_" . $elem["topology_id"], + "Menu1Page" => $elem["topology_page"], + "Menu1Url" => "main.php?p=" . $elem["topology_page"] . $elem["topology_url_opt"], + "Menu1UrlPopup" => $elem["topology_popup"], + "Menu1UrlPopupOpen" => $elem["topology_url"], + "Menu1Name" => $centreonMenu->translate( + $elem['topology_modules'], + $elem['topology_url'], + $elem["topology_name"] + ), + "Menu1Popup" => $elem["topology_popup"] ? true : false + ); } } $DBRESULT->closeCursor(); @@ -150,20 +159,20 @@ $autoLoginUrl = ""; if (!strstr($_SERVER['REQUEST_URI'], '?')) { $root_menu = get_my_first_allowed_root_menu($centreon->user->access->topologyStr); - $autoLoginUrl .= "?p=".$root_menu["topology_page"]; + $autoLoginUrl .= "?p=" . $root_menu["topology_page"]; } - $autoLoginUrl .= "&autologin=1&useralias=$userAlias&token=".$centreon->user->getToken(); - + $autoLoginUrl .= "&autologin=1&useralias=$userAlias&token=" . $centreon->user->getToken(); + $prefix = ''; if (!strncmp($_SERVER["SERVER_PROTOCOL"], "HTTP/", 5)) { $prefix .= "http://"; } else { $prefix .= "https://"; } - $prefix .= $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; + $prefix .= $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $prefix = str_replace("main.php", "index.php", $prefix); $msg = _("Right Click here to add an autologin link directly to your bookmarks"); - $tpl->assign("autoLoginUrl", $prefix.$autoLoginUrl); + $tpl->assign("autoLoginUrl", $prefix . $autoLoginUrl); } else { $msg = _("Please define autologin authentication key in your profile."); $tpl->assign("autoLoginUrl", '#'); @@ -174,21 +183,29 @@ /* * Grab elements for level 2 */ -$rq = "SELECT topology_page, topology_url_opt, topology_popup, topology_url, topology_name, topology_modules FROM topology WHERE topology_parent = '".$level1."' $lcaSTR AND topology_show = '1' ORDER BY topology_group, topology_order"; +$rq = "SELECT topology_page, topology_url_opt, topology_popup, topology_url, topology_name, topology_modules " . + "FROM topology WHERE topology_parent = '" . $level1 . + "' $lcaSTR AND topology_show = '1' ORDER BY topology_group, topology_order"; $DBRESULT = $pearDB->query($rq); $firstP = null; $sep = " "; for ($i = 0; $DBRESULT->rowCount() && ($elem = $DBRESULT->fetchRow()); $i++) { $firstP ? null : $firstP = $elem["topology_page"]; - + $pageAccess = $centreon->user->access->page($elem["topology_page"]); if (($pageAccess == "1") || ($pageAccess == "2")) { - $elemArr[2][$i] = array("Menu2Sep" => $sep, - "Menu2Url" => "main.php?p=".$elem["topology_page"].$elem["topology_url_opt"], - "Menu2UrlPopup" => $elem["topology_popup"], - "Menu2UrlPopupOpen" => $elem["topology_url"].$auth, - "Menu2Name" => $centreonMenu->translate($elem['topology_modules'], $elem['topology_url'], $elem["topology_name"]), - "Menu2Popup" => $elem["topology_popup"] ? true : false); + $elemArr[2][$i] = array( + "Menu2Sep" => $sep, + "Menu2Url" => "main.php?p=" . $elem["topology_page"] . $elem["topology_url_opt"], + "Menu2UrlPopup" => $elem["topology_popup"], + "Menu2UrlPopupOpen" => $elem["topology_url"] . $auth, + "Menu2Name" => $centreonMenu->translate( + $elem['topology_modules'], + $elem['topology_url'], + $elem["topology_name"] + ), + "Menu2Popup" => $elem["topology_popup"] ? true : false + ); } $sep = " | "; } @@ -196,11 +213,15 @@ /* * Grab elements for level 3 */ -$request = "SELECT * FROM topology WHERE topology_parent = '".($level2 ? $level1.$level2 : $firstP)."' $lcaSTR AND topology_show = '1' AND topology_page is not null ORDER BY topology_group, topology_order"; +$request = "SELECT * FROM topology WHERE topology_parent = '" . ($level2 ? $level1 . $level2 : $firstP) . + "' $lcaSTR AND topology_show = '1' AND topology_page is not null ORDER BY topology_group, topology_order"; $DBRESULT = $pearDB->query($request); for ($i = 0; $elem = $DBRESULT->fetchRow(); $i++) { # grab menu title for each group - $DBRESULT_title = $pearDB->query("SELECT topology_name FROM topology WHERE topology_parent = '".$elem["topology_parent"]."' AND topology_show = '1' AND topology_page IS NULL AND topology_group = '".$elem["topology_group"]."' LIMIT 1"); + $query = "SELECT topology_name FROM topology WHERE topology_parent = '" . $elem["topology_parent"] . + "' AND topology_show = '1' AND topology_page IS NULL AND topology_group = '" . + $elem["topology_group"] . "' LIMIT 1"; + $DBRESULT_title = $pearDB->query($query); $title = ""; $topoName = $DBRESULT_title->fetchRow(); if ($DBRESULT_title->rowCount()) { @@ -211,17 +232,23 @@ $pageAccess = $centreon->user->access->page($elem["topology_page"]); if (($pageAccess == "1") || ($pageAccess == "2")) { - $Menu3Url = "main.php?p=".$elem["topology_page"].$elem["topology_url_opt"]; + $Menu3Url = "main.php?p=" . $elem["topology_page"] . $elem["topology_url_opt"]; $elemArr[3][$elem["topology_group"]]["title"] = $title; - $elemArr[3][$elem["topology_group"]]["tab"][$i] = array("Menu3Url" => $Menu3Url, - "Menu3ID" => $elem["topology_page"], - "MenuStyleClass" => $elem["topology_style_class"], - "MenuStyleID" => $elem["topology_style_id"], - "MenuOnClick" => $elem["topology_OnClick"], - "MenuIsOnClick" => $elem["topology_OnClick"] ? true : false, - "Menu3UrlPopup" => $elem["topology_url"], - "Menu3Name" => $centreonMenu->translate($elem['topology_modules'], $elem['topology_url'], $elem["topology_name"]), - "Menu3Popup" => $elem["topology_popup"] ? true : false); + $elemArr[3][$elem["topology_group"]]["tab"][$i] = array( + "Menu3Url" => $Menu3Url, + "Menu3ID" => $elem["topology_page"], + "MenuStyleClass" => $elem["topology_style_class"], + "MenuStyleID" => $elem["topology_style_id"], + "MenuOnClick" => $elem["topology_OnClick"], + "MenuIsOnClick" => $elem["topology_OnClick"] ? true : false, + "Menu3UrlPopup" => $elem["topology_url"], + "Menu3Name" => $centreonMenu->translate( + $elem['topology_modules'], + $elem['topology_url'], + $elem["topology_name"] + ), + "Menu3Popup" => $elem["topology_popup"] ? true : false + ); } } unset($elem); @@ -230,17 +257,25 @@ * Grab elements for level 4 */ if ($level1 && $level2 && $level3) { - $request = "SELECT topology_page, topology_url_opt, topology_url, topology_OnClick, topology_name, topology_popup, topology_modules FROM topology WHERE topology_parent = '".$level1.$level2.$level3."' $lcaSTR AND topology_show = '1' ORDER BY topology_order"; + $request = "SELECT topology_page, topology_url_opt, topology_url, topology_OnClick, topology_name, " . + "topology_popup, topology_modules FROM topology WHERE topology_parent = '" . $level1 . $level2 . $level3 . + "' $lcaSTR AND topology_show = '1' ORDER BY topology_order"; $DBRESULT = $pearDB->query($request); for ($i = 0; $elem = $DBRESULT->fetchRow(); $i++) { $pageAccess = $centreon->user->access->page($elem["topology_page"]); if (($pageAccess == "1") || ($pageAccess == "2")) { - $elemArr[4][$level1.$level2.$level3][$i] = array("Menu4Url" => "main.php?p=".$elem["topology_page"].$elem["topology_url_opt"], - "Menu4UrlPopup" => $elem["topology_url"], - "MenuOnClick" => $elem["topology_OnClick"], - "MenuIsOnClick" => $elem["topology_OnClick"] ? true : false, - "Menu4Name" => $centreonMenu->translate($elem['topology_modules'], $elem['topology_url'], $elem["topology_name"]), - "Menu4Popup" => $elem["topology_popup"] ? true : false); + $elemArr[4][$level1 . $level2 . $level3][$i] = array( + "Menu4Url" => "main.php?p=" . $elem["topology_page"] . $elem["topology_url_opt"], + "Menu4UrlPopup" => $elem["topology_url"], + "MenuOnClick" => $elem["topology_OnClick"], + "MenuIsOnClick" => $elem["topology_OnClick"] ? true : false, + "Menu4Name" => $centreonMenu->translate( + $elem['topology_modules'], + $elem['topology_url'], + $elem["topology_name"] + ), + "Menu4Popup" => $elem["topology_popup"] ? true : false + ); } $centreonLang->bindLang(); } @@ -277,7 +312,7 @@ count($elemArr[2]) ? $tpl->assign("elemArr2", $elemArr[2]) : null; count($elemArr[3]) ? $tpl->assign("elemArr3", $elemArr[3]) : null; count($elemArr[4]) ? $tpl->assign("elemArr4", $elemArr[4]) : null; -$tpl->assign("idParent", $level1.$level2.$level3); +$tpl->assign("idParent", $level1 . $level2 . $level3); /* * User Online @@ -286,16 +321,28 @@ $tab_user = array(); $tab_user_admin = array(); $tab_user_non_admin = array(); - $DBRESULT = $pearDB->query("SELECT session.session_id, contact.contact_alias, contact.contact_admin, session.user_id, session.ip_address FROM session, contact WHERE contact.contact_id = session.user_id - ORDER BY contact.contact_alias"); + $query = "SELECT session.session_id, contact.contact_alias, contact.contact_admin, session.user_id, " . + "session.ip_address FROM session, contact WHERE contact.contact_id = session.user_id " . + "ORDER BY contact.contact_alias"; + $DBRESULT = $pearDB->query($query); while ($session = $DBRESULT->fetchRow()) { if ($session["contact_admin"] == 1) { - $tab_user_admin[$session["user_id"]] = array("ip"=>$session["ip_address"], "id"=>$session["user_id"], "alias"=>$session["contact_alias"], "admin"=>$session["contact_admin"]); + $tab_user_admin[$session["user_id"]] = array( + "ip" => $session["ip_address"], + "id" => $session["user_id"], + "alias" => $session["contact_alias"], + "admin" => $session["contact_admin"] + ); } else { - $tab_user_non_admin[$session["user_id"]] = array("ip"=>$session["ip_address"], "id"=>$session["user_id"], "alias"=>$session["contact_alias"], "admin"=>$session["contact_admin"]); + $tab_user_non_admin[$session["user_id"]] = array( + "ip" => $session["ip_address"], + "id" => $session["user_id"], + "alias" => $session["contact_alias"], + "admin" => $session["contact_admin"] + ); } } - + $tab_user = array_merge($tab_user_admin, $tab_user_non_admin); unset($tab_user_admin); unset($tab_user_non_admin); diff --git a/www/include/core/menu/menuJS.php b/www/include/core/menu/menuJS.php index 959b2612b77..b97554db944 100644 --- a/www/include/core/menu/menuJS.php +++ b/www/include/core/menu/menuJS.php @@ -39,8 +39,8 @@ ?> \ No newline at end of file diff --git a/www/include/core/menu/userFullScreenPreferences.php b/www/include/core/menu/userFullScreenPreferences.php index 3583694597f..bcee952fa6c 100644 --- a/www/include/core/menu/userFullScreenPreferences.php +++ b/www/include/core/menu/userFullScreenPreferences.php @@ -34,18 +34,20 @@ */ require_once realpath(dirname(__FILE__) . "/../../config/centreon.config.php"); -require_once _CENTREON_PATH_."/www/class/centreonDB.class.php"; -require_once _CENTREON_PATH_."/www/class/centreon.class.php"; -require_once _CENTREON_PATH_."/www/class/centreonSession.class.php"; +require_once _CENTREON_PATH_ . "/www/class/centreonDB.class.php"; +require_once _CENTREON_PATH_ . "/www/class/centreon.class.php"; +require_once _CENTREON_PATH_ . "/www/class/centreonSession.class.php"; session_start(); if (!isset($_SESSION['centreon']) || !isset($_POST['timestamp']) || !is_numeric($_POST['timestamp'])) { exit(); } - + if (isset($_SESSION['fullScreen'])) { if (isset($_SESSION['fullScreen']['timestamp']) && isset($_SESSION['fullScreen']['value'])) { - if (is_numeric($_SESSION['fullScreen']['timestamp']) && $_SESSION['fullScreen']['timestamp'] <= $_POST['timestamp']) { + if (is_numeric($_SESSION['fullScreen']['timestamp']) && + $_SESSION['fullScreen']['timestamp'] <= $_POST['timestamp'] + ) { $_SESSION['fullScreen']['value'] = !$_SESSION['fullScreen']['value']; $_SESSION['fullScreen']['timestamp'] = $_POST['timestamp']; } diff --git a/www/include/core/menu/userMenuPreferences.php b/www/include/core/menu/userMenuPreferences.php index d57014a0091..a5c2c0a89b4 100644 --- a/www/include/core/menu/userMenuPreferences.php +++ b/www/include/core/menu/userMenuPreferences.php @@ -32,11 +32,11 @@ * For more information : contact@centreon.com * */ - + require_once realpath(dirname(__FILE__) . "/../../config/centreon.config.php"); -require_once _CENTREON_PATH_."/www/class/centreonDB.class.php"; -require_once _CENTREON_PATH_."/www/class/centreon.class.php"; -require_once _CENTREON_PATH_."/www/class/centreonSession.class.php"; +require_once _CENTREON_PATH_ . "/www/class/centreonDB.class.php"; +require_once _CENTREON_PATH_ . "/www/class/centreon.class.php"; +require_once _CENTREON_PATH_ . "/www/class/centreonSession.class.php"; session_start(); session_write_close(); @@ -46,13 +46,15 @@ } $oreon = $_SESSION['centreon']; - + $pearDB = new CentreonDB(); /* * Check session id */ -$session = $pearDB->query("SELECT user_id FROM `session` WHERE session_id = '".$pearDB->escape(session_id())."' AND user_id = '".$pearDB->escape($_GET['uid'])."'"); +$query = "SELECT user_id FROM `session` WHERE session_id = '" . + $pearDB->escape(session_id()) . "' AND user_id = '" . $pearDB->escape($_GET['uid']) . "'"; +$session = $pearDB->query($query); if (!$session->rowCount()) { exit; } @@ -60,7 +62,7 @@ if (isset($_GET['div']) && isset($_GET['uid'])) { $my_div = htmlentities($_GET['div'], ENT_QUOTES, "UTF-8"); $my_uid = htmlentities($_GET['uid'], ENT_QUOTES, "UTF-8"); - + if (!isset($_SESSION['_Div_' . $my_div]) || $_SESSION['_Div_' . $my_div] == 1) { $_SESSION['_Div_' . $my_div] = 0; } else { diff --git a/www/include/core/menu/xml/menuXML.php b/www/include/core/menu/xml/menuXML.php index d91a3e7372d..f318d6e2d80 100644 --- a/www/include/core/menu/xml/menuXML.php +++ b/www/include/core/menu/xml/menuXML.php @@ -35,15 +35,15 @@ require_once "../../../../../config/centreon.config.php"; -require_once _CENTREON_PATH_."/www/include/common/common-Func.php"; +require_once _CENTREON_PATH_ . "/www/include/common/common-Func.php"; -require_once _CENTREON_PATH_."/www/class/centreonDB.class.php"; -require_once _CENTREON_PATH_."/www/class/centreonXML.class.php"; -require_once _CENTREON_PATH_."/www/class/centreonACL.class.php"; -require_once _CENTREON_PATH_."/www/class/centreon.class.php"; -require_once _CENTREON_PATH_."/www/class/centreonSession.class.php"; -require_once _CENTREON_PATH_."/www/class/centreonLang.class.php"; -require_once _CENTREON_PATH_."/www/class/centreonMenu.class.php"; +require_once _CENTREON_PATH_ . "/www/class/centreonDB.class.php"; +require_once _CENTREON_PATH_ . "/www/class/centreonXML.class.php"; +require_once _CENTREON_PATH_ . "/www/class/centreonACL.class.php"; +require_once _CENTREON_PATH_ . "/www/class/centreon.class.php"; +require_once _CENTREON_PATH_ . "/www/class/centreonSession.class.php"; +require_once _CENTREON_PATH_ . "/www/class/centreonLang.class.php"; +require_once _CENTREON_PATH_ . "/www/class/centreonMenu.class.php"; session_start(); session_write_close(); @@ -63,15 +63,15 @@ /* * Check Session existence */ -$session = $pearDB->query("SELECT user_id FROM `session` WHERE session_id = '".$pearDB->escape($sid)."'"); +$session = $pearDB->query("SELECT user_id FROM `session` WHERE session_id = '" . $pearDB->escape($sid) . "'"); if (!$session->rowCount()) { $buffer = new CentreonXML(); $buffer->startElement("root"); $buffer->endElement(); - + header('Content-Type: text/xml'); header('Cache-Control: no-cache'); - + $buffer->output(); } else { $centreon = $_SESSION['centreon']; @@ -98,7 +98,8 @@ /* * Get CSS */ - $DBRESULT2 = $pearDB->query("SELECT css_name FROM `css_color_menu` WHERE menu_nb = '".$pearDB->escape($_GET["menu"])."' LIMIT 1"); + $query = "SELECT css_name FROM `css_color_menu` WHERE menu_nb = '" . $pearDB->escape($_GET["menu"]) . "' LIMIT 1"; + $DBRESULT2 = $pearDB->query($query); $menu_style = $DBRESULT2->fetchRow(); ob_start(); @@ -113,34 +114,45 @@ $buffer->writeElement("Menu1Color", "menu_1"); $buffer->writeElement("Menu2Color", "menu_2"); - $rq = "SELECT topology_name, topology_page, topology_url_opt, topology_modules, topology_popup, topology_url FROM topology WHERE topology_parent IS NULL ".$access->queryBuilder("AND", "topology_page", $topoStr) . " AND topology_show = '1' ORDER BY topology_order"; + $rq = "SELECT topology_name, topology_page, topology_url_opt, topology_modules, topology_popup, topology_url " . + "FROM topology WHERE topology_parent IS NULL " . + $access->queryBuilder("AND", "topology_page", $topoStr) . " AND topology_show = '1' ORDER BY topology_order"; $DBRESULT = $pearDB->query($rq); $buffer->startElement("level_1"); while ($elem = $DBRESULT->fetchRow()) { $buffer->startElement("Menu1"); $buffer->writeElement("Menu1Page", $elem["topology_page"]); $buffer->writeElement("Menu1ClassImg", $_GET["menu"] == $elem["topology_page"] ? $menu1_bgimg : ""); - $buffer->writeElement("Menu1Url", "main.php?p=".$elem["topology_page"].$elem["topology_url_opt"]); + $buffer->writeElement("Menu1Url", "main.php?p=" . $elem["topology_page"] . $elem["topology_url_opt"]); $buffer->writeElement("Menu1UrlPopup", $elem["topology_popup"]); $buffer->writeElement("Menu1UrlPopupOpen", $elem["topology_url"]); - $buffer->writeElement("Menu1Name", $centreonMenu->translate($elem['topology_modules'], $elem['topology_url'], $elem["topology_name"]), 0); + $buffer->writeElement( + "Menu1Name", + $centreonMenu->translate($elem['topology_modules'], $elem['topology_url'], $elem["topology_name"]), + 0 + ); $buffer->writeElement("Menu1Popup", $elem["topology_popup"] ? "true" : "false"); $buffer->endElement(); } $buffer->endElement(); - $rq = "SELECT * FROM topology WHERE topology_parent = '".$pearDB->escape($_GET["menu"])."' " .$access->queryBuilder("AND", "topology_page", $topoStr) . - "AND topology_show = '1' " . - "ORDER BY topology_group, topology_order"; + $rq = "SELECT * FROM topology WHERE topology_parent = '" . + $pearDB->escape($_GET["menu"]) . "' " . $access->queryBuilder("AND", "topology_page", $topoStr) . + "AND topology_show = '1' " . + "ORDER BY topology_group, topology_order"; $DBRESULT = $pearDB->query($rq); $buffer->startElement("level_2"); while ($elem = $DBRESULT->fetchRow()) { $buffer->startElement("Menu2"); $buffer->writeElement("Menu2Sep", ""); - $buffer->writeElement("Menu2Url", "main.php?p=".$elem["topology_page"].$elem["topology_url_opt"]); + $buffer->writeElement("Menu2Url", "main.php?p=" . $elem["topology_page"] . $elem["topology_url_opt"]); $buffer->writeElement("Menu2UrlPopup", $elem["topology_popup"]); $buffer->writeElement("Menu2UrlPopupOpen", $elem["topology_url"]); - $buffer->writeElement("Menu2Name", $centreonMenu->translate($elem['topology_modules'], $elem['topology_url'], $elem["topology_name"]), 0); + $buffer->writeElement( + "Menu2Name", + $centreonMenu->translate($elem['topology_modules'], $elem['topology_url'], $elem["topology_name"]), + 0 + ); $buffer->writeElement("Menu2Popup", $elem["topology_popup"] ? "true" : "false"); $buffer->endElement(); } From f0441da30174520506bc7a869d25c15bcd60cd16 Mon Sep 17 00:00:00 2001 From: loiclau Date: Thu, 17 Aug 2017 16:37:44 +0200 Subject: [PATCH 182/207] * fix style service status --- .../monitoring/status/Services/service.php | 118 ++++++---- .../status/Services/serviceGrid.php | 84 ++++--- .../status/Services/serviceGridJS.php | 209 +++++++++-------- .../monitoring/status/Services/serviceJS.php | 217 +++++++++++------- .../status/Services/serviceSummary.php | 135 ++++++----- .../status/Services/serviceSummaryJS.php | 197 ++++++++-------- .../status/Services/xml/makeXMLForOneHost.php | 72 +++--- .../Services/xml/makeXMLForOneService.php | 70 +++--- .../status/Services/xml/serviceGridXML.php | 48 ++-- .../status/Services/xml/serviceSummaryXML.php | 40 ++-- .../status/Services/xml/serviceXML.php | 22 +- 11 files changed, 675 insertions(+), 537 deletions(-) diff --git a/www/include/monitoring/status/Services/service.php b/www/include/monitoring/status/Services/service.php index 1edee84e4b9..d5ae930ff23 100644 --- a/www/include/monitoring/status/Services/service.php +++ b/www/include/monitoring/status/Services/service.php @@ -77,9 +77,9 @@ foreach ($myinputsGet as $key => $value) { if (!empty($value)) { $filters[$key] = $value; - } else if (!empty($myinputsPost[$key])) { + } elseif (!empty($myinputsPost[$key])) { $filters[$key] = $myinputsPost[$key]; - } else if ($resetFilter && isset($_SESSION['filters'][$url][$key]) && !empty($_SESSION['filters'][$url][$key])) { + } elseif ($resetFilter && isset($_SESSION['filters'][$url][$key]) && !empty($_SESSION['filters'][$url][$key])) { $filters[$key] = $_SESSION['filters'][$url][$key]; } else { $filters[$key] = ''; @@ -182,16 +182,17 @@ } else { if (empty($filters["sort_type"])) { $sort_type = $filters["sort_type"]; - } else if (isset($centreon->optGen["global_sort_type"])) { - $sort_type = CentreonDB::escape($centreon->optGen["global_sort_type"]); + } elseif (isset($centreon->optGen["global_sort_type"])) { + $sort_type = CentreonDB::escape($centreon->optGen["global_sort_type"]); } else { $sort_type = "host_name"; } if (empty($filters["order"])) { $order = $filters["order"]; - } else if (isset($centreon->optGen["global_sort_order"]) && - $centreon->optGen["global_sort_order"] != "") { + } elseif (isset($centreon->optGen["global_sort_order"]) && + $centreon->optGen["global_sort_order"] != "" + ) { $order = $centreon->optGen["global_sort_order"]; } else { $order = "ASC"; @@ -328,26 +329,30 @@ function setO(_i) { $action_list[75] = _("Hosts : Set Downtime"); } -$attrs = array('onchange' => "javascript: ". - " var bChecked = isChecked(); ". - " if (this.form.elements['o1'].selectedIndex != 0 && !bChecked) {". - " alert('"._("Please select one or more items")."'); return false;} " . - " if (this.form.elements['o1'].selectedIndex == 0) {". - " return false;} ". - " if (cmdCallback(this.value)) { setO(this.value); submit();} else { setO(this.value); }"); +$attrs = array( + 'onchange' => "javascript: " . + " var bChecked = isChecked(); " . + " if (this.form.elements['o1'].selectedIndex != 0 && !bChecked) {" . + " alert('" . _("Please select one or more items") . "'); return false;} " . + " if (this.form.elements['o1'].selectedIndex == 0) {" . + " return false;} " . + " if (cmdCallback(this.value)) { setO(this.value); submit();} else { setO(this.value); }" +); $form->addElement('select', 'o1', null, $action_list, $attrs); $form->setDefaults(array('o1' => null)); $o1 = $form->getElement('o1'); $o1->setValue(null); -$attrs = array('onchange' => "javascript: ". - " var bChecked = isChecked(); ". - " if (this.form.elements['o2'].selectedIndex != 0 && !bChecked) {". - " alert('"._("Please select one or more items")."'); return false;} ". - " if (this.form.elements['o2'].selectedIndex == 0) {". - " return false;} ". - " if (cmdCallback(this.value)) { setO(this.value); submit();} else { setO(this.value); }"); +$attrs = array( + 'onchange' => "javascript: " . + " var bChecked = isChecked(); " . + " if (this.form.elements['o2'].selectedIndex != 0 && !bChecked) {" . + " alert('" . _("Please select one or more items") . "'); return false;} " . + " if (this.form.elements['o2'].selectedIndex == 0) {" . + " return false;} " . + " if (cmdCallback(this.value)) { setO(this.value); submit();} else { setO(this.value); }" +); $form->addElement('select', 'o2', null, $action_list, $attrs); $form->setDefaults(array('o2' => null)); $o2 = $form->getElement('o2'); @@ -362,12 +367,13 @@ function setO(_i) { "warning" => _("Warning"), "critical" => _("Critical"), "unknown" => _("Unknown"), - "pending" => _("Pending")); + "pending" => _("Pending") +); $statusService = array( "svc_unhandled" => _("Unhandled Problems"), "svcpb" => _("Service Problems"), - "svc" => _("All") + "svc" => _("All") ); if ($o == "svc") { @@ -386,19 +392,31 @@ function setO(_i) { } } -$form->addElement('select', 'statusFilter', _('Status'), $statusList, array('id' => 'statusFilter', 'onChange' => "filterStatus(this.value);")); +$form->addElement( + 'select', + 'statusFilter', + _('Status'), + $statusList, + array('id' => 'statusFilter', 'onChange' => "filterStatus(this.value);") +); if ((!isset($_GET['o']) || empty($_GET['o'])) && isset($_SESSION['monitoring_service_status_filter'])) { $form->setDefaults(array('statusFilter' => $_SESSION['monitoring_service_status_filter'])); $sDefaultOrder = "1"; } -$form->addElement('select', 'statusService', _('Service Status'), $statusService, array('id' => 'statusService', 'onChange' => "statusServices(this.value);")); +$form->addElement( + 'select', + 'statusService', + _('Service Status'), + $statusService, + array('id' => 'statusService', 'onChange' => "statusServices(this.value);") +); /* Get default service status by GET */ if (isset($_GET['o']) && in_array($_GET['o'], array_keys($statusService))) { $form->setDefaults(array('statusService' => $_GET['o'])); -/* Get default service status in SESSION */ -} elseif ((!isset($_GET['o']) || empty($_GET['o'])) && isset($_SESSION['monitoring_service_status'])) { + /* Get default service status in SESSION */ +} elseif ((!isset($_GET['o']) || empty($_GET['o'])) && isset($_SESSION['monitoring_service_status'])) { $o = $_SESSION['monitoring_service_status']; $form->setDefaults(array('statusService' => $_SESSION['monitoring_service_status'])); $sDefaultOrder = "1"; @@ -410,7 +428,13 @@ function setO(_i) { foreach ($crits as $critId => $crit) { $critArray[$critId] = $crit['sc_name'] . " ({$crit['level']})"; } -$form->addElement('select', 'criticality', _('Severity'), $critArray, array('id' => 'critFilter', 'onChange' => "filterCrit(this.value);")); +$form->addElement( + 'select', + 'criticality', + _('Severity'), + $critArray, + array('id' => 'critFilter', 'onChange' => "filterCrit(this.value);") +); $form->setDefaults(array('criticality' => isset($_SESSION['criticality_id']) ? $_SESSION['criticality_id'] : "0")); $renderer = new HTML_QuickForm_Renderer_ArraySmarty($tpl); @@ -431,26 +455,25 @@ function setO(_i) { ?> + function displayingLevel2(val) { + var sel1 = document.getElementById("typeDisplay").value; + _o = sel1; + if (val != '') { + _o = _o + "_" + val; + } + + monitoring_refresh(); + } + addElement('select', 'typeDisplay', _('Display'), $aTypeAffichageLevel1, array('id' => 'typeDisplay', 'onChange' => "displayingLevel1(this.value);")); -$form->addElement('select', 'typeDisplay2', _('Display '), $aTypeAffichageLevel2, array('id' => 'typeDisplay2', 'onChange' => "displayingLevel2(this.value);")); +$form->addElement( + 'select', + 'typeDisplay', + _('Display'), + $aTypeAffichageLevel1, + array('id' => 'typeDisplay', 'onChange' => "displayingLevel1(this.value);") +); +$form->addElement( + 'select', + 'typeDisplay2', + _('Display '), + $aTypeAffichageLevel2, + array('id' => 'typeDisplay2', 'onChange' => "displayingLevel2(this.value);") +); $form->setDefaults(array('typeDisplay2' => 'pb')); foreach (array('o1', 'o2') as $option) { $attrs = array('onchange' => "javascript: setO(this.form.elements['$option'].value); submit();"); - $form->addElement('select', $option, null, array(null => _("More actions..."), + $form->addElement('select', $option, null, array( + null => _("More actions..."), "3" => _("Verification Check"), "4" => _("Verification Check (Forced)"), "70" => _("Services : Acknowledge"), @@ -156,7 +169,8 @@ function displayingLevel2(val) "82" => _("Hosts : Enable Notification"), "83" => _("Hosts : Disable Notification"), "92" => _("Hosts : Enable Check"), - "93" => _("Hosts : Disable Check")), $attrs); + "93" => _("Hosts : Disable Check") + ), $attrs); $form->setDefaults(array($option => null)); $o1 = $form->getElement($option); diff --git a/www/include/monitoring/status/Services/serviceGridJS.php b/www/include/monitoring/status/Services/serviceGridJS.php index b2ba514e6bb..09f5300d26f 100644 --- a/www/include/monitoring/status/Services/serviceGridJS.php +++ b/www/include/monitoring/status/Services/serviceGridJS.php @@ -53,120 +53,131 @@ ?> \ No newline at end of file diff --git a/www/include/monitoring/status/Services/serviceJS.php b/www/include/monitoring/status/Services/serviceJS.php index 28731891c05..3b459ff5e72 100644 --- a/www/include/monitoring/status/Services/serviceJS.php +++ b/www/include/monitoring/status/Services/serviceJS.php @@ -53,26 +53,28 @@ ?> +addElement( + 'select', + 'typeDisplay', + _('Display'), + $aTypeAffichageLevel1, + array('id' => 'typeDisplay', 'onChange' => "displayingLevel1(this.value);") +); +$form->addElement( + 'select', + 'typeDisplay2', + _('Display '), + $aTypeAffichageLevel2, + array('id' => 'typeDisplay2', 'onChange' => "displayingLevel2(this.value);") +); -function displayingLevel2(val) -{ - var sel1 = document.getElementById("typeDisplay").value; - _o = "svcSum"; - if (val != '') { - _o = _o + "_" + val; - } - - monitoring_refresh(); -} - -addElement('select', 'typeDisplay', _('Display'), $aTypeAffichageLevel1, array('id' => 'typeDisplay', 'onChange' => "displayingLevel1(this.value);")); -$form->addElement('select', 'typeDisplay2', _('Display '), $aTypeAffichageLevel2, array('id' => 'typeDisplay2', 'onChange' => "displayingLevel2(this.value);")); - foreach (array('o1', 'o2') as $option) { - $attrs = array('onchange'=>"javascript: setO(this.form.elements['$option'].value); submit();"); - $form->addElement('select', - 'o1', - null, - array(null => _("More actions..."), - "3" => _("Verification Check"), - "4" => _("Verification Check (Forced)"), - "70" => _("Services : Acknowledge"), - "71" => _("Services : Disacknowledge"), - "80" => _("Services : Enable Notification"), - "81" => _("Services : Disable Notification"), - "90" => _("Services : Enable Check"), - "91" => _("Services : Disable Check"), - "72" => _("Hosts : Acknowledge"), - "73" => _("Hosts : Disacknowledge"), - "82" => _("Hosts : Enable Notification"), - "83" => _("Hosts : Disable Notification"), - "92" => _("Hosts : Enable Check"), - "93" => _("Hosts : Disable Check")), $attrs); + $attrs = array('onchange' => "javascript: setO(this.form.elements['$option'].value); submit();"); + $form->addElement( + 'select', + 'o1', + null, + array( + null => _("More actions..."), + "3" => _("Verification Check"), + "4" => _("Verification Check (Forced)"), + "70" => _("Services : Acknowledge"), + "71" => _("Services : Disacknowledge"), + "80" => _("Services : Enable Notification"), + "81" => _("Services : Disable Notification"), + "90" => _("Services : Enable Check"), + "91" => _("Services : Disable Check"), + "72" => _("Hosts : Acknowledge"), + "73" => _("Hosts : Disacknowledge"), + "82" => _("Hosts : Enable Notification"), + "83" => _("Hosts : Disable Notification"), + "92" => _("Hosts : Enable Check"), + "93" => _("Hosts : Disable Check") + ), + $attrs + ); $form->setDefaults(array($option => null)); $o1 = $form->getElement($option); $o1->setValue(null); diff --git a/www/include/monitoring/status/Services/serviceSummaryJS.php b/www/include/monitoring/status/Services/serviceSummaryJS.php index be509940d18..2a222016a2c 100644 --- a/www/include/monitoring/status/Services/serviceSummaryJS.php +++ b/www/include/monitoring/status/Services/serviceSummaryJS.php @@ -53,119 +53,130 @@ ?> \ No newline at end of file diff --git a/www/include/monitoring/status/Services/xml/makeXMLForOneHost.php b/www/include/monitoring/status/Services/xml/makeXMLForOneHost.php index cf3d892464b..129981528b6 100644 --- a/www/include/monitoring/status/Services/xml/makeXMLForOneHost.php +++ b/www/include/monitoring/status/Services/xml/makeXMLForOneHost.php @@ -78,46 +78,46 @@ /** ************************************************** * Check Arguments From GET tab */ -$host_id = $obj->checkArgument("host_id", $_GET, 0); -$enable = $obj->checkArgument("enable", $_GET, ""); -$disable = $obj->checkArgument("disable", $_GET, "disable"); -$dateFormat = $obj->checkArgument("date_time_format_status", $_GET, "Y/m/d H:i:s"); +$host_id = $obj->checkArgument("host_id", $_GET, 0); +$enable = $obj->checkArgument("enable", $_GET, ""); +$disable = $obj->checkArgument("disable", $_GET, "disable"); +$dateFormat = $obj->checkArgument("date_time_format_status", $_GET, "Y/m/d H:i:s"); /** *************************************************** * Get Host status */ -$rq1 = " SELECT h.state," . - " h.address," . - " h.name," . - " h.alias," . - " i.name AS poller, " . - " h.perfdata," . - " h.check_attempt," . - " h.state_type," . - " h.last_check, " . - " h.next_check, " . - " h.latency," . - " h.execution_time," . - " h.last_state_change," . - " h.last_notification," . - " h.next_host_notification," . - " h.last_hard_state_change," . - " h.last_hard_state," . - " h.last_time_up," . - " h.last_time_down," . - " h.last_time_unreachable," . - " h.notification_number," . - " h.scheduled_downtime_depth," . - " h.output," . - " h.notes," . - " h.notify," . - " h.event_handler_enabled," . - " h.icon_image, " . - " h.timezone" . - " FROM hosts h, instances i " . - " WHERE h.host_id = " . $host_id . - " AND h.instance_id = i.instance_id " . - " LIMIT 1"; +$rq1 = " SELECT h.state," . + " h.address," . + " h.name," . + " h.alias," . + " i.name AS poller, " . + " h.perfdata," . + " h.check_attempt," . + " h.state_type," . + " h.last_check, " . + " h.next_check, " . + " h.latency," . + " h.execution_time," . + " h.last_state_change," . + " h.last_notification," . + " h.next_host_notification," . + " h.last_hard_state_change," . + " h.last_hard_state," . + " h.last_time_up," . + " h.last_time_down," . + " h.last_time_unreachable," . + " h.notification_number," . + " h.scheduled_downtime_depth," . + " h.output," . + " h.notes," . + " h.notify," . + " h.event_handler_enabled," . + " h.icon_image, " . + " h.timezone" . + " FROM hosts h, instances i " . + " WHERE h.host_id = " . $host_id . + " AND h.instance_id = i.instance_id " . + " LIMIT 1"; /* * Request */ diff --git a/www/include/monitoring/status/Services/xml/makeXMLForOneService.php b/www/include/monitoring/status/Services/xml/makeXMLForOneService.php index e9f57fc26ba..8c4acb9eb24 100644 --- a/www/include/monitoring/status/Services/xml/makeXMLForOneService.php +++ b/www/include/monitoring/status/Services/xml/makeXMLForOneService.php @@ -78,10 +78,10 @@ /** ************************************************** * Check Arguments From GET tab */ -$svc_id = $obj->checkArgument("svc_id", $_GET, 0); -$enable = $obj->checkArgument("enable", $_GET, ""); -$disable = $obj->checkArgument("disable", $_GET, "disable"); -$dateFormat = $obj->checkArgument("date_time_format_status", $_GET, "Y/m/d H:i:s"); +$svc_id = $obj->checkArgument("svc_id", $_GET, 0); +$enable = $obj->checkArgument("enable", $_GET, ""); +$disable = $obj->checkArgument("disable", $_GET, "disable"); +$dateFormat = $obj->checkArgument("date_time_format_status", $_GET, "Y/m/d H:i:s"); $tab = preg_split('/\_/', $svc_id); $host_id = $tab[0]; @@ -91,34 +91,34 @@ * Get Service status */ $rq1 = "SELECT s.state," . - " h.name, " . - " s.description," . - " s.last_check," . - " s.next_check," . - " s.last_state_change," . - " s.last_notification," . - " s.last_hard_state_change," . - " s.last_hard_state," . - " s.latency," . - " s.last_time_ok," . - " s.last_time_critical," . - " s.last_time_unknown," . - " s.last_time_warning," . - " s.notification_number," . - " s.scheduled_downtime_depth," . - " s.output," . - " s.notes," . - " ROUND(s.percent_state_change) as percent_state_change," . - " s.notify," . - " s.perfdata," . - " s.state_type," . - " s.execution_time," . - " s.event_handler_enabled, " . - " s.icon_image, " . - " s.display_name " . - " FROM hosts h, services s " . - " WHERE s.host_id = h.host_id " . - " AND s.host_id = $host_id AND service_id = $service_id LIMIT 1"; + " h.name, " . + " s.description," . + " s.last_check," . + " s.next_check," . + " s.last_state_change," . + " s.last_notification," . + " s.last_hard_state_change," . + " s.last_hard_state," . + " s.latency," . + " s.last_time_ok," . + " s.last_time_critical," . + " s.last_time_unknown," . + " s.last_time_warning," . + " s.notification_number," . + " s.scheduled_downtime_depth," . + " s.output," . + " s.notes," . + " ROUND(s.percent_state_change) as percent_state_change," . + " s.notify," . + " s.perfdata," . + " s.state_type," . + " s.execution_time," . + " s.event_handler_enabled, " . + " s.icon_image, " . + " s.display_name " . + " FROM hosts h, services s " . + " WHERE s.host_id = h.host_id " . + " AND s.host_id = $host_id AND service_id = $service_id LIMIT 1"; /* * Init Buffer @@ -133,7 +133,7 @@ /* Split the plugin_output */ $outputLines = preg_split('/
|
|\\\n|\x0A|\x0D\x0A|\n/', $data['output']); if (strlen($outputLines[0]) > 100) { - $pluginShortOuput = sprintf("%.100s", $outputLines[0])."..."; + $pluginShortOuput = sprintf("%.100s", $outputLines[0]) . "..."; } else { $pluginShortOuput = $outputLines[0]; } @@ -205,8 +205,8 @@ } $tab_perf = preg_split("/\ /", $data["perfdata"]); - $perf_data = array_slice($tab_perf,0,4); - if(count($tab_perf) > 5) { + $perf_data = array_slice($tab_perf, 0, 4); + if (count($tab_perf) > 5) { $perf_data[5] = "..."; } diff --git a/www/include/monitoring/status/Services/xml/serviceGridXML.php b/www/include/monitoring/status/Services/xml/serviceGridXML.php index 089f00389db..fe1e2a7f131 100644 --- a/www/include/monitoring/status/Services/xml/serviceGridXML.php +++ b/www/include/monitoring/status/Services/xml/serviceGridXML.php @@ -66,16 +66,16 @@ /* ************************************************** * Check Arguments From GET tab */ -$o = $obj->checkArgument("o", $_GET, "h"); -$p = $obj->checkArgument("p", $_GET, "2"); -$nc = $obj->checkArgument("nc", $_GET, "0"); -$num = $obj->checkArgument("num", $_GET, 0); -$limit = $obj->checkArgument("limit", $_GET, 20); -$instance = $obj->checkArgument("instance", $_GET, $obj->defaultPoller); +$o = $obj->checkArgument("o", $_GET, "h"); +$p = $obj->checkArgument("p", $_GET, "2"); +$nc = $obj->checkArgument("nc", $_GET, "0"); +$num = $obj->checkArgument("num", $_GET, 0); +$limit = $obj->checkArgument("limit", $_GET, 20); +$instance = $obj->checkArgument("instance", $_GET, $obj->defaultPoller); $hostgroups = $obj->checkArgument("hostgroups", $_GET, $obj->defaultHostgroups); -$search = $obj->checkArgument("search", $_GET, ""); -$sort_type = $obj->checkArgument("sort_type", $_GET, "host_name"); -$order = $obj->checkArgument("order", $_GET, "ASC"); +$search = $obj->checkArgument("search", $_GET, ""); +$sort_type = $obj->checkArgument("sort_type", $_GET, "host_name"); +$order = $obj->checkArgument("order", $_GET, "ASC"); $dateFormat = $obj->checkArgument("date_time_format_status", $_GET, "Y/m/d H:i:s"); /* @@ -86,51 +86,51 @@ /** ********************************************* * Get Host status */ -$rq1 = " SELECT SQL_CALC_FOUND_ROWS DISTINCT hosts.name, hosts.state, hosts.icon_image, hosts.host_id " . - " FROM hosts "; +$rq1 = " SELECT SQL_CALC_FOUND_ROWS DISTINCT hosts.name, hosts.state, hosts.icon_image, hosts.host_id " . + " FROM hosts "; if ($hostgroups) { $rq1 .= ", hosts_hostgroups hg, hostgroups hg2 "; } if (!$obj->is_admin) { - $rq1 .= ", centreon_acl "; + $rq1 .= ", centreon_acl "; } -$rq1 .= " WHERE hosts.name NOT LIKE '_Module_%' "; +$rq1 .= " WHERE hosts.name NOT LIKE '_Module_%' "; if (!$obj->is_admin) { - $rq1 .= " AND hosts.host_id = centreon_acl.host_id "; + $rq1 .= " AND hosts.host_id = centreon_acl.host_id "; $rq1 .= $obj->access->queryBuilder("AND", "group_id", $obj->grouplistStr); } if ($o == "svcgrid_pb" || $o == "svcOV_pb" || $o == "svcgrid_ack_0" || $o == "svcOV_ack_0") { $rq1 .= " AND hosts.host_id IN (" . - " SELECT s.host_id FROM services s " . - " WHERE s.state != 0 AND s.state != 4 AND s.enabled = 1)"; + " SELECT s.host_id FROM services s " . + " WHERE s.state != 0 AND s.state != 4 AND s.enabled = 1)"; } if ($o == "svcgrid_ack_1" || $o == "svcOV_ack_1") { $rq1 .= " AND hosts.host_id IN (" . - " SELECT s.host_id FROM services s " . - " WHERE s.acknowledged = '1' AND s.enabled = 1)"; + " SELECT s.host_id FROM services s " . + " WHERE s.acknowledged = '1' AND s.enabled = 1)"; } if ($search != "") { $rq1 .= " AND hosts.name like '%" . $search . "%' "; } if ($instance != -1) { - $rq1 .= " AND hosts.instance_id = ".$instance.""; + $rq1 .= " AND hosts.instance_id = " . $instance . ""; } if ($hostgroups) { $rq1 .= " AND hosts.host_id = hg.host_id "; - $rq1 .= " AND hg.hostgroup_id IN (".$hostgroups.") "; + $rq1 .= " AND hg.hostgroup_id IN (" . $hostgroups . ") "; $rq1 .= " AND hg.hostgroup_id = hg2.hostgroup_id "; } $rq1 .= " AND hosts.enabled = 1 "; switch ($sort_type) { case 'current_state': - $rq1 .= " ORDER BY hosts.state ". $order.",hosts.name "; + $rq1 .= " ORDER BY hosts.state " . $order . ",hosts.name "; break; default: - $rq1 .= " ORDER BY hosts.name ". $order; + $rq1 .= " ORDER BY hosts.name " . $order; break; } -$rq1 .= " LIMIT ".($num * $limit).",".$limit; +$rq1 .= " LIMIT " . ($num * $limit) . "," . $limit; /* * Execute request @@ -154,7 +154,7 @@ if ($str != "") { $str .= ","; } - $str .= "'".$ndo["name"]."'"; + $str .= "'" . $ndo["name"] . "'"; $tab_final[$ndo["name"]] = array("cs" => $ndo["state"], "hid" => $ndo["host_id"]); if ($ndo["icon_image"] != "") { $tabIcone[$ndo["name"]] = $ndo["icon_image"]; diff --git a/www/include/monitoring/status/Services/xml/serviceSummaryXML.php b/www/include/monitoring/status/Services/xml/serviceSummaryXML.php index cbc9c54f499..f63ace20782 100644 --- a/www/include/monitoring/status/Services/xml/serviceSummaryXML.php +++ b/www/include/monitoring/status/Services/xml/serviceSummaryXML.php @@ -65,16 +65,16 @@ /* ************************************************** * Check Arguments From GET tab */ -$o = $obj->checkArgument("o", $_GET, "h"); -$p = $obj->checkArgument("p", $_GET, "2"); -$nc = $obj->checkArgument("nc", $_GET, "0"); -$num = $obj->checkArgument("num", $_GET, 0); -$limit = $obj->checkArgument("limit", $_GET, 20); -$instance = $obj->checkArgument("instance", $_GET, $obj->defaultPoller); +$o = $obj->checkArgument("o", $_GET, "h"); +$p = $obj->checkArgument("p", $_GET, "2"); +$nc = $obj->checkArgument("nc", $_GET, "0"); +$num = $obj->checkArgument("num", $_GET, 0); +$limit = $obj->checkArgument("limit", $_GET, 20); +$instance = $obj->checkArgument("instance", $_GET, $obj->defaultPoller); $hostgroups = $obj->checkArgument("hostgroups", $_GET, $obj->defaultHostgroups); -$search = $obj->checkArgument("search", $_GET, ""); -$sort_type = $obj->checkArgument("sort_type", $_GET, "host_name"); -$order = $obj->checkArgument("order", $_GET, "ASC"); +$search = $obj->checkArgument("search", $_GET, ""); +$sort_type = $obj->checkArgument("sort_type", $_GET, "host_name"); +$order = $obj->checkArgument("order", $_GET, "ASC"); $dateFormat = $obj->checkArgument("date_time_format_status", $_GET, "Y/m/d H:i:s"); /* * Backup poller selection @@ -107,12 +107,18 @@ . $obj->access->queryBuilder("AND", "hosts.host_id", "centreon_acl.host_id") . " " . $obj->access->queryBuilder("AND", "group_id", $obj->grouplistStr) . " "; -if ($o == "svcgrid_pb" || $o == "svcOV_pb" || $o == "svcSum_pb" || $o == "svcgrid_ack_0" || $o == "svcOV_ack_0" || $o == "svcSum_ack_0") { +if ($o == "svcgrid_pb" || + $o == "svcOV_pb" || + $o == "svcSum_pb" || + $o == "svcgrid_ack_0" || + $o == "svcOV_ack_0" || + $o == "svcSum_ack_0" +) { $rq1 .= "AND hosts.host_id IN ( " - . "SELECT s.host_id FROM services s " - . "WHERE s.state != 0 " - . "AND s.state != 4 " - . "AND s.enabled = 1) "; + . "SELECT s.host_id FROM services s " + . "WHERE s.state != 0 " + . "AND s.state != 4 " + . "AND s.enabled = 1) "; } if ($o == "svcgrid_ack_1" || $o == "svcOV_ack_1" || $o == "svcSum_ack_1") { @@ -132,7 +138,7 @@ if ($hostgroups) { $rq1 .= " AND hosts.host_id = hg.host_id " - . "AND hg.hostgroup_id IN (".$hostgroups.") " + . "AND hg.hostgroup_id IN (" . $hostgroups . ") " . "AND hg.hostgroup_id = hg2.hostgroup_id "; } @@ -146,7 +152,7 @@ break; } - # LIMIT +# LIMIT $rq1 .= "LIMIT " . ($num * $limit) . "," . $limit . " "; @@ -173,7 +179,7 @@ while ($ndo = $DBRESULT_NDO1->fetchRow()) { $tab_final[$ndo["name"]]["nb_service_k"] = 0; $tab_final[$ndo["name"]]["host_id"] = $ndo["host_id"]; - if ($o != "svcSum_pb" && $o != "svcSum_ack_1" && $o != "svcSum_ack_0") { + if ($o != "svcSum_pb" && $o != "svcSum_ack_1" && $o != "svcSum_ack_0") { $tab_final[$ndo["name"]]["nb_service_k"] = $obj->monObj->getServiceStatusCount($ndo["name"], $obj, $o, 0, $obj); } $tab_final[$ndo["name"]]["nb_service_w"] = 0 + $obj->monObj->getServiceStatusCount($ndo["name"], $obj, $o, 1, $obj); diff --git a/www/include/monitoring/status/Services/xml/serviceXML.php b/www/include/monitoring/status/Services/xml/serviceXML.php index 0923c26d991..75f36972f3b 100644 --- a/www/include/monitoring/status/Services/xml/serviceXML.php +++ b/www/include/monitoring/status/Services/xml/serviceXML.php @@ -515,7 +515,7 @@ $obj->XML->writeElement( "ca", $data["current_attempt"] . "/" . $data["max_check_attempts"] - . " (" . $obj->stateType[$data["state_type"]] . ")" + . " (" . $obj->stateType[$data["state_type"]] . ")" ); if (isset($data['criticality']) && $data['criticality'] != '' && isset($critCache[$data['service_id']])) { $obj->XML->writeElement("hci", 1); // has criticality @@ -535,13 +535,13 @@ $obj->XML->writeElement( "dtmXml", "./include/monitoring/downtime/xml/broker/makeXMLForDowntime.php?hid=" - . $data['host_id'] . "&svc_id=" . $data['service_id'] + . $data['host_id'] . "&svc_id=" . $data['service_id'] ); $obj->XML->writeElement("dtmXsl", "./include/monitoring/downtime/xsl/popupForDowntime.xsl"); $obj->XML->writeElement( "ackXml", "./include/monitoring/acknowlegement/xml/broker/makeXMLForAck.php?hid=" - . $data['host_id'] . "&svc_id=" . $data['service_id'] + . $data['host_id'] . "&svc_id=" . $data['service_id'] ); $obj->XML->writeElement("ackXsl", "./include/monitoring/acknowlegement/xsl/popupForAck.xsl"); @@ -590,7 +590,15 @@ $data["notes_url"] ); } - $obj->XML->writeElement("snu", CentreonUtils::escapeSecure($obj->serviceObj->replaceMacroInString($data["service_id"], $data["notes_url"]))); + $obj->XML->writeElement( + "snu", + CentreonUtils::escapeSecure( + $obj->serviceObj->replaceMacroInString( + $data["service_id"], + $data["notes_url"] + ) + ) + ); } else { $obj->XML->writeElement("snu", 'none'); } @@ -598,7 +606,11 @@ if ($data["action_url"] != "") { $data["action_url"] = str_replace("\$SERVICEDESC\$", $data["description"], $data["action_url"]); $data["action_url"] = str_replace("\$SERVICESTATEID\$", $data["state"], $data["action_url"]); - $data["action_url"] = str_replace("\$SERVICESTATE\$", $obj->statusService[$data["state"]], $data["action_url"]); + $data["action_url"] = str_replace( + "\$SERVICESTATE\$", + $obj->statusService[$data["state"]], + $data["action_url"] + ); $data["action_url"] = str_replace("\$HOSTNAME\$", $data["name"], $data["action_url"]); if (isset($data["alias"]) && $data["alias"]) { $data["action_url"] = str_replace("\$HOSTALIAS\$", $data["alias"], $data["action_url"]); From 2b9179f83d62a1e629f275aa7403777af40874d5 Mon Sep 17 00:00:00 2001 From: loiclau Date: Thu, 17 Aug 2017 17:12:46 +0200 Subject: [PATCH 183/207] * fix style graph template --- www/include/views/graphTemplates/DB-Func.php | 116 +++++++++++----- .../graphTemplates/formGraphTemplate.php | 130 +++++++++++------- .../views/graphTemplates/graphTemplates.php | 20 +-- .../graphTemplates/listGraphTemplates.php | 103 +++++++++----- 4 files changed, 234 insertions(+), 135 deletions(-) diff --git a/www/include/views/graphTemplates/DB-Func.php b/www/include/views/graphTemplates/DB-Func.php index 235acd97ee3..6efba099041 100644 --- a/www/include/views/graphTemplates/DB-Func.php +++ b/www/include/views/graphTemplates/DB-Func.php @@ -45,7 +45,9 @@ function testExistence($name = null) if (isset($form)) { $id = $form->getSubmitValue('graph_id'); } - $res = $pearDB->query("SELECT graph_id, name FROM giv_graphs_template WHERE name = '".htmlentities($name, ENT_QUOTES, "UTF-8")."'"); + $query = "SELECT graph_id, name FROM giv_graphs_template WHERE name = '" . + htmlentities($name, ENT_QUOTES, "UTF-8") . "'"; + $res = $pearDB->query($query); $graph = $res->fetchRow(); /* * Modif case @@ -67,7 +69,7 @@ function deleteGraphTemplateInDB($graphs = array()) global $pearDB; foreach ($graphs as $key => $value) { - $pearDB->query("DELETE FROM giv_graphs_template WHERE graph_id = '".$key."'"); + $pearDB->query("DELETE FROM giv_graphs_template WHERE graph_id = '" . $key . "'"); } defaultOreonGraph(); } @@ -76,18 +78,20 @@ function multipleGraphTemplateInDB($graphs = array(), $nbrDup = array()) { foreach ($graphs as $key => $value) { global $pearDB; - $res = $pearDB->query("SELECT * FROM giv_graphs_template WHERE graph_id = '".$key."' LIMIT 1"); + $res = $pearDB->query("SELECT * FROM giv_graphs_template WHERE graph_id = '" . $key . "' LIMIT 1"); $row = $res->fetchRow(); $row["graph_id"] = ''; $row["default_tpl1"] = '0'; for ($i = 1; $i <= $nbrDup[$key]; $i++) { $val = null; foreach ($row as $key2 => $value2) { - $key2 == "name" ? ($name = $value2 = $value2."_".$i) : null; - $val ? $val .= ($value2!=null?(", '".$value2."'"):", NULL") : $val .= ($value2!=null?("'".$value2."'"):"NULL"); + $key2 == "name" ? ($name = $value2 = $value2 . "_" . $i) : null; + $val + ? $val .= ($value2 != null ? (", '" . $value2 . "'") : ", NULL") + : $val .= ($value2 != null ? ("'" . $value2 . "'") : "NULL"); } if (testExistence($name)) { - $val ? $rq = "INSERT INTO giv_graphs_template VALUES (".$val.")" : $rq = null; + $val ? $rq = "INSERT INTO giv_graphs_template VALUES (" . $val . ")" : $rq = null; $pearDB->query($rq); } } @@ -100,7 +104,8 @@ function defaultOreonGraph() $rq = "SELECT DISTINCT graph_id FROM giv_graphs_template WHERE default_tpl1 = '1'"; $res = $pearDB->query($rq); if (!$res->rowCount()) { - $rq = "UPDATE giv_graphs_template SET default_tpl1 = '1' WHERE graph_id = (SELECT MIN(graph_id) FROM giv_graphs_template)"; + $rq = "UPDATE giv_graphs_template SET default_tpl1 = '1' " . + "WHERE graph_id = (SELECT MIN(graph_id) FROM giv_graphs_template)"; $pearDB->query($rq); } } @@ -137,22 +142,45 @@ function insertGraphTemplate() noDefaultOreonGraph(); } $rq = "INSERT INTO `giv_graphs_template` ( `graph_id` , `name` , " . - "`vertical_label` , `width` , `height` , `base` , `lower_limit`, `upper_limit` , `size_to_max`, `default_tpl1` , `split_component` , `scaled`, `stacked` , `comment`) "; + "`vertical_label` , `width` , `height` , `base` , `lower_limit`, `upper_limit` , `size_to_max`, " . + "`default_tpl1` , `split_component` , `scaled`, `stacked` , `comment`) "; $rq .= "VALUES ("; $rq .= "NULL, "; - isset($ret["name"]) && $ret["name"] != null ? $rq .= "'".htmlentities($ret["name"], ENT_QUOTES, "UTF-8")."', ": $rq .= "NULL, "; - isset($ret["vertical_label"]) && $ret["vertical_label"] != null ? $rq .= "'".htmlentities($ret["vertical_label"], ENT_QUOTES, "UTF-8")."', ": $rq .= "NULL, "; - isset($ret["width"]) && $ret["width"] != null ? $rq .= "'".htmlentities($ret["width"], ENT_QUOTES, "UTF-8")."', ": $rq .= "NULL, "; - isset($ret["height"]) && $ret["height"] != null ? $rq .= "'".htmlentities($ret["height"], ENT_QUOTES, "UTF-8")."', ": $rq .= "NULL, "; - isset($ret["base"]) && $ret["base"] != null ? $rq .= "'".htmlentities($ret["base"], ENT_QUOTES, "UTF-8")."', ": $rq .= "NULL, "; - isset($ret["lower_limit"]) && $ret["lower_limit"] != null ? $rq .= "'".$ret["lower_limit"]."', ": $rq .= "NULL, "; - isset($ret["upper_limit"]) && $ret["upper_limit"] != null ? $rq .= "'".$ret["upper_limit"]."', ": $rq .= "NULL, "; - isset($ret["size_to_max"]) && $ret["size_to_max"] != null ? $rq .= "'".$ret["size_to_max"]."', ": $rq .= "0, "; - isset($ret["default_tpl1"]) && $ret["default_tpl1"] != null ? $rq .= "'".$ret["default_tpl1"]."', ": $rq .= "NULL, "; + isset($ret["name"]) && $ret["name"] != null + ? $rq .= "'" . htmlentities($ret["name"], ENT_QUOTES, "UTF-8") . "', " + : $rq .= "NULL, "; + isset($ret["vertical_label"]) && $ret["vertical_label"] != null + ? $rq .= "'" . htmlentities($ret["vertical_label"], ENT_QUOTES, "UTF-8") . "', " + : $rq .= "NULL, "; + isset($ret["width"]) && $ret["width"] != null + ? $rq .= "'" . htmlentities($ret["width"], ENT_QUOTES, "UTF-8") . "', " + : $rq .= "NULL, "; + isset($ret["height"]) && $ret["height"] != null + ? $rq .= "'" . htmlentities($ret["height"], ENT_QUOTES, "UTF-8") . "', " + : $rq .= "NULL, "; + isset($ret["base"]) && $ret["base"] != null + ? $rq .= "'" . htmlentities($ret["base"], ENT_QUOTES, "UTF-8") . "', " + : $rq .= "NULL, "; + isset($ret["lower_limit"]) && $ret["lower_limit"] != null + ? $rq .= "'" . $ret["lower_limit"] . "', " + : $rq .= "NULL, "; + isset($ret["upper_limit"]) && $ret["upper_limit"] != null + ? $rq .= "'" . $ret["upper_limit"] . "', " + : $rq .= "NULL, "; + isset($ret["size_to_max"]) && $ret["size_to_max"] != null + ? $rq .= "'" . $ret["size_to_max"] . "', " + : $rq .= "0, "; + isset($ret["default_tpl1"]) && $ret["default_tpl1"] != null + ? $rq .= "'" . $ret["default_tpl1"] . "', " + : $rq .= "NULL, "; $rq .= "NULL, "; // Column split chart (removed options) - isset($ret["scaled"]) && $ret["scaled"] != null ? $rq .= "'".$ret["scaled"]."', ": $rq .= "'0', "; - isset($ret["stacked"]) && $ret["stacked"] != null ? $rq .= "'".htmlentities($ret["stacked"], ENT_QUOTES, "UTF-8")."', ": $rq .= "NULL, "; - isset($ret["comment"]) && $ret["comment"] != null ? $rq .= "'".htmlentities($ret["comment"], ENT_QUOTES, "UTF-8")."'": $rq .= "NULL"; + isset($ret["scaled"]) && $ret["scaled"] != null ? $rq .= "'" . $ret["scaled"] . "', " : $rq .= "'0', "; + isset($ret["stacked"]) && $ret["stacked"] != null + ? $rq .= "'" . htmlentities($ret["stacked"], ENT_QUOTES, "UTF-8") . "', " + : $rq .= "NULL, "; + isset($ret["comment"]) && $ret["comment"] != null + ? $rq .= "'" . htmlentities($ret["comment"], ENT_QUOTES, "UTF-8") . "'" + : $rq .= "NULL"; $rq .= ")"; $pearDB->query($rq); defaultOreonGraph(); @@ -175,32 +203,50 @@ function updateGraphTemplate($graph_id = null) } $rq = "UPDATE giv_graphs_template "; $rq .= "SET name = "; - isset($ret["name"]) && $ret["name"] != null ? $rq .= "'".htmlentities($ret["name"], ENT_QUOTES, "UTF-8")."', ": $rq .= "NULL, "; - $rq .= "vertical_label = "; - isset($ret["vertical_label"]) && $ret["vertical_label"] != null ? $rq .= "'".htmlentities($ret["vertical_label"], ENT_QUOTES, "UTF-8")."', ": $rq .= "NULL, "; + isset($ret["name"]) && $ret["name"] != null + ? $rq .= "'" . htmlentities($ret["name"], ENT_QUOTES, "UTF-8") . "', " + : $rq .= "NULL, "; + $rq .= "vertical_label = "; + isset($ret["vertical_label"]) && $ret["vertical_label"] != null + ? $rq .= "'" . htmlentities($ret["vertical_label"], ENT_QUOTES, "UTF-8") . "', " + : $rq .= "NULL, "; $rq .= "width = "; - isset($ret["width"]) && $ret["width"] != null ? $rq .= "'".$ret["width"]."', ": $rq .= "NULL, "; + isset($ret["width"]) && $ret["width"] != null ? $rq .= "'" . $ret["width"] . "', " : $rq .= "NULL, "; $rq .= "height = "; - isset($ret["height"]) && $ret["height"] != null ? $rq .= "'".$ret["height"]."', ": $rq .= "NULL, "; + isset($ret["height"]) && $ret["height"] != null ? $rq .= "'" . $ret["height"] . "', " : $rq .= "NULL, "; $rq .= "base = "; - isset($ret["base"]) && $ret["base"] != null ? $rq .= "'".$ret["base"]."', ": $rq .= "NULL, "; + isset($ret["base"]) && $ret["base"] != null ? $rq .= "'" . $ret["base"] . "', " : $rq .= "NULL, "; $rq .= "lower_limit = "; - isset($ret["lower_limit"]) && $ret["lower_limit"] != null ? $rq .= "'".$ret["lower_limit"]."', ": $rq .= "NULL, "; + isset($ret["lower_limit"]) && $ret["lower_limit"] != null + ? $rq .= "'" . $ret["lower_limit"] . "', " + : $rq .= "NULL, "; $rq .= "upper_limit = "; - isset($ret["upper_limit"]) && $ret["upper_limit"] != null ? $rq .= "'".$ret["upper_limit"]."', ": $rq .= "NULL, "; + isset($ret["upper_limit"]) && $ret["upper_limit"] != null + ? $rq .= "'" . $ret["upper_limit"] . "', " + : $rq .= "NULL, "; $rq .= "size_to_max = "; - isset($ret["size_to_max"]) && $ret["size_to_max"] != null ? $rq .= "'".$ret["size_to_max"]."', ": $rq .= "0, "; + isset($ret["size_to_max"]) && $ret["size_to_max"] != null + ? $rq .= "'" . $ret["size_to_max"] . "', " + : $rq .= "0, "; $rq .= "default_tpl1 = "; - isset($ret["default_tpl1"]) && $ret["default_tpl1"] != null ? $rq .= "'".$ret["default_tpl1"]."', ": $rq .= "NULL, "; + isset($ret["default_tpl1"]) && $ret["default_tpl1"] != null + ? $rq .= "'" . $ret["default_tpl1"] . "', " + : $rq .= "NULL, "; $rq .= "split_component = "; - isset($ret["split_component"]) && $ret["split_component"] != null ? $rq .= "'".$ret["split_component"]."', ": $rq .= "NULL, "; + isset($ret["split_component"]) && $ret["split_component"] != null + ? $rq .= "'" . $ret["split_component"] . "', " + : $rq .= "NULL, "; $rq .= "scaled = "; - isset($ret["scaled"]) && $ret["scaled"] != null ? $rq .= "'".$ret["scaled"]."', ": $rq .= "'0', "; + isset($ret["scaled"]) && $ret["scaled"] != null ? $rq .= "'" . $ret["scaled"] . "', " : $rq .= "'0', "; $rq .= "stacked = "; - isset($ret["stacked"]) && $ret["stacked"] != null ? $rq .= "'".$ret["stacked"]."', ": $rq .= "NULL, "; + isset($ret["stacked"]) && $ret["stacked"] != null + ? $rq .= "'" . $ret["stacked"] . "', " + : $rq .= "NULL, "; $rq .= "comment = "; - isset($ret["comment"]) && $ret["comment"] != null ? $rq .= "'".htmlentities($ret["comment"], ENT_QUOTES, "UTF-8")."' ": $rq .= "NULL "; - $rq .= "WHERE graph_id = '".$graph_id."'"; + isset($ret["comment"]) && $ret["comment"] != null + ? $rq .= "'" . htmlentities($ret["comment"], ENT_QUOTES, "UTF-8") . "' " + : $rq .= "NULL "; + $rq .= "WHERE graph_id = '" . $graph_id . "'"; $pearDB->query($rq); defaultOreonGraph(); } diff --git a/www/include/views/graphTemplates/formGraphTemplate.php b/www/include/views/graphTemplates/formGraphTemplate.php index 3cddd10d968..9ef34c403ca 100644 --- a/www/include/views/graphTemplates/formGraphTemplate.php +++ b/www/include/views/graphTemplates/formGraphTemplate.php @@ -38,7 +38,7 @@ $graph = array(); if (($o == "c" || $o == "w") && $graph_id) { - $res = $pearDB->query("SELECT * FROM giv_graphs_template WHERE graph_id = '".$graph_id."' LIMIT 1"); + $res = $pearDB->query("SELECT * FROM giv_graphs_template WHERE graph_id = '" . $graph_id . "' LIMIT 1"); /* * Set base value */ @@ -63,15 +63,15 @@ # Var information to format the element # -$attrsText = array("size"=>"30"); -$attrsText2 = array("size"=>"6"); +$attrsText = array("size" => "30"); +$attrsText2 = array("size" => "6"); $attrsAdvSelect = array("style" => "width: 200px; height: 100px;"); -$attrsTextarea = array("rows"=>"3", "cols"=>"30"); +$attrsTextarea = array("rows" => "3", "cols" => "30"); # ## Form begin # -$form = new HTML_QuickForm('Form', 'post', "?p=".$p); +$form = new HTML_QuickForm('Form', 'post', "?p=" . $p); if ($o == "a") { $form->addElement('header', 'ftitle', _("Add a Graph Template")); } elseif ($o == "c") { @@ -87,47 +87,55 @@ $form->addElement('header', 'color', _("Legend")); $form->addElement('text', 'name', _("Template Name"), $attrsText); -$form->addElement('select', 'img_format', _("Image Type"), array("PNG"=>"PNG", "GIF"=>"GIF")); +$form->addElement('select', 'img_format', _("Image Type"), array("PNG" => "PNG", "GIF" => "GIF")); $form->addElement('text', 'vertical_label', _("Vertical Label"), $attrsText); $form->addElement('text', 'width', _("Width"), $attrsText2); $form->addElement('text', 'height', _("Height"), $attrsText2); $form->addElement('text', 'lower_limit', _("Lower Limit"), $attrsText2); -$form->addElement('text', 'upper_limit', _("Upper Limit"), array('id' => 'upperLimitTxt', - 'size' => '6')); -$form->addElement('checkbox', 'size_to_max', _("Size to max"), '', array('id' => 'sizeToMax', - 'onClick' => 'sizeToMaxx();')); +$form->addElement('text', 'upper_limit', _("Upper Limit"), array( + 'id' => 'upperLimitTxt', + 'size' => '6' +)); +$form->addElement('checkbox', 'size_to_max', _("Size to max"), '', array( + 'id' => 'sizeToMax', + 'onClick' => 'sizeToMaxx();' +)); $form->addElement('text', 'ds_name', _("Data Source Name"), $attrsText); -$form->addElement('select', 'base', _("Base"), array("1000"=>"1000", "1024"=>"1024")); +$form->addElement('select', 'base', _("Base"), array("1000" => "1000", "1024" => "1024")); -$periods = array( "10800"=>_("Last 3 Hours"), - "21600"=>_("Last 6 Hours"), - "43200"=>_("Last 12 Hours"), - "86400"=>_("Last 24 Hours"), - "172800"=>_("Last 2 Days"), - "302400"=>_("Last 4 Days"), - "604800"=>_("Last 7 Days"), - "1209600"=>_("Last 14 Days"), - "2419200"=>_("Last 28 Days"), - "2592000"=>_("Last 30 Days"), - "2678400"=>_("Last 31 Days"), - "5184000"=>_("Last 2 Months"), - "10368000"=>_("Last 4 Months"), - "15552000"=>_("Last 6 Months"), - "31104000"=>_("Last Year")); +$periods = array( + "10800" => _("Last 3 Hours"), + "21600" => _("Last 6 Hours"), + "43200" => _("Last 12 Hours"), + "86400" => _("Last 24 Hours"), + "172800" => _("Last 2 Days"), + "302400" => _("Last 4 Days"), + "604800" => _("Last 7 Days"), + "1209600" => _("Last 14 Days"), + "2419200" => _("Last 28 Days"), + "2592000" => _("Last 30 Days"), + "2678400" => _("Last 31 Days"), + "5184000" => _("Last 2 Months"), + "10368000" => _("Last 4 Months"), + "15552000" => _("Last 6 Months"), + "31104000" => _("Last Year") +); $sel = $form->addElement('select', 'period', _("Graph Period"), $periods); -$steps = array( "0"=>_("No Step"), - "2"=>"2", - "6"=>"6", - "10"=>"10", - "20"=>"20", - "50"=>"50", - "100"=>"100"); +$steps = array( + "0" => _("No Step"), + "2" => "2", + "6" => "6", + "10" => "10", + "20" => "20", + "50" => "50", + "100" => "100" +); $sel = $form->addElement('select', 'step', _("Recovery Step"), $steps); if ($o == "c" || $o == "a") { - $form->addElement('button', $nameColor.'_modify', _("Modify"), $attrsText5); + $form->addElement('button', $nameColor . '_modify', _("Modify"), $attrsText5); } $form->addElement('checkbox', 'stacked', _("Stacking")); @@ -150,7 +158,7 @@ $form->addRule('title', _("Required Field"), 'required'); $form->registerRule('exist', 'callback', 'testExistence'); $form->addRule('name', _("Name is already in use"), 'exist'); -$form->setRequiredNote("* ". _("Required fields")); +$form->setRequiredNote("* " . _("Required fields")); /* @@ -162,7 +170,12 @@ # Just watch if ($o == "w") { - $form->addElement("button", "change", _("Modify"), array("onClick"=>"javascript:window.location.href='?p=".$p."&o=c&graph_id=".$graph_id."'")); + $form->addElement( + "button", + "change", + _("Modify"), + array("onClick" => "javascript:window.location.href='?p=" . $p . "&o=c&graph_id=" . $graph_id . "'") + ); $form->setDefaults($graph); $form->freeze(); } elseif ($o == "c") { @@ -173,16 +186,16 @@ $subA = $form->addElement('submit', 'submitA', _("Save"), array("class" => "btc bt_success")); $res = $form->addElement('reset', 'reset', _("Delete"), array("class" => "btc bt_danger")); } -$tpl->assign('msg', array ("changeL"=>"?p=".$p."&o=c&graph_id=".$graph_id, "changeT"=>_("Modify"))); +$tpl->assign('msg', array("changeL" => "?p=" . $p . "&o=c&graph_id=" . $graph_id, "changeT" => _("Modify"))); $tpl->assign("sort1", _("Properties")); $tpl->assign("sort2", _("Data Sources")); - // prepare help texts +// prepare help texts $helptext = ""; include_once("help.php"); foreach ($help as $key => $text) { - $helptext .= ''."\n"; + $helptext .= '' . "\n"; } $tpl->assign("helptext", $helptext); @@ -209,7 +222,15 @@ function popup_color_picker(t,name) { hcolor = bckcolor.substr(1,6); } } - Modalbox.show('./include/common/javascript/color_picker_mb.php?name='+name, { title: '" . _('Pick a color') . "', width: width, height: height , afterLoad: function(){cp_init(t, hcolor);} }); + Modalbox.show( + './include/common/javascript/color_picker_mb.php?name='+name, + { + title: '" . _('Pick a color') . "', + width: width, + height: height , + afterLoad: function(){cp_init(t, hcolor);} + } + ); } "); @@ -227,7 +248,12 @@ function popup_color_picker(t,name) { updateGraphTemplateInDB($graphObj->getValue()); } $o = "w"; - $form->addElement("button", "change", _("Modify"), array("onClick"=>"javascript:window.location.href='?p=".$p."&o=c&graph_id=".$graphObj->getValue()."'")); + $form->addElement( + "button", + "change", + _("Modify"), + array("onClick" => "javascript:window.location.href='?p=" . $p . "&o=c&graph_id=" . $graphObj->getValue() . "'") + ); $form->freeze(); $valid = true; } @@ -247,18 +273,18 @@ function popup_color_picker(t,name) { } ?> diff --git a/www/include/views/graphTemplates/graphTemplates.php b/www/include/views/graphTemplates/graphTemplates.php index 969e8294a10..d8e16266117 100644 --- a/www/include/views/graphTemplates/graphTemplates.php +++ b/www/include/views/graphTemplates/graphTemplates.php @@ -48,7 +48,7 @@ isset($_GET["dupNbr"]) ? $cG = $_GET["dupNbr"] : $cG = null; isset($_POST["dupNbr"]) ? $cP = $_POST["dupNbr"] : $cP = null; $cG ? $dupNbr = $cG : $dupNbr = $cP; - + /* * Pear library */ @@ -64,36 +64,36 @@ /* * PHP functions */ -require_once $path."DB-Func.php"; +require_once $path . "DB-Func.php"; require_once "./include/common/common-Func.php"; switch ($o) { case "a": - require_once $path."formGraphTemplate.php"; + require_once $path . "formGraphTemplate.php"; break; #Add a Graph Template case "w": - require_once $path."formGraphTemplate.php"; + require_once $path . "formGraphTemplate.php"; break; #Watch aGraph Template case "c": - require_once $path."formGraphTemplate.php"; + require_once $path . "formGraphTemplate.php"; break; #Modify a Graph Template case "s": enableGraphTemplateInDB($lca_id); - require_once $path."listGraphTemplates.php"; + require_once $path . "listGraphTemplates.php"; break; #Activate a Graph Template case "u": disableGraphTemplateInDB($lca_id); - require_once $path."listGraphTemplates.php"; + require_once $path . "listGraphTemplates.php"; break; #Desactivate a Graph Template case "m": multipleGraphTemplateInDB(isset($select) ? $select : array(), $dupNbr); - require_once $path."listGraphTemplates.php"; + require_once $path . "listGraphTemplates.php"; break; #Duplicate n Graph Templates case "d": deleteGraphTemplateInDB(isset($select) ? $select : array()); - require_once $path."listGraphTemplates.php"; + require_once $path . "listGraphTemplates.php"; break; #Delete n Graph Templates default: - require_once $path."listGraphTemplates.php" ; + require_once $path . "listGraphTemplates.php"; break; } diff --git a/www/include/views/graphTemplates/listGraphTemplates.php b/www/include/views/graphTemplates/listGraphTemplates.php index c117018e851..ae329073b7f 100644 --- a/www/include/views/graphTemplates/listGraphTemplates.php +++ b/www/include/views/graphTemplates/listGraphTemplates.php @@ -43,10 +43,10 @@ $search = ''; if (isset($_POST['searchGT']) && $_POST['searchGT']) { $search = $_POST['searchGT']; - $SearchTool = " WHERE name LIKE '%".$search."%'"; + $SearchTool = " WHERE name LIKE '%" . $search . "%'"; } -$res = $pearDB->query("SELECT COUNT(*) FROM giv_graphs_template".$SearchTool); +$res = $pearDB->query("SELECT COUNT(*) FROM giv_graphs_template" . $SearchTool); $tmp = $res->fetchRow(); $rows = $tmp["COUNT(*)"]; @@ -68,10 +68,11 @@ $tpl->assign("headerMenu_options", _("Options")); #List -$rq = "SELECT graph_id, name, default_tpl1, vertical_label, base, split_component FROM giv_graphs_template gg $SearchTool ORDER BY name LIMIT ".$num * $limit.", ".$limit; +$rq = "SELECT graph_id, name, default_tpl1, vertical_label, base, split_component " . + "FROM giv_graphs_template gg $SearchTool ORDER BY name LIMIT " . $num * $limit . ", " . $limit; $res = $pearDB->query($rq); -$form = new HTML_QuickForm('select_form', 'POST', "?p=".$p); +$form = new HTML_QuickForm('select_form', 'POST', "?p=" . $p); /* * Different style between each lines */ @@ -81,16 +82,21 @@ */ $elemArr = array(); for ($i = 0; $graph = $res->fetchRow(); $i++) { - $selectedElements = $form->addElement('checkbox', "select[".$graph['graph_id']."]"); - $moptions = " 31 && (event.keyCode < 45 || event.keyCode > 57)) event.returnValue = false; if(event.which > 31 && (event.which < 45 || event.which > 57)) return false;\" maxlength=\"3\" size=\"3\" value='1' style=\"margin-bottom:0px;\" name='dupNbr[".$graph['graph_id']."]'>"; - $elemArr[$i] = array("MenuClass"=>"list_".$style, - "RowMenu_select"=>$selectedElements->toHtml(), - "RowMenu_name"=>$graph["name"], - "RowMenu_link"=>"?p=".$p."&o=c&graph_id=".$graph['graph_id'], - "RowMenu_desc"=>$graph["vertical_label"], - "RowMenu_base"=>$graph["base"], - "RowMenu_split_component"=>$graph["split_component"] ? _("Yes") : _("No"), - "RowMenu_options"=>$moptions); + $selectedElements = $form->addElement('checkbox', "select[" . $graph['graph_id'] . "]"); + $moptions = " 31 && (event.keyCode < 45 || event.keyCode > 57)) " . + "event.returnValue = false; if(event.which > 31 && (event.which < 45 || event.which > 57)) return false;" . + "\" maxlength=\"3\" size=\"3\" value='1' style=\"margin-bottom:0px;\" name='dupNbr[" . + $graph['graph_id'] . "]' />"; + $elemArr[$i] = array( + "MenuClass" => "list_" . $style, + "RowMenu_select" => $selectedElements->toHtml(), + "RowMenu_name" => $graph["name"], + "RowMenu_link" => "?p=" . $p . "&o=c&graph_id=" . $graph['graph_id'], + "RowMenu_desc" => $graph["vertical_label"], + "RowMenu_base" => $graph["base"], + "RowMenu_split_component" => $graph["split_component"] ? _("Yes") : _("No"), + "RowMenu_options" => $moptions + ); $style != "two" ? $style = "two" : $style = "one"; } $tpl->assign("elemArr", $elemArr); @@ -98,42 +104,63 @@ /* * Different messages we put in the template */ -$tpl->assign('msg', array ("addL"=>"?p=".$p."&o=a", "addT"=>_("Add"), "delConfirm"=>_("Do you confirm the deletion ?"))); +$tpl->assign( + 'msg', + array("addL" => "?p=" . $p . "&o=a", "addT" => _("Add"), "delConfirm" => _("Do you confirm the deletion ?")) +); /* * Toolbar select */ ?> - + "javascript: " . - "if (this.form.elements['o1'].selectedIndex == 1 && confirm('"._("Do you confirm the duplication ?")."')) {" . - " setO(this.form.elements['o1'].value); submit();} " . - "else if (this.form.elements['o1'].selectedIndex == 2 && confirm('"._("Do you confirm the deletion ?")."')) {" . - " setO(this.form.elements['o1'].value); submit();} " . - "else if (this.form.elements['o1'].selectedIndex == 3) {" . - " setO(this.form.elements['o1'].value); submit();} " . - ""); -$form->addElement('select', 'o1', null, array(null=>_("More actions..."), "m"=>_("Duplicate"), "d"=>_("Delete")), $attrs1); + 'onchange' => "javascript: " . + "if (this.form.elements['o1'].selectedIndex == 1 && confirm('" . + _("Do you confirm the duplication ?") . "')) {" . + " setO(this.form.elements['o1'].value); submit();} " . + "else if (this.form.elements['o1'].selectedIndex == 2 && confirm('" . + _("Do you confirm the deletion ?") . "')) {" . + " setO(this.form.elements['o1'].value); submit();} " . + "else if (this.form.elements['o1'].selectedIndex == 3) {" . + " setO(this.form.elements['o1'].value); submit();} " . + "" +); +$form->addElement( + 'select', + 'o1', + null, + array(null => _("More actions..."), "m" => _("Duplicate"), "d" => _("Delete")), + $attrs1 +); $form->setDefaults(array('o1' => null)); $o1 = $form->getElement('o1'); $o1->setValue(null); $attrs = array( - 'onchange'=>"javascript: " . - "if (this.form.elements['o2'].selectedIndex == 1 && confirm('"._("Do you confirm the duplication ?")."')) {" . - " setO(this.form.elements['o2'].value); submit();} " . - "else if (this.form.elements['o2'].selectedIndex == 2 && confirm('"._("Do you confirm the deletion ?")."')) {" . - " setO(this.form.elements['o2'].value); submit();} " . - "else if (this.form.elements['o2'].selectedIndex == 3) {" . - " setO(this.form.elements['o2'].value); submit();} " . - ""); -$form->addElement('select', 'o2', null, array(null=>_("More actions..."), "m"=>_("Duplicate"), "d"=>_("Delete")), $attrs); + 'onchange' => "javascript: " . + "if (this.form.elements['o2'].selectedIndex == 1 && confirm('" . + _("Do you confirm the duplication ?") . "')) {" . + " setO(this.form.elements['o2'].value); submit();} " . + "else if (this.form.elements['o2'].selectedIndex == 2 && confirm('" . + _("Do you confirm the deletion ?") . "')) {" . + " setO(this.form.elements['o2'].value); submit();} " . + "else if (this.form.elements['o2'].selectedIndex == 3) {" . + " setO(this.form.elements['o2'].value); submit();} " . + "" +); +$form->addElement( + 'select', + 'o2', + null, + array(null => _("More actions..."), "m" => _("Duplicate"), "d" => _("Delete")), + $attrs +); $form->setDefaults(array('o2' => null)); $o2 = $form->getElement('o2'); From 8e9590c54ba45dc8ac9672a0cbaeb659fe98de96 Mon Sep 17 00:00:00 2001 From: loiclau Date: Thu, 17 Aug 2017 17:24:47 +0200 Subject: [PATCH 184/207] * fix style eventLogs --- www/include/eventLogs/export/data.php | 82 +-- www/include/eventLogs/viewLog.php | 910 +++++++++++++------------- www/include/eventLogs/xml/data.php | 153 +++-- 3 files changed, 592 insertions(+), 553 deletions(-) diff --git a/www/include/eventLogs/export/data.php b/www/include/eventLogs/export/data.php index 415f479cdda..bb462f3e81b 100644 --- a/www/include/eventLogs/export/data.php +++ b/www/include/eventLogs/export/data.php @@ -50,8 +50,8 @@ /** ***************************************** * Connect MySQL DB */ -$pearDB = new CentreonDB(); -$pearDBO = new CentreonDB("centstorage"); +$pearDB = new CentreonDB(); +$pearDBO = new CentreonDB("centstorage"); /** * Security check @@ -79,7 +79,7 @@ */ $csv_flag = 1; //setting the csv_flag variable to change limit in SQL request of getODSXmlLog.php when CSV exporting ob_start(); -require_once _CENTREON_PATH_."www/include/eventLogs/xml/data.php"; +require_once _CENTREON_PATH_ . "www/include/eventLogs/xml/data.php"; $flow = ob_get_contents(); ob_end_clean(); @@ -96,57 +96,59 @@ */ $xml = new SimpleXMLElement($flow); if ($engine == "false") { - echo _("Begin date")."; "._("End date").";\n"; + echo _("Begin date") . "; " . _("End date") . ";\n"; echo date(_('m/d/Y (H:i:s)'), intval($xml->infos->start)) - .";".date(_('m/d/Y (H:i:s)'), intval($xml->infos->end))."\n"; + . ";" . date(_('m/d/Y (H:i:s)'), intval($xml->infos->end)) . "\n"; echo "\n"; - echo _("Type").";"._("Notification").";"._("Alert").";"._("error")."\n"; - echo ";".$xml->infos->notification.";".$xml->infos->alert.";".$xml->infos->error."\n"; + echo _("Type") . ";" . _("Notification") . ";" . _("Alert") . ";" . _("error") . "\n"; + echo ";" . $xml->infos->notification . ";" . $xml->infos->alert . ";" . $xml->infos->error . "\n"; echo "\n"; - echo _("Host").";"._("Up").";"._("Down").";"._("Unreachable")."\n"; - echo ";".$xml->infos->up.";".$xml->infos->down.";".$xml->infos->unreachable."\n"; + echo _("Host") . ";" . _("Up") . ";" . _("Down") . ";" . _("Unreachable") . "\n"; + echo ";" . $xml->infos->up . ";" . $xml->infos->down . ";" . $xml->infos->unreachable . "\n"; echo "\n"; - echo _("Service").";"._("Ok").";"._("Warning").";"._("Critical").";"._("Unknown")."\n"; - echo ";".$xml->infos->ok.";".$xml->infos->warning.";".$xml->infos->critical.";".$xml->infos->unknown."\n"; + echo _("Service") . ";" . _("Ok") . ";" . _("Warning") . ";" . _("Critical") . ";" . _("Unknown") . "\n"; + echo ";" . $xml->infos->ok . ";" . $xml->infos->warning . ";" . + $xml->infos->critical . ";" . $xml->infos->unknown . "\n"; echo "\n"; - echo _("Day").";". - _("Time").";". - _("Host").";". - _("Address").";". - _("Service").";". - _("Status").";". - _("Type").";". - _("Retry").";". - _("Output").";". - _("Contact").";". - _("Cmd")."\n"; + echo _("Day") . ";" . + _("Time") . ";" . + _("Host") . ";" . + _("Address") . ";" . + _("Service") . ";" . + _("Status") . ";" . + _("Type") . ";" . + _("Retry") . ";" . + _("Output") . ";" . + _("Contact") . ";" . + _("Cmd") . "\n"; foreach ($xml->line as $line) { - echo $line->date.";". - $line->time.";". - $line->host_name.";". - $line->address.";". - $line->service_description.";". - $line->status.";". - $line->type.";". - $line->retry.";". - $line->output.";". - $line->contact.";". - $line->contact_cmd."\n"; + echo $line->date . ";" . + $line->time . ";" . + $line->host_name . ";" . + $line->address . ";" . + $line->service_description . ";" . + $line->status . ";" . + $line->type . ";" . + $line->retry . ";" . + $line->output . ";" . + $line->contact . ";" . + $line->contact_cmd . "\n"; } } else { - echo _("Begin date")."; "._("End date").";\n"; - echo date(_('m/d/Y (H:i:s)'), intval($xml->infos->start)).";". - date(_('m/d/Y (H:i:s)'), intval($xml->infos->end))."\n"; + echo _("Begin date") . "; " . _("End date") . ";\n"; + echo date(_('m/d/Y (H:i:s)'), intval($xml->infos->start)) . ";" . + date(_('m/d/Y (H:i:s)'), intval($xml->infos->end)) . "\n"; echo "\n"; - echo _("Type").";"._("Notification").";"._("Alert").";"._("error")."\n"; - echo ";".$xml->infos->notification.";".$xml->infos->alert.";".$xml->infos->error."\n"; + echo _("Type") . ";" . _("Notification") . ";" . _("Alert") . ";" . _("error") . "\n"; + echo ";" . $xml->infos->notification . ";" . $xml->infos->alert . ";" . $xml->infos->error . "\n"; echo "\n"; - echo _("Day").";"._("Time").";"._("Poller").";"._("Output").";"."\n"; + echo _("Day") . ";" . _("Time") . ";" . _("Poller") . ";" . _("Output") . ";" . "\n"; foreach ($xml->line as $line) { - echo "\"".$line->date."\";\"".$line->time."\";\"".$line->poller."\";\"".$line->output."\";"."\n"; + echo "\"" . $line->date . "\";\"" . $line->time . "\";\"" . $line->poller . + "\";\"" . $line->output . "\";" . "\n"; } } diff --git a/www/include/eventLogs/viewLog.php b/www/include/eventLogs/viewLog.php index f6072c5634c..dbc457ece71 100644 --- a/www/include/eventLogs/viewLog.php +++ b/www/include/eventLogs/viewLog.php @@ -242,7 +242,7 @@ $form->addElement('select2', 'host_filter', _("Hosts"), array(), $attrHost1); $serviceGroupRoute = './include/common/webServices/rest/' - .'internal.php?object=centreon_configuration_servicegroup&action=list'; + . 'internal.php?object=centreon_configuration_servicegroup&action=list'; $attrServicegroup1 = array( 'datasourceOrigin' => 'ajax', 'allowClear' => false, @@ -300,503 +300,515 @@ diff --git a/www/include/eventLogs/xml/data.php b/www/include/eventLogs/xml/data.php index 79653546bc0..99e99a7c2ad 100644 --- a/www/include/eventLogs/xml/data.php +++ b/www/include/eventLogs/xml/data.php @@ -177,7 +177,11 @@ $is_admin = isUserAdmin($sid); if (isset($sid) && $sid) { $access = new CentreonAcl($contact_id, $is_admin); - $lca = array("LcaHost" => $access->getHostsServices($pearDBO, 1), "LcaHostGroup" => $access->getHostGroups(), "LcaSG" => $access->getServiceGroups()); + $lca = array( + "LcaHost" => $access->getHostsServices($pearDBO, 1), + "LcaHostGroup" => $access->getHostGroups(), + "LcaSG" => $access->getServiceGroups() + ); } $num = isset($inputs["num"]) ? htmlentities($inputs["num"]) : "0"; @@ -234,12 +238,12 @@ if ($StartDate != "") { preg_match("/^([0-9]*)\/([0-9]*)\/([0-9]*)/", $StartDate, $matchesD); preg_match("/^([0-9]*):([0-9]*)/", $StartTime, $matchesT); - $start = mktime($matchesT[1], $matchesT[2], "0", $matchesD[1], $matchesD[2], $matchesD[3], -1) ; + $start = mktime($matchesT[1], $matchesT[2], "0", $matchesD[1], $matchesD[2], $matchesD[3], -1); } -if ($EndDate != "") { +if ($EndDate != "") { preg_match("/^([0-9]*)\/([0-9]*)\/([0-9]*)/", $EndDate, $matchesD); preg_match("/^([0-9]*):([0-9]*)/", $EndTime, $matchesT); - $end = mktime($matchesT[1], $matchesT[2], "0", $matchesD[1], $matchesD[2], $matchesD[3], -1) ; + $end = mktime($matchesT[1], $matchesT[2], "0", $matchesD[1], $matchesD[2], $matchesD[3], -1); } $period = 86400; @@ -251,8 +255,14 @@ $general_opt = getStatusColor($pearDB); -$tab_color_service = array(STATUS_OK => 'service_ok', STATUS_WARNING => 'service_warning', STATUS_CRITICAL => 'service_critical', STATUS_UNKNOWN => 'service_unknown', STATUS_PENDING => 'pending'); -$tab_color_host = array(STATUS_UP => 'host_up', STATUS_DOWN => 'host_down', STATUS_UNREACHABLE => 'host_unreachable'); +$tab_color_service = array( + STATUS_OK => 'service_ok', + STATUS_WARNING => 'service_warning', + STATUS_CRITICAL => 'service_critical', + STATUS_UNKNOWN => 'service_unknown', + STATUS_PENDING => 'pending' +); +$tab_color_host = array(STATUS_UP => 'host_up', STATUS_DOWN => 'host_down', STATUS_UNREACHABLE => 'host_unreachable'); $tab_type = array("1" => "HARD", "0" => "SOFT"); $tab_class = array("0" => "list_one", "1" => "list_two"); @@ -297,7 +307,7 @@ $buffer->writeElement("search_S", $search_S); $buffer->endElement(); -$msg_type_set = array (); +$msg_type_set = array(); if ($alert == 'true') { array_push($msg_type_set, "'0'"); } @@ -307,7 +317,7 @@ if ($notification == 'true') { array_push($msg_type_set, "'2'"); } -if ($notification== 'true') { +if ($notification == 'true') { array_push($msg_type_set, "'3'"); } if ($error == 'true') { @@ -319,39 +329,40 @@ $host_msg_status_set = array(); if ($up == 'true') { - array_push($host_msg_status_set, "'".STATUS_UP."'"); + array_push($host_msg_status_set, "'" . STATUS_UP . "'"); } if ($down == 'true') { - array_push($host_msg_status_set, "'".STATUS_DOWN."'"); + array_push($host_msg_status_set, "'" . STATUS_DOWN . "'"); } if ($unreachable == 'true') { - array_push($host_msg_status_set, "'".STATUS_UNREACHABLE."'"); + array_push($host_msg_status_set, "'" . STATUS_UNREACHABLE . "'"); } $svc_msg_status_set = array(); if ($ok == 'true') { - array_push($svc_msg_status_set, "'".STATUS_OK."'"); + array_push($svc_msg_status_set, "'" . STATUS_OK . "'"); } if ($warning == 'true') { - array_push($svc_msg_status_set, "'".STATUS_WARNING."'"); + array_push($svc_msg_status_set, "'" . STATUS_WARNING . "'"); } if ($critical == 'true') { - array_push($svc_msg_status_set, "'".STATUS_CRITICAL."'"); + array_push($svc_msg_status_set, "'" . STATUS_CRITICAL . "'"); } if ($unknown == 'true') { - array_push($svc_msg_status_set, "'".STATUS_UNKNOWN."'"); + array_push($svc_msg_status_set, "'" . STATUS_UNKNOWN . "'"); } $flag_begin = 0; $whereOutput = ""; if (isset($output) && $output != "") { - $whereOutput = " AND logs.output like '%".$pearDBO->escape($output)."%' "; + $whereOutput = " AND logs.output like '%" . $pearDBO->escape($output) . "%' "; } $innerJoinEngineLog = ""; if ($engine == "true" && isset($openid) && $openid != "") { - $innerJoinEngineLog = " inner join instances i on i.name = logs.instance_name AND i.instance_id IN (" . $pearDBO->escape($openid) . ") "; + $innerJoinEngineLog = " inner join instances i on i.name = logs.instance_name AND i.instance_id IN (" . + $pearDBO->escape($openid) . ") "; } if ($notification == 'true') { @@ -359,7 +370,7 @@ $msg_req .= "("; $flag_begin = 1; $msg_req .= " (`msg_type` = '3' "; - $msg_req .= " AND `status` IN (" . implode(',', $host_msg_status_set)."))"; + $msg_req .= " AND `status` IN (" . implode(',', $host_msg_status_set) . "))"; $msg_req .= ") "; } if (count($svc_msg_status_set)) { @@ -369,7 +380,7 @@ $msg_req .= " OR "; } $msg_req .= " (`msg_type` = '2' "; - $msg_req .= " AND `status` IN (" . implode(',', $svc_msg_status_set)."))"; + $msg_req .= " AND `status` IN (" . implode(',', $svc_msg_status_set) . "))"; if ($flag_begin == 0) { $msg_req .= ") "; } @@ -387,7 +398,7 @@ } $flag_begin = 1; $msg_req .= " ((`msg_type` IN ('1', '10', '11') "; - $msg_req .= " AND `status` IN (" . implode(',', $host_msg_status_set).")) "; + $msg_req .= " AND `status` IN (" . implode(',', $host_msg_status_set) . ")) "; $msg_req .= ") "; } if (count($svc_msg_status_set)) { @@ -399,7 +410,7 @@ } $flag_begin = 1; $msg_req .= " ((`msg_type` IN ('0', '10', '11') "; - $msg_req .= " AND `status` IN (" . implode(',', $svc_msg_status_set).")) "; + $msg_req .= " AND `status` IN (" . implode(',', $svc_msg_status_set) . ")) "; $msg_req .= ") "; } if ($flag_begin) { @@ -410,7 +421,7 @@ } if ($oh == 'true') { $flag_begin = 1; - $msg_req .= " `type` = '".TYPE_HARD."' "; + $msg_req .= " `type` = '" . TYPE_HARD . "' "; } } // Error filter is only used in the engine log page. @@ -423,7 +434,7 @@ $msg_req .= " `msg_type` IN ('4','5') "; } if ($flag_begin) { - $msg_req = " AND (".$msg_req.") "; + $msg_req = " AND (" . $msg_req . ") "; } $tab_id = preg_split("/\,/", $openid); @@ -445,10 +456,10 @@ if ($id == "") { continue; } - + $type = $tab_tmp[0]; - - + + if ($type == "HG" && (isset($lca["LcaHostGroup"][$id]) || $is_admin)) { $filters = true; // Get hosts from hostgroups @@ -489,12 +500,12 @@ $tab_svc[$hostId][$id] = $lca["LcaHost"][$hostId][$id]; } elseif ($type == "MS") { $filters = true; - $tab_svc["_Module_Meta"][$id] = "meta_".$id; + $tab_svc["_Module_Meta"][$id] = "meta_" . $id; } } // Build final request -$req = "SELECT SQL_CALC_FOUND_ROWS ".(!$is_admin ? "DISTINCT" : "")." +$req = "SELECT SQL_CALC_FOUND_ROWS " . (!$is_admin ? "DISTINCT" : "") . " logs.ctime, logs.host_id, logs.host_name, @@ -508,11 +519,11 @@ logs.status, logs.type, logs.instance_name - FROM logs ".$innerJoinEngineLog. + FROM logs " . $innerJoinEngineLog . ((!$is_admin) ? - " inner join centreon_acl acl on (logs.host_id = acl.host_id AND (acl.service_id IS NULL OR " - . " acl.service_id = logs.service_id)) " - . " WHERE acl.group_id IN (".$access->getAccessGroupsString().") AND " : "WHERE ") + " inner join centreon_acl acl on (logs.host_id = acl.host_id AND (acl.service_id IS NULL OR " + . " acl.service_id = logs.service_id)) " + . " WHERE acl.group_id IN (" . $access->getAccessGroupsString() . ") AND " : "WHERE ") . " logs.ctime > '$start' AND logs.ctime <= '$end' $whereOutput $msg_req"; /* @@ -536,17 +547,26 @@ if ($str_unitH != "") { $str_unitH = "(logs.host_id IN ($str_unitH) AND logs.service_id IS NULL)"; if (isset($search_host) && $search_host != "") { - $host_search_sql = " AND logs.host_name LIKE '%".$pearDBO->escape($search_host)."%' "; + $host_search_sql = " AND logs.host_name LIKE '%" . $pearDBO->escape($search_host) . "%' "; } } - + /* * Add services */ $flag = 0; $str_unitSVC = ""; $service_search_sql = ""; - if ((count($tab_svc) || count($tab_host_ids)) && ($up == 'true' || $down == 'true' || $unreachable == 'true' || $ok == 'true' || $warning == 'true' || $critical == 'true' || $unknown == 'true')) { + if ((count($tab_svc) || count($tab_host_ids)) && + ( + $up == 'true' || + $down == 'true' || + $unreachable == 'true' || + $ok == 'true' || $warning == 'true' || + $critical == 'true' || + $unknown == 'true' + ) + ) { $req_append = ""; foreach ($tab_svc as $host_id => $services) { $str = ""; @@ -558,18 +578,18 @@ } } if ($str != "") { - $str_unitSVC .= $req_append . " (logs.host_id = '".$host_id."' AND logs.service_id IN ($str)) "; + $str_unitSVC .= $req_append . " (logs.host_id = '" . $host_id . "' AND logs.service_id IN ($str)) "; $req_append = " OR"; } } if (isset($search_service) && $search_service != "") { - $service_search_sql = " AND logs.service_description LIKE '%".$pearDBO->escape($search_service)."%' "; + $service_search_sql = " AND logs.service_description LIKE '%" . $pearDBO->escape($search_service) . "%' "; } if ($str_unitH != "" && $str_unitSVC != "") { $str_unitSVC = " OR " . $str_unitSVC; } if ($str_unitH != "" || $str_unitSVC != "") { - $req .= " AND (".$str_unitH.$str_unitSVC.")"; + $req .= " AND (" . $str_unitH . $str_unitSVC . ")"; } } else { $req .= "AND 0 "; @@ -595,43 +615,43 @@ if ($export !== "1") { $limitReq = " LIMIT " . $num * $limit . ", " . $limit; } - $DBRESULT = $pearDBO->query($req .$limitReq); + $DBRESULT = $pearDBO->query($req . $limitReq); $rows = $pearDBO->numberRows(); - + if (!($DBRESULT->rowCount()) && ($num != 0)) { if ($export !== "1") { - $limitReq2 =" LIMIT " . (floor($rows / $limit) * $limit) . ", " . $limit; + $limitReq2 = " LIMIT " . (floor($rows / $limit) * $limit) . ", " . $limit; } $DBRESULT = $pearDBO->query($req . $limitReq2); } $buffer->startElement("selectLimit"); - for ($i = 10; $i <= 100; $i = $i +10) { + for ($i = 10; $i <= 100; $i = $i + 10) { $buffer->writeElement("limitValue", $i); } $buffer->writeElement("limit", $limit); $buffer->endElement(); - + require_once _CENTREON_PATH_ . "www/include/common/checkPagination.php"; /* * pagination */ - + $pageArr = array(); $istart = 0; for ($i = 5, $istart = $num; $istart > 0 && $i > 0; $i--) { $istart--; } - - for ($i2 = 0, $iend = $num; ( $iend < ($rows / $limit -1)) && ( $i2 < (5 + $i)); $i2++) { + + for ($i2 = 0, $iend = $num; ($iend < ($rows / $limit - 1)) && ($i2 < (5 + $i)); $i2++) { $iend++; } - + for ($i = $istart; $i <= $iend; $i++) { - $pageArr[$i] = array("url_page"=>"&num=$i&limit=".$limit, "label_page"=>($i +1),"num"=> $i); + $pageArr[$i] = array("url_page" => "&num=$i&limit=" . $limit, "label_page" => ($i + 1), "num" => $i); } - + if ($i > 1) { foreach ($pageArr as $key => $tab) { $buffer->startElement("page"); @@ -647,10 +667,10 @@ $buffer->endElement(); } } - + $prev = $num - 1; $next = $num + 1; - + if ($num > 0) { $buffer->startElement("first"); $buffer->writeAttribute("show", "true"); @@ -662,7 +682,7 @@ $buffer->text("none"); $buffer->endElement(); } - + if ($num > 1) { $buffer->startElement("prev"); $buffer->writeAttribute("show", "true"); @@ -674,7 +694,7 @@ $buffer->text("none"); $buffer->endElement(); } - + if ($num < $page_max - 1) { $buffer->startElement("next"); $buffer->writeAttribute("show", "true"); @@ -686,10 +706,10 @@ $buffer->text("none"); $buffer->endElement(); } - + $last = $page_max - 1; - - if ($num < $page_max-1) { + + if ($num < $page_max - 1) { $buffer->startElement("last"); $buffer->writeAttribute("show", "true"); $buffer->text($last); @@ -700,7 +720,7 @@ $buffer->text("none"); $buffer->endElement(); } - + /* * Full Request */ @@ -713,27 +733,32 @@ $displayType = $tab_type[$log['type']]; } $log["msg_type"] > 1 ? $buffer->writeElement("retry", "") : $buffer->writeElement("retry", $log["retry"]); - $log["msg_type"] == 2 || $log["msg_type"] == 3 ? $buffer->writeElement("type", "NOTIF") : $buffer->writeElement("type", $displayType); - + $log["msg_type"] == 2 || $log["msg_type"] == 3 + ? $buffer->writeElement("type", "NOTIF") + : $buffer->writeElement("type", $displayType); + /* * Color initialisation for services and hosts status */ $color = ''; if (isset($log["status"])) { - if (isset($tab_color_service[$log["status"]]) && isset($log["service_description"]) && $log["service_description"] != "") { + if (isset($tab_color_service[$log["status"]]) && + isset($log["service_description"]) && + $log["service_description"] != "" + ) { $color = $tab_color_service[$log["status"]]; } elseif (isset($tab_color_host[$log["status"]])) { $color = $tab_color_host[$log["status"]]; } } - + /* * Variable initialisation to color "INITIAL STATE" on envent logs */ if ($log["output"] == "" && $log["status"] != "") { $log["output"] = "INITIAL STATE"; } - + $buffer->startElement("status"); $buffer->writeAttribute("color", $color); $displayStatus = $log["status"]; @@ -744,10 +769,10 @@ } $buffer->text($displayStatus); $buffer->endElement(); - + if (!strncmp($log["host_name"], "_Module_Meta", strlen("_Module_Meta"))) { preg_match('/meta_([0-9]*)/', $log["service_description"], $matches); - $DBRESULT2 = $pearDB->query("SELECT meta_name FROM meta_service WHERE meta_id = '".$matches[1]."'"); + $DBRESULT2 = $pearDB->query("SELECT meta_name FROM meta_service WHERE meta_id = '" . $matches[1] . "'"); $meta = $DBRESULT2->fetchRow(); $DBRESULT2->closeCursor(); $buffer->writeElement("host_name", "Meta", false); From 6ca0f514cf6b1687686a641bea14d4ce247622df Mon Sep 17 00:00:00 2001 From: Kevin Duret Date: Thu, 17 Aug 2017 17:49:44 +0200 Subject: [PATCH 185/207] fix rest api acceptance tests --- tests/rest_api/rest_api.postman_collection.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/rest_api/rest_api.postman_collection.json b/tests/rest_api/rest_api.postman_collection.json index bb93c007eb5..5559d46e462 100644 --- a/tests/rest_api/rest_api.postman_collection.json +++ b/tests/rest_api/rest_api.postman_collection.json @@ -34063,8 +34063,8 @@ " tests[\"Body contains list of contacts\"] = contactData;", " var i = 0;", " while (i < contactData.length) {", - " if (postman.getEnvironmentVariable(\"contact_alias\") == contactData[i].alias){", - " tests[\"Body contains added contact_alias\"] = postman.getEnvironmentVariable(\"contact_alias\") == contactData[i].alias;", + " if (postman.getEnvironmentVariable(\"contact_alias\") == contactData[i].name){", + " tests[\"Body contains added contact_alias\"] = postman.getEnvironmentVariable(\"contact_alias\") == contactData[i].name;", " break;", " }", " i++;", From bd4726135bb16aa1c0a891c004a2ac35827bcffa Mon Sep 17 00:00:00 2001 From: loiclau Date: Thu, 17 Aug 2017 17:54:47 +0200 Subject: [PATCH 186/207] * fix style install --- www/install/php/Update-2.0.2_to_2.1.1.php | 5 +- www/install/php/Update-2.0.2_to_2.1.2.php | 5 +- www/install/php/Update-2.0.2_to_2.1.3.php | 18 ++--- www/install/php/Update-2.0.2_to_2.1.php | 5 +- www/install/php/Update-2.1-RC8_to_2.1.1.php | 4 +- www/install/php/Update-2.1-RC8_to_2.1.2.php | 4 +- www/install/php/Update-2.1-RC8_to_2.1.php | 4 +- www/install/php/Update-2.1.10_to_2.2.0-b1.php | 55 ++++++++----- www/install/php/Update-2.1.11_to_2.2.0.php | 55 ++++++++----- www/install/php/Update-2.1.12_to_2.2.0-b1.php | 60 +++++++++----- .../php/Update-2.1.12_to_2.2.0-b1.post.php | 3 +- www/install/php/Update-2.1.13_to_2.3.0.php | 59 +++++++++----- .../php/Update-2.1.13_to_2.3.0.post.php | 45 +++++++---- www/install/php/Update-2.1.1_to_2.1.3.php | 13 ++-- www/install/php/Update-2.1.2_to_2.1.3.php | 13 ++-- .../php/Update-2.2.0_to_2.3.0-b1.post.php | 49 ++++++++---- .../php/Update-2.2.2_to_2.3.0.post.php | 44 +++++++---- www/install/php/Update-2.3.3_to_2.3.4.php | 11 ++- .../php/Update-2.3.9_to_2.4.0-RC1.post.php | 1 - .../Update-2.4.0-RC5_to_2.4.0-RC6.post.php | 10 +-- .../Update-2.4.0-RC6_to_2.4.0-RC7.post.php | 24 +++--- www/install/php/Update-2.4.1_to_2.4.2.php | 9 ++- .../php/Update-2.4.5_to_2.5.0.post.php | 78 ++++++++++--------- www/install/php/Update-2.5.1_to_2.5.2.php | 11 ++- .../php/Update-2.6.6_to_2.7.0-RC1.post.php | 11 +-- .../php/Update-2.7.0-RC2_to_2.7.0.post.php | 2 - www/install/php/Update-2.7.0_to_2.7.1.php | 10 +-- www/install/php/Update-2.7.1_to_2.7.2.php | 7 +- .../php/Update-2.8.0-beta2_to_2.8.0.php | 2 - www/install/php/Update-2.8.3_to_2.8.4.php | 2 +- 30 files changed, 374 insertions(+), 245 deletions(-) diff --git a/www/install/php/Update-2.0.2_to_2.1.1.php b/www/install/php/Update-2.0.2_to_2.1.1.php index fb617d462c2..c2b16c39642 100644 --- a/www/install/php/Update-2.0.2_to_2.1.1.php +++ b/www/install/php/Update-2.0.2_to_2.1.1.php @@ -37,6 +37,7 @@ $update_query = "SHOW COLUMNS FROM `service` WHERE Field LIKE 'service_first_notification_delay'"; $RES = $pearDB->query($update_query); if (!$RES->rowCount()) { - $pearDB->query("ALTER TABLE `service` ADD `service_first_notification_delay` INT NULL AFTER `service_notifications_enabled`"); + $query = "ALTER TABLE `service` ADD `service_first_notification_delay` " . + "INT NULL AFTER `service_notifications_enabled`"; + $pearDB->query($query); } -?> \ No newline at end of file diff --git a/www/install/php/Update-2.0.2_to_2.1.2.php b/www/install/php/Update-2.0.2_to_2.1.2.php index fb617d462c2..c2b16c39642 100644 --- a/www/install/php/Update-2.0.2_to_2.1.2.php +++ b/www/install/php/Update-2.0.2_to_2.1.2.php @@ -37,6 +37,7 @@ $update_query = "SHOW COLUMNS FROM `service` WHERE Field LIKE 'service_first_notification_delay'"; $RES = $pearDB->query($update_query); if (!$RES->rowCount()) { - $pearDB->query("ALTER TABLE `service` ADD `service_first_notification_delay` INT NULL AFTER `service_notifications_enabled`"); + $query = "ALTER TABLE `service` ADD `service_first_notification_delay` " . + "INT NULL AFTER `service_notifications_enabled`"; + $pearDB->query($query); } -?> \ No newline at end of file diff --git a/www/install/php/Update-2.0.2_to_2.1.3.php b/www/install/php/Update-2.0.2_to_2.1.3.php index 682c718d408..2dedcc119df 100644 --- a/www/install/php/Update-2.0.2_to_2.1.3.php +++ b/www/install/php/Update-2.0.2_to_2.1.3.php @@ -35,18 +35,18 @@ */ if (isset($pearDBndo)) { - $update_query = "SHOW COLUMNS FROM `centreon_acl` WHERE Field LIKE 'host_id'"; - $RES = $pearDBndo->query($update_query); - if (!$RES->rowCount()) { - $pearDBndo->query("ALTER TABLE `centreon_acl` ADD `host_id` INT NULL AFTER `id`"); - $pearDBndo->query("ALTER TABLE `centreon_acl` ADD `service_id` INT NULL AFTER `host_name`"); - } + $update_query = "SHOW COLUMNS FROM `centreon_acl` WHERE Field LIKE 'host_id'"; + $RES = $pearDBndo->query($update_query); + if (!$RES->rowCount()) { + $pearDBndo->query("ALTER TABLE `centreon_acl` ADD `host_id` INT NULL AFTER `id`"); + $pearDBndo->query("ALTER TABLE `centreon_acl` ADD `service_id` INT NULL AFTER `host_name`"); + } } $update_query = "SHOW COLUMNS FROM `service` WHERE Field LIKE 'service_first_notification_delay'"; $RES = $pearDB->query($update_query); if (!$RES->rowCount()) { - $pearDB->query("ALTER TABLE `service` ADD `service_first_notification_delay` INT NULL AFTER `service_notifications_enabled`"); + $query = "ALTER TABLE `service` ADD `service_first_notification_delay` " . + "INT NULL AFTER `service_notifications_enabled`"; + $pearDB->query($query); } - -?> \ No newline at end of file diff --git a/www/install/php/Update-2.0.2_to_2.1.php b/www/install/php/Update-2.0.2_to_2.1.php index fb617d462c2..c2b16c39642 100644 --- a/www/install/php/Update-2.0.2_to_2.1.php +++ b/www/install/php/Update-2.0.2_to_2.1.php @@ -37,6 +37,7 @@ $update_query = "SHOW COLUMNS FROM `service` WHERE Field LIKE 'service_first_notification_delay'"; $RES = $pearDB->query($update_query); if (!$RES->rowCount()) { - $pearDB->query("ALTER TABLE `service` ADD `service_first_notification_delay` INT NULL AFTER `service_notifications_enabled`"); + $query = "ALTER TABLE `service` ADD `service_first_notification_delay` " . + "INT NULL AFTER `service_notifications_enabled`"; + $pearDB->query($query); } -?> \ No newline at end of file diff --git a/www/install/php/Update-2.1-RC8_to_2.1.1.php b/www/install/php/Update-2.1-RC8_to_2.1.1.php index fb617d462c2..a90dcfa9113 100644 --- a/www/install/php/Update-2.1-RC8_to_2.1.1.php +++ b/www/install/php/Update-2.1-RC8_to_2.1.1.php @@ -37,6 +37,6 @@ $update_query = "SHOW COLUMNS FROM `service` WHERE Field LIKE 'service_first_notification_delay'"; $RES = $pearDB->query($update_query); if (!$RES->rowCount()) { - $pearDB->query("ALTER TABLE `service` ADD `service_first_notification_delay` INT NULL AFTER `service_notifications_enabled`"); + $pearDB->query("ALTER TABLE `service` ADD `service_first_notification_delay` + INT NULL AFTER `service_notifications_enabled`"); } -?> \ No newline at end of file diff --git a/www/install/php/Update-2.1-RC8_to_2.1.2.php b/www/install/php/Update-2.1-RC8_to_2.1.2.php index fb617d462c2..83db58dcdad 100644 --- a/www/install/php/Update-2.1-RC8_to_2.1.2.php +++ b/www/install/php/Update-2.1-RC8_to_2.1.2.php @@ -37,6 +37,6 @@ $update_query = "SHOW COLUMNS FROM `service` WHERE Field LIKE 'service_first_notification_delay'"; $RES = $pearDB->query($update_query); if (!$RES->rowCount()) { - $pearDB->query("ALTER TABLE `service` ADD `service_first_notification_delay` INT NULL AFTER `service_notifications_enabled`"); + $pearDB->query("ALTER TABLE `service` ADD `service_first_notification_delay` +INT NULL AFTER `service_notifications_enabled`"); } -?> \ No newline at end of file diff --git a/www/install/php/Update-2.1-RC8_to_2.1.php b/www/install/php/Update-2.1-RC8_to_2.1.php index fb617d462c2..83db58dcdad 100644 --- a/www/install/php/Update-2.1-RC8_to_2.1.php +++ b/www/install/php/Update-2.1-RC8_to_2.1.php @@ -37,6 +37,6 @@ $update_query = "SHOW COLUMNS FROM `service` WHERE Field LIKE 'service_first_notification_delay'"; $RES = $pearDB->query($update_query); if (!$RES->rowCount()) { - $pearDB->query("ALTER TABLE `service` ADD `service_first_notification_delay` INT NULL AFTER `service_notifications_enabled`"); + $pearDB->query("ALTER TABLE `service` ADD `service_first_notification_delay` +INT NULL AFTER `service_notifications_enabled`"); } -?> \ No newline at end of file diff --git a/www/install/php/Update-2.1.10_to_2.2.0-b1.php b/www/install/php/Update-2.1.10_to_2.2.0-b1.php index d69c119e045..5c171c86538 100644 --- a/www/install/php/Update-2.1.10_to_2.2.0-b1.php +++ b/www/install/php/Update-2.1.10_to_2.2.0-b1.php @@ -55,21 +55,29 @@ function upgradeReplaceSpecialChars($str) $query = "SELECT host_id, host_alias, host_name FROM host"; $res = $pearDB->query($query); while ($rows = $res->fetchRow()) { - $query2 = "UPDATE host SET host_name = '".upgradeReplaceSpecialChars(html_entity_decode($rows['host_name']))."', - host_alias = '" . upgradeReplaceSpecialChars(html_entity_decode($rows['host_alias'])) . "' WHERE host_id = '".$rows['host_id']."'"; + $query2 = "UPDATE host SET host_name = '" . + upgradeReplaceSpecialChars(html_entity_decode($rows['host_name'])) . "', + host_alias = '" . + upgradeReplaceSpecialChars(html_entity_decode($rows['host_alias'])) . + "' WHERE host_id = '" . $rows['host_id'] . "'"; $pearDB->query($query2); } /** * Decodes Service description and service alias */ - $query = "SELECT service_id, service_description, service_alias, command_command_id_arg, command_command_id_arg2 FROM service"; + $query = "SELECT service_id, service_description, service_alias, command_command_id_arg, command_command_id_arg2 +FROM service"; $res = $pearDB->query($query); while ($rows = $res->fetchRow()) { - $query2 = "UPDATE service SET service_description = '".upgradeReplaceSpecialChars(html_entity_decode($rows['service_description']))."', + $query2 = "UPDATE service SET service_description = '" . + upgradeReplaceSpecialChars(html_entity_decode($rows['service_description'])) . "', service_alias = '" . upgradeReplaceSpecialChars(html_entity_decode($rows['service_alias'])) . "', - command_command_id_arg = '". upgradeReplaceSpecialChars(html_entity_decode($rows['command_command_id_arg'])) ."', - command_command_id_arg2 = '". upgradeReplaceSpecialChars(html_entity_decode($rows['command_command_id_arg2'])) ."' WHERE service_id = '".$rows['service_id']."'"; + command_command_id_arg = '" . + upgradeReplaceSpecialChars(html_entity_decode($rows['command_command_id_arg'])) . "', + command_command_id_arg2 = '" . + upgradeReplaceSpecialChars(html_entity_decode($rows['command_command_id_arg2'])) . + "' WHERE service_id = '" . $rows['service_id'] . "'"; $pearDB->query($query2); } @@ -79,9 +87,11 @@ function upgradeReplaceSpecialChars($str) $query = "SELECT command_id, command_name, command_line, command_example FROM command"; $res = $pearDB->query($query); while ($rows = $res->fetchRow()) { - $query2 = "UPDATE command SET command_name = '".upgradeReplaceSpecialChars(html_entity_decode($rows['command_name']))."', + $query2 = "UPDATE command SET command_name = '" . + upgradeReplaceSpecialChars(html_entity_decode($rows['command_name'])) . "', command_line = '" . upgradeReplaceSpecialChars(html_entity_decode($rows['command_line'])) . "', - command_example = '". upgradeReplaceSpecialChars(html_entity_decode($rows['command_example'])) ."' WHERE command_id = '".$rows['command_id']."'"; + command_example = '" . upgradeReplaceSpecialChars(html_entity_decode($rows['command_example'])) . + "' WHERE command_id = '" . $rows['command_id'] . "'"; $pearDB->query($query2); } @@ -91,8 +101,10 @@ function upgradeReplaceSpecialChars($str) $query = "SELECT hg_id, hg_alias, hg_name FROM hostgroup"; $res = $pearDB->query($query); while ($rows = $res->fetchRow()) { - $query2 = "UPDATE hostgroup SET hg_name = '".upgradeReplaceSpecialChars(html_entity_decode($rows['hg_name']))."', - hg_alias = '" . upgradeReplaceSpecialChars(html_entity_decode($rows['hg_alias'])) . "' WHERE hg_id = '".$rows['hg_id']."'"; + $query2 = "UPDATE hostgroup SET hg_name = '" . + upgradeReplaceSpecialChars(html_entity_decode($rows['hg_name'])) . "', + hg_alias = '" . upgradeReplaceSpecialChars(html_entity_decode($rows['hg_alias'])) . + "' WHERE hg_id = '" . $rows['hg_id'] . "'"; $pearDB->query($query2); } @@ -103,8 +115,9 @@ function upgradeReplaceSpecialChars($str) $res = $pearDB->query($query); while ($rows = $res->fetchRow()) { $query2 = "UPDATE on_demand_macro_host - SET host_macro_value = '".upgradeReplaceSpecialChars(html_entity_decode($rows['host_macro_value']))."' - WHERE host_macro_id = '".$rows['host_macro_id']."'"; + SET host_macro_value = '" . + upgradeReplaceSpecialChars(html_entity_decode($rows['host_macro_value'])) . "' + WHERE host_macro_id = '" . $rows['host_macro_id'] . "'"; $pearDB->query($query2); } @@ -115,8 +128,9 @@ function upgradeReplaceSpecialChars($str) $res = $pearDB->query($query); while ($rows = $res->fetchRow()) { $query2 = "UPDATE on_demand_macro_service - SET svc_macro_value = '".upgradeReplaceSpecialChars(html_entity_decode($rows['svc_macro_value']))."' - WHERE svc_macro_id = '".$rows['svc_macro_id']."'"; + SET svc_macro_value = '" . + upgradeReplaceSpecialChars(html_entity_decode($rows['svc_macro_value'])) . "' + WHERE svc_macro_id = '" . $rows['svc_macro_id'] . "'"; $pearDB->query($query2); } @@ -128,14 +142,15 @@ function upgradeReplaceSpecialChars($str) `cfg_nagios_id` int(11) DEFAULT NULL, `broker_module` varchar(255) DEFAULT NULL, PRIMARY KEY (`bk_mod_id`) - ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1" ; + ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1"; $pearDB->query($query); $query = "SELECT nagios_id as cfg_nagios_id, broker_module FROM cfg_nagios WHERE nagios_server_id IN ( SELECT id from nagios_server WHERE localhost = '1')"; $res = $pearDB->query($query); while ($rows = $res->fetchRow()) { - $query2 = "INSERT INTO cfg_nagios_broker_module (`cfg_nagios_id`, `broker_module`) VALUES ('".$rows['cfg_nagios_id']."', '".$rows['broker_module']."')"; + $query2 = "INSERT INTO cfg_nagios_broker_module (`cfg_nagios_id`, `broker_module`) VALUES ('" . + $rows['cfg_nagios_id'] . "', '" . $rows['broker_module'] . "')"; $pearDB->query($query2); } } @@ -150,9 +165,11 @@ function upgradeReplaceSpecialChars($str) $query = "SELECT id, host_name, service_description FROM index_data"; $res = $pearDBO->query($query); while ($rows = $res->fetchRow()) { - $query2 = "UPDATE index_data SET host_name = '" . upgradeReplaceSpecialChars(html_entity_decode($rows['host_name'])) . "', - service_description = '". upgradeReplaceSpecialChars(html_entity_decode($rows['service_description'])) ."' WHERE id = '".$rows['id']."'"; + $query2 = "UPDATE index_data SET host_name = '" . + upgradeReplaceSpecialChars(html_entity_decode($rows['host_name'])) . "', + service_description = '" . + upgradeReplaceSpecialChars(html_entity_decode($rows['service_description'])) . + "' WHERE id = '" . $rows['id'] . "'"; $pearDBO->query($query2); } } -?> \ No newline at end of file diff --git a/www/install/php/Update-2.1.11_to_2.2.0.php b/www/install/php/Update-2.1.11_to_2.2.0.php index d69c119e045..af9b1a81ad8 100644 --- a/www/install/php/Update-2.1.11_to_2.2.0.php +++ b/www/install/php/Update-2.1.11_to_2.2.0.php @@ -55,21 +55,29 @@ function upgradeReplaceSpecialChars($str) $query = "SELECT host_id, host_alias, host_name FROM host"; $res = $pearDB->query($query); while ($rows = $res->fetchRow()) { - $query2 = "UPDATE host SET host_name = '".upgradeReplaceSpecialChars(html_entity_decode($rows['host_name']))."', - host_alias = '" . upgradeReplaceSpecialChars(html_entity_decode($rows['host_alias'])) . "' WHERE host_id = '".$rows['host_id']."'"; + $query2 = "UPDATE host SET host_name = '" . + upgradeReplaceSpecialChars(html_entity_decode($rows['host_name'])) . "', + host_alias = '" . + upgradeReplaceSpecialChars(html_entity_decode($rows['host_alias'])) . + "' WHERE host_id = '" . $rows['host_id'] . "'"; $pearDB->query($query2); } /** * Decodes Service description and service alias */ - $query = "SELECT service_id, service_description, service_alias, command_command_id_arg, command_command_id_arg2 FROM service"; + $query = "SELECT service_id, service_description, service_alias, command_command_id_arg, command_command_id_arg2 + FROM service"; $res = $pearDB->query($query); while ($rows = $res->fetchRow()) { - $query2 = "UPDATE service SET service_description = '".upgradeReplaceSpecialChars(html_entity_decode($rows['service_description']))."', + $query2 = "UPDATE service SET service_description = '" . + upgradeReplaceSpecialChars(html_entity_decode($rows['service_description'])) . "', service_alias = '" . upgradeReplaceSpecialChars(html_entity_decode($rows['service_alias'])) . "', - command_command_id_arg = '". upgradeReplaceSpecialChars(html_entity_decode($rows['command_command_id_arg'])) ."', - command_command_id_arg2 = '". upgradeReplaceSpecialChars(html_entity_decode($rows['command_command_id_arg2'])) ."' WHERE service_id = '".$rows['service_id']."'"; + command_command_id_arg = '" . + upgradeReplaceSpecialChars(html_entity_decode($rows['command_command_id_arg'])) . "', + command_command_id_arg2 = '" . + upgradeReplaceSpecialChars(html_entity_decode($rows['command_command_id_arg2'])) . + "' WHERE service_id = '" . $rows['service_id'] . "'"; $pearDB->query($query2); } @@ -79,9 +87,11 @@ function upgradeReplaceSpecialChars($str) $query = "SELECT command_id, command_name, command_line, command_example FROM command"; $res = $pearDB->query($query); while ($rows = $res->fetchRow()) { - $query2 = "UPDATE command SET command_name = '".upgradeReplaceSpecialChars(html_entity_decode($rows['command_name']))."', + $query2 = "UPDATE command SET command_name = '" . + upgradeReplaceSpecialChars(html_entity_decode($rows['command_name'])) . "', command_line = '" . upgradeReplaceSpecialChars(html_entity_decode($rows['command_line'])) . "', - command_example = '". upgradeReplaceSpecialChars(html_entity_decode($rows['command_example'])) ."' WHERE command_id = '".$rows['command_id']."'"; + command_example = '" . upgradeReplaceSpecialChars(html_entity_decode($rows['command_example'])) . + "' WHERE command_id = '" . $rows['command_id'] . "'"; $pearDB->query($query2); } @@ -91,8 +101,10 @@ function upgradeReplaceSpecialChars($str) $query = "SELECT hg_id, hg_alias, hg_name FROM hostgroup"; $res = $pearDB->query($query); while ($rows = $res->fetchRow()) { - $query2 = "UPDATE hostgroup SET hg_name = '".upgradeReplaceSpecialChars(html_entity_decode($rows['hg_name']))."', - hg_alias = '" . upgradeReplaceSpecialChars(html_entity_decode($rows['hg_alias'])) . "' WHERE hg_id = '".$rows['hg_id']."'"; + $query2 = "UPDATE hostgroup SET hg_name = '" . + upgradeReplaceSpecialChars(html_entity_decode($rows['hg_name'])) . "', + hg_alias = '" . upgradeReplaceSpecialChars(html_entity_decode($rows['hg_alias'])) . + "' WHERE hg_id = '" . $rows['hg_id'] . "'"; $pearDB->query($query2); } @@ -103,8 +115,9 @@ function upgradeReplaceSpecialChars($str) $res = $pearDB->query($query); while ($rows = $res->fetchRow()) { $query2 = "UPDATE on_demand_macro_host - SET host_macro_value = '".upgradeReplaceSpecialChars(html_entity_decode($rows['host_macro_value']))."' - WHERE host_macro_id = '".$rows['host_macro_id']."'"; + SET host_macro_value = '" . + upgradeReplaceSpecialChars(html_entity_decode($rows['host_macro_value'])) . "' + WHERE host_macro_id = '" . $rows['host_macro_id'] . "'"; $pearDB->query($query2); } @@ -115,8 +128,9 @@ function upgradeReplaceSpecialChars($str) $res = $pearDB->query($query); while ($rows = $res->fetchRow()) { $query2 = "UPDATE on_demand_macro_service - SET svc_macro_value = '".upgradeReplaceSpecialChars(html_entity_decode($rows['svc_macro_value']))."' - WHERE svc_macro_id = '".$rows['svc_macro_id']."'"; + SET svc_macro_value = '" . + upgradeReplaceSpecialChars(html_entity_decode($rows['svc_macro_value'])) . "' + WHERE svc_macro_id = '" . $rows['svc_macro_id'] . "'"; $pearDB->query($query2); } @@ -128,14 +142,15 @@ function upgradeReplaceSpecialChars($str) `cfg_nagios_id` int(11) DEFAULT NULL, `broker_module` varchar(255) DEFAULT NULL, PRIMARY KEY (`bk_mod_id`) - ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1" ; + ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1"; $pearDB->query($query); $query = "SELECT nagios_id as cfg_nagios_id, broker_module FROM cfg_nagios WHERE nagios_server_id IN ( SELECT id from nagios_server WHERE localhost = '1')"; $res = $pearDB->query($query); while ($rows = $res->fetchRow()) { - $query2 = "INSERT INTO cfg_nagios_broker_module (`cfg_nagios_id`, `broker_module`) VALUES ('".$rows['cfg_nagios_id']."', '".$rows['broker_module']."')"; + $query2 = "INSERT INTO cfg_nagios_broker_module (`cfg_nagios_id`, `broker_module`) VALUES ('" . + $rows['cfg_nagios_id'] . "', '" . $rows['broker_module'] . "')"; $pearDB->query($query2); } } @@ -150,9 +165,11 @@ function upgradeReplaceSpecialChars($str) $query = "SELECT id, host_name, service_description FROM index_data"; $res = $pearDBO->query($query); while ($rows = $res->fetchRow()) { - $query2 = "UPDATE index_data SET host_name = '" . upgradeReplaceSpecialChars(html_entity_decode($rows['host_name'])) . "', - service_description = '". upgradeReplaceSpecialChars(html_entity_decode($rows['service_description'])) ."' WHERE id = '".$rows['id']."'"; + $query2 = "UPDATE index_data SET host_name = '" . + upgradeReplaceSpecialChars(html_entity_decode($rows['host_name'])) . "', + service_description = '" . + upgradeReplaceSpecialChars(html_entity_decode($rows['service_description'])) . + "' WHERE id = '" . $rows['id'] . "'"; $pearDBO->query($query2); } } -?> \ No newline at end of file diff --git a/www/install/php/Update-2.1.12_to_2.2.0-b1.php b/www/install/php/Update-2.1.12_to_2.2.0-b1.php index d69c119e045..8df723d35d3 100644 --- a/www/install/php/Update-2.1.12_to_2.2.0-b1.php +++ b/www/install/php/Update-2.1.12_to_2.2.0-b1.php @@ -55,21 +55,29 @@ function upgradeReplaceSpecialChars($str) $query = "SELECT host_id, host_alias, host_name FROM host"; $res = $pearDB->query($query); while ($rows = $res->fetchRow()) { - $query2 = "UPDATE host SET host_name = '".upgradeReplaceSpecialChars(html_entity_decode($rows['host_name']))."', - host_alias = '" . upgradeReplaceSpecialChars(html_entity_decode($rows['host_alias'])) . "' WHERE host_id = '".$rows['host_id']."'"; + $query2 = "UPDATE host SET host_name = '" . + upgradeReplaceSpecialChars(html_entity_decode($rows['host_name'])) . "', + host_alias = '" . + upgradeReplaceSpecialChars(html_entity_decode($rows['host_alias'])) . + "' WHERE host_id = '" . $rows['host_id'] . "'"; $pearDB->query($query2); } /** * Decodes Service description and service alias */ - $query = "SELECT service_id, service_description, service_alias, command_command_id_arg, command_command_id_arg2 FROM service"; + $query = "SELECT service_id, service_description, service_alias, command_command_id_arg, command_command_id_arg2 + FROM service"; $res = $pearDB->query($query); while ($rows = $res->fetchRow()) { - $query2 = "UPDATE service SET service_description = '".upgradeReplaceSpecialChars(html_entity_decode($rows['service_description']))."', + $query2 = "UPDATE service SET service_description = '" . + upgradeReplaceSpecialChars(html_entity_decode($rows['service_description'])) . "', service_alias = '" . upgradeReplaceSpecialChars(html_entity_decode($rows['service_alias'])) . "', - command_command_id_arg = '". upgradeReplaceSpecialChars(html_entity_decode($rows['command_command_id_arg'])) ."', - command_command_id_arg2 = '". upgradeReplaceSpecialChars(html_entity_decode($rows['command_command_id_arg2'])) ."' WHERE service_id = '".$rows['service_id']."'"; + command_command_id_arg = '" . + upgradeReplaceSpecialChars(html_entity_decode($rows['command_command_id_arg'])) . "', + command_command_id_arg2 = '" . + upgradeReplaceSpecialChars(html_entity_decode($rows['command_command_id_arg2'])) . + "' WHERE service_id = '" . $rows['service_id'] . "'"; $pearDB->query($query2); } @@ -79,9 +87,13 @@ function upgradeReplaceSpecialChars($str) $query = "SELECT command_id, command_name, command_line, command_example FROM command"; $res = $pearDB->query($query); while ($rows = $res->fetchRow()) { - $query2 = "UPDATE command SET command_name = '".upgradeReplaceSpecialChars(html_entity_decode($rows['command_name']))."', - command_line = '" . upgradeReplaceSpecialChars(html_entity_decode($rows['command_line'])) . "', - command_example = '". upgradeReplaceSpecialChars(html_entity_decode($rows['command_example'])) ."' WHERE command_id = '".$rows['command_id']."'"; + $query2 = "UPDATE command SET command_name = '" . + upgradeReplaceSpecialChars(html_entity_decode($rows['command_name'])) . "', + command_line = '" . + upgradeReplaceSpecialChars(html_entity_decode($rows['command_line'])) . "', + command_example = '" . + upgradeReplaceSpecialChars(html_entity_decode($rows['command_example'])) . + "' WHERE command_id = '" . $rows['command_id'] . "'"; $pearDB->query($query2); } @@ -91,8 +103,11 @@ function upgradeReplaceSpecialChars($str) $query = "SELECT hg_id, hg_alias, hg_name FROM hostgroup"; $res = $pearDB->query($query); while ($rows = $res->fetchRow()) { - $query2 = "UPDATE hostgroup SET hg_name = '".upgradeReplaceSpecialChars(html_entity_decode($rows['hg_name']))."', - hg_alias = '" . upgradeReplaceSpecialChars(html_entity_decode($rows['hg_alias'])) . "' WHERE hg_id = '".$rows['hg_id']."'"; + $query2 = "UPDATE hostgroup SET hg_name = '" . + upgradeReplaceSpecialChars(html_entity_decode($rows['hg_name'])) . "', + hg_alias = '" . + upgradeReplaceSpecialChars(html_entity_decode($rows['hg_alias'])) . + "' WHERE hg_id = '" . $rows['hg_id'] . "'"; $pearDB->query($query2); } @@ -103,8 +118,9 @@ function upgradeReplaceSpecialChars($str) $res = $pearDB->query($query); while ($rows = $res->fetchRow()) { $query2 = "UPDATE on_demand_macro_host - SET host_macro_value = '".upgradeReplaceSpecialChars(html_entity_decode($rows['host_macro_value']))."' - WHERE host_macro_id = '".$rows['host_macro_id']."'"; + SET host_macro_value = '" . + upgradeReplaceSpecialChars(html_entity_decode($rows['host_macro_value'])) . "' + WHERE host_macro_id = '" . $rows['host_macro_id'] . "'"; $pearDB->query($query2); } @@ -115,8 +131,9 @@ function upgradeReplaceSpecialChars($str) $res = $pearDB->query($query); while ($rows = $res->fetchRow()) { $query2 = "UPDATE on_demand_macro_service - SET svc_macro_value = '".upgradeReplaceSpecialChars(html_entity_decode($rows['svc_macro_value']))."' - WHERE svc_macro_id = '".$rows['svc_macro_id']."'"; + SET svc_macro_value = '" . + upgradeReplaceSpecialChars(html_entity_decode($rows['svc_macro_value'])) . "' + WHERE svc_macro_id = '" . $rows['svc_macro_id'] . "'"; $pearDB->query($query2); } @@ -128,14 +145,15 @@ function upgradeReplaceSpecialChars($str) `cfg_nagios_id` int(11) DEFAULT NULL, `broker_module` varchar(255) DEFAULT NULL, PRIMARY KEY (`bk_mod_id`) - ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1" ; + ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1"; $pearDB->query($query); $query = "SELECT nagios_id as cfg_nagios_id, broker_module FROM cfg_nagios WHERE nagios_server_id IN ( SELECT id from nagios_server WHERE localhost = '1')"; $res = $pearDB->query($query); while ($rows = $res->fetchRow()) { - $query2 = "INSERT INTO cfg_nagios_broker_module (`cfg_nagios_id`, `broker_module`) VALUES ('".$rows['cfg_nagios_id']."', '".$rows['broker_module']."')"; + $query2 = "INSERT INTO cfg_nagios_broker_module (`cfg_nagios_id`, `broker_module`) VALUES ('" . + $rows['cfg_nagios_id'] . "', '" . $rows['broker_module'] . "')"; $pearDB->query($query2); } } @@ -150,9 +168,11 @@ function upgradeReplaceSpecialChars($str) $query = "SELECT id, host_name, service_description FROM index_data"; $res = $pearDBO->query($query); while ($rows = $res->fetchRow()) { - $query2 = "UPDATE index_data SET host_name = '" . upgradeReplaceSpecialChars(html_entity_decode($rows['host_name'])) . "', - service_description = '". upgradeReplaceSpecialChars(html_entity_decode($rows['service_description'])) ."' WHERE id = '".$rows['id']."'"; + $query2 = "UPDATE index_data SET host_name = '" . + upgradeReplaceSpecialChars(html_entity_decode($rows['host_name'])) . "', + service_description = '" . + upgradeReplaceSpecialChars(html_entity_decode($rows['service_description'])) . + "' WHERE id = '" . $rows['id'] . "'"; $pearDBO->query($query2); } } -?> \ No newline at end of file diff --git a/www/install/php/Update-2.1.12_to_2.2.0-b1.post.php b/www/install/php/Update-2.1.12_to_2.2.0-b1.post.php index 424c4f45192..c43c6af373f 100644 --- a/www/install/php/Update-2.1.12_to_2.2.0-b1.post.php +++ b/www/install/php/Update-2.1.12_to_2.2.0-b1.post.php @@ -42,10 +42,9 @@ if ($str != "") { $str .= ","; } - $str .= "(".$row['nagios_id'] . ", '" .$row['broker_module']. "')"; + $str .= "(" . $row['nagios_id'] . ", '" . $row['broker_module'] . "')"; } if ($str) { $pearDB->query("INSERT INTO cfg_nagios_broker_module (cfg_nagios_id, broker_module) VALUES " . $str); } } -?> \ No newline at end of file diff --git a/www/install/php/Update-2.1.13_to_2.3.0.php b/www/install/php/Update-2.1.13_to_2.3.0.php index 0d64a3eab32..e1deccacc4b 100644 --- a/www/install/php/Update-2.1.13_to_2.3.0.php +++ b/www/install/php/Update-2.1.13_to_2.3.0.php @@ -55,21 +55,29 @@ function upgradeReplaceSpecialChars($str) $query = "SELECT host_id, host_alias, host_name FROM host"; $res = $pearDB->query($query); while ($rows = $res->fetchRow()) { - $query2 = "UPDATE host SET host_name = '".upgradeReplaceSpecialChars(html_entity_decode($rows['host_name']))."', - host_alias = '" . upgradeReplaceSpecialChars(html_entity_decode($rows['host_alias'])) . "' WHERE host_id = '".$rows['host_id']."'"; + $query2 = "UPDATE host SET host_name = '" . + upgradeReplaceSpecialChars(html_entity_decode($rows['host_name'])) . "', + host_alias = '" . + upgradeReplaceSpecialChars(html_entity_decode($rows['host_alias'])) . + "' WHERE host_id = '" . $rows['host_id'] . "'"; $pearDB->query($query2); } /** * Decodes Service description and service alias */ - $query = "SELECT service_id, service_description, service_alias, command_command_id_arg, command_command_id_arg2 FROM service"; + $query = "SELECT service_id, service_description, service_alias, command_command_id_arg, command_command_id_arg2 " . + "FROM service"; $res = $pearDB->query($query); while ($rows = $res->fetchRow()) { - $query2 = "UPDATE service SET service_description = '".upgradeReplaceSpecialChars(html_entity_decode($rows['service_description']))."', + $query2 = "UPDATE service SET service_description = '" . + upgradeReplaceSpecialChars(html_entity_decode($rows['service_description'])) . "', service_alias = '" . upgradeReplaceSpecialChars(html_entity_decode($rows['service_alias'])) . "', - command_command_id_arg = '". upgradeReplaceSpecialChars(html_entity_decode($rows['command_command_id_arg'])) ."', - command_command_id_arg2 = '". upgradeReplaceSpecialChars(html_entity_decode($rows['command_command_id_arg2'])) ."' WHERE service_id = '".$rows['service_id']."'"; + command_command_id_arg = '" . + upgradeReplaceSpecialChars(html_entity_decode($rows['command_command_id_arg'])) . "', + command_command_id_arg2 = '" . + upgradeReplaceSpecialChars(html_entity_decode($rows['command_command_id_arg2'])) . + "' WHERE service_id = '" . $rows['service_id'] . "'"; $pearDB->query($query2); } @@ -79,9 +87,12 @@ function upgradeReplaceSpecialChars($str) $query = "SELECT command_id, command_name, command_line, command_example FROM command"; $res = $pearDB->query($query); while ($rows = $res->fetchRow()) { - $query2 = "UPDATE command SET command_name = '".upgradeReplaceSpecialChars(html_entity_decode($rows['command_name']))."', + $query2 = "UPDATE command SET command_name = '" . + upgradeReplaceSpecialChars(html_entity_decode($rows['command_name'])) . "', command_line = '" . upgradeReplaceSpecialChars(html_entity_decode($rows['command_line'])) . "', - command_example = '". upgradeReplaceSpecialChars(html_entity_decode($rows['command_example'])) ."' WHERE command_id = '".$rows['command_id']."'"; + command_example = '" . + upgradeReplaceSpecialChars(html_entity_decode($rows['command_example'])) . + "' WHERE command_id = '" . $rows['command_id'] . "'"; $pearDB->query($query2); } @@ -91,8 +102,11 @@ function upgradeReplaceSpecialChars($str) $query = "SELECT hg_id, hg_alias, hg_name FROM hostgroup"; $res = $pearDB->query($query); while ($rows = $res->fetchRow()) { - $query2 = "UPDATE hostgroup SET hg_name = '".upgradeReplaceSpecialChars(html_entity_decode($rows['hg_name']))."', - hg_alias = '" . upgradeReplaceSpecialChars(html_entity_decode($rows['hg_alias'])) . "' WHERE hg_id = '".$rows['hg_id']."'"; + $query2 = "UPDATE hostgroup SET hg_name = '" . + upgradeReplaceSpecialChars(html_entity_decode($rows['hg_name'])) . "', + hg_alias = '" . + upgradeReplaceSpecialChars(html_entity_decode($rows['hg_alias'])) . + "' WHERE hg_id = '" . $rows['hg_id'] . "'"; $pearDB->query($query2); } @@ -103,8 +117,9 @@ function upgradeReplaceSpecialChars($str) $res = $pearDB->query($query); while ($rows = $res->fetchRow()) { $query2 = "UPDATE on_demand_macro_host - SET host_macro_value = '".upgradeReplaceSpecialChars(html_entity_decode($rows['host_macro_value']))."' - WHERE host_macro_id = '".$rows['host_macro_id']."'"; + SET host_macro_value = '" . + upgradeReplaceSpecialChars(html_entity_decode($rows['host_macro_value'])) . "' + WHERE host_macro_id = '" . $rows['host_macro_id'] . "'"; $pearDB->query($query2); } @@ -114,9 +129,9 @@ function upgradeReplaceSpecialChars($str) $query = "SELECT svc_macro_id, svc_macro_value FROM on_demand_macro_service"; $res = $pearDB->query($query); while ($rows = $res->fetchRow()) { - $query2 = "UPDATE on_demand_macro_service - SET svc_macro_value = '".upgradeReplaceSpecialChars(html_entity_decode($rows['svc_macro_value']))."' - WHERE svc_macro_id = '".$rows['svc_macro_id']."'"; + $query2 = "UPDATE on_demand_macro_service SET svc_macro_value = '" . + upgradeReplaceSpecialChars(html_entity_decode($rows['svc_macro_value'])) . "' + WHERE svc_macro_id = '" . $rows['svc_macro_id'] . "'"; $pearDB->query($query2); } @@ -128,14 +143,15 @@ function upgradeReplaceSpecialChars($str) `cfg_nagios_id` int(11) DEFAULT NULL, `broker_module` varchar(255) DEFAULT NULL, PRIMARY KEY (`bk_mod_id`) - ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1" ; + ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1"; $pearDB->query($query); $query = "SELECT nagios_id as cfg_nagios_id, broker_module FROM cfg_nagios WHERE nagios_server_id IN ( SELECT id from nagios_server WHERE localhost = '1')"; $res = $pearDB->query($query); while ($rows = $res->fetchRow()) { - $query2 = "INSERT INTO cfg_nagios_broker_module (`cfg_nagios_id`, `broker_module`) VALUES ('".$rows['cfg_nagios_id']."', '".$rows['broker_module']."')"; + $query2 = "INSERT INTO cfg_nagios_broker_module (`cfg_nagios_id`, `broker_module`) VALUES ('" . + $rows['cfg_nagios_id'] . "', '" . $rows['broker_module'] . "')"; $pearDB->query($query2); } @@ -152,8 +168,11 @@ function upgradeReplaceSpecialChars($str) $query = "SELECT id, host_name, service_description FROM index_data"; $res = $pearDBO->query($query); while ($rows = $res->fetchRow()) { - $query2 = "UPDATE index_data SET host_name = '" . upgradeReplaceSpecialChars(html_entity_decode($rows['host_name'])) . "', - service_description = '". upgradeReplaceSpecialChars(html_entity_decode($rows['service_description'])) ."' WHERE id = '".$rows['id']."'"; + $query2 = "UPDATE index_data SET host_name = '" . + upgradeReplaceSpecialChars(html_entity_decode($rows['host_name'])) . + "',service_description = '" . + upgradeReplaceSpecialChars(html_entity_decode($rows['service_description'])) . + "' WHERE id = '" . $rows['id'] . "'"; $pearDBO->query($query2); } -} \ No newline at end of file +} diff --git a/www/install/php/Update-2.1.13_to_2.3.0.post.php b/www/install/php/Update-2.1.13_to_2.3.0.post.php index 2bd9b793e72..9fd9ff84365 100644 --- a/www/install/php/Update-2.1.13_to_2.3.0.post.php +++ b/www/install/php/Update-2.1.13_to_2.3.0.post.php @@ -49,35 +49,51 @@ case 'ldap_host': if ($row['value'] != null && $row['value'] != '') { $insertLdap = true; - array_unshift($queries, "INSERT INTO auth_ressource (ar_id, ar_type, ar_enable, ar_order) VALUES (2, 'ldap_tmpl', '0', 0)"); - array_unshift($queries, "INSERT INTO auth_ressource (ar_id, ar_type, ar_enable, ar_order) VALUES (1, 'ldap', '1', 1)"); - $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) VALUES (1, 'host', '" . $row['value'] . "')"; + array_unshift( + $queries, + "INSERT INTO auth_ressource (ar_id, ar_type, ar_enable, ar_order) +VALUES (2, 'ldap_tmpl', '0', 0)" + ); + array_unshift( + $queries, + "INSERT INTO auth_ressource (ar_id, ar_type, ar_enable, ar_order) VALUES (1, 'ldap', '1', 1)" + ); + $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) +VALUES (1, 'host', '" . $row['value'] . "')"; } break; case 'ldap_port': - $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) VALUES (1, 'port', '" . $row['value'] . "')"; + $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) +VALUES (1, 'port', '" . $row['value'] . "')"; break; case 'ldap_base_dn': - $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) VALUES (2, 'user_base_search', '" . $row['value'] . "')"; + $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) +VALUES (2, 'user_base_search', '" . $row['value'] . "')"; break; case 'ldap_login_attrib': - $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) VALUES (2, 'alias', '" . $row['value'] . "')"; + $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) +VALUES (2, 'alias', '" . $row['value'] . "')"; break; case 'ldap_ssl': - $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) VALUES (1, 'use_ssl', '" . $row['value'] . "')"; + $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) +VALUES (1, 'use_ssl', '" . $row['value'] . "')"; break; case 'ldap_search_user': - $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) VALUES (2, 'bind_dn', '" . $row['value'] . "')"; + $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) +VALUES (2, 'bind_dn', '" . $row['value'] . "')"; break; case 'ldap_search_user_pwd': - $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) VALUES (2, 'bind_pass', '" . $row['value'] . "')"; + $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) +VALUES (2, 'bind_pass', '" . $row['value'] . "')"; break; case 'ldap_search_filter': $user_filter = str_replace(array('&', '*'), array('&', '%s'), $row['value']); - $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) VALUES (2, 'user_filter', '" . $user_filter . "')"; + $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) +VALUES (2, 'user_filter', '" . $user_filter . "')"; break; case 'ldap_protocol_version': - $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) VALUES (1, 'protocol_version', '" . $row['value'] . "')"; + $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) +VALUES (1, 'protocol_version', '" . $row['value'] . "')"; break; } } @@ -98,7 +114,6 @@ $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) VALUES (2, 'tmpl', '0')"; - foreach ($queries as $query) { try { $pearDB->query($query); @@ -109,7 +124,9 @@ } /* Delete old values */ - $query = "DELETE FROM `options` WHERE `key` IN ('ldap_host', 'ldap_port', 'ldap_base_dn', 'ldap_login_attrib', 'ldap_ssl', 'ldap_search_user', 'ldap_search_user_pwd', 'ldap_search_filter', 'ldap_protocol_version')"; + $query = "DELETE FROM `options` WHERE `key` +IN ('ldap_host', 'ldap_port', 'ldap_base_dn', 'ldap_login_attrib', 'ldap_ssl', 'ldap_search_user', +'ldap_search_user_pwd', 'ldap_search_filter', 'ldap_protocol_version')"; try { $pearDB->query($query); } catch (\PDOException $e) { @@ -119,5 +136,3 @@ return false; } } - -?> \ No newline at end of file diff --git a/www/install/php/Update-2.1.1_to_2.1.3.php b/www/install/php/Update-2.1.1_to_2.1.3.php index ddf5bc78877..3ad7e5fa9de 100644 --- a/www/install/php/Update-2.1.1_to_2.1.3.php +++ b/www/install/php/Update-2.1.1_to_2.1.3.php @@ -35,11 +35,10 @@ */ if (isset($pearDBndo)) { - $update_query = "SHOW COLUMNS FROM `centreon_acl` WHERE Field LIKE 'host_id'"; - $RES = $pearDBndo->query($update_query); - if (!$RES->rowCount()) { - $pearDBndo->query("ALTER TABLE `centreon_acl` ADD `host_id` INT NULL AFTER `id`"); - $pearDBndo->query("ALTER TABLE `centreon_acl` ADD `service_id` INT NULL AFTER `host_name`"); - } + $update_query = "SHOW COLUMNS FROM `centreon_acl` WHERE Field LIKE 'host_id'"; + $RES = $pearDBndo->query($update_query); + if (!$RES->rowCount()) { + $pearDBndo->query("ALTER TABLE `centreon_acl` ADD `host_id` INT NULL AFTER `id`"); + $pearDBndo->query("ALTER TABLE `centreon_acl` ADD `service_id` INT NULL AFTER `host_name`"); + } } -?> \ No newline at end of file diff --git a/www/install/php/Update-2.1.2_to_2.1.3.php b/www/install/php/Update-2.1.2_to_2.1.3.php index ddf5bc78877..3ad7e5fa9de 100644 --- a/www/install/php/Update-2.1.2_to_2.1.3.php +++ b/www/install/php/Update-2.1.2_to_2.1.3.php @@ -35,11 +35,10 @@ */ if (isset($pearDBndo)) { - $update_query = "SHOW COLUMNS FROM `centreon_acl` WHERE Field LIKE 'host_id'"; - $RES = $pearDBndo->query($update_query); - if (!$RES->rowCount()) { - $pearDBndo->query("ALTER TABLE `centreon_acl` ADD `host_id` INT NULL AFTER `id`"); - $pearDBndo->query("ALTER TABLE `centreon_acl` ADD `service_id` INT NULL AFTER `host_name`"); - } + $update_query = "SHOW COLUMNS FROM `centreon_acl` WHERE Field LIKE 'host_id'"; + $RES = $pearDBndo->query($update_query); + if (!$RES->rowCount()) { + $pearDBndo->query("ALTER TABLE `centreon_acl` ADD `host_id` INT NULL AFTER `id`"); + $pearDBndo->query("ALTER TABLE `centreon_acl` ADD `service_id` INT NULL AFTER `host_name`"); + } } -?> \ No newline at end of file diff --git a/www/install/php/Update-2.2.0_to_2.3.0-b1.post.php b/www/install/php/Update-2.2.0_to_2.3.0-b1.post.php index 8c3adb70c74..cbb3611f66e 100644 --- a/www/install/php/Update-2.2.0_to_2.3.0-b1.post.php +++ b/www/install/php/Update-2.2.0_to_2.3.0-b1.post.php @@ -48,34 +48,50 @@ case 'ldap_host': if ($row['value'] != null && $row['value'] != '') { $insertLdap = true; - array_unshift($queries, "INSERT INTO auth_ressource (ar_id, ar_type, ar_enable, ar_order) VALUES (2, 'ldap_tmpl', '0', 0)"); - array_unshift($queries, "INSERT INTO auth_ressource (ar_id, ar_type, ar_enable, ar_order) VALUES (1, 'ldap', '1', 1)"); - $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) VALUES (1, 'host', '" . $row['value'] . "')"; + array_unshift( + $queries, + "INSERT INTO auth_ressource (ar_id, ar_type, ar_enable, ar_order) + VALUES (2, 'ldap_tmpl', '0', 0)" + ); + array_unshift( + $queries, + "INSERT INTO auth_ressource (ar_id, ar_type, ar_enable, ar_order) VALUES (1, 'ldap', '1', 1)" + ); + $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) +VALUES (1, 'host', '" . $row['value'] . "')"; } break; case 'ldap_port': - $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) VALUES (1, 'port', '" . $row['value'] . "')"; + $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) +VALUES (1, 'port', '" . $row['value'] . "')"; break; case 'ldap_base_dn': - $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) VALUES (2, 'user_base_search', '" . $row['value'] . "')"; + $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) +VALUES (2, 'user_base_search', '" . $row['value'] . "')"; break; case 'ldap_login_attrib': - $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) VALUES (2, 'alias', '" . $row['value'] . "')"; + $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) +VALUES (2, 'alias', '" . $row['value'] . "')"; break; case 'ldap_ssl': - $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) VALUES (1, 'use_ssl', '" . $row['value'] . "')"; + $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) +VALUES (1, 'use_ssl', '" . $row['value'] . "')"; break; case 'ldap_search_user': - $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) VALUES (2, 'bind_dn', '" . $row['value'] . "')"; + $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) +VALUES (2, 'bind_dn', '" . $row['value'] . "')"; break; case 'ldap_search_user_pwd': - $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) VALUES (2, 'bind_pass', '" . $row['value'] . "')"; + $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) +VALUES (2, 'bind_pass', '" . $row['value'] . "')"; break; case 'ldap_search_filter': - $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) VALUES (2, 'user_base_search', '" . $row['value'] . "')"; + $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) +VALUES (2, 'user_base_search', '" . $row['value'] . "')"; break; case 'ldap_protocol_version': - $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) VALUES (1, 'protocol_version', '" . $row['value'] . "')"; + $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) +VALUES (1, 'protocol_version', '" . $row['value'] . "')"; break; } } @@ -94,9 +110,8 @@ $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) VALUES (2, 'group_name', '')"; $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) VALUES (2, 'group_member', '')"; $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) VALUES (2, 'tmpl', '0')"; - - - + + foreach ($queries as $query) { try { $pearDB->query($query); @@ -104,10 +119,11 @@ $errors = true; } } - + } /* Delete old values */ - $query = "DELETE FROM `options` WHERE `key` IN ('ldap_host', 'ldap_port', 'ldap_base_dn', 'ldap_login_attrib', 'ldap_ssl', 'ldap_search_user', 'ldap_search_user_pwd', 'ldap_search_filter', 'ldap_protocol_version')"; + $query = "DELETE FROM `options` WHERE `key` IN ('ldap_host', 'ldap_port', 'ldap_base_dn', 'ldap_login_attrib', + 'ldap_ssl', 'ldap_search_user', 'ldap_search_user_pwd', 'ldap_search_filter', 'ldap_protocol_version')"; try { $pearDB->query($query); } catch (\PDOException $e) { @@ -117,4 +133,3 @@ return false; } } -?> \ No newline at end of file diff --git a/www/install/php/Update-2.2.2_to_2.3.0.post.php b/www/install/php/Update-2.2.2_to_2.3.0.post.php index a304caec798..b7b64ba4c3f 100644 --- a/www/install/php/Update-2.2.2_to_2.3.0.post.php +++ b/www/install/php/Update-2.2.2_to_2.3.0.post.php @@ -49,35 +49,51 @@ case 'ldap_host': if ($row['value'] != null && $row['value'] != '') { $insertLdap = true; - array_unshift($queries, "INSERT INTO auth_ressource (ar_id, ar_type, ar_enable, ar_order) VALUES (2, 'ldap_tmpl', '0', 0)"); - array_unshift($queries, "INSERT INTO auth_ressource (ar_id, ar_type, ar_enable, ar_order) VALUES (1, 'ldap', '1', 1)"); - $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) VALUES (1, 'host', '" . $row['value'] . "')"; + array_unshift( + $queries, + "INSERT INTO auth_ressource (ar_id, ar_type, ar_enable, ar_order) +VALUES (2, 'ldap_tmpl', '0', 0)" + ); + array_unshift( + $queries, + "INSERT INTO auth_ressource (ar_id, ar_type, ar_enable, ar_order) VALUES (1, 'ldap', '1', 1)" + ); + $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) +VALUES (1, 'host', '" . $row['value'] . "')"; } break; case 'ldap_port': - $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) VALUES (1, 'port', '" . $row['value'] . "')"; + $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) +VALUES (1, 'port', '" . $row['value'] . "')"; break; case 'ldap_base_dn': - $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) VALUES (2, 'user_base_search', '" . $row['value'] . "')"; + $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) +VALUES (2, 'user_base_search', '" . $row['value'] . "')"; break; case 'ldap_login_attrib': - $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) VALUES (2, 'alias', '" . $row['value'] . "')"; + $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) +VALUES (2, 'alias', '" . $row['value'] . "')"; break; case 'ldap_ssl': - $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) VALUES (1, 'use_ssl', '" . $row['value'] . "')"; + $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) +VALUES (1, 'use_ssl', '" . $row['value'] . "')"; break; case 'ldap_search_user': - $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) VALUES (2, 'bind_dn', '" . $row['value'] . "')"; + $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) +VALUES (2, 'bind_dn', '" . $row['value'] . "')"; break; case 'ldap_search_user_pwd': - $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) VALUES (2, 'bind_pass', '" . $row['value'] . "')"; + $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) +VALUES (2, 'bind_pass', '" . $row['value'] . "')"; break; case 'ldap_search_filter': $user_filter = str_replace(array('&', '*'), array('&', '%s'), $row['value']); - $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) VALUES (2, 'user_filter', '" . $user_filter . "')"; + $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) +VALUES (2, 'user_filter', '" . $user_filter . "')"; break; case 'ldap_protocol_version': - $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) VALUES (1, 'protocol_version', '" . $row['value'] . "')"; + $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) +VALUES (1, 'protocol_version', '" . $row['value'] . "')"; break; } } @@ -98,7 +114,6 @@ $queries[] = "INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) VALUES (2, 'tmpl', '0')"; - foreach ($queries as $query) { try { $pearDB->query($query); @@ -109,7 +124,9 @@ } /* Delete old values */ - $query = "DELETE FROM `options` WHERE `key` IN ('ldap_host', 'ldap_port', 'ldap_base_dn', 'ldap_login_attrib', 'ldap_ssl', 'ldap_search_user', 'ldap_search_user_pwd', 'ldap_search_filter', 'ldap_protocol_version')"; + $query = "DELETE FROM `options` WHERE `key` +IN ('ldap_host', 'ldap_port', 'ldap_base_dn', 'ldap_login_attrib', 'ldap_ssl', 'ldap_search_user', + 'ldap_search_user_pwd', 'ldap_search_filter', 'ldap_protocol_version')"; try { $pearDB->query($query); } catch (\PDOException $e) { @@ -119,4 +136,3 @@ return false; } } -?> \ No newline at end of file diff --git a/www/install/php/Update-2.3.3_to_2.3.4.php b/www/install/php/Update-2.3.3_to_2.3.4.php index 306048d8d57..37ffc5aa87b 100644 --- a/www/install/php/Update-2.3.3_to_2.3.4.php +++ b/www/install/php/Update-2.3.3_to_2.3.4.php @@ -39,8 +39,11 @@ if ($res->rowCount()) { $row = $res->fetchRow(); $prefix = $row['db_prefix']; - $pearDBndo->query("ALTER TABLE `{$prefix}hoststatus` CHANGE `hoststatus_id` `hoststatus_id` BIGINT NOT NULL AUTO_INCREMENT"); - $pearDBndo->query("ALTER TABLE `{$prefix}servicestatus` CHANGE `servicestatus_id` `servicestatus_id` BIGINT NOT NULL AUTO_INCREMENT"); - } + $query = "ALTER TABLE `{$prefix}hoststatus` CHANGE `hoststatus_id` `hoststatus_id` BIGINT " . + "NOT NULL AUTO_INCREMENT"; + $pearDBndo->query($query); + $query = "ALTER TABLE `{$prefix}servicestatus` CHANGE `servicestatus_id` `servicestatus_id` BIGINT " . + "NOT NULL AUTO_INCREMENT"; + $pearDBndo->query($query); + } } -?> diff --git a/www/install/php/Update-2.3.9_to_2.4.0-RC1.post.php b/www/install/php/Update-2.3.9_to_2.4.0-RC1.post.php index 27273c52b25..16fb921586d 100644 --- a/www/install/php/Update-2.3.9_to_2.4.0-RC1.post.php +++ b/www/install/php/Update-2.3.9_to_2.4.0-RC1.post.php @@ -60,4 +60,3 @@ $pearDB->query($str . $str2); } }*/ -?> \ No newline at end of file diff --git a/www/install/php/Update-2.4.0-RC5_to_2.4.0-RC6.post.php b/www/install/php/Update-2.4.0-RC5_to_2.4.0-RC6.post.php index cd9791cb1cb..e5865d215d5 100644 --- a/www/install/php/Update-2.4.0-RC5_to_2.4.0-RC6.post.php +++ b/www/install/php/Update-2.4.0-RC5_to_2.4.0-RC6.post.php @@ -35,21 +35,21 @@ */ if (isset($pearDB)) { - $query = "SELECT n.interval_length FROM cfg_nagios n, nagios_server ns WHERE ns.id = n.nagios_server_id AND n.interval_length IS NOT NULL ORDER BY localhost DESC LIMIT 1"; + $query = "SELECT n.interval_length FROM cfg_nagios n, nagios_server ns +WHERE ns.id = n.nagios_server_id AND n.interval_length IS NOT NULL ORDER BY localhost DESC LIMIT 1"; $res = $pearDB->query($query); $row = $res->fetchRow(); - + /* * Check configured value */ if (!isset($row['interval_length'])) { - $row['interval_length'] = 60; + $row['interval_length'] = 60; } - + /* * Update */ $str = "INSERT INTO options (`key`, `value`) VALUES ('interval_length', '" . $row['interval_length'] . "')"; $pearDB->query($str); } -?> \ No newline at end of file diff --git a/www/install/php/Update-2.4.0-RC6_to_2.4.0-RC7.post.php b/www/install/php/Update-2.4.0-RC6_to_2.4.0-RC7.post.php index 20077e30cde..f2e72575375 100644 --- a/www/install/php/Update-2.4.0-RC6_to_2.4.0-RC7.post.php +++ b/www/install/php/Update-2.4.0-RC6_to_2.4.0-RC7.post.php @@ -35,7 +35,8 @@ */ if (isset($pearDB)) { - $pearDB->query("DELETE FROM `auth_ressource` WHERE `ar_id` NOT IN (SELECT DISTINCT ar_id FROM auth_ressource_info)"); + $pearDB->query("DELETE FROM `auth_ressource` +WHERE `ar_id` NOT IN (SELECT DISTINCT ar_id FROM auth_ressource_info)"); $res = $pearDB->query("SELECT `value` FROM `options` WHERE `key` = 'ldap_auth_enable'"); $row = $res->fetchRow(); // LDAP is enabled, we can proceed with the migration @@ -66,27 +67,31 @@ foreach ($hostData as $arId => $hData) { if (isset($hData['host'])) { $i++; - $sql = "INSERT INTO auth_ressource_host (auth_ressource_id, host_address, host_port, use_ssl, use_tls, host_order) - VALUES (".$arId.", '".$hData['host']."', '".$hData['port']."', '".$hData['use_ssl']."', '".$hData['use_tls']."', $i)"; + $sql = "INSERT INTO auth_ressource_host (auth_ressource_id, + host_address, host_port, use_ssl, use_tls, host_order) + VALUES (" . $arId . ", '" . $hData['host'] . "', '" . $hData['port'] . + "', '" . $hData['use_ssl'] . "', '" . $hData['use_tls'] . "', $i)"; $pearDB->query($sql); - $pearDB->query("DELETE FROM auth_ressource_info WHERE `ari_name` IN ('host', 'port', 'use_ssl', 'use_tls') AND ar_id = $arId"); + $pearDB->query("DELETE FROM auth_ressource_info +WHERE `ari_name` IN ('host', 'port', 'use_ssl', 'use_tls') AND ar_id = $arId"); foreach ($data as $k => $v) { $pearDB->query("INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) - VALUES (".$arId.", '".$k."', '".$v."')"); + VALUES (" . $arId . ", '" . $k . "', '" . $v . "')"); } foreach ($templateData as $k => $v) { $pearDB->query("INSERT INTO auth_ressource_info (ar_id, ari_name, ari_value) - VALUES (".$arId.", '".$k."', '".$v."')"); + VALUES (" . $arId . ", '" . $k . "', '" . $v . "')"); } } } $pearDB->query("UPDATE auth_ressource SET ar_name = 'Default configuration', ar_description = 'Default configuration' WHERE ar_enable = '1'"); - $pearDB->query("DELETE FROM `options` WHERE `key` LIKE 'ldap\_%' AND `key` <> 'ldap_auth_enable' AND `key` <> 'ldap_last_acl_update'"); + $pearDB->query("DELETE FROM `options` WHERE `key` LIKE 'ldap\_%' +AND `key` <> 'ldap_auth_enable' AND `key` <> 'ldap_last_acl_update'"); $pearDB->query("DELETE FROM `auth_ressource` WHERE `ar_enable` = '0'"); } - + /* * Checks if enable_perfdata_sync exists */ @@ -95,7 +100,7 @@ $pearDB->query("INSERT INTO `options` (`key`, `value`) VALUES ('enable_perfdata_sync', '1')"); } unset($res); - + /* * Checks if enable_logs_sync exists */ @@ -105,4 +110,3 @@ } unset($res); } -?> \ No newline at end of file diff --git a/www/install/php/Update-2.4.1_to_2.4.2.php b/www/install/php/Update-2.4.1_to_2.4.2.php index 0a7d48c8013..5492d3cb975 100644 --- a/www/install/php/Update-2.4.1_to_2.4.2.php +++ b/www/install/php/Update-2.4.1_to_2.4.2.php @@ -38,8 +38,9 @@ if ($res->rowCount()) { $row = $res->fetchRow(); $prefix = $row['db_prefix']; - $pearDBndo->query("ALTER TABLE `{$prefix}acknowledgements` ADD INDEX idx_reporting_ack (object_id, acknowledgement_id, entry_time)"); - $pearDBndo->query("ALTER TABLE `{$prefix}downtimehistory` ADD INDEX idx_reporting_donwtime (was_started, actual_start_time, actual_end_time)"); - } + $pearDBndo->query("ALTER TABLE `{$prefix}acknowledgements` +ADD INDEX idx_reporting_ack (object_id, acknowledgement_id, entry_time)"); + $pearDBndo->query("ALTER TABLE `{$prefix}downtimehistory` +ADD INDEX idx_reporting_donwtime (was_started, actual_start_time, actual_end_time)"); + } } -?> diff --git a/www/install/php/Update-2.4.5_to_2.5.0.post.php b/www/install/php/Update-2.4.5_to_2.5.0.post.php index a7dda61e5e9..2d72e39d810 100644 --- a/www/install/php/Update-2.4.5_to_2.5.0.post.php +++ b/www/install/php/Update-2.4.5_to_2.5.0.post.php @@ -47,13 +47,14 @@ while ($row = $res->fetchRow()) { if (!isset($hc[$row['name']])) { $pearDB->query("INSERT INTO hostcategories (hc_name, hc_alias, level, icon_id, hc_comment) VALUES ( - '".$pearDB->escape($row['name'])."', - '".$pearDB->escape($row['name'])."', - '".$pearDB->escape($row['level'])."', - '".$pearDB->escape($row['icon_id'])."', - '".$pearDB->escape($row['comments'])."' + '" . $pearDB->escape($row['name']) . "', + '" . $pearDB->escape($row['name']) . "', + '" . $pearDB->escape($row['level']) . "', + '" . $pearDB->escape($row['icon_id']) . "', + '" . $pearDB->escape($row['comments']) . "' )"); - $res2 = $pearDB->query("SELECT MAX(hc_id) as last_id FROM hostcategories WHERE hc_name = '".$pearDB->escape($row['name'])."'"); + $res2 = $pearDB->query("SELECT MAX(hc_id) as last_id FROM hostcategories WHERE hc_name = '" . + $pearDB->escape($row['name']) . "'"); $row2 = $res2->fetchRow(); $hc[$row['name']] = $row2['last_id']; } @@ -61,7 +62,7 @@ {$hc[$row['name']]}, {$row['host_id']} )"); } - + /* * Service severity */ @@ -73,14 +74,16 @@ $sc = array(); while ($row = $res->fetchRow()) { if (!isset($sc[$row['name']])) { - $pearDB->query("INSERT INTO service_categories (sc_name, sc_description, level, icon_id, sc_activate) VALUES ( - '".$pearDB->escape($row['name'])."', - '".$pearDB->escape($row['name'])."', - '".$pearDB->escape($row['level'])."', - '".$pearDB->escape($row['icon_id'])."', + $pearDB->query("INSERT INTO service_categories (sc_name, sc_description, level, icon_id, sc_activate) " . + "VALUES ( + '" . $pearDB->escape($row['name']) . "', + '" . $pearDB->escape($row['name']) . "', + '" . $pearDB->escape($row['level']) . "', + '" . $pearDB->escape($row['icon_id']) . "', '1' )"); - $res2 = $pearDB->query("SELECT MAX(sc_id) as last_id FROM service_categories WHERE sc_name = '".$pearDB->escape($row['name'])."'"); + $res2 = $pearDB->query("SELECT MAX(sc_id) as last_id FROM service_categories WHERE sc_name = '" . + $pearDB->escape($row['name']) . "'"); $row2 = $res2->fetchRow(); $sc[$row['name']] = $row2['last_id']; } @@ -88,38 +91,41 @@ {$sc[$row['name']]}, {$row['service_id']} )"); } - + $pearDB->query("DROP TABLE criticality_resource_relations"); $pearDB->query("DROP TABLE criticality"); - + /** * conf.pm */ - - $patterns = array('/--ADDRESS--/', - '/--DBUSER--/', - '/--DBPASS--/', - '/--CONFDB--/', - '/--STORAGEDB--/', - '/--CENTREONDIR--/', - '/--DBPORT--/', - '/--INSTANCEMODE--/', - '/--CENTREON_VARLIB--/'); - $replacements = array($conf_centreon['hostCentreon'], - $conf_centreon['user'], - $conf_centreon['password'], - $conf_centreon['db'], - $conf_centreon['dbcstg'], - _CENTREON_PATH_, - isset($conf_centreon['port']) ? $conf_centreon['port'] : 3306, - "central", - "@CENTREON_VARLIB@"); - + $patterns = array( + '/--ADDRESS--/', + '/--DBUSER--/', + '/--DBPASS--/', + '/--CONFDB--/', + '/--STORAGEDB--/', + '/--CENTREONDIR--/', + '/--DBPORT--/', + '/--INSTANCEMODE--/', + '/--CENTREON_VARLIB--/' + ); + + $replacements = array( + $conf_centreon['hostCentreon'], + $conf_centreon['user'], + $conf_centreon['password'], + $conf_centreon['db'], + $conf_centreon['dbcstg'], + _CENTREON_PATH_, + isset($conf_centreon['port']) ? $conf_centreon['port'] : 3306, + "central", + "@CENTREON_VARLIB@" + ); + $centreonConfPmFile = '@CENTREON_ETC@/conf.pm'; $contents = file_get_contents('../../var/configFilePmTemplate'); $contents = preg_replace($patterns, $replacements, $contents); file_put_contents($centreonConfPmFile, $contents); //@unlink('@CENTREON_ETC@/conf.pm'); } -?> \ No newline at end of file diff --git a/www/install/php/Update-2.5.1_to_2.5.2.php b/www/install/php/Update-2.5.1_to_2.5.2.php index d3a193d6c9f..acca40c317d 100644 --- a/www/install/php/Update-2.5.1_to_2.5.2.php +++ b/www/install/php/Update-2.5.1_to_2.5.2.php @@ -37,7 +37,10 @@ $res = $pearDB->query( "SELECT IF ( EXISTS( - SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = 'centreon' AND TABLE_NAME = 'nagios_server' AND COLUMN_NAME = 'init_script_centreontrapd' + SELECT * FROM information_schema.COLUMNS + WHERE TABLE_SCHEMA = 'centreon' + AND TABLE_NAME = 'nagios_server' + AND COLUMN_NAME = 'init_script_centreontrapd' ), 'yes', 'no' @@ -46,8 +49,8 @@ if ($res->rowCount()) { $row = $res->fetchRow(); if ($row['init_trap'] == 'no') { - $pearDB->query("ALTER TABLE `nagios_server` CHANGE `init_script_snmptt` `init_script_centreontrapd` VARCHAR(255)"); + $query = "ALTER TABLE `nagios_server` CHANGE `init_script_snmptt` `init_script_centreontrapd` VARCHAR(255)"; + $pearDB->query($query); } - } + } } -?> diff --git a/www/install/php/Update-2.6.6_to_2.7.0-RC1.post.php b/www/install/php/Update-2.6.6_to_2.7.0-RC1.post.php index f9cf9b503a4..d00b5269bcb 100644 --- a/www/install/php/Update-2.6.6_to_2.7.0-RC1.post.php +++ b/www/install/php/Update-2.6.6_to_2.7.0-RC1.post.php @@ -56,7 +56,7 @@ } } $query3 = "UPDATE cfg_centreonbroker - SET retention_path = '" . $pearDB->escape($retention_path). "' + SET retention_path = '" . $pearDB->escape($retention_path) . "' WHERE config_id = " . $pearDB->escape($row1['config_id']); $pearDB->query($query3); } @@ -66,7 +66,9 @@ (SELECT cbi2.config_id,cbi2.config_group,cbi2.config_group_id FROM cfg_centreonbroker_info cbi1, cfg_centreonbroker_info cbi2, cfg_centreonbroker_info cbi3 WHERE cbi1.config_id = cbi2.config_id and cbi1.config_group = cbi2.config_group - AND cbi2.config_id = cbi3.config_id AND cbi2.config_group = cbi3.config_group AND cbi2.config_group_id = cbi3.config_group_id + AND cbi2.config_id = cbi3.config_id + AND cbi2.config_group = cbi3.config_group + AND cbi2.config_group_id = cbi3.config_group_id AND cbi1.config_group='output' AND cbi2.config_group='output' AND cbi3.config_group='output' @@ -88,7 +90,7 @@ } # Delete failover names which join to non existing failover - $query ="UPDATE cfg_centreonbroker_info + $query = "UPDATE cfg_centreonbroker_info SET config_value='' WHERE config_key = 'failover' AND config_value NOT IN @@ -115,7 +117,7 @@ WHERE config_group='correlation' OR config_group='stats' OR config_group='temporary'"; - $pearDB->query($query); + $pearDB->query($query); # Delete correlation, stats and temporary tabs $query = "DELETE FROM cb_tag @@ -131,4 +133,3 @@ OR name='temporary'"; $pearDB->query($query); } -?> diff --git a/www/install/php/Update-2.7.0-RC2_to_2.7.0.post.php b/www/install/php/Update-2.7.0-RC2_to_2.7.0.post.php index 726ff78dd71..f52e8b393da 100644 --- a/www/install/php/Update-2.7.0-RC2_to_2.7.0.post.php +++ b/www/install/php/Update-2.7.0-RC2_to_2.7.0.post.php @@ -51,5 +51,3 @@ $pearDB->query($query2); } - -?> diff --git a/www/install/php/Update-2.7.0_to_2.7.1.php b/www/install/php/Update-2.7.0_to_2.7.1.php index 22f936bf59f..27c881dc273 100644 --- a/www/install/php/Update-2.7.0_to_2.7.1.php +++ b/www/install/php/Update-2.7.0_to_2.7.1.php @@ -39,11 +39,9 @@ $querySelect = "select contact_id, contact_name, contact_alias from contact "; $res = $pearDB->query($querySelect); while ($row = $res->fetchRow()) { - $queryUpdate = " Update contact set contact_name = '".html_entity_decode($row['contact_name'])."'," - . " contact_alias = '".html_entity_decode($row['contact_alias'])."'" - . " where contact_id = ".$row['contact_id'].";"; + $queryUpdate = " Update contact set contact_name = '" . html_entity_decode($row['contact_name']) . "'," + . " contact_alias = '" . html_entity_decode($row['contact_alias']) . "'" + . " where contact_id = " . $row['contact_id'] . ";"; $pearDB->query($queryUpdate); - } + } } - -?> diff --git a/www/install/php/Update-2.7.1_to_2.7.2.php b/www/install/php/Update-2.7.1_to_2.7.2.php index 43bb626b0b1..d342f9ba6cb 100644 --- a/www/install/php/Update-2.7.1_to_2.7.2.php +++ b/www/install/php/Update-2.7.1_to_2.7.2.php @@ -39,13 +39,12 @@ $querySelect = "SELECT meta_id, meta_name FROM meta_service "; $res = $pearDB->query($querySelect); while ($row = $res->fetchRow()) { - $queryUpdate = "UPDATE IGNORE service s, host h, host_service_relation hsr SET s.service_description = 'meta_" . $row['meta_id'] . "' " + $queryUpdate = "UPDATE IGNORE service s, host h, host_service_relation hsr SET s.service_description = 'meta_" + . $row['meta_id'] . "' " . "WHERE h.host_name = '_Module_Meta' " . "AND s.service_description = '" . $row['meta_name'] . "' " . "AND h.host_id = hsr.host_host_id " . "AND s.service_id = hsr.service_service_id;"; $pearDB->query($queryUpdate); - } + } } - -?> diff --git a/www/install/php/Update-2.8.0-beta2_to_2.8.0.php b/www/install/php/Update-2.8.0-beta2_to_2.8.0.php index 90b73866a7e..b5839e7fa00 100644 --- a/www/install/php/Update-2.8.0-beta2_to_2.8.0.php +++ b/www/install/php/Update-2.8.0-beta2_to_2.8.0.php @@ -104,5 +104,3 @@ } } } - -?> diff --git a/www/install/php/Update-2.8.3_to_2.8.4.php b/www/install/php/Update-2.8.3_to_2.8.4.php index 854e7333a89..bfca3224b74 100644 --- a/www/install/php/Update-2.8.3_to_2.8.4.php +++ b/www/install/php/Update-2.8.3_to_2.8.4.php @@ -39,7 +39,7 @@ $query = "SELECT count(*) AS number FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = 'hosts' - AND table_schema = '".$conf_centreon['dbcstg']."' + AND table_schema = '" . $conf_centreon['dbcstg'] . "' AND column_name = 'timezone'"; $res = $pearDBO->query($query); $data = $res->fetchRow(); From e2dbc7c023b5c6cb7adfcc2d998523c778294a11 Mon Sep 17 00:00:00 2001 From: Kevin Duret Date: Fri, 18 Aug 2017 09:12:09 +0200 Subject: [PATCH 187/207] avoid php warning when default broker field value is empty --- www/class/centreonConfigCentreonBroker.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/www/class/centreonConfigCentreonBroker.php b/www/class/centreonConfigCentreonBroker.php index 46f2cb8b2d1..7efadb8ad30 100644 --- a/www/class/centreonConfigCentreonBroker.php +++ b/www/class/centreonConfigCentreonBroker.php @@ -1145,6 +1145,9 @@ public function getInfoDb($string) */ $configs = explode(':', $string); foreach ($configs as $config) { + if (strpos($config, '=') == false) { + continue; + } list($key, $value) = explode('=', $config); switch ($key) { case 'D': From 58e72195b1a2ec795363bcad58f5bdfe2aea268b Mon Sep 17 00:00:00 2001 From: Kevin Duret Date: Fri, 18 Aug 2017 09:22:57 +0200 Subject: [PATCH 188/207] fix clapi require libs --- www/class/centreon-clapi/centreonAPI.class.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/www/class/centreon-clapi/centreonAPI.class.php b/www/class/centreon-clapi/centreonAPI.class.php index 167bd08654c..85c1d292252 100644 --- a/www/class/centreon-clapi/centreonAPI.class.php +++ b/www/class/centreon-clapi/centreonAPI.class.php @@ -398,7 +398,7 @@ protected function requireLibs($object) if ($object != "") { if (isset($this->relationObject[$object]['class']) && isset($this->relationObject[$object]['module']) - && !class_exists("Centreon" . $this->relationObject[$object]['class']) + && !class_exists("\CentreonClapi\Centreon" . $this->relationObject[$object]['class']) ) { if ($this->relationObject[$object]['module'] == 'core') { require_once "centreon" . $this->relationObject[$object]['class'] . ".class.php"; @@ -674,7 +674,6 @@ public function launchAction($exit = true) $objName = ""; } - if (!isset($this->relationObject[$this->object]['class']) || !class_exists($objName)) { print "Object $this->object not found in Centreon API.\n"; return 1; From 80a0405267ed1405b9838821637ed7c5aa4d26cf Mon Sep 17 00:00:00 2001 From: loiclau Date: Fri, 18 Aug 2017 10:58:56 +0200 Subject: [PATCH 189/207] * fix style lib html --- www/lib/HTML/Common.php | 943 +++++++++++---------- www/lib/HTML/QuickForm.php | 1256 +++++++++++++++++----------- www/lib/HTML/QuickForm/select.php | 198 ++--- www/lib/HTML/QuickForm/select2.php | 75 +- 4 files changed, 1373 insertions(+), 1099 deletions(-) diff --git a/www/lib/HTML/Common.php b/www/lib/HTML/Common.php index b6b82e63c17..a97b9abc18e 100644 --- a/www/lib/HTML/Common.php +++ b/www/lib/HTML/Common.php @@ -1,472 +1,471 @@ - - * @copyright 2001-2009 The PHP Group - * @license http://www.php.net/license/3_01.txt PHP License 3.01 - * @version CVS: $Id: Common.php,v 1.15 2009/04/03 15:26:22 avb Exp $ - * @link http://pear.php.net/package/HTML_Common/ - */ - -/** - * Base class for all HTML classes - * - * @category HTML - * @package HTML_Common - * @author Adam Daniel - * @version Release: 1.2.5 - * @abstract - */ -class HTML_Common -{ - /** - * Associative array of attributes - * @var array - * @access private - */ - var $_attributes = array(); - - /** - * Tab offset of the tag - * @var int - * @access private - */ - var $_tabOffset = 0; - - /** - * Tab string - * @var string - * @since 1.7 - * @access private - */ - var $_tab = "\11"; - - /** - * Contains the line end string - * @var string - * @since 1.7 - * @access private - */ - var $_lineEnd = "\12"; - - /** - * HTML comment on the object - * @var string - * @since 1.5 - * @access private - */ - var $_comment = ''; - - /** - * Class constructor - * @param mixed $attributes Associative array of table tag attributes - * or HTML attributes name="value" pairs - * @param int $tabOffset Indent offset in tabs - * @access public - */ - function HTML_Common($attributes = null, $tabOffset = 0) - { - $this->setAttributes($attributes); - $this->setTabOffset($tabOffset); - } // end constructor - - /** - * Returns the current API version - * @access public - * @returns double - */ - function apiVersion() - { - return 1.7; - } // end func apiVersion - - /** - * Returns the lineEnd - * - * @since 1.7 - * @access private - * @return string - */ - function _getLineEnd() - { - return $this->_lineEnd; - } // end func getLineEnd - - /** - * Returns a string containing the unit for indenting HTML - * - * @since 1.7 - * @access private - * @return string - */ - function _getTab() - { - return $this->_tab; - } // end func _getTab - - /** - * Returns a string containing the offset for the whole HTML code - * - * @return string - * @access private - */ - function _getTabs() - { - return str_repeat($this->_getTab(), $this->_tabOffset); - } // end func _getTabs - - /** - * Returns an HTML formatted attribute string - * @param array $attributes - * @return string - * @access private - */ - function _getAttrString($attributes) - { - $strAttr = ''; - - if (is_array($attributes)) { - $charset = HTML_Common::charset(); - foreach ($attributes as $key => $value) { - if(is_array($value)){ - foreach ($value as $val){ - $strAttr .= ' ' . $key . '="' . htmlspecialchars($val, ENT_COMPAT, $charset) . '"'; - } - }else{ - $strAttr .= ' ' . $key . '="' . htmlspecialchars($value, ENT_COMPAT, $charset) . '"'; - } - - } - } - return $strAttr; - } // end func _getAttrString - - /** - * Returns a valid atrributes array from either a string or array - * @param mixed $attributes Either a typical HTML attribute string or an associative array - * @access private - * @return array - */ - function _parseAttributes($attributes) - { - if (is_array($attributes)) { - $ret = array(); - foreach ($attributes as $key => $value) { - if (is_int($key)) { - $key = $value = strtolower($value); - } else { - $key = strtolower($key); - } - $ret[$key] = $value; - } - return $ret; - - } elseif (is_string($attributes)) { - $preg = "/(([A-Za-z_:]|[^\\x00-\\x7F])([A-Za-z0-9_:.-]|[^\\x00-\\x7F])*)" . - "([ \\n\\t\\r]+)?(=([ \\n\\t\\r]+)?(\"[^\"]*\"|'[^']*'|[^ \\n\\t\\r]*))?/"; - if (preg_match_all($preg, $attributes, $regs)) { - for ($counter=0; $counter $value) { - $attr1[$key] = $value; - } - } // end func _updateAtrrArray - - /** - * Removes the given attribute from the given array - * - * @param string $attr Attribute name - * @param array $attributes Attribute array - * @since 1.4 - * @access private - * @return void - */ - function _removeAttr($attr, &$attributes) - { - $attr = strtolower($attr); - if (isset($attributes[$attr])) { - unset($attributes[$attr]); - } - } //end func _removeAttr - - /** - * Returns the value of the given attribute - * - * @param string $attr Attribute name - * @since 1.5 - * @access public - * @return string|null returns null if an attribute does not exist - */ - function getAttribute($attr) - { - $attr = strtolower($attr); - if (isset($this->_attributes[$attr])) { - return $this->_attributes[$attr]; - } - return null; - } //end func getAttribute - - /** - * Sets the value of the attribute - * - * @param string Attribute name - * @param string Attribute value (will be set to $name if omitted) - * @access public - */ - function setAttribute($name, $value = null) - { - $name = strtolower($name); - if (is_null($value)) { - $value = $name; - } - $this->_attributes[$name] = $value; - } // end func setAttribute - - /** - * Sets the HTML attributes - * @param mixed $attributes Either a typical HTML attribute string or an associative array - * @access public - */ - function setAttributes($attributes) - { - $this->_attributes = $this->_parseAttributes($attributes); - } // end func setAttributes - - /** - * Returns the assoc array (default) or string of attributes - * - * @param bool Whether to return the attributes as string - * @since 1.6 - * @access public - * @return mixed attributes - */ - function getAttributes($asString = false) - { - if ($asString) { - return $this->_getAttrString($this->_attributes); - } else { - return $this->_attributes; - } - } //end func getAttributes - - /** - * Updates the passed attributes without changing the other existing attributes - * @param mixed $attributes Either a typical HTML attribute string or an associative array - * @access public - */ - function updateAttributes($attributes) - { - $this->_updateAttrArray($this->_attributes, $this->_parseAttributes($attributes)); - } // end func updateAttributes - - /** - * Removes an attribute - * - * @param string $attr Attribute name - * @since 1.4 - * @access public - * @return void - */ - function removeAttribute($attr) - { - $this->_removeAttr($attr, $this->_attributes); - } //end func removeAttribute - - /** - * Sets the line end style to Windows, Mac, Unix or a custom string. - * - * @param string $style "win", "mac", "unix" or custom string. - * @since 1.7 - * @access public - * @return void - */ - function setLineEnd($style) - { - switch ($style) { - case 'win': - $this->_lineEnd = "\15\12"; - break; - case 'unix': - $this->_lineEnd = "\12"; - break; - case 'mac': - $this->_lineEnd = "\15"; - break; - default: - $this->_lineEnd = $style; - } - } // end func setLineEnd - - /** - * Sets the tab offset - * - * @param int $offset - * @access public - */ - function setTabOffset($offset) - { - $this->_tabOffset = $offset; - } // end func setTabOffset - - /** - * Returns the tabOffset - * - * @since 1.5 - * @access public - * @return int - */ - function getTabOffset() - { - return $this->_tabOffset; - } //end func getTabOffset - - /** - * Sets the string used to indent HTML - * - * @since 1.7 - * @param string $string String used to indent ("\11", "\t", ' ', etc.). - * @access public - * @return void - */ - function setTab($string) - { - $this->_tab = $string; - } // end func setTab - - /** - * Sets the HTML comment to be displayed at the beginning of the HTML string - * - * @param string - * @since 1.4 - * @access public - * @return void - */ - function setComment($comment) - { - $this->_comment = $comment; - } // end func setHtmlComment - - /** - * Returns the HTML comment - * - * @since 1.5 - * @access public - * @return string - */ - function getComment() - { - return $this->_comment; - } //end func getComment - - /** - * Abstract method. Must be extended to return the objects HTML - * - * @access public - * @return string - * @abstract - */ - function toHtml() - { - return ''; - } // end func toHtml - - /** - * Displays the HTML to the screen - * - * @access public - */ - function display() - { - print $this->toHtml(); - } // end func display - - /** - * Sets the charset to use by htmlspecialchars() function - * - * Since this parameter is expected to be global, the function is designed - * to be called statically: - * - * HTML_Common::charset('utf-8'); - * - * or - * - * $charset = HTML_Common::charset(); - * - * - * @param string New charset to use. Omit if just getting the - * current value. Consult the htmlspecialchars() docs - * for a list of supported character sets. - * @return string Current charset - * @access public - * @static - */ - function charset($newCharset = null) - { - static $charset = 'ISO-8859-1'; - - if (!is_null($newCharset)) { - $charset = $newCharset; - } - return $charset; - } // end func charset -} // end class HTML_Common -?> + + * @copyright 2001-2009 The PHP Group + * @license http://www.php.net/license/3_01.txt PHP License 3.01 + * @version CVS: $Id: Common.php,v 1.15 2009/04/03 15:26:22 avb Exp $ + * @link http://pear.php.net/package/HTML_Common/ + */ + +/** + * Base class for all HTML classes + * + * @category HTML + * @package HTML_Common + * @author Adam Daniel + * @version Release: 1.2.5 + * @abstract + */ +class HTML_Common +{ + /** + * Associative array of attributes + * @var array + * @access private + */ + public $_attributes = array(); + + /** + * Tab offset of the tag + * @var int + * @access private + */ + public $_tabOffset = 0; + + /** + * Tab string + * @var string + * @since 1.7 + * @access private + */ + public $_tab = "\11"; + + /** + * Contains the line end string + * @var string + * @since 1.7 + * @access private + */ + public $_lineEnd = "\12"; + + /** + * HTML comment on the object + * @var string + * @since 1.5 + * @access private + */ + public $_comment = ''; + + /** + * Class constructor + * @param mixed $attributes Associative array of table tag attributes + * or HTML attributes name="value" pairs + * @param int $tabOffset Indent offset in tabs + * @access public + */ + public function HTML_Common($attributes = null, $tabOffset = 0) + { + $this->setAttributes($attributes); + $this->setTabOffset($tabOffset); + } // end constructor + + /** + * Returns the current API version + * @access public + * @returns double + */ + public function apiVersion() + { + return 1.7; + } // end func apiVersion + + /** + * Returns the lineEnd + * + * @since 1.7 + * @access private + * @return string + */ + public function _getLineEnd() + { + return $this->_lineEnd; + } // end func getLineEnd + + /** + * Returns a string containing the unit for indenting HTML + * + * @since 1.7 + * @access private + * @return string + */ + public function _getTab() + { + return $this->_tab; + } // end func _getTab + + /** + * Returns a string containing the offset for the whole HTML code + * + * @return string + * @access private + */ + public function _getTabs() + { + return str_repeat($this->_getTab(), $this->_tabOffset); + } // end func _getTabs + + /** + * Returns an HTML formatted attribute string + * @param array $attributes + * @return string + * @access private + */ + public function _getAttrString($attributes) + { + $strAttr = ''; + + if (is_array($attributes)) { + $charset = HTML_Common::charset(); + foreach ($attributes as $key => $value) { + if (is_array($value)) { + foreach ($value as $val) { + $strAttr .= ' ' . $key . '="' . htmlspecialchars($val, ENT_COMPAT, $charset) . '"'; + } + } else { + $strAttr .= ' ' . $key . '="' . htmlspecialchars($value, ENT_COMPAT, $charset) . '"'; + } + + } + } + return $strAttr; + } // end func _getAttrString + + /** + * Returns a valid atrributes array from either a string or array + * @param mixed $attributes Either a typical HTML attribute string or an associative array + * @access private + * @return array + */ + public function _parseAttributes($attributes) + { + if (is_array($attributes)) { + $ret = array(); + foreach ($attributes as $key => $value) { + if (is_int($key)) { + $key = $value = strtolower($value); + } else { + $key = strtolower($key); + } + $ret[$key] = $value; + } + return $ret; + + } elseif (is_string($attributes)) { + $preg = "/(([A-Za-z_:]|[^\\x00-\\x7F])([A-Za-z0-9_:.-]|[^\\x00-\\x7F])*)" . + "([ \\n\\t\\r]+)?(=([ \\n\\t\\r]+)?(\"[^\"]*\"|'[^']*'|[^ \\n\\t\\r]*))?/"; + if (preg_match_all($preg, $attributes, $regs)) { + for ($counter = 0; $counter < count($regs[1]); $counter++) { + $name = $regs[1][$counter]; + $check = $regs[0][$counter]; + $value = $regs[7][$counter]; + if (trim($name) == trim($check)) { + $arrAttr[strtolower(trim($name))] = strtolower(trim($name)); + } else { + if (substr($value, 0, 1) == "\"" || substr($value, 0, 1) == "'") { + $arrAttr[strtolower(trim($name))] = substr($value, 1, -1); + } else { + $arrAttr[strtolower(trim($name))] = trim($value); + } + } + } + return $arrAttr; + } + } + } // end func _parseAttributes + + /** + * Returns the array key for the given non-name-value pair attribute + * + * @param string $attr Attribute + * @param array $attributes Array of attribute + * @since 1.0 + * @access private + * @return bool + */ + public function _getAttrKey($attr, $attributes) + { + if (isset($attributes[strtolower($attr)])) { + return true; + } else { + return null; + } + } //end func _getAttrKey + + /** + * Updates the attributes in $attr1 with the values in $attr2 without changing the other existing attributes + * @param array $attr1 Original attributes array + * @param array $attr2 New attributes array + * @access private + */ + public function _updateAttrArray(&$attr1, $attr2) + { + if (!is_array($attr2)) { + return false; + } + foreach ($attr2 as $key => $value) { + $attr1[$key] = $value; + } + } // end func _updateAtrrArray + + /** + * Removes the given attribute from the given array + * + * @param string $attr Attribute name + * @param array $attributes Attribute array + * @since 1.4 + * @access private + * @return void + */ + public function _removeAttr($attr, &$attributes) + { + $attr = strtolower($attr); + if (isset($attributes[$attr])) { + unset($attributes[$attr]); + } + } //end func _removeAttr + + /** + * Returns the value of the given attribute + * + * @param string $attr Attribute name + * @since 1.5 + * @access public + * @return string|null returns null if an attribute does not exist + */ + public function getAttribute($attr) + { + $attr = strtolower($attr); + if (isset($this->_attributes[$attr])) { + return $this->_attributes[$attr]; + } + return null; + } //end func getAttribute + + /** + * Sets the value of the attribute + * + * @param string Attribute name + * @param string Attribute value (will be set to $name if omitted) + * @access public + */ + public function setAttribute($name, $value = null) + { + $name = strtolower($name); + if (is_null($value)) { + $value = $name; + } + $this->_attributes[$name] = $value; + } // end func setAttribute + + /** + * Sets the HTML attributes + * @param mixed $attributes Either a typical HTML attribute string or an associative array + * @access public + */ + public function setAttributes($attributes) + { + $this->_attributes = $this->_parseAttributes($attributes); + } // end func setAttributes + + /** + * Returns the assoc array (default) or string of attributes + * + * @param bool Whether to return the attributes as string + * @since 1.6 + * @access public + * @return mixed attributes + */ + public function getAttributes($asString = false) + { + if ($asString) { + return $this->_getAttrString($this->_attributes); + } else { + return $this->_attributes; + } + } //end func getAttributes + + /** + * Updates the passed attributes without changing the other existing attributes + * @param mixed $attributes Either a typical HTML attribute string or an associative array + * @access public + */ + public function updateAttributes($attributes) + { + $this->_updateAttrArray($this->_attributes, $this->_parseAttributes($attributes)); + } // end func updateAttributes + + /** + * Removes an attribute + * + * @param string $attr Attribute name + * @since 1.4 + * @access public + * @return void + */ + public function removeAttribute($attr) + { + $this->_removeAttr($attr, $this->_attributes); + } //end func removeAttribute + + /** + * Sets the line end style to Windows, Mac, Unix or a custom string. + * + * @param string $style "win", "mac", "unix" or custom string. + * @since 1.7 + * @access public + * @return void + */ + public function setLineEnd($style) + { + switch ($style) { + case 'win': + $this->_lineEnd = "\15\12"; + break; + case 'unix': + $this->_lineEnd = "\12"; + break; + case 'mac': + $this->_lineEnd = "\15"; + break; + default: + $this->_lineEnd = $style; + } + } // end func setLineEnd + + /** + * Sets the tab offset + * + * @param int $offset + * @access public + */ + public function setTabOffset($offset) + { + $this->_tabOffset = $offset; + } // end func setTabOffset + + /** + * Returns the tabOffset + * + * @since 1.5 + * @access public + * @return int + */ + public function getTabOffset() + { + return $this->_tabOffset; + } //end func getTabOffset + + /** + * Sets the string used to indent HTML + * + * @since 1.7 + * @param string $string String used to indent ("\11", "\t", ' ', etc.). + * @access public + * @return void + */ + public function setTab($string) + { + $this->_tab = $string; + } // end func setTab + + /** + * Sets the HTML comment to be displayed at the beginning of the HTML string + * + * @param string + * @since 1.4 + * @access public + * @return void + */ + public function setComment($comment) + { + $this->_comment = $comment; + } // end func setHtmlComment + + /** + * Returns the HTML comment + * + * @since 1.5 + * @access public + * @return string + */ + public function getComment() + { + return $this->_comment; + } //end func getComment + + /** + * Abstract method. Must be extended to return the objects HTML + * + * @access public + * @return string + * @abstract + */ + public function toHtml() + { + return ''; + } // end func toHtml + + /** + * Displays the HTML to the screen + * + * @access public + */ + public function display() + { + print $this->toHtml(); + } // end func display + + /** + * Sets the charset to use by htmlspecialchars() function + * + * Since this parameter is expected to be global, the function is designed + * to be called statically: + * + * HTML_Common::charset('utf-8'); + * + * or + * + * $charset = HTML_Common::charset(); + * + * + * @param string New charset to use. Omit if just getting the + * current value. Consult the htmlspecialchars() docs + * for a list of supported character sets. + * @return string Current charset + * @access public + * @static + */ + public function charset($newCharset = null) + { + static $charset = 'ISO-8859-1'; + + if (!is_null($newCharset)) { + $charset = $newCharset; + } + return $charset; + } // end func charset +} // end class HTML_Common diff --git a/www/lib/HTML/QuickForm.php b/www/lib/HTML/QuickForm.php index af4cce5621b..629e8c77420 100644 --- a/www/lib/HTML/QuickForm.php +++ b/www/lib/HTML/QuickForm.php @@ -3,7 +3,7 @@ /** * Create, validate and process HTML forms - * + * * PHP versions 4 and 5 * * LICENSE: This source file is subject to version 3.01 of the PHP license @@ -36,59 +36,59 @@ * Element types known to HTML_QuickForm * @see HTML_QuickForm::registerElementType(), HTML_QuickForm::getRegisteredTypes(), * HTML_QuickForm::isTypeRegistered() - * @global array $GLOBALS['HTML_QUICKFORM_ELEMENT_TYPES'] - */ -$GLOBALS['HTML_QUICKFORM_ELEMENT_TYPES'] = - array( - 'group' =>array('HTML/QuickForm/group.php','HTML_QuickForm_group'), - 'hidden' =>array('HTML/QuickForm/hidden.php','HTML_QuickForm_hidden'), - 'reset' =>array('HTML/QuickForm/reset.php','HTML_QuickForm_reset'), - 'checkbox' =>array('HTML/QuickForm/checkbox.php','HTML_QuickForm_checkbox'), - 'customcheckbox' =>array('HTML/QuickForm/customcheckbox.php','HTML_QuickForm_customcheckbox'), - 'file' =>array('HTML/QuickForm/file.php','HTML_QuickForm_file'), - 'image' =>array('HTML/QuickForm/image.php','HTML_QuickForm_image'), - 'password' =>array('HTML/QuickForm/password.php','HTML_QuickForm_password'), - 'radio' =>array('HTML/QuickForm/radio.php','HTML_QuickForm_radio'), - 'button' =>array('HTML/QuickForm/button.php','HTML_QuickForm_button'), - 'submit' =>array('HTML/QuickForm/submit.php','HTML_QuickForm_submit'), - 'select' =>array('HTML/QuickForm/select.php','HTML_QuickForm_select'), - 'select2' =>array('HTML/QuickForm/select2.php','HTML_QuickForm_select2'), - 'tags' =>array('HTML/QuickForm/tags.php','HTML_QuickForm_tags'), - 'hiddenselect' =>array('HTML/QuickForm/hiddenselect.php','HTML_QuickForm_hiddenselect'), - 'text' =>array('HTML/QuickForm/text.php','HTML_QuickForm_text'), - 'textarea' =>array('HTML/QuickForm/textarea.php','HTML_QuickForm_textarea'), - 'link' =>array('HTML/QuickForm/link.php','HTML_QuickForm_link'), - 'advcheckbox' =>array('HTML/QuickForm/advcheckbox.php','HTML_QuickForm_advcheckbox'), - 'date' =>array('HTML/QuickForm/date.php','HTML_QuickForm_date'), - 'static' =>array('HTML/QuickForm/static.php','HTML_QuickForm_static'), - 'header' =>array('HTML/QuickForm/header.php', 'HTML_QuickForm_header'), - 'html' =>array('HTML/QuickForm/html.php', 'HTML_QuickForm_html'), - 'hierselect' =>array('HTML/QuickForm/hierselect.php', 'HTML_QuickForm_hierselect'), - 'autocomplete' =>array('HTML/QuickForm/autocomplete.php', 'HTML_QuickForm_autocomplete'), - 'xbutton' =>array('HTML/QuickForm/xbutton.php','HTML_QuickForm_xbutton') - ); + * @global array $GLOBALS ['HTML_QUICKFORM_ELEMENT_TYPES'] + */ +$GLOBALS['HTML_QUICKFORM_ELEMENT_TYPES'] = + array( + 'group' => array('HTML/QuickForm/group.php', 'HTML_QuickForm_group'), + 'hidden' => array('HTML/QuickForm/hidden.php', 'HTML_QuickForm_hidden'), + 'reset' => array('HTML/QuickForm/reset.php', 'HTML_QuickForm_reset'), + 'checkbox' => array('HTML/QuickForm/checkbox.php', 'HTML_QuickForm_checkbox'), + 'customcheckbox' => array('HTML/QuickForm/customcheckbox.php', 'HTML_QuickForm_customcheckbox'), + 'file' => array('HTML/QuickForm/file.php', 'HTML_QuickForm_file'), + 'image' => array('HTML/QuickForm/image.php', 'HTML_QuickForm_image'), + 'password' => array('HTML/QuickForm/password.php', 'HTML_QuickForm_password'), + 'radio' => array('HTML/QuickForm/radio.php', 'HTML_QuickForm_radio'), + 'button' => array('HTML/QuickForm/button.php', 'HTML_QuickForm_button'), + 'submit' => array('HTML/QuickForm/submit.php', 'HTML_QuickForm_submit'), + 'select' => array('HTML/QuickForm/select.php', 'HTML_QuickForm_select'), + 'select2' => array('HTML/QuickForm/select2.php', 'HTML_QuickForm_select2'), + 'tags' => array('HTML/QuickForm/tags.php', 'HTML_QuickForm_tags'), + 'hiddenselect' => array('HTML/QuickForm/hiddenselect.php', 'HTML_QuickForm_hiddenselect'), + 'text' => array('HTML/QuickForm/text.php', 'HTML_QuickForm_text'), + 'textarea' => array('HTML/QuickForm/textarea.php', 'HTML_QuickForm_textarea'), + 'link' => array('HTML/QuickForm/link.php', 'HTML_QuickForm_link'), + 'advcheckbox' => array('HTML/QuickForm/advcheckbox.php', 'HTML_QuickForm_advcheckbox'), + 'date' => array('HTML/QuickForm/date.php', 'HTML_QuickForm_date'), + 'static' => array('HTML/QuickForm/static.php', 'HTML_QuickForm_static'), + 'header' => array('HTML/QuickForm/header.php', 'HTML_QuickForm_header'), + 'html' => array('HTML/QuickForm/html.php', 'HTML_QuickForm_html'), + 'hierselect' => array('HTML/QuickForm/hierselect.php', 'HTML_QuickForm_hierselect'), + 'autocomplete' => array('HTML/QuickForm/autocomplete.php', 'HTML_QuickForm_autocomplete'), + 'xbutton' => array('HTML/QuickForm/xbutton.php', 'HTML_QuickForm_xbutton') + ); /** - * Validation rules known to HTML_QuickForm + * Validation rules known to HTML_QuickForm * @see HTML_QuickForm::registerRule(), HTML_QuickForm::getRegisteredRules(), * HTML_QuickForm::isRuleRegistered() - * @global array $GLOBALS['_HTML_QuickForm_registered_rules'] + * @global array $GLOBALS ['_HTML_QuickForm_registered_rules'] */ $GLOBALS['_HTML_QuickForm_registered_rules'] = array( - 'required' => array('html_quickform_rule_required', 'HTML/QuickForm/Rule/Required.php'), - 'maxlength' => array('html_quickform_rule_range', 'HTML/QuickForm/Rule/Range.php'), - 'minlength' => array('html_quickform_rule_range', 'HTML/QuickForm/Rule/Range.php'), - 'rangelength' => array('html_quickform_rule_range', 'HTML/QuickForm/Rule/Range.php'), - 'email' => array('html_quickform_rule_email', 'HTML/QuickForm/Rule/Email.php'), - 'regex' => array('html_quickform_rule_regex', 'HTML/QuickForm/Rule/Regex.php'), - 'lettersonly' => array('html_quickform_rule_regex', 'HTML/QuickForm/Rule/Regex.php'), - 'alphanumeric' => array('html_quickform_rule_regex', 'HTML/QuickForm/Rule/Regex.php'), - 'numeric' => array('html_quickform_rule_regex', 'HTML/QuickForm/Rule/Regex.php'), - 'nopunctuation' => array('html_quickform_rule_regex', 'HTML/QuickForm/Rule/Regex.php'), - 'nonzero' => array('html_quickform_rule_regex', 'HTML/QuickForm/Rule/Regex.php'), - 'callback' => array('html_quickform_rule_callback', 'HTML/QuickForm/Rule/Callback.php'), - 'token' => array('html_quickform_rule_token', 'HTML/QuickForm/Rule/Token.php'), - 'compare' => array('html_quickform_rule_compare', 'HTML/QuickForm/Rule/Compare.php') + 'required' => array('html_quickform_rule_required', 'HTML/QuickForm/Rule/Required.php'), + 'maxlength' => array('html_quickform_rule_range', 'HTML/QuickForm/Rule/Range.php'), + 'minlength' => array('html_quickform_rule_range', 'HTML/QuickForm/Rule/Range.php'), + 'rangelength' => array('html_quickform_rule_range', 'HTML/QuickForm/Rule/Range.php'), + 'email' => array('html_quickform_rule_email', 'HTML/QuickForm/Rule/Email.php'), + 'regex' => array('html_quickform_rule_regex', 'HTML/QuickForm/Rule/Regex.php'), + 'lettersonly' => array('html_quickform_rule_regex', 'HTML/QuickForm/Rule/Regex.php'), + 'alphanumeric' => array('html_quickform_rule_regex', 'HTML/QuickForm/Rule/Regex.php'), + 'numeric' => array('html_quickform_rule_regex', 'HTML/QuickForm/Rule/Regex.php'), + 'nopunctuation' => array('html_quickform_rule_regex', 'HTML/QuickForm/Rule/Regex.php'), + 'nonzero' => array('html_quickform_rule_regex', 'HTML/QuickForm/Rule/Regex.php'), + 'callback' => array('html_quickform_rule_callback', 'HTML/QuickForm/Rule/Callback.php'), + 'token' => array('html_quickform_rule_token', 'HTML/QuickForm/Rule/Token.php'), + 'compare' => array('html_quickform_rule_compare', 'HTML/QuickForm/Rule/Compare.php') ); // {{{ error codes @@ -96,21 +96,21 @@ /**#@+ * Error codes for HTML_QuickForm * - * Codes are mapped to textual messages by errorMessage() method, if you add a + * Codes are mapped to textual messages by errorMessage() method, if you add a * new code be sure to add a new message for it to errorMessage() * * @see HTML_QuickForm::errorMessage() - */ -define('QUICKFORM_OK', 1); -define('QUICKFORM_ERROR', -1); -define('QUICKFORM_INVALID_RULE', -2); -define('QUICKFORM_NONEXIST_ELEMENT', -3); -define('QUICKFORM_INVALID_FILTER', -4); -define('QUICKFORM_UNREGISTERED_ELEMENT', -5); -define('QUICKFORM_INVALID_ELEMENT_NAME', -6); -define('QUICKFORM_INVALID_PROCESS', -7); -define('QUICKFORM_DEPRECATED', -8); -define('QUICKFORM_INVALID_DATASOURCE', -9); + */ +define('QUICKFORM_OK', 1); +define('QUICKFORM_ERROR', -1); +define('QUICKFORM_INVALID_RULE', -2); +define('QUICKFORM_NONEXIST_ELEMENT', -3); +define('QUICKFORM_INVALID_FILTER', -4); +define('QUICKFORM_UNREGISTERED_ELEMENT', -5); +define('QUICKFORM_INVALID_ELEMENT_NAME', -6); +define('QUICKFORM_INVALID_PROCESS', -7); +define('QUICKFORM_DEPRECATED', -8); +define('QUICKFORM_INVALID_DATASOURCE', -9); /**#@-*/ // }}} @@ -135,7 +135,7 @@ class HTML_QuickForm extends HTML_Common * @var array * @access private */ - var $_elements = array(); + public $_elements = array(); /** * Array containing element name to index map @@ -143,7 +143,7 @@ class HTML_QuickForm extends HTML_Common * @var array * @access private */ - var $_elementIndex = array(); + public $_elementIndex = array(); /** * Array containing indexes of duplicate elements @@ -151,31 +151,31 @@ class HTML_QuickForm extends HTML_Common * @var array * @access private */ - var $_duplicateIndex = array(); + public $_duplicateIndex = array(); /** * Array containing required field IDs * @since 1.0 * @var array * @access private - */ - var $_required = array(); + */ + public $_required = array(); /** * Prefix message in javascript alert if error * @since 1.0 * @var string * @access public - */ - var $_jsPrefix = 'Invalid information entered.'; + */ + public $_jsPrefix = 'Invalid information entered.'; /** * Postfix message in javascript alert if error * @since 1.0 * @var string * @access public - */ - var $_jsPostfix = 'Please correct these fields.'; + */ + public $_jsPostfix = 'Please correct these fields.'; /** * Datasource object implementing the informal @@ -184,7 +184,7 @@ class HTML_QuickForm extends HTML_Common * @var object * @access private */ - var $_datasource; + public $_datasource; /** * Array of default form values @@ -192,7 +192,7 @@ class HTML_QuickForm extends HTML_Common * @var array * @access private */ - var $_defaultValues = array(); + public $_defaultValues = array(); /** * Array of constant form values @@ -200,7 +200,7 @@ class HTML_QuickForm extends HTML_Common * @var array * @access private */ - var $_constantValues = array(); + public $_constantValues = array(); /** * Array of submitted form values @@ -208,7 +208,7 @@ class HTML_QuickForm extends HTML_Common * @var array * @access private */ - var $_submitValues = array(); + public $_submitValues = array(); /** * Array of submitted form files @@ -216,7 +216,7 @@ class HTML_QuickForm extends HTML_Common * @var integer * @access public */ - var $_submitFiles = array(); + public $_submitFiles = array(); /** * Value for maxfilesize hidden element if form contains file input @@ -224,7 +224,7 @@ class HTML_QuickForm extends HTML_Common * @var integer * @access public */ - var $_maxFileSize = 1048576; // 1 Mb = 1048576 + public $_maxFileSize = 1048576; // 1 Mb = 1048576 /** * Flag to know if all fields are frozen @@ -232,7 +232,7 @@ class HTML_QuickForm extends HTML_Common * @var boolean * @access private */ - var $_freezeAll = false; + public $_freezeAll = false; /** * Array containing the form rules @@ -240,14 +240,14 @@ class HTML_QuickForm extends HTML_Common * @var array * @access private */ - var $_rules = array(); + public $_rules = array(); /** * Form rules, global variety * @var array * @access private */ - var $_formRules = array(); + public $_formRules = array(); /** * Array containing the validation errors @@ -255,7 +255,7 @@ class HTML_QuickForm extends HTML_Common * @var array * @access private */ - var $_errors = array(); + public $_errors = array(); /** * Note for required fields in the form @@ -263,57 +263,65 @@ class HTML_QuickForm extends HTML_Common * @since 1.0 * @access private */ - var $_requiredNote = '* denotes required field'; + public $_requiredNote = '*' . + ' denotes required field'; /** * Whether the form was submitted * @var boolean * @access private */ - var $_flagSubmitted = false; - + public $_flagSubmitted = false; + /** * - * @var type + * @var type */ - var $_tokenValidated = false; + public $_tokenValidated = false; // }}} // {{{ constructor /** * Class constructor - * @param string $formName Form's name. - * @param string $method (optional)Form's method defaults to 'POST' - * @param string $action (optional)Form's action - * @param string $target (optional)Form's target defaults to '_self' - * @param mixed $attributes (optional)Extra attributes for tag - * @param bool $trackSubmit (optional)Whether to track if the form was submitted by adding a special hidden field + * @param string $formName Form's name. + * @param string $method (optional)Form's method defaults to 'POST' + * @param string $action (optional)Form's action + * @param string $target (optional)Form's target defaults to '_self' + * @param mixed $attributes (optional)Extra attributes for tag + * @param bool $trackSubmit (optional)Whether to track if the form was submitted by adding a special hidden field * @access public */ - function HTML_QuickForm($formName='', $method='post', $action='', $target='', $attributes=null, $trackSubmit = false) - { + public function HTML_QuickForm( + $formName = '', + $method = 'post', + $action = '', + $target = '', + $attributes = null, + $trackSubmit = false + ) { HTML_Common::HTML_Common($attributes); $method = (strtoupper($method) == 'GET') ? 'get' : 'post'; $action = ($action == '') ? $_SERVER['PHP_SELF'] : $action; $target = empty($target) ? array() : array('target' => $target); - $attributes = array('action'=>$action, 'method'=>$method, 'name'=>$formName, 'id'=>$formName) + $target; + $attributes = array('action' => $action, 'method' => $method, 'name' => $formName, 'id' => $formName) + $target; $this->updateAttributes($attributes); if (!$trackSubmit || isset($_REQUEST['_qf__' . $formName])) { if (1 == get_magic_quotes_gpc()) { - $this->_submitValues = $this->_recursiveFilter('stripslashes', 'get' == $method? $_GET: $_POST); + $this->_submitValues = $this->_recursiveFilter('stripslashes', 'get' == $method ? $_GET : $_POST); foreach ($_FILES as $keyFirst => $valFirst) { foreach ($valFirst as $keySecond => $valSecond) { if ('name' == $keySecond) { - $this->_submitFiles[$keyFirst][$keySecond] = $this->_recursiveFilter('stripslashes', $valSecond); + $this->_submitFiles[$keyFirst][$keySecond] = + $this->_recursiveFilter('stripslashes', $valSecond); } else { $this->_submitFiles[$keyFirst][$keySecond] = $valSecond; } } } } else { - $this->_submitValues = 'get' == $method? $_GET: $_POST; - $this->_submitFiles = $_FILES; + $this->_submitValues = 'get' == $method ? $_GET : $_POST; + $this->_submitFiles = $_FILES; } $this->_flagSubmitted = count($this->_submitValues) > 0 || count($this->_submitFiles) > 0; } @@ -350,7 +358,7 @@ function HTML_QuickForm($formName='', $method='post', $action='', $target='', $a * @access public * @return float */ - function apiVersion() + public function apiVersion() { return 3.2; } // end func apiVersion @@ -361,14 +369,14 @@ function apiVersion() /** * Registers a new element type * - * @param string $typeName Name of element type - * @param string $include Include path for element type - * @param string $className Element class name + * @param string $typeName Name of element type + * @param string $include Include path for element type + * @param string $className Element class name * @since 1.0 * @access public * @return void */ - function registerElementType($typeName, $include, $className) + public function registerElementType($typeName, $include, $className) { $GLOBALS['HTML_QUICKFORM_ELEMENT_TYPES'][strtolower($typeName)] = array($include, $className); } // end func registerElementType @@ -379,15 +387,15 @@ function registerElementType($typeName, $include, $className) /** * Registers a new validation rule * - * @param string $ruleName Name of validation rule - * @param string $type Either: 'regex', 'function' or 'rule' for an HTML_QuickForm_Rule object - * @param string $data1 Name of function, regular expression or HTML_QuickForm_Rule classname - * @param string $data2 Object parent of above function or HTML_QuickForm_Rule file path + * @param string $ruleName Name of validation rule + * @param string $type Either: 'regex', 'function' or 'rule' for an HTML_QuickForm_Rule object + * @param string $data1 Name of function, regular expression or HTML_QuickForm_Rule classname + * @param string $data2 Object parent of above function or HTML_QuickForm_Rule file path * @since 1.0 * @access public * @return void */ - function registerRule($ruleName, $type, $data1, $data2 = null) + public function registerRule($ruleName, $type, $data1, $data2 = null) { include_once('HTML/QuickForm/RuleRegistry.php'); $registry =& HTML_QuickForm_RuleRegistry::singleton(); @@ -400,12 +408,12 @@ function registerRule($ruleName, $type, $data1, $data2 = null) /** * Returns true if element is in the form * - * @param string $element form name of element to check + * @param string $element form name of element to check * @since 1.0 * @access public * @return boolean */ - function elementExists($element=null) + public function elementExists($element = null) { return isset($this->_elementIndex[$element]); } // end func elementExists @@ -419,15 +427,15 @@ function elementExists($element=null) * Datasource default and constant values will feed the QuickForm object if * the datasource implements defaultValues() and constantValues() methods. * - * @param object $datasource datasource object implementing the informal datasource protocol - * @param mixed $defaultsFilter string or array of filter(s) to apply to default values - * @param mixed $constantsFilter string or array of filter(s) to apply to constants values + * @param object $datasource datasource object implementing the informal datasource protocol + * @param mixed $defaultsFilter string or array of filter(s) to apply to default values + * @param mixed $constantsFilter string or array of filter(s) to apply to constants values * @since 3.3 * @access public * @return void * @throws HTML_QuickForm_Error */ - function setDatasource(&$datasource, $defaultsFilter = null, $constantsFilter = null) + public function setDatasource(&$datasource, $defaultsFilter = null, $constantsFilter = null) { if (is_object($datasource)) { $this->_datasource =& $datasource; @@ -438,7 +446,15 @@ function setDatasource(&$datasource, $defaultsFilter = null, $constantsFilter = $this->setConstants($datasource->constantValues($this), $constantsFilter); } } else { - return PEAR::raiseError(null, QUICKFORM_INVALID_DATASOURCE, null, E_USER_WARNING, "Datasource is not an object in QuickForm::setDatasource()", 'HTML_QuickForm_Error', true); + return PEAR::raiseError( + null, + QUICKFORM_INVALID_DATASOURCE, + null, + E_USER_WARNING, + "Datasource is not an object in QuickForm::setDatasource()", + 'HTML_QuickForm_Error', + true + ); } } // end func setDatasource @@ -448,27 +464,43 @@ function setDatasource(&$datasource, $defaultsFilter = null, $constantsFilter = /** * Initializes default form values * - * @param array $defaultValues values used to fill the form - * @param mixed $filter (optional) filter(s) to apply to all default values + * @param array $defaultValues values used to fill the form + * @param mixed $filter (optional) filter(s) to apply to all default values * @since 1.0 * @access public * @return void * @throws HTML_QuickForm_Error */ - function setDefaults($defaultValues = null, $filter = null) + public function setDefaults($defaultValues = null, $filter = null) { if (is_array($defaultValues)) { if (isset($filter)) { if (is_array($filter) && (2 != count($filter) || !is_callable($filter))) { foreach ($filter as $val) { if (!is_callable($val)) { - return PEAR::raiseError(null, QUICKFORM_INVALID_FILTER, null, E_USER_WARNING, "Callback function does not exist in QuickForm::setDefaults()", 'HTML_QuickForm_Error', true); + return PEAR::raiseError( + null, + QUICKFORM_INVALID_FILTER, + null, + E_USER_WARNING, + "Callback function does not exist in QuickForm::setDefaults()", + 'HTML_QuickForm_Error', + true + ); } else { $defaultValues = $this->_recursiveFilter($val, $defaultValues); } } } elseif (!is_callable($filter)) { - return PEAR::raiseError(null, QUICKFORM_INVALID_FILTER, null, E_USER_WARNING, "Callback function does not exist in QuickForm::setDefaults()", 'HTML_QuickForm_Error', true); + return PEAR::raiseError( + null, + QUICKFORM_INVALID_FILTER, + null, + E_USER_WARNING, + "Callback function does not exist in QuickForm::setDefaults()", + 'HTML_QuickForm_Error', + true + ); } else { $defaultValues = $this->_recursiveFilter($filter, $defaultValues); } @@ -487,28 +519,44 @@ function setDefaults($defaultValues = null, $filter = null) * Initializes constant form values. * These values won't get overridden by POST or GET vars * - * @param array $constantValues values used to fill the form - * @param mixed $filter (optional) filter(s) to apply to all default values + * @param array $constantValues values used to fill the form + * @param mixed $filter (optional) filter(s) to apply to all default values * * @since 2.0 * @access public * @return void * @throws HTML_QuickForm_Error */ - function setConstants($constantValues = null, $filter = null) + public function setConstants($constantValues = null, $filter = null) { if (is_array($constantValues)) { if (isset($filter)) { if (is_array($filter) && (2 != count($filter) || !is_callable($filter))) { foreach ($filter as $val) { if (!is_callable($val)) { - return PEAR::raiseError(null, QUICKFORM_INVALID_FILTER, null, E_USER_WARNING, "Callback function does not exist in QuickForm::setConstants()", 'HTML_QuickForm_Error', true); + return PEAR::raiseError( + null, + QUICKFORM_INVALID_FILTER, + null, + E_USER_WARNING, + "Callback function does not exist in QuickForm::setConstants()", + 'HTML_QuickForm_Error', + true + ); } else { $constantValues = $this->_recursiveFilter($val, $constantValues); } } } elseif (!is_callable($filter)) { - return PEAR::raiseError(null, QUICKFORM_INVALID_FILTER, null, E_USER_WARNING, "Callback function does not exist in QuickForm::setConstants()", 'HTML_QuickForm_Error', true); + return PEAR::raiseError( + null, + QUICKFORM_INVALID_FILTER, + null, + E_USER_WARNING, + "Callback function does not exist in QuickForm::setConstants()", + 'HTML_QuickForm_Error', + true + ); } else { $constantValues = $this->_recursiveFilter($filter, $constantValues); } @@ -526,12 +574,12 @@ function setConstants($constantValues = null, $filter = null) /** * Sets the value of MAX_FILE_SIZE hidden element * - * @param int $bytes Size in bytes + * @param int $bytes Size in bytes * @since 3.0 * @access public * @return void */ - function setMaxFileSize($bytes = 0) + public function setMaxFileSize($bytes = 0) { if ($bytes > 0) { $this->_maxFileSize = $bytes; @@ -554,7 +602,7 @@ function setMaxFileSize($bytes = 0) * @access public * @return int max file size in bytes */ - function getMaxFileSize() + public function getMaxFileSize() { return $this->_maxFileSize; } // end func getMaxFileSize @@ -564,19 +612,19 @@ function getMaxFileSize() /** * Creates a new form element of the given type. - * - * This method accepts variable number of parameters, their + * + * This method accepts variable number of parameters, their * meaning and count depending on $elementType * - * @param string $elementType type of element to add (text, textarea, file...) + * @param string $elementType type of element to add (text, textarea, file...) * @since 1.0 * @access public * @return HTML_QuickForm_Element * @throws HTML_QuickForm_Error */ - function &createElement($elementType) + public function &createElement($elementType) { - $args = func_get_args(); + $args = func_get_args(); $element =& HTML_QuickForm::_loadElement('createElement', $elementType, array_slice($args, 1)); return $element; } // end func createElement @@ -587,19 +635,27 @@ function &createElement($elementType) /** * Returns a form element of the given type * - * @param string $event event to send to newly created element ('createElement' or 'addElement') - * @param string $type element type - * @param array $args arguments for event + * @param string $event event to send to newly created element ('createElement' or 'addElement') + * @param string $type element type + * @param array $args arguments for event * @since 2.0 * @access private * @return HTML_QuickForm_Element * @throws HTML_QuickForm_Error */ - function &_loadElement($event, $type, $args) + public function &_loadElement($event, $type, $args) { $type = strtolower($type); if (!HTML_QuickForm::isTypeRegistered($type)) { - $error = PEAR::raiseError(null, QUICKFORM_UNREGISTERED_ELEMENT, null, E_USER_WARNING, "Element '$type' does not exist in HTML_QuickForm::_loadElement()", 'HTML_QuickForm_Error', true); + $error = PEAR::raiseError( + null, + QUICKFORM_UNREGISTERED_ELEMENT, + null, + E_USER_WARNING, + "Element '$type' does not exist in HTML_QuickForm::_loadElement()", + 'HTML_QuickForm_Error', + true + ); return $error; } $className = $GLOBALS['HTML_QUICKFORM_ELEMENT_TYPES'][$type][1]; @@ -623,22 +679,22 @@ function &_loadElement($event, $type, $args) /** * Adds an element into the form - * - * If $element is a string representing element type, then this - * method accepts variable number of parameters, their meaning + * + * If $element is a string representing element type, then this + * method accepts variable number of parameters, their meaning * and count depending on $element * - * @param mixed $element element object or type of element to add (text, textarea, file...) + * @param mixed $element element object or type of element to add (text, textarea, file...) * @since 1.0 * @return HTML_QuickForm_Element a reference to newly added element * @access public * @throws HTML_QuickForm_Error */ - function &addElement($element) + public function &addElement($element) { if (is_object($element) && is_subclass_of($element, 'html_quickform_element')) { - $elementObject = &$element; - $elementObject->onQuickFormEvent('updateValue', null, $this); + $elementObject = &$element; + $elementObject->onQuickFormEvent('updateValue', null, $this); } else { $args = func_get_args(); $elementObject =& $this->_loadElement('addElement', $element, array_slice($args, 1)); @@ -656,7 +712,15 @@ function &addElement($element) $elKeys = array_keys($this->_elements); $this->_duplicateIndex[$elementName][] = end($elKeys); } else { - $error = PEAR::raiseError(null, QUICKFORM_INVALID_ELEMENT_NAME, null, E_USER_WARNING, "Element '$elementName' already exists in HTML_QuickForm::addElement()", 'HTML_QuickForm_Error', true); + $error = PEAR::raiseError( + null, + QUICKFORM_INVALID_ELEMENT_NAME, + null, + E_USER_WARNING, + "Element '$elementName' already exists in HTML_QuickForm::addElement()", + 'HTML_QuickForm_Error', + true + ); return $error; } } else { @@ -670,42 +734,66 @@ function &addElement($element) return $elementObject; } // end func addElement - + // }}} // {{{ insertElementBefore() - /** - * Inserts a new element right before the other element - * - * Warning: it is not possible to check whether the $element is already - * added to the form, therefore if you want to move the existing form - * element to a new position, you'll have to use removeElement(): - * $form->insertElementBefore($form->removeElement('foo', false), 'bar'); - * - * @access public - * @since 3.2.4 - * @param HTML_QuickForm_element Element to insert - * @param string Name of the element before which the new - * one is inserted - * @return HTML_QuickForm_element reference to inserted element - * @throws HTML_QuickForm_Error - */ - function &insertElementBefore(&$element, $nameAfter) + /** + * Inserts a new element right before the other element + * + * Warning: it is not possible to check whether the $element is already + * added to the form, therefore if you want to move the existing form + * element to a new position, you'll have to use removeElement(): + * $form->insertElementBefore($form->removeElement('foo', false), 'bar'); + * + * @access public + * @since 3.2.4 + * @param HTML_QuickForm_element Element to insert + * @param string Name of the element before which the new + * one is inserted + * @return HTML_QuickForm_element reference to inserted element + * @throws HTML_QuickForm_Error + */ + public function &insertElementBefore(&$element, $nameAfter) { if (!empty($this->_duplicateIndex[$nameAfter])) { - $error = PEAR::raiseError(null, QUICKFORM_INVALID_ELEMENT_NAME, null, E_USER_WARNING, 'Several elements named "' . $nameAfter . '" exist in HTML_QuickForm::insertElementBefore().', 'HTML_QuickForm_Error', true); + $error = PEAR::raiseError( + null, + QUICKFORM_INVALID_ELEMENT_NAME, + null, + E_USER_WARNING, + 'Several elements named "' . $nameAfter . '" exist in HTML_QuickForm::insertElementBefore().', + 'HTML_QuickForm_Error', + true + ); return $error; } elseif (!$this->elementExists($nameAfter)) { - $error = PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$nameAfter' does not exist in HTML_QuickForm::insertElementBefore()", 'HTML_QuickForm_Error', true); + $error = PEAR::raiseError( + null, + QUICKFORM_NONEXIST_ELEMENT, + null, + E_USER_WARNING, + "Element '$nameAfter' does not exist in HTML_QuickForm::insertElementBefore()", + 'HTML_QuickForm_Error', + true + ); return $error; } $elementName = $element->getName(); - $targetIdx = $this->_elementIndex[$nameAfter]; - $duplicate = false; + $targetIdx = $this->_elementIndex[$nameAfter]; + $duplicate = false; // Like in addElement(), check that it's not an incompatible duplicate if (!empty($elementName) && isset($this->_elementIndex[$elementName])) { if ($this->_elements[$this->_elementIndex[$elementName]]->getType() != $element->getType()) { - $error = PEAR::raiseError(null, QUICKFORM_INVALID_ELEMENT_NAME, null, E_USER_WARNING, "Element '$elementName' already exists in HTML_QuickForm::insertElementBefore()", 'HTML_QuickForm_Error', true); + $error = PEAR::raiseError( + null, + QUICKFORM_INVALID_ELEMENT_NAME, + null, + E_USER_WARNING, + "Element '$elementName' already exists in HTML_QuickForm::insertElementBefore()", + 'HTML_QuickForm_Error', + true + ); return $error; } $duplicate = true; @@ -746,47 +834,55 @@ function &insertElementBefore(&$element, $nameAfter) /** * Adds an element group - * @param array $elements array of elements composing the group - * @param string $name (optional)group name - * @param string $groupLabel (optional)group label - * @param string $separator (optional)string to separate elements - * @param string $appendName (optional)specify whether the group name should be + * @param array $elements array of elements composing the group + * @param string $name (optional)group name + * @param string $groupLabel (optional)group label + * @param string $separator (optional)string to separate elements + * @param string $appendName (optional)specify whether the group name should be * used in the form element name ex: group[element] * @return HTML_QuickForm_group reference to a newly added group * @since 2.8 * @access public * @throws HTML_QuickForm_Error */ - function &addGroup($elements, $name=null, $groupLabel='', $separator=null, $appendName = true) + public function &addGroup($elements, $name = null, $groupLabel = '', $separator = null, $appendName = true) { static $anonGroups = 1; if (0 == strlen($name)) { - $name = 'qf_group_' . $anonGroups++; + $name = 'qf_group_' . $anonGroups++; $appendName = false; } $group =& $this->addElement('group', $name, $groupLabel, $elements, $separator, $appendName); return $group; } // end func addGroup - + // }}} // {{{ &getElement() /** * Returns a reference to the element * - * @param string $element Element name + * @param string $element Element name * @since 2.0 * @access public * @return HTML_QuickForm_element reference to element * @throws HTML_QuickForm_Error */ - function &getElement($element) + public function &getElement($element) { if (isset($this->_elementIndex[$element])) { return $this->_elements[$this->_elementIndex[$element]]; } else { - $error = PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$element' does not exist in HTML_QuickForm::getElement()", 'HTML_QuickForm_Error', true); + $error = PEAR::raiseError( + null, + QUICKFORM_NONEXIST_ELEMENT, + null, + E_USER_WARNING, + "Element '$element' does not exist in HTML_QuickForm::getElement()", + 'HTML_QuickForm_Error', + true + ); return $error; } } // end func getElement @@ -796,20 +892,28 @@ function &getElement($element) /** * Returns the element's raw value - * - * This returns the value as submitted by the form (not filtered) + * + * This returns the value as submitted by the form (not filtered) * or set via setDefaults() or setConstants() * - * @param string $element Element name + * @param string $element Element name * @since 2.0 * @access public * @return mixed element value * @throws HTML_QuickForm_Error */ - function &getElementValue($element) + public function &getElementValue($element) { if (!isset($this->_elementIndex[$element])) { - $error = PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$element' does not exist in HTML_QuickForm::getElementValue()", 'HTML_QuickForm_Error', true); + $error = PEAR::raiseError( + null, + QUICKFORM_NONEXIST_ELEMENT, + null, + E_USER_WARNING, + "Element '$element' does not exist in HTML_QuickForm::getElementValue()", + 'HTML_QuickForm_Error', + true + ); return $error; } $value = $this->_elements[$this->_elementIndex[$element]]->getValue(); @@ -819,7 +923,7 @@ function &getElementValue($element) if (is_array($value)) { $value[] = $v; } else { - $value = (null === $value)? $v: array($value, $v); + $value = (null === $value) ? $v : array($value, $v); } } } @@ -837,15 +941,18 @@ function &getElementValue($element) * @since 2.0 * @access public * @return mixed submitted element value or null if not set - */ - function getSubmitValue($elementName) + */ + public function getSubmitValue($elementName) { $value = null; if (isset($this->_submitValues[$elementName]) || isset($this->_submitFiles[$elementName])) { - $value = isset($this->_submitValues[$elementName])? $this->_submitValues[$elementName]: array(); + $value = isset($this->_submitValues[$elementName]) ? $this->_submitValues[$elementName] : array(); if (is_array($value) && isset($this->_submitFiles[$elementName])) { foreach ($this->_submitFiles[$elementName] as $k => $v) { - $value = HTML_QuickForm::arrayMerge($value, $this->_reindexFiles($this->_submitFiles[$elementName][$k], $k)); + $value = HTML_QuickForm::arrayMerge( + $value, + $this->_reindexFiles($this->_submitFiles[$elementName][$k], $k) + ); } } @@ -854,36 +961,40 @@ function getSubmitValue($elementName) } elseif (false !== ($pos = strpos($elementName, '['))) { $base = str_replace( - array('\\', '\''), array('\\\\', '\\\''), - substr($elementName, 0, $pos) - ); - $idx = "['" . str_replace( - array('\\', '\'', ']', '['), array('\\\\', '\\\'', '', "']['"), - substr($elementName, $pos + 1, -1) - ) . "']"; + array('\\', '\''), array('\\\\', '\\\''), + substr($elementName, 0, $pos) + ); + $idx = "['" . + str_replace( + array('\\', '\'', ']', '['), + array('\\\\', '\\\'', '', "']['"), + substr($elementName, $pos + 1, -1) + ) . "']"; if (isset($this->_submitValues[$base])) { - $value = eval("return (isset(\$this->_submitValues['{$base}']{$idx})) ? \$this->_submitValues['{$base}']{$idx} : null;"); + $value = eval("return (isset(\$this->_submitValues['{$base}']{$idx})) " . + "? \$this->_submitValues['{$base}']{$idx} : null;"); } if ((is_array($value) || null === $value) && isset($this->_submitFiles[$base])) { $props = array('name', 'type', 'size', 'tmp_name', 'error'); - $code = "if (!isset(\$this->_submitFiles['{$base}']['name']{$idx})) {\n" . - " return null;\n" . - "} else {\n" . - " \$v = array();\n"; + $code = "if (!isset(\$this->_submitFiles['{$base}']['name']{$idx})) {\n" . + " return null;\n" . + "} else {\n" . + " \$v = array();\n"; foreach ($props as $prop) { - $code .= " \$v = HTML_QuickForm::arrayMerge(\$v, \$this->_reindexFiles(\$this->_submitFiles['{$base}']['{$prop}']{$idx}, '{$prop}'));\n"; + $code .= " \$v = HTML_QuickForm::arrayMerge(\$v, \$this->_reindexFiles(" . + "\$this->_submitFiles['{$base}']['{$prop}']{$idx}, '{$prop}'));\n"; } $fileValue = eval($code . " return \$v;\n}\n"); if (null !== $fileValue) { - $value = null === $value? $fileValue: HTML_QuickForm::arrayMerge($value, $fileValue); + $value = null === $value ? $fileValue : HTML_QuickForm::arrayMerge($value, $fileValue); } } } - + // This is only supposed to work for groups with appendName = false if (null === $value && 'group' == $this->getElementType($elementName)) { - $group =& $this->getElement($elementName); + $group =& $this->getElement($elementName); $elements =& $group->getElements(); foreach (array_keys($elements) as $key) { $name = $group->getElementName($key); @@ -901,14 +1012,14 @@ function getSubmitValue($elementName) // }}} // {{{ _reindexFiles() - /** - * A helper function to change the indexes in $_FILES array - * - * @param mixed Some value from the $_FILES array - * @param string The key from the $_FILES array that should be appended - * @return array - */ - function _reindexFiles($value, $key) + /** + * A helper function to change the indexes in $_FILES array + * + * @param mixed Some value from the $_FILES array + * @param string The key from the $_FILES array that should be appended + * @return array + */ + public function _reindexFiles($value, $key) { if (!is_array($value)) { return array($key => $value); @@ -927,31 +1038,31 @@ function _reindexFiles($value, $key) /** * Returns error corresponding to validated element * - * @param string $element Name of form element to check + * @param string $element Name of form element to check * @since 1.0 * @access public * @return string error message corresponding to checked element */ - function getElementError($element) + public function getElementError($element) { if (isset($this->_errors[$element])) { return $this->_errors[$element]; } } // end func getElementError - + // }}} // {{{ setElementError() /** * Set error message for a form element * - * @param string $element Name of form element to set error for - * @param string $message Error message, if empty then removes the current error message - * @since 1.0 + * @param string $element Name of form element to set error for + * @param string $message Error message, if empty then removes the current error message + * @since 1.0 * @access public * @return void */ - function setElementError($element, $message = null) + public function setElementError($element, $message = null) { if (!empty($message)) { $this->_errors[$element] = $message; @@ -959,39 +1070,39 @@ function setElementError($element, $message = null) unset($this->_errors[$element]); } } // end func setElementError - - // }}} - // {{{ getElementType() - - /** - * Returns the type of the given element - * - * @param string $element Name of form element - * @since 1.1 - * @access public - * @return string Type of the element, false if the element is not found - */ - function getElementType($element) - { - if (isset($this->_elementIndex[$element])) { - return $this->_elements[$this->_elementIndex[$element]]->getType(); - } - return false; - } // end func getElementType - - // }}} - // {{{ updateElementAttr() + + // }}} + // {{{ getElementType() + + /** + * Returns the type of the given element + * + * @param string $element Name of form element + * @since 1.1 + * @access public + * @return string Type of the element, false if the element is not found + */ + public function getElementType($element) + { + if (isset($this->_elementIndex[$element])) { + return $this->_elements[$this->_elementIndex[$element]]->getType(); + } + return false; + } // end func getElementType + + // }}} + // {{{ updateElementAttr() /** * Updates Attributes for one or more elements * - * @param mixed $elements Array of element names/objects or string of elements to be updated - * @param mixed $attrs Array or sting of html attributes + * @param mixed $elements Array of element names/objects or string of elements to be updated + * @param mixed $attrs Array or sting of html attributes * @since 2.10 * @access public * @return void */ - function updateElementAttr($elements, $attrs) + public function updateElementAttr($elements, $attrs) { if (is_string($elements)) { $elements = preg_split('/[ ]?,[ ]?/', $elements); @@ -1017,20 +1128,28 @@ function updateElementAttr($elements, $attrs) * Removes an element * * The method "unlinks" an element from the form, returning the reference - * to the element object. If several elements named $elementName exist, + * to the element object. If several elements named $elementName exist, * it removes the first one, leaving the others intact. - * - * @param string $elementName The element name - * @param boolean $removeRules True if rules for this element are to be removed too + * + * @param string $elementName The element name + * @param boolean $removeRules True if rules for this element are to be removed too * @access public * @since 2.0 * @return HTML_QuickForm_element a reference to the removed element * @throws HTML_QuickForm_Error */ - function &removeElement($elementName, $removeRules = true) + public function &removeElement($elementName, $removeRules = true) { if (!isset($this->_elementIndex[$elementName])) { - $error = PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$elementName' does not exist in HTML_QuickForm::removeElement()", 'HTML_QuickForm_Error', true); + $error = PEAR::raiseError( + null, + QUICKFORM_NONEXIST_ELEMENT, + null, + E_USER_WARNING, + "Element '$elementName' does not exist in HTML_QuickForm::removeElement()", + 'HTML_QuickForm_Error', + true + ); return $error; } $el =& $this->_elements[$this->_elementIndex[$elementName]]; @@ -1059,41 +1178,73 @@ function &removeElement($elementName, $removeRules = true) * Adds a validation rule for the given field * * If the element is in fact a group, it will be considered as a whole. - * To validate grouped elements as separated entities, + * To validate grouped elements as separated entities, * use addGroupRule instead of addRule. * - * @param string $element Form element name - * @param string $message Message to display for invalid data - * @param string $type Rule type, use getRegisteredRules() to get types - * @param string $format (optional)Required for extra rule data - * @param string $validation (optional)Where to perform validation: "server", "client" - * @param boolean $reset Client-side validation: reset the form element to its original value if there is an error? - * @param boolean $force Force the rule to be applied, even if the target form element does not exist + * @param string $element Form element name + * @param string $message Message to display for invalid data + * @param string $type Rule type, use getRegisteredRules() to get types + * @param string $format (optional)Required for extra rule data + * @param string $validation (optional)Where to perform validation: "server", "client" + * @param boolean $reset Client-side validation: + * reset the form element to its original value if there is an error? + * @param boolean $force Force the rule to be applied, even if the target form element does not exist * @since 1.0 * @access public * @throws HTML_QuickForm_Error */ - function addRule($element, $message, $type, $format=null, $validation='server', $reset = false, $force = false) - { + public function addRule( + $element, + $message, + $type, + $format = null, + $validation = 'server', + $reset = false, + $force = false + ) { if (!$force) { if (!is_array($element) && !$this->elementExists($element)) { - return PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$element' does not exist in HTML_QuickForm::addRule()", 'HTML_QuickForm_Error', true); + return PEAR::raiseError( + null, + QUICKFORM_NONEXIST_ELEMENT, + null, + E_USER_WARNING, + "Element '$element' does not exist in HTML_QuickForm::addRule()", + 'HTML_QuickForm_Error', + true + ); } elseif (is_array($element)) { foreach ($element as $el) { if (!$this->elementExists($el)) { - return PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$el' does not exist in HTML_QuickForm::addRule()", 'HTML_QuickForm_Error', true); + return PEAR::raiseError( + null, + QUICKFORM_NONEXIST_ELEMENT, + null, + E_USER_WARNING, + "Element '$el' does not exist in HTML_QuickForm::addRule()", + 'HTML_QuickForm_Error', + true + ); } } } } if (false === ($newName = $this->isRuleRegistered($type, true))) { - return PEAR::raiseError(null, QUICKFORM_INVALID_RULE, null, E_USER_WARNING, "Rule '$type' is not registered in HTML_QuickForm::addRule()", 'HTML_QuickForm_Error', true); + return PEAR::raiseError( + null, + QUICKFORM_INVALID_RULE, + null, + E_USER_WARNING, + "Rule '$type' is not registered in HTML_QuickForm::addRule()", + 'HTML_QuickForm_Error', + true + ); } elseif (is_string($newName)) { $type = $newName; } if (is_array($element)) { $dependent = $element; - $element = array_shift($dependent); + $element = array_shift($dependent); } else { $dependent = null; } @@ -1104,15 +1255,20 @@ function addRule($element, $message, $type, $format=null, $validation='server', $this->_rules[$element] = array(); } if ($validation == 'client') { - $this->updateAttributes(array('onsubmit' => 'try { var myValidator = validate_' . $this->_attributes['id'] . '; } catch(e) { return true; } return myValidator(this);')); + $this->updateAttributes( + array( + 'onsubmit' => 'try { var myValidator = validate_' . $this->_attributes['id'] . + '; } catch(e) { return true; } return myValidator(this);' + ) + ); } $this->_rules[$element][] = array( - 'type' => $type, - 'format' => $format, - 'message' => $message, - 'validation' => $validation, - 'reset' => $reset, - 'dependent' => $dependent + 'type' => $type, + 'format' => $format, + 'message' => $message, + 'validation' => $validation, + 'reset' => $reset, + 'dependent' => $dependent ); } // end func addRule @@ -1128,21 +1284,36 @@ function addRule($element, $message, $type, $format=null, $validation='server', * the same rule will be applied to all elements in the group. * Use addRule if you need to validate the group against a function. * - * @param string $group Form group name - * @param mixed $arg1 Array for multiple elements or error message string for one element - * @param string $type (optional)Rule type use getRegisteredRules() to get types - * @param string $format (optional)Required for extra rule data - * @param int $howmany (optional)How many valid elements should be in the group - * @param string $validation (optional)Where to perform validation: "server", "client" - * @param bool $reset Client-side: whether to reset the element's value to its original state if validation failed. + * @param string $group Form group name + * @param mixed $arg1 Array for multiple elements or error message string for one element + * @param string $type (optional)Rule type use getRegisteredRules() to get types + * @param string $format (optional)Required for extra rule data + * @param int $howmany (optional)How many valid elements should be in the group + * @param string $validation (optional)Where to perform validation: "server", "client" + * @param bool $reset Client-side: whether to reset the element's value to its original state if failed. * @since 2.5 * @access public * @throws HTML_QuickForm_Error */ - function addGroupRule($group, $arg1, $type='', $format=null, $howmany=0, $validation = 'server', $reset = false) - { + public function addGroupRule( + $group, + $arg1, + $type = '', + $format = null, + $howmany = 0, + $validation = 'server', + $reset = false + ) { if (!$this->elementExists($group)) { - return PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Group '$group' does not exist in HTML_QuickForm::addGroupRule()", 'HTML_QuickForm_Error', true); + return PEAR::raiseError( + null, + QUICKFORM_NONEXIST_ELEMENT, + null, + E_USER_WARNING, + "Group '$group' does not exist in HTML_QuickForm::addGroupRule()", + 'HTML_QuickForm_Error', + true + ); } $groupObj =& $this->getElement($group); @@ -1152,22 +1323,31 @@ function addGroupRule($group, $arg1, $type='', $format=null, $howmany=0, $valida $elementName = $groupObj->getElementName($elementIndex); foreach ($rules as $rule) { $format = (isset($rule[2])) ? $rule[2] : null; - $validation = (isset($rule[3]) && 'client' == $rule[3])? 'client': 'server'; + $validation = (isset($rule[3]) && 'client' == $rule[3]) ? 'client' : 'server'; $reset = isset($rule[4]) && $rule[4]; $type = $rule[1]; if (false === ($newName = $this->isRuleRegistered($type, true))) { - return PEAR::raiseError(null, QUICKFORM_INVALID_RULE, null, E_USER_WARNING, "Rule '$type' is not registered in HTML_QuickForm::addGroupRule()", 'HTML_QuickForm_Error', true); + return PEAR::raiseError( + null, + QUICKFORM_INVALID_RULE, + null, + E_USER_WARNING, + "Rule '$type' is not registered in HTML_QuickForm::addGroupRule()", + 'HTML_QuickForm_Error', + true + ); } elseif (is_string($newName)) { $type = $newName; } $this->_rules[$elementName][] = array( - 'type' => $type, - 'format' => $format, - 'message' => $rule[0], - 'validation' => $validation, - 'reset' => $reset, - 'group' => $group); + 'type' => $type, + 'format' => $format, + 'message' => $rule[0], + 'validation' => $validation, + 'reset' => $reset, + 'group' => $group + ); if ('required' == $type || 'uploadedfile' == $type) { $groupObj->_required[] = $elementName; @@ -1175,7 +1355,12 @@ function addGroupRule($group, $arg1, $type='', $format=null, $howmany=0, $valida $required++; } if ('client' == $validation) { - $this->updateAttributes(array('onsubmit' => 'try { var myValidator = validate_' . $this->_attributes['id'] . '; } catch(e) { return true; } return myValidator(this);')); + $this->updateAttributes( + array( + 'onsubmit' => 'try { var myValidator = validate_' . $this->_attributes['id'] . + '; } catch(e) { return true; } return myValidator(this);' + ) + ); } } } @@ -1184,7 +1369,15 @@ function addGroupRule($group, $arg1, $type='', $format=null, $howmany=0, $valida } } elseif (is_string($arg1)) { if (false === ($newName = $this->isRuleRegistered($type, true))) { - return PEAR::raiseError(null, QUICKFORM_INVALID_RULE, null, E_USER_WARNING, "Rule '$type' is not registered in HTML_QuickForm::addGroupRule()", 'HTML_QuickForm_Error', true); + return PEAR::raiseError( + null, + QUICKFORM_INVALID_RULE, + null, + E_USER_WARNING, + "Rule '$type' is not registered in HTML_QuickForm::addGroupRule()", + 'HTML_QuickForm_Error', + true + ); } elseif (is_string($newName)) { $type = $newName; } @@ -1199,17 +1392,24 @@ function addGroupRule($group, $arg1, $type='', $format=null, $howmany=0, $valida } } - $this->_rules[$group][] = array('type' => $type, - 'format' => $format, - 'message' => $arg1, - 'validation' => $validation, - 'howmany' => $howmany, - 'reset' => $reset); + $this->_rules[$group][] = array( + 'type' => $type, + 'format' => $format, + 'message' => $arg1, + 'validation' => $validation, + 'howmany' => $howmany, + 'reset' => $reset + ); if ($type == 'required') { $this->_required[] = $group; } if ($validation == 'client') { - $this->updateAttributes(array('onsubmit' => 'try { var myValidator = validate_' . $this->_attributes['id'] . '; } catch(e) { return true; } return myValidator(this);')); + $this->updateAttributes( + array( + 'onsubmit' => 'try { var myValidator = validate_' . + $this->_attributes['id'] . '; } catch(e) { return true; } return myValidator(this);' + ) + ); } } } // end func addGroupRule @@ -1217,42 +1417,58 @@ function addGroupRule($group, $arg1, $type='', $format=null, $howmany=0, $valida // }}} // {{{ addFormRule() - /** - * Adds a global validation rule - * - * This should be used when for a rule involving several fields or if - * you want to use some completely custom validation for your form. - * The rule function/method should return true in case of successful - * validation and array('element name' => 'error') when there were errors. - * - * @access public - * @param mixed Callback, either function name or array(&$object, 'method') - * @throws HTML_QuickForm_Error - */ - function addFormRule($rule) + /** + * Adds a global validation rule + * + * This should be used when for a rule involving several fields or if + * you want to use some completely custom validation for your form. + * The rule function/method should return true in case of successful + * validation and array('element name' => 'error') when there were errors. + * + * @access public + * @param mixed Callback, either function name or array(&$object, 'method') + * @throws HTML_QuickForm_Error + */ + public function addFormRule($rule) { if (!is_callable($rule)) { - return PEAR::raiseError(null, QUICKFORM_INVALID_RULE, null, E_USER_WARNING, 'Callback function does not exist in HTML_QuickForm::addFormRule()', 'HTML_QuickForm_Error', true); + return PEAR::raiseError( + null, + QUICKFORM_INVALID_RULE, + null, + E_USER_WARNING, + 'Callback function does not exist in HTML_QuickForm::addFormRule()', + 'HTML_QuickForm_Error', + true + ); } $this->_formRules[] = $rule; } - + // }}} // {{{ applyFilter() /** * Applies a data filter for the given field(s) * - * @param mixed $element Form element name or array of such names - * @param mixed $filter Callback, either function name or array(&$object, 'method') + * @param mixed $element Form element name or array of such names + * @param mixed $filter Callback, either function name or array(&$object, 'method') * @since 2.0 * @access public * @throws HTML_QuickForm_Error */ - function applyFilter($element, $filter) + public function applyFilter($element, $filter) { if (!is_callable($filter)) { - return PEAR::raiseError(null, QUICKFORM_INVALID_FILTER, null, E_USER_WARNING, "Callback function does not exist in QuickForm::applyFilter()", 'HTML_QuickForm_Error', true); + return PEAR::raiseError( + null, + QUICKFORM_INVALID_FILTER, + null, + E_USER_WARNING, + "Callback function does not exist in QuickForm::applyFilter()", + 'HTML_QuickForm_Error', + true + ); } if ($element == '__ALL__') { $this->_submitValues = $this->_recursiveFilter($filter, $this->_submitValues); @@ -1266,10 +1482,12 @@ function applyFilter($element, $filter) if (false === strpos($elName, '[')) { $this->_submitValues[$elName] = $this->_recursiveFilter($filter, $value); } else { - $idx = "['" . str_replace( - array('\\', '\'', ']', '['), array('\\\\', '\\\'', '', "']['"), - $elName - ) . "']"; + $idx = "['" . + str_replace( + array('\\', '\'', ']', '['), + array('\\\\', '\\\'', '', "']['"), + $elName + ) . "']"; eval("\$this->_submitValues{$idx} = \$this->_recursiveFilter(\$filter, \$value);"); } } @@ -1283,13 +1501,13 @@ function applyFilter($element, $filter) /** * Recursively apply a filter function * - * @param string $filter filter to apply - * @param mixed $value submitted values + * @param string $filter filter to apply + * @param mixed $value submitted values * @since 2.0 * @access private * @return cleaned values */ - function _recursiveFilter($filter, $value) + public function _recursiveFilter($filter, $value) { if (is_array($value)) { $cleanValues = array(); @@ -1305,19 +1523,19 @@ function _recursiveFilter($filter, $value) // }}} // {{{ arrayMerge() - /** - * Merges two arrays - * - * Merges two array like the PHP function array_merge but recursively. - * The main difference is that existing keys will not be renumbered - * if they are integers. - * - * @access public - * @param array $a original array - * @param array $b array which will be merged into first one - * @return array merged array - */ - function arrayMerge($a, $b) + /** + * Merges two arrays + * + * Merges two array like the PHP function array_merge but recursively. + * The main difference is that existing keys will not be renumbered + * if they are integers. + * + * @access public + * @param array $a original array + * @param array $b array which will be merged into first one + * @return array merged array + */ + public function arrayMerge($a, $b) { foreach ($b as $k => $v) { if (is_array($v)) { @@ -1342,12 +1560,12 @@ function arrayMerge($a, $b) /** * Returns whether or not the form element type is supported * - * @param string $type Form element type + * @param string $type Form element type * @since 1.0 * @access public * @return boolean */ - function isTypeRegistered($type) + public function isTypeRegistered($type) { return isset($GLOBALS['HTML_QUICKFORM_ELEMENT_TYPES'][strtolower($type)]); } // end func isTypeRegistered @@ -1362,7 +1580,7 @@ function isTypeRegistered($type) * @access public * @return array */ - function getRegisteredTypes() + public function getRegisteredTypes() { return array_keys($GLOBALS['HTML_QUICKFORM_ELEMENT_TYPES']); } // end func getRegisteredTypes @@ -1373,13 +1591,13 @@ function getRegisteredTypes() /** * Returns whether or not the given rule is supported * - * @param string $name Validation rule name + * @param string $name Validation rule name * @param bool Whether to automatically register subclasses of HTML_QuickForm_Rule * @since 1.0 * @access public * @return mixed true if previously registered, false if not, new rule name if auto-registering worked */ - function isRuleRegistered($name, $autoRegister = false) + public function isRuleRegistered($name, $autoRegister = false) { if (is_scalar($name) && isset($GLOBALS['_HTML_QuickForm_registered_rules'][$name])) { return true; @@ -1390,7 +1608,7 @@ function isRuleRegistered($name, $autoRegister = false) include_once 'HTML/QuickForm/RuleRegistry.php'; $ruleName = false; if (is_object($name) && is_a($name, 'html_quickform_rule')) { - $ruleName = !empty($name->name)? $name->name: strtolower(get_class($name)); + $ruleName = !empty($name->name) ? $name->name : strtolower(get_class($name)); } elseif (is_string($name) && class_exists($name)) { $parent = strtolower($name); do { @@ -1417,7 +1635,7 @@ function isRuleRegistered($name, $autoRegister = false) * @access public * @return array */ - function getRegisteredRules() + public function getRegisteredRules() { return array_keys($GLOBALS['_HTML_QuickForm_registered_rules']); } // end func getRegisteredRules @@ -1428,12 +1646,12 @@ function getRegisteredRules() /** * Returns whether or not the form element is required * - * @param string $element Form element name + * @param string $element Form element name * @since 1.0 * @access public * @return boolean */ - function isElementRequired($element) + public function isElementRequired($element) { return in_array($element, $this->_required, true); } // end func isElementRequired @@ -1444,17 +1662,17 @@ function isElementRequired($element) /** * Returns whether or not the form element is frozen * - * @param string $element Form element name + * @param string $element Form element name * @since 1.0 * @access public * @return boolean */ - function isElementFrozen($element) + public function isElementFrozen($element) { - if (isset($this->_elementIndex[$element])) { - return $this->_elements[$this->_elementIndex[$element]]->isFrozen(); - } - return false; + if (isset($this->_elementIndex[$element])) { + return $this->_elements[$this->_elementIndex[$element]]->isFrozen(); + } + return false; } // end func isElementFrozen // }}} @@ -1463,30 +1681,30 @@ function isElementFrozen($element) /** * Sets JavaScript warning messages * - * @param string $pref Prefix warning - * @param string $post Postfix warning + * @param string $pref Prefix warning + * @param string $post Postfix warning * @since 1.1 * @access public * @return void */ - function setJsWarnings($pref, $post) + public function setJsWarnings($pref, $post) { $this->_jsPrefix = $pref; $this->_jsPostfix = $post; } // end func setJsWarnings - + // }}} // {{{ setRequiredNote() /** * Sets required-note * - * @param string $note Message indicating some elements are required + * @param string $note Message indicating some elements are required * @since 1.1 * @access public * @return void */ - function setRequiredNote($note) + public function setRequiredNote($note) { $this->_requiredNote = $note; } // end func setRequiredNote @@ -1501,7 +1719,7 @@ function setRequiredNote($note) * @access public * @return string */ - function getRequiredNote() + public function getRequiredNote() { return $this->_requiredNote; } // end func getRequiredNote @@ -1516,53 +1734,59 @@ function getRequiredNote() * @return boolean true if no error found * @throws HTML_QuickForm_Error */ - function validate() + public function validate() { - if (count($this->_rules) == 0 && count($this->_formRules) == 0 && + if (count($this->_rules) == 0 && count($this->_formRules) == 0 && $this->isSubmitted()) { return (0 == count($this->_errors)); } elseif (!$this->isSubmitted()) { return false; } - + include_once('HTML/QuickForm/RuleRegistry.php'); $registry =& HTML_QuickForm_RuleRegistry::singleton(); foreach ($this->_rules as $target => $rules) { $submitValue = $this->getSubmitValue($target); - + foreach ($rules as $rule) { if ((isset($rule['group']) && isset($this->_errors[$rule['group']])) || - isset($this->_errors[$target])) { + isset($this->_errors[$target]) + ) { continue 2; } // If element is not required and is empty, we shouldn't validate it if (!$this->isElementRequired($target)) { if (!isset($submitValue) || '' == $submitValue) { continue 2; - // Fix for bug #3501: we shouldn't validate not uploaded files, either. - // Unfortunately, we can't just use $element->isUploadedFile() since - // the element in question can be buried in group. Thus this hack. - // See also bug #12014, we should only consider a file that has - // status UPLOAD_ERR_NO_FILE as not uploaded, in all other cases - // validation should be performed, so that e.g. 'maxfilesize' rule - // will display an error if status is UPLOAD_ERR_INI_SIZE - // or UPLOAD_ERR_FORM_SIZE + // Fix for bug #3501: we shouldn't validate not uploaded files, either. + // Unfortunately, we can't just use $element->isUploadedFile() since + // the element in question can be buried in group. Thus this hack. + // See also bug #12014, we should only consider a file that has + // status UPLOAD_ERR_NO_FILE as not uploaded, in all other cases + // validation should be performed, so that e.g. 'maxfilesize' rule + // will display an error if status is UPLOAD_ERR_INI_SIZE + // or UPLOAD_ERR_FORM_SIZE } elseif (is_array($submitValue)) { if (false === ($pos = strpos($target, '['))) { $isUpload = !empty($this->_submitFiles[$target]); } else { $base = str_replace( - array('\\', '\''), array('\\\\', '\\\''), - substr($target, 0, $pos) - ); - $idx = "['" . str_replace( - array('\\', '\'', ']', '['), array('\\\\', '\\\'', '', "']['"), - substr($target, $pos + 1, -1) - ) . "']"; + array('\\', '\''), + array('\\\\', '\\\''), + substr($target, 0, $pos) + ); + $idx = "['" . + str_replace( + array('\\', '\'', ']', '['), + array('\\\\', '\\\'', '', "']['"), + substr($target, $pos + 1, -1) + ) . "']"; eval("\$isUpload = isset(\$this->_submitFiles['{$base}']['name']{$idx});"); } - if ($isUpload && (!isset($submitValue['error']) || UPLOAD_ERR_NO_FILE == $submitValue['error'])) { + if ($isUpload && + (!isset($submitValue['error']) || UPLOAD_ERR_NO_FILE == $submitValue['error']) + ) { continue 2; } } @@ -1588,18 +1812,26 @@ function validate() } } } - + // process the global rules now foreach ($this->_formRules as $rule) { if (true !== ($res = call_user_func($rule, $this->_submitValues, $this->_submitFiles))) { if (is_array($res)) { $this->_errors += $res; } else { - return PEAR::raiseError(null, QUICKFORM_ERROR, null, E_USER_WARNING, 'Form rule callback returned invalid value in HTML_QuickForm::validate()', 'HTML_QuickForm_Error', true); + return PEAR::raiseError( + null, + QUICKFORM_ERROR, + null, + E_USER_WARNING, + 'Form rule callback returned invalid value in HTML_QuickForm::validate()', + 'HTML_QuickForm_Error', + true + ); } } } - + return (0 == count($this->_errors)); } // end func validate @@ -1609,12 +1841,12 @@ function validate() /** * Displays elements without HTML input tags * - * @param mixed $elementList array or string of element(s) to be frozen + * @param mixed $elementList array or string of element(s) to be frozen * @since 1.0 * @access public * @throws HTML_QuickForm_Error */ - function freeze($elementList=null) + public function freeze($elementList = null) { if (!isset($elementList)) { $this->_freezeAll = true; @@ -1635,11 +1867,21 @@ function freeze($elementList=null) } if (!empty($elementList)) { - return PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Nonexistant element(s): '" . implode("', '", array_keys($elementList)) . "' in HTML_QuickForm::freeze()", 'HTML_QuickForm_Error', true); + return PEAR::raiseError( + null, + QUICKFORM_NONEXIST_ELEMENT, + null, + E_USER_WARNING, + "Nonexistant element(s): '" . implode("', '", array_keys( + $elementList + )) . "' in HTML_QuickForm::freeze()", + 'HTML_QuickForm_Error', + true + ); } return true; } // end func freeze - + // }}} // {{{ isFrozen() @@ -1650,9 +1892,9 @@ function freeze($elementList=null) * @access public * @return boolean */ - function isFrozen() + public function isFrozen() { - return $this->_freezeAll; + return $this->_freezeAll; } // end func isFrozen // }}} @@ -1661,42 +1903,52 @@ function isFrozen() /** * Performs the form data processing * - * @param mixed $callback Callback, either function name or array(&$object, 'method') - * @param bool $mergeFiles Whether uploaded files should be processed too + * @param mixed $callback Callback, either function name or array(&$object, 'method') + * @param bool $mergeFiles Whether uploaded files should be processed too * @since 1.0 * @access public * @throws HTML_QuickForm_Error * @return mixed Whatever value the $callback function returns */ - function process($callback, $mergeFiles = true) + public function process($callback, $mergeFiles = true) { if (!is_callable($callback)) { - return PEAR::raiseError(null, QUICKFORM_INVALID_PROCESS, null, E_USER_WARNING, "Callback function does not exist in QuickForm::process()", 'HTML_QuickForm_Error', true); + return PEAR::raiseError( + null, + QUICKFORM_INVALID_PROCESS, + null, + E_USER_WARNING, + "Callback function does not exist in QuickForm::process()", + 'HTML_QuickForm_Error', + true + ); } - $values = ($mergeFiles === true) ? HTML_QuickForm::arrayMerge($this->_submitValues, $this->_submitFiles) : $this->_submitValues; + $values = ($mergeFiles === true) + ? HTML_QuickForm::arrayMerge($this->_submitValues, $this->_submitFiles) + : $this->_submitValues; return call_user_func($callback, $values); } // end func process // }}} // {{{ accept() - /** - * Accepts a renderer - * - * @param object An HTML_QuickForm_Renderer object - * @since 3.0 - * @access public - * @return void - */ - function accept(&$renderer) + /** + * Accepts a renderer + * + * @param object An HTML_QuickForm_Renderer object + * @since 3.0 + * @access public + * @return void + */ + public function accept(&$renderer) { $this->createSecurityToken(); $renderer->startForm($this); foreach (array_keys($this->_elements) as $key) { $element =& $this->_elements[$key]; $elementName = $element->getName(); - $required = ($this->isElementRequired($elementName) && !$element->isFrozen()); - $error = $this->getElementError($elementName); + $required = ($this->isElementRequired($elementName) && !$element->isFrozen()); + $error = $this->getElementError($elementName); $element->accept($renderer, $required, $error); } $renderer->finishForm($this); @@ -1705,14 +1957,14 @@ function accept(&$renderer) // }}} // {{{ defaultRenderer() - /** - * Returns a reference to default renderer object - * - * @access public - * @since 3.0 - * @return object a default renderer object - */ - function &defaultRenderer() + /** + * Returns a reference to default renderer object + * + * @access public + * @since 3.0 + * @return object a default renderer object + */ + public function &defaultRenderer() { if (!isset($GLOBALS['_HTML_QuickForm_default_renderer'])) { include_once('HTML/QuickForm/Renderer/Default.php'); @@ -1734,7 +1986,7 @@ function &defaultRenderer() * @since 1.0 * @access public */ - function toHtml ($in_data = null) + public function toHtml($in_data = null) { if (!is_null($in_data)) { $this->addElement('html', $in_data); @@ -1754,7 +2006,7 @@ function toHtml ($in_data = null) * @access public * @return string Javascript to perform validation, empty string if no 'client' rules were added */ - function getValidationScript() + public function getValidationScript() { if (empty($this->_rules) || empty($this->_attributes['onsubmit'])) { return ''; @@ -1764,12 +2016,12 @@ function getValidationScript() $registry =& HTML_QuickForm_RuleRegistry::singleton(); $test = array(); $js_escape = array( - "\r" => '\r', - "\n" => '\n', - "\t" => '\t', - "'" => "\\'", - '"' => '\"', - '\\' => '\\\\' + "\r" => '\r', + "\n" => '\n', + "\t" => '\t', + "'" => "\\'", + '"' => '\"', + '\\' => '\\\\' ); foreach ($this->_rules as $elementName => $rules) { @@ -1777,11 +2029,11 @@ function getValidationScript() if ('client' == $rule['validation']) { unset($element); - $dependent = isset($rule['dependent']) && is_array($rule['dependent']); + $dependent = isset($rule['dependent']) && is_array($rule['dependent']); $rule['message'] = strtr($rule['message'], $js_escape); if (isset($rule['group'])) { - $group =& $this->getElement($rule['group']); + $group =& $this->getElement($rule['group']); // No JavaScript validation for frozen elements if ($group->isFrozen()) { continue 2; @@ -1794,7 +2046,7 @@ function getValidationScript() } } } elseif ($dependent) { - $element = array(); + $element = array(); $element[] =& $this->getElement($elementName); foreach ($rule['dependent'] as $elName) { $element[] =& $this->getElement($elName); @@ -1820,7 +2072,7 @@ function getValidationScript() if (count($test) > 0) { return "\n' - .''; @@ -243,7 +243,7 @@ function getElementJs($raw = true, $min = false) * * @return type */ - function getElementHtmlName() + public function getElementHtmlName() { return $this->_elementHtmlName; } @@ -254,7 +254,7 @@ function getElementHtmlName() * @param boolean $min * @return string */ - function getElementCss($raw = true, $min = false) + public function getElementCss($raw = true, $min = false) { $cssFile = './include/common/javascript/jquery/plugins/select2/css/'; @@ -273,7 +273,7 @@ function getElementCss($raw = true, $min = false) * * @return string */ - function toHtml() + public function toHtml() { $strHtml = ''; $readonly = ''; @@ -291,12 +291,11 @@ function toHtml() } - /** * * @return string */ - function getJsInit() + public function getJsInit() { $allowClear = 'true'; if (false === $this->_allowClear || $this->_flagFrozen) { @@ -324,13 +323,14 @@ function getJsInit() $defaultData = $this->setFixedDatas() . ','; $this->setDefaultFixedDatas(); } - + $additionnalJs .= ' ' . $this->_jsCallback; $javascriptString = ' From 1b3c3a3cec2f2c3d6812d9eb742af4b0ce41f5db Mon Sep 17 00:00:00 2001 From: qgarnier Date: Wed, 23 Aug 2017 15:10:34 +0200 Subject: [PATCH 201/207] Fix error parsing --- www/include/monitoring/objectDetails/serviceDetails.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/include/monitoring/objectDetails/serviceDetails.php b/www/include/monitoring/objectDetails/serviceDetails.php index ce4bd6fd10f..22b88b7d5f2 100644 --- a/www/include/monitoring/objectDetails/serviceDetails.php +++ b/www/include/monitoring/objectDetails/serviceDetails.php @@ -547,7 +547,7 @@ $optionsURL = "host_name=" . urlencode($host_name) . "&service_description=" . urlencode($svc_description); - $query = "SELECT id FROM `index_data` WHERE host_name = '" . $pearDBO->escape($host_name) . "' AND service_description = '" . $pearDBO->escape($svc_description) . "' LIMIT 1" + $query = "SELECT id FROM `index_data` WHERE host_name = '" . $pearDBO->escape($host_name) . "' AND service_description = '" . $pearDBO->escape($svc_description) . "' LIMIT 1"; $DBRES = $pearDBO->query($query); $index_data = 0; if ($DBRES->rowCount()) { From e3df08990803e059053e166c7a62d1e0a0b61c40 Mon Sep 17 00:00:00 2001 From: Kevin Duret Date: Wed, 30 Aug 2017 10:04:10 +0200 Subject: [PATCH 202/207] style(area/backend): fix coding style in graph class --- www/class/centreonGraphService.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/www/class/centreonGraphService.class.php b/www/class/centreonGraphService.class.php index ac5f7f0344a..d5f15fb4371 100644 --- a/www/class/centreonGraphService.class.php +++ b/www/class/centreonGraphService.class.php @@ -135,7 +135,8 @@ public function getData($rows = 200) $displayformat = "%7.2lf"; } $commandLegendLine .= ' VDEF:l' . $i . $key . '=v' . $i . ',' . $key; - $commandLegendLine .= ' PRINT:l' . $i . $key . ':"' . str_replace(':', '\:', $metric['metric_legend']) . + $commandLegendLine .= ' PRINT:l' . $i . $key . ':"' . + str_replace(':', '\:', $metric['metric_legend']) . '|' . ucfirst($name) . '|' . $displayformat . '"'; } } From bf6676c68df5501e0091f907309a2e470c0572fc Mon Sep 17 00:00:00 2001 From: qgarnier Date: Wed, 23 Aug 2017 15:00:36 +0200 Subject: [PATCH 203/207] Ref #4867 --- www/class/centreonAuth.LDAP.class.php | 8 ++++---- www/class/centreonLDAP.class.php | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/www/class/centreonAuth.LDAP.class.php b/www/class/centreonAuth.LDAP.class.php index b2cc6935c02..5f08ff6b961 100644 --- a/www/class/centreonAuth.LDAP.class.php +++ b/www/class/centreonAuth.LDAP.class.php @@ -272,8 +272,8 @@ public function updateUserDn() $this->CentreonLog->insertLog(3, "LDAP AUTH : Update user DN for user " . html_entity_decode($this->contactInfos['contact_alias'], ENT_QUOTES, 'UTF-8')); $queryUpdateExtInfos = "UPDATE contact SET - contact_ldap_dn = '" . $this->pearDB->escape($userDn, false) . "', - contact_name = '" . $this->pearDB->escape($userDisplay, false) . "', + contact_ldap_dn = '" . $this->pearDB->escape($userDn) . "', + contact_name = '" . $this->pearDB->escape($userDisplay) . "', contact_email = " . $userEmail . ", contact_pager = " . $userPager . ", ar_id = ".$this->arId." @@ -313,7 +313,7 @@ public function updateUserDn() contact_enable_notifications) VALUES (" . $tmplId . ", '" . $this->contactInfos['contact_alias'] . "', '" . - $userDisplay . "', 'ldap', '" . $userDn . "', " . $this->arId . + $userDisplay . "', 'ldap', '" . $this->pearDB->escape($userDn) . "', " . $this->arId . ", " . $userEmail . ", " . $userPager . ", '1', '1', '1', '2')"; try { $this->pearDB->query($query); @@ -321,7 +321,7 @@ public function updateUserDn() * Get the contact_id */ $query = "SELECT contact_id FROM contact - WHERE contact_ldap_dn = '" . $this->pearDB->escape($userDn, false) . "'"; + WHERE contact_ldap_dn = '" . $this->pearDB->escape($userDn) . "'"; $res = $this->pearDB->query($query); $row = $res->fetchRow(); $contact_id = $row['contact_id']; diff --git a/www/class/centreonLDAP.class.php b/www/class/centreonLDAP.class.php index e5cc8513564..76c923da952 100644 --- a/www/class/centreonLDAP.class.php +++ b/www/class/centreonLDAP.class.php @@ -471,7 +471,6 @@ public function listUserForGroup($groupdn) if (trim($this->groupSearchInfo['member']) == '') { return array(); } - $groupdn = str_replace('\\', '\\\\', $groupdn); $group = $this->getEntry($groupdn, $this->groupSearchInfo['member']); $list = array(); if (!isset($group[$this->groupSearchInfo['member']])) { From d729bcb4eef02d69b5d194fa3cb819059d375f5a Mon Sep 17 00:00:00 2001 From: Laurent Pinsivy Date: Wed, 30 Aug 2017 14:15:03 +0100 Subject: [PATCH 204/207] Prepare Centreon Web 2.8.13 release note --- doc/en/release_notes/centreon-2.8/centreon-2.8.13.rst | 11 +++++++++++ doc/en/release_notes/centreon-2.8/index.rst | 1 + doc/fr/release_notes/centreon-2.8/centreon-2.8.13.rst | 11 +++++++++++ doc/fr/release_notes/centreon-2.8/index.rst | 1 + 4 files changed, 24 insertions(+) create mode 100644 doc/en/release_notes/centreon-2.8/centreon-2.8.13.rst create mode 100644 doc/fr/release_notes/centreon-2.8/centreon-2.8.13.rst diff --git a/doc/en/release_notes/centreon-2.8/centreon-2.8.13.rst b/doc/en/release_notes/centreon-2.8/centreon-2.8.13.rst new file mode 100644 index 00000000000..b71724dfd19 --- /dev/null +++ b/doc/en/release_notes/centreon-2.8/centreon-2.8.13.rst @@ -0,0 +1,11 @@ +################### +Centreon Web 2.8.13 +################### + +Enhancements +============ + + +Bugfix +====== + diff --git a/doc/en/release_notes/centreon-2.8/index.rst b/doc/en/release_notes/centreon-2.8/index.rst index 2ea00ac173c..11278c34e00 100644 --- a/doc/en/release_notes/centreon-2.8/index.rst +++ b/doc/en/release_notes/centreon-2.8/index.rst @@ -19,3 +19,4 @@ Please find here the release notes dedicated to the last 2.8.x version of Centre centreon-2.8.10 centreon-2.8.11 centreon-2.8.12 + centreon-2.8.13 diff --git a/doc/fr/release_notes/centreon-2.8/centreon-2.8.13.rst b/doc/fr/release_notes/centreon-2.8/centreon-2.8.13.rst new file mode 100644 index 00000000000..b71724dfd19 --- /dev/null +++ b/doc/fr/release_notes/centreon-2.8/centreon-2.8.13.rst @@ -0,0 +1,11 @@ +################### +Centreon Web 2.8.13 +################### + +Enhancements +============ + + +Bugfix +====== + diff --git a/doc/fr/release_notes/centreon-2.8/index.rst b/doc/fr/release_notes/centreon-2.8/index.rst index 2ea00ac173c..11278c34e00 100644 --- a/doc/fr/release_notes/centreon-2.8/index.rst +++ b/doc/fr/release_notes/centreon-2.8/index.rst @@ -19,3 +19,4 @@ Please find here the release notes dedicated to the last 2.8.x version of Centre centreon-2.8.10 centreon-2.8.11 centreon-2.8.12 + centreon-2.8.13 From 0ace0cc6d81f3acbedc7d4f26f96a1cba8ba4525 Mon Sep 17 00:00:00 2001 From: Kevin Duret Date: Fri, 1 Sep 2017 15:55:17 +0200 Subject: [PATCH 205/207] test(Jenkins) remove-old-ci-map --- Jenkinsfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index fef65d6e43c..0f215be8ace 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -164,7 +164,6 @@ try { build job: 'centreon-poller-display/master', wait: false build job: 'centreon-pp-manager/master', wait: false build job: 'centreon-bam/master', wait: false - build job: 'centreon-map-web', wait: false build job: 'des-mbi-bundle-centos6', wait: false build job: 'des-mbi-bundle-centos7', wait: false } From 9b781c5a594a479a8ed50a99a636be4519c67c03 Mon Sep 17 00:00:00 2001 From: Kevin Duret Date: Tue, 29 Aug 2017 16:25:56 +0200 Subject: [PATCH 206/207] docs(release notes): add 2.7.11 release notes to 2.8.x doc --- .../centreon-2.7/centreon-2.7.11.rst | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 doc/en/release_notes/centreon-2.7/centreon-2.7.11.rst diff --git a/doc/en/release_notes/centreon-2.7/centreon-2.7.11.rst b/doc/en/release_notes/centreon-2.7/centreon-2.7.11.rst new file mode 100644 index 00000000000..e96878a3ac2 --- /dev/null +++ b/doc/en/release_notes/centreon-2.7/centreon-2.7.11.rst @@ -0,0 +1,28 @@ +############### +Centreon 2.7.11 +############### + +The 2.7.11 release for Centreon Web is now available for `download `_. +The full release notes for 2.7.11 follow. + +****** +Notice +****** + +If you are upgrading from a version prior to 2.7.0, make sure to go through all the release notes available +`here `_. + +Bug Fixes +========= + +- Fix ldap authentication #5216 +- Fix CLAPI export using filters #5084 +- Fix CLAPI poller generate (generate, test, move, restart/reload/ applycfg) #5224 #5221 +- Fix Incorrect style for "Scheduled downtime" in dashboard #5240 +- Fix Contact - import LDAP apply new CSS style #5235 +- Fix HTML export with filters #4868 +- Fix brokercfg export with filter +- Fix get command list query #5229 +- Apply sso fixes from 2.8.x +- Improve performances #5157 +- Convert string in UTF-8 #5118 #5244 From 66795f49c465d24763ce6224034dd9fe51f48de4 Mon Sep 17 00:00:00 2001 From: Matthieu Kermagoret Date: Wed, 30 Aug 2017 11:07:43 +0200 Subject: [PATCH 207/207] docs(broker): explain how to authenticate Broker connections. Centreon Broker connections can be authenticated using X.509 certificates. This commit adds new paragraphs in the documentation to explain how to generate certificates correctly and configure Centreon Broker properly. --- .../configuration/broker_certificates.png | Bin 0 -> 56433 bytes .../poller/02configuration.rst | 57 +++++++++++++++- .../configuration/broker_certificates.png | Bin 0 -> 56433 bytes .../poller/02configuration.rst | 62 +++++++++++++++++- 4 files changed, 116 insertions(+), 3 deletions(-) create mode 100644 doc/en/_static/images/configuration/broker_certificates.png create mode 100644 doc/fr/_static/images/configuration/broker_certificates.png diff --git a/doc/en/_static/images/configuration/broker_certificates.png b/doc/en/_static/images/configuration/broker_certificates.png new file mode 100644 index 0000000000000000000000000000000000000000..badb0b463d62013d0ff082a1d4b6942f99457636 GIT binary patch literal 56433 zcmbrl1ymhdwgn0y0RjYfPYCYr5E3K_7Tn$8;O@a4f;$9vcXxMpJ-EBeFYax*?{~j` zJ^nu#r*bIWRlD|@bImn(zz+$LcW}6H5D*aWzI_#xhJbjb0(`Szp@B6IYLwW(f6&^Z zB7zXlFaLfw;_}=OIuIF{;y)BT5V0U2h#|fS3dlOlA1t}s$k;X?KN~1V zWWO~fF=eDxY)5y_P-W@C@#VT9>G$VF4NEVF)R7a;Z2_ zH8?!Hoceflv|hEGDrxu5)z#Hf5cq6}hG(Ms10M=dz(1D$?J+N_{<{3@W(p9&AxTQZ zqtS9m%A7!#GW(g-eeUt-)6sWAMHg~gk5i(WrqkHP3Vm(}k16}|n=9wq?Ue9mLcPmw zJ8c~fiIE0L>-+WXo3Gblz*Ukuy-UEq=T}U1GprF6Ht-3o`U)Elb>M`^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