diff --git a/doc/en/configuration_guide/commands.rst b/doc/en/configuration_guide/commands.rst index 64f72254759..6a3ff53e467 100644 --- a/doc/en/configuration_guide/commands.rst +++ b/doc/en/configuration_guide/commands.rst @@ -20,8 +20,10 @@ All the commands can be configured in the menu: **Configuration > Commands**. .. image :: /images/user/configuration/04commandlist.png :align: center +.. note:: + By default, locked commands are hidden. Check the "Locked elements" box to list all commands. -**************** +**************** Adding a command **************** @@ -48,11 +50,12 @@ Configuration fields * The **Command Type** field allows us to choose the type of command. * The **Command Line** field indicates the application or the script use with the command. * The **Enable shell** box allows us to enable functions that are specific to a shell such as the pipe, etc. -* The **Argument Example** and **$HOSTADDRESS$** fields define examples of arguments (each argument starts with a ”!”) and a test IP address respectively. +* The **Argument Example** and **$HOSTADDRESS$** fields define examples of arguments (each argument starts with a ”!”) and a test IP address respectively. These fields serve to execute the command line defined above via the web interface by clicking on the blue arrow : |bluearrow|. * The **Describe arguments** button serves to add a description to arguments of the “$ARGn$” type. This description will be visible when using the command in a host or service form. * The **Clear arguments** button deletes the description of arguments defined * The **Describe macros** button serves to add a description to all macros. This description will be visible when using the command in a host or service form. + * The **Connectors** field serves to link a Connector to the command. For more information on Connectors refer to the chapter entitled: `Perl Connector's documentation `_ and `SSH Connector's documentation `_. * The **Graph template** field serves to link the command to a graphic model. * The **Comment** field can be used to make a comment on the command. diff --git a/doc/en/configuration_guide/models.rst b/doc/en/configuration_guide/models.rst index 64c2931553c..3a22fa3f3e5 100644 --- a/doc/en/configuration_guide/models.rst +++ b/doc/en/configuration_guide/models.rst @@ -69,6 +69,9 @@ To add a host template: .. note:: Refer to the chapter covering configuration of :ref:`hosts` to configure a template because the form is identical. +.. note:: + By default, locked host templates are hidden. Check the "Locked elements" box to list all templates. + ****************** Services Templates ****************** @@ -93,6 +96,9 @@ To add a Service Template: .. note:: Refer to the chapter covering configuration of :ref:`services` to configure a template because the form is identical. +.. note:: + By default, locked service templates are hidden. Check the "Locked elements" box to list all templates. + ************* Best practice ************* diff --git a/doc/en/images/user/configuration/04commandlist.png b/doc/en/images/user/configuration/04commandlist.png index e8caa7bcd98..13aa9736659 100644 Binary files a/doc/en/images/user/configuration/04commandlist.png and b/doc/en/images/user/configuration/04commandlist.png differ diff --git a/doc/fr/configuration_guide/commands.rst b/doc/fr/configuration_guide/commands.rst index d5054647f06..e7fd2c62286 100644 --- a/doc/fr/configuration_guide/commands.rst +++ b/doc/fr/configuration_guide/commands.rst @@ -11,14 +11,20 @@ Il est possible d'exécuter cette commande en précisant des arguments. Il existe trois types de commandes : -* Les commandes de **vérification** sont utilisées par les ordonnanceurs afin de vérifier le statut d'un hôte ou d'un service. +* Les commandes de **vérification** sont utilisées par les ordonnanceurs afin de vérifier le statut d'un hôte ou d'un + service. * Les commandes de **notification** sont utilisées par les ordonnanceurs pour alerter les contacts (via mail, SMS...). -* Des commandes **diverses** sont utilisées par les modules complémentaires (pour effectuer certaines actions), par l'ordonnanceur pour le traitement des données... +* Les commandes de **découverte** sont utilisées par les règles de découverte de services. +* Des commandes **diverses** sont utilisées par les modules complémentaires (pour effectuer certaines actions), par + l'ordonnanceur pour le traitement des données... Toutes les commandes peuvent être configurées au sein du menu **Configuration > Commandes**. - + .. image :: /images/guide_utilisateur/configuration/04commandlist.png - :align: center + :align: center + +.. note:: + Par défaut, les commandes verrouillées sont masquées. Cocher la case "Eléments verrouillés" pour les afficher toutes. ******************** Ajouter une commande @@ -27,14 +33,14 @@ Ajouter une commande Avant d'ajouter une commande : 1. Sélectionnez dans le menu de gauche le type de commande que vous souhaitez ajouter (Contrôles, Notifications, Divers). - + .. image :: /images/guide_utilisateur/configuration/04leftmenu.png - :align: center - + :align: center + 2. Cliquez sur **Ajouter** - + .. image :: /images/guide_utilisateur/configuration/04command.png - :align: center + :align: center .. note:: Les champs de configuration d'une commande sont les mêmes qu'importe le type de commande choisi. diff --git a/doc/fr/configuration_guide/models.rst b/doc/fr/configuration_guide/models.rst index 8d3d85670ac..5f6905c450d 100644 --- a/doc/fr/configuration_guide/models.rst +++ b/doc/fr/configuration_guide/models.rst @@ -71,6 +71,9 @@ Pour ajouter un modèle d'hôtes : .. note:: Se rapporter au chapitre de configuration des :ref:`hôtes` pour configurer un modèle car le formulaire est identique. +.. note:: + Par défaut, les modèles d'hôte verrouillés sont masqués. Cocher la case "Eléments verrouillés" pour les afficher tous. + *********************** Les modèles de services *********************** @@ -128,6 +131,9 @@ Configuration La liaison des modèles de services avec les modèles d'hôtes a lieu dans l'onglet **Relations** des modèles de services ou des modèles d'hôtes. +.. note:: + Par défaut, les modèles de service verrouillés sont masqués. Cocher la case "Eléments verrouillés" pour les afficher tous. + *********************** Les modèles de contacts *********************** diff --git a/doc/fr/images/guide_utilisateur/configuration/04commandlist.png b/doc/fr/images/guide_utilisateur/configuration/04commandlist.png index e8caa7bcd98..13aa9736659 100644 Binary files a/doc/fr/images/guide_utilisateur/configuration/04commandlist.png and b/doc/fr/images/guide_utilisateur/configuration/04commandlist.png differ diff --git a/lang/fr_FR.UTF-8/LC_MESSAGES/messages.po b/lang/fr_FR.UTF-8/LC_MESSAGES/messages.po index 94dcf0288be..c7c1aff7a67 100644 --- a/lang/fr_FR.UTF-8/LC_MESSAGES/messages.po +++ b/lang/fr_FR.UTF-8/LC_MESSAGES/messages.po @@ -14836,3 +14836,6 @@ msgstr "Un Remote Server principal doit être sélectionné, avant d'utiliser de msgid "Attach additional Remote Servers" msgstr "Ajouter des Remote Server additonnels" + +msgid "Locked elements" +msgstr "Eléments verrouillés" diff --git a/www/include/configuration/configObject/command/listCommand.ihtml b/www/include/configuration/configObject/command/listCommand.ihtml index ce0f789e84c..6f21cd74df2 100644 --- a/www/include/configuration/configObject/command/listCommand.ihtml +++ b/www/include/configuration/configObject/command/listCommand.ihtml @@ -10,7 +10,13 @@ - {$form.Search.html} + +
+ + +
+ + diff --git a/www/include/configuration/configObject/command/listCommand.php b/www/include/configuration/configObject/command/listCommand.php index 5acf94f9475..66104e5d597 100755 --- a/www/include/configuration/configObject/command/listCommand.php +++ b/www/include/configuration/configObject/command/listCommand.php @@ -40,16 +40,27 @@ include_once "./class/centreonUtils.class.php"; include_once "./include/common/autoNumLimit.php"; +$type = filter_var( + $_POST['type'] ?? $_GET['type'] ?? $centreon->historySearch[$url]['type'] ?? null, + FILTER_VALIDATE_INT +); + $search = filter_var( - $_POST['searchC'] ?? $_GET['searchC'] ?? null, + $_POST['searchC'] ?? $_GET['searchC'] ?? $centreon->historySearch[$url]['search' . $type] ?? '', FILTER_SANITIZE_STRING ); -$type = filter_var( - $_POST['type'] ?? $_GET['type'] ?? null, - FILTER_VALIDATE_INT +$displayLocked = filter_var( + $_POST['displayLocked'] ?? $_GET['displayLocked'] ?? 'off', + FILTER_VALIDATE_BOOLEAN ); +// keep checkbox state if navigating in pagination +// this trick is mandatory cause unchecked checkboxes do not post any data +if (($centreon->historyPage[$url] > 0 || $num !== 0) && isset($centreon->historySearch[$url]['displayLocked'])) { + $displayLocked = $centreon->historySearch[$url]['displayLocked']; +} + // As the four pages of this menu are generated dynamically from the same ihtml and php files, // we need to save $type and to overload the $num value set in the pagination.php file to restore each user's filter. $savedType = $centreon->historySearch[$url]['type'] ?? null; @@ -59,40 +70,28 @@ if (isset($type) && $type !== $savedType) { //if so, we reset the pagination and save the current $type $num = $centreon->historyPage[$url] = 0; - $centreon->historySearch[$url]['type'] = $type; } else { //saving again the pagination filter $centreon->historyPage[$url] = $num; } -if (isset($_POST['searchC']) || isset($_GET['searchC'])) { - //saving user's search field value - $centreon->historySearch[$url] = array(); - // the four pages have the same $url, so we need to distinguish each page using its $type, - // and to save the four search filters. - $centreon->historySearch[$url]['search' . $type] = $search; -} else { - //restoring user's search field value - $search = $centreon->historySearch[$url]['search' . $type] ?? null; -} +// store filters in session +$centreon->historySearch[$url] = [ + 'search' . $type => $search, + 'type' => $type, + 'displayLocked' => $displayLocked +]; +// Locked filter +$lockedFilter = $displayLocked ? "" : "AND command_locked = 0 "; -$type_str = $type ? " AND `command_type` = " . $type : ""; +// Type filter +$typeFilter = $type ? "AND `command_type` = " . $type . " " : ""; $search = tidySearchKey($search, $advanced_search); -//List of elements - Depends on different criteria -if (isset($search) && $search) { - $rq = "SELECT SQL_CALC_FOUND_ROWS `command_id`, `command_name`, `command_line`, `command_type`, " . - "`command_activate` FROM `command` WHERE `command_name` LIKE '%" . $search . "%' " . - $type_str . " ORDER BY `command_name` LIMIT " . $num * $limit . ", " . $limit; -} elseif ($type) { - $rq = "SELECT SQL_CALC_FOUND_ROWS `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 SQL_CALC_FOUND_ROWS `command_id`, `command_name`, `command_line`, `command_type`, " . - "`command_activate` FROM `command` ORDER BY `command_name` LIMIT " . $num * $limit . ", " . $limit; -} +$rq = "SELECT SQL_CALC_FOUND_ROWS `command_id`, `command_name`, `command_line`, `command_type`, " . + "`command_activate` FROM `command` WHERE `command_name` LIKE '%" . $search . "%' " . + $typeFilter . $lockedFilter . " ORDER BY `command_name` LIMIT " . $num * $limit . ", " . $limit; $dbResult = $pearDB->query($rq); $rows = $pearDB->query("SELECT FOUND_ROWS()")->fetchColumn(); @@ -117,7 +116,7 @@ $tpl->assign("headerMenu_suse", _("Services Uses")); $tpl->assign("headerMenu_options", _("Options")); -$form = new HTML_QuickForm('form', 'POST', "?p=" . $p); +$form = new HTML_QuickFormCustom('form', 'POST', "?p=" . $p); // Different style between each lines $style = "one"; @@ -253,5 +252,5 @@ function setO(_i) { $tpl->assign('limit', $limit); $tpl->assign('type', $type); $tpl->assign('searchC', $search); - +$tpl->assign("displayLocked", $displayLocked); $tpl->display("listCommand.ihtml"); diff --git a/www/include/configuration/configObject/host_template_model/listHostTemplateModel.ihtml b/www/include/configuration/configObject/host_template_model/listHostTemplateModel.ihtml index d95ec19110a..38529a4c174 100644 --- a/www/include/configuration/configObject/host_template_model/listHostTemplateModel.ihtml +++ b/www/include/configuration/configObject/host_template_model/listHostTemplateModel.ihtml @@ -12,7 +12,13 @@ - {$form.Search.html} + +
+ + +
+ + diff --git a/www/include/configuration/configObject/host_template_model/listHostTemplateModel.php b/www/include/configuration/configObject/host_template_model/listHostTemplateModel.php index 2ca9fa979ca..f20f33189f9 100755 --- a/www/include/configuration/configObject/host_template_model/listHostTemplateModel.php +++ b/www/include/configuration/configObject/host_template_model/listHostTemplateModel.php @@ -54,24 +54,35 @@ $DBRESULT->closeCursor(); $search = filter_var( - $_POST['searchHT'] ?? $_GET['searchHT'] ?? null, + $_POST['searchHT'] ?? $_GET['searchHT'] ?? $centreon->historySearch[$url]['search'] ?? '', FILTER_SANITIZE_STRING ); -if (isset($_POST['searchHT']) || isset($_GET['searchHT'])) { - //saving filters values - $centreon->historySearch[$url] = array(); - $centreon->historySearch[$url]['search'] = $search; -} else { - //restoring saved values - $search = $centreon->historySearch[$url]['search'] ?? null; +$displayLocked = filter_var( + $_POST['displayLocked'] ?? $_GET['displayLocked'] ?? 'off', + FILTER_VALIDATE_BOOLEAN +); + +// keep checkbox state if navigating in pagination +// this trick is mandatory cause unchecked checkboxes do not post any data +if (($centreon->historyPage[$url] > 0 || $num !== 0) && isset($centreon->historySearch[$url]['displayLocked'])) { + $displayLocked = $centreon->historySearch[$url]['displayLocked']; } -// Host Template list +// store filters in session +$centreon->historySearch[$url] = [ + 'search' => $search, + 'displayLocked' => $displayLocked +]; +// Locked filter +$lockedFilter = $displayLocked ? "" : "AND host_locked = 0 "; + +// Host Template list $rq = "SELECT SQL_CALC_FOUND_ROWS host_id, host_name, host_alias, host_activate, host_template_model_htm_id " . - "FROM host" . - " WHERE host_register = '0' "; + "FROM host " . + "WHERE host_register = '0' " . + $lockedFilter; if ($search) { $rq .= "AND (host_name LIKE '%" . CentreonDB::escape($search) . "%' OR host_alias LIKE '%" . CentreonDB::escape($search) . "%')"; @@ -252,4 +263,5 @@ function setO(_i) { $form->accept($renderer); $tpl->assign('form', $renderer->toArray()); $tpl->assign('searchHT', $search); +$tpl->assign("displayLocked", $displayLocked); $tpl->display("listHostTemplateModel.ihtml"); diff --git a/www/include/configuration/configObject/service_template_model/listServiceTemplateModel.ihtml b/www/include/configuration/configObject/service_template_model/listServiceTemplateModel.ihtml index 21b71b69889..a89a4b099fb 100644 --- a/www/include/configuration/configObject/service_template_model/listServiceTemplateModel.ihtml +++ b/www/include/configuration/configObject/service_template_model/listServiceTemplateModel.ihtml @@ -11,7 +11,13 @@ - {$form.Search.html} + +
+ + +
+ + diff --git a/www/include/configuration/configObject/service_template_model/listServiceTemplateModel.php b/www/include/configuration/configObject/service_template_model/listServiceTemplateModel.php index ed6e38c93fe..e144e0362b8 100644 --- a/www/include/configuration/configObject/service_template_model/listServiceTemplateModel.php +++ b/www/include/configuration/configObject/service_template_model/listServiceTemplateModel.php @@ -49,19 +49,30 @@ $o = ""; $search = filter_var( - $_POST['searchST'] ?? $_GET['searchST'] ?? null, + $_POST['searchST'] ?? $_GET['searchST'] ?? $centreon->historySearch[$url]['search'] ?? '', FILTER_SANITIZE_STRING ); -if (isset($_POST['searchST']) || isset($_GET['searchST'])) { - //saving filters values - $centreon->historySearch[$url] = array(); - $centreon->historySearch[$url]["search"] = $search; -} else { - //restoring saved values - $search = $centreon->historySearch[$url]["search"] ?? null; +$displayLocked = filter_var( + $_POST['displayLocked'] ?? $_GET['displayLocked'] ?? 'off', + FILTER_VALIDATE_BOOLEAN +); + +// keep checkbox state if navigating in pagination +// this trick is mandatory cause unchecked checkboxes do not post any data +if (($centreon->historyPage[$url] > 0 || $num !== 0) && isset($centreon->historySearch[$url]['displayLocked'])) { + $displayLocked = $centreon->historySearch[$url]['displayLocked']; } +// store filters in session +$centreon->historySearch[$url] = [ + 'search' => $search, + 'displayLocked' => $displayLocked +]; + +// Locked filter +$lockedFilter = $displayLocked ? "" : "AND sv.service_locked = 0 "; + //Service Template Model list if ($search) { $query = "SELECT SQL_CALC_FOUND_ROWS sv.service_id, sv.service_description, sv.service_alias, " . @@ -69,12 +80,14 @@ "FROM service sv " . "WHERE (sv.service_description LIKE '%" . $search . "%' OR sv.service_alias LIKE '%" . $search . "%') " . "AND sv.service_register = '0' " . + $lockedFilter . "ORDER BY service_description LIMIT " . $num * $limit . ", " . $limit; } else { $query = "SELECT SQL_CALC_FOUND_ROWS 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' " . + $lockedFilter . "ORDER BY service_description LIMIT " . $num * $limit . ", " . $limit; } $dbResult = $pearDB->query($query); @@ -319,10 +332,10 @@ function setO(_i) { $tpl->assign('limit', $limit); $tpl->assign('searchST', $search); +$tpl->assign("displayLocked", $displayLocked); // Apply a template definition $renderer = new HTML_QuickForm_Renderer_ArraySmarty($tpl); $form->accept($renderer); $tpl->assign('form', $renderer->toArray()); $tpl->display("listServiceTemplateModel.ihtml"); -?>