2008-02-11 00:15:46 +01:00
|
|
|
<?php
|
2021-03-22 17:39:24 +01:00
|
|
|
/**
|
|
|
|
* Module Manager main script.
|
|
|
|
*
|
|
|
|
* @category Module
|
|
|
|
* @package Pandora FMS
|
|
|
|
* @subpackage Agent Configuration
|
|
|
|
* @version 1.0.0
|
|
|
|
* @license See below
|
|
|
|
*
|
|
|
|
* ______ ___ _______ _______ ________
|
|
|
|
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
|
|
|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
|
|
|
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
|
|
|
*
|
|
|
|
* ============================================================================
|
|
|
|
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
|
|
|
* Please see http://pandorafms.org for full contribution list
|
|
|
|
* 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 for version 2.
|
|
|
|
* 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 PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
* ============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
// You can redefine $url and unset $id_agente to reuse the form. Dirty (hope temporal) hack.
|
|
|
|
$url_id_agente = (isset($id_agente) === true) ? '&id_agente='.$id_agente : '';
|
|
|
|
|
|
|
|
$url = sprintf(
|
|
|
|
'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=module%s',
|
|
|
|
$url_id_agente
|
|
|
|
);
|
2007-02-27 20:03:56 +01:00
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
enterprise_include('godmode/agentes/module_manager.php');
|
|
|
|
$isFunctionPolicies = enterprise_include_once('include/functions_policies.php');
|
|
|
|
require_once $config['homedir'].'/include/functions_modules.php';
|
|
|
|
require_once $config['homedir'].'/include/functions_agents.php';
|
|
|
|
require_once $config['homedir'].'/include/functions_servers.php';
|
2009-03-24 Esteban Sanchez <estebans@artica.es>
* general/pandora_help.php: Added support for enterprise help files.
* include/javascript/pandora.js: Renamed pandora_help() to
open_help().
* include/functions_ui.php: Renamed event function on
print_help_icon(). Removed deprecated pandora_help().
* godmode/agentes/module_manager.php: Added enterprise hooks.
* godmode/agentes/module_manager_editor.php: Added categories
construction here. Added enterprise hooks.
* godmode/agentes/module_manager_editor_common.php: Replaced
deprecated pandora_help() with print_help_icon(). Moved categories
construction to module_manager_editor.
* include/config_process.php: Updated build version.
* include/styles/pandora.css: Fixed textarea height.
* godmode/agentes/manage_config_remote.php,
godmode/agentes/massive_config.php,
godmode/agentes/massive_edit_modules.php,
godmode/agentes/module_manager_editor_network.php,
godmode/agentes/module_manager_editor_plugin.php,
godmode/agentes/module_manager_editor_prediction.php,
godmode/agentes/module_manager_editor_wmi.php,
godmode/agentes/planned_downtime.php, godmode/alerts/alert_list.php,
godmode/alerts/configure_alert_compound.php,
godmode/modules/manage_network_components_form_network.php,
godmode/modules/manage_network_components_form_wmi.php,
godmode/reporting/map_builder.php,
godmode/servers/manage_export_form.php,
godmode/servers/manage_recontask_form.php, godmode/servers/plugin.php,
godmode/setup/setup.php, operation/agentes/alerts_status.php,
operation/agentes/tactical.php,
godmode/agentes/agent_manager.php: Replaced deprecated pandora_help()
with print_help_icon().
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1557 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-03-24 16:38:54 +01:00
|
|
|
|
2022-10-24 16:44:10 +02:00
|
|
|
$search_string = get_parameter('search_string');
|
2008-03-06 Sancho Lerena <slerena@gmail.com>
Pandora FMS 2.0 development first commit. 1.4 version is now 2.0
* pandoradb_data.sql: Added correct tnetwork_components, fixed
ttipo_modulo (categoria values).
* include/styles/pandora.css: Added some server icons, tab style
for module editor has been improved.
* include/functions_db.php: added new functions, lang_string and
check_login, and a first review of several functions that currently
need change for new config session parameters in array $config[]
* include/javascript/pandora.js: Added a new global include for
spare javascript functions before included into a few pages.
* include/languages/language_en.php: New tokens.
* include/help*: New contextual help system.
* include/config_process.php: New way to manage config.
* include/functions.php: Added new functions to manage global
* operation/agentes/estado_ultimopaquete.php: removed old javascript
code from there.
* operation/agentes/estado_agente.php: Removed references to deprecated
field "agent_type".
* operation/agentes/tactical.php: Some code cleanup and progressbar
issues merged from 1.3.1 branch. Need to add support to new server
types and new module types.
* operation/servers/view_server.php: Added support to new servers, code
cleanup.
* reporting/fgraph.php: Code cleanup, changes to use new config method,
and a lot of style change.
* general/pandora_help.php: New source for contextual help in the way
of moodle.
* general/footer.php, general/noaccess.php: Code cleanup and uses of
new config.
* module_manager_editor: New editors for each module family. Need
finish and implement EDITION of data, now only inserts data.
* godmode/agentes/agent_manager.php: Implemented new server assigment
and edition.
* godmode/agentes/configurar_agente.php: Small changes that affects
module management, visualization and agent management.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@739 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-03-07 17:22:16 +01:00
|
|
|
|
2016-08-17 11:59:06 +02:00
|
|
|
global $policy_page;
|
|
|
|
|
2022-11-23 17:42:53 +01:00
|
|
|
if (isset($policy_page) === false) {
|
2019-01-30 16:18:44 +01:00
|
|
|
$policy_page = false;
|
|
|
|
}
|
2016-08-17 11:59:06 +02:00
|
|
|
|
2022-11-23 17:42:53 +01:00
|
|
|
$checked = (bool) get_parameter('checked');
|
|
|
|
$sec2 = (string) get_parameter('sec2');
|
2020-07-06 10:09:36 +02:00
|
|
|
|
2022-11-23 17:42:53 +01:00
|
|
|
// Table for filter bar.
|
|
|
|
$filterTable = new stdClass();
|
|
|
|
$filterTable->class = 'fixed_filter_bar';
|
|
|
|
$filterTable->data = [];
|
2023-01-11 13:02:18 +01:00
|
|
|
$filterTable->cellstyle[0][0] = 'width:0';
|
|
|
|
$filterTable->data[0][0] = __('Search');
|
|
|
|
$filterTable->data[1][0] .= html_print_input_text(
|
2020-07-06 10:09:36 +02:00
|
|
|
'search_string',
|
|
|
|
$search_string,
|
|
|
|
'',
|
2023-01-11 13:02:18 +01:00
|
|
|
30,
|
2020-07-06 10:09:36 +02:00
|
|
|
255,
|
2022-12-16 12:55:56 +01:00
|
|
|
true,
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
'',
|
2023-01-11 13:02:18 +01:00
|
|
|
''
|
2020-07-06 10:09:36 +02:00
|
|
|
);
|
2022-11-23 17:42:53 +01:00
|
|
|
$filterTable->data[0][0] .= html_print_input_hidden('search', 1, true);
|
|
|
|
|
|
|
|
if ((bool) $policy_page === false) {
|
2023-01-11 13:02:18 +01:00
|
|
|
$filterTable->data[0][1] = __('Show in hierachy mode');
|
|
|
|
$filterTable->data[1][1] = html_print_checkbox_switch(
|
2022-11-23 17:42:53 +01:00
|
|
|
'status_hierachy_mode',
|
|
|
|
'',
|
|
|
|
((string) $checked === 'true'),
|
|
|
|
true,
|
|
|
|
false,
|
|
|
|
'onChange=change_mod_filter();'
|
|
|
|
);
|
2019-01-30 16:18:44 +01:00
|
|
|
}
|
|
|
|
|
2023-01-11 13:02:18 +01:00
|
|
|
$filterTable->data[1][2] = html_print_submit_button(
|
2022-10-25 13:13:52 +02:00
|
|
|
__('Filter'),
|
|
|
|
'filter',
|
|
|
|
false,
|
|
|
|
[
|
2022-11-23 17:42:53 +01:00
|
|
|
'icon' => 'search',
|
|
|
|
'class' => 'float-right',
|
|
|
|
'mode' => 'secondary mini',
|
|
|
|
],
|
|
|
|
true
|
2022-10-25 13:13:52 +02:00
|
|
|
);
|
2022-11-23 17:42:53 +01:00
|
|
|
|
|
|
|
// Print filter table.
|
2023-02-14 07:52:13 +01:00
|
|
|
echo '<form id="create_module_type" method="post" action="'.$url.'">';
|
2022-11-23 17:42:53 +01:00
|
|
|
html_print_table($filterTable);
|
2023-02-14 07:52:13 +01:00
|
|
|
echo '</form>';
|
2008-03-06 Sancho Lerena <slerena@gmail.com>
Pandora FMS 2.0 development first commit. 1.4 version is now 2.0
* pandoradb_data.sql: Added correct tnetwork_components, fixed
ttipo_modulo (categoria values).
* include/styles/pandora.css: Added some server icons, tab style
for module editor has been improved.
* include/functions_db.php: added new functions, lang_string and
check_login, and a first review of several functions that currently
need change for new config session parameters in array $config[]
* include/javascript/pandora.js: Added a new global include for
spare javascript functions before included into a few pages.
* include/languages/language_en.php: New tokens.
* include/help*: New contextual help system.
* include/config_process.php: New way to manage config.
* include/functions.php: Added new functions to manage global
* operation/agentes/estado_ultimopaquete.php: removed old javascript
code from there.
* operation/agentes/estado_agente.php: Removed references to deprecated
field "agent_type".
* operation/agentes/tactical.php: Some code cleanup and progressbar
issues merged from 1.3.1 branch. Need to add support to new server
types and new module types.
* operation/servers/view_server.php: Added support to new servers, code
cleanup.
* reporting/fgraph.php: Code cleanup, changes to use new config method,
and a lot of style change.
* general/pandora_help.php: New source for contextual help in the way
of moodle.
* general/footer.php, general/noaccess.php: Code cleanup and uses of
new config.
* module_manager_editor: New editors for each module family. Need
finish and implement EDITION of data, now only inserts data.
* godmode/agentes/agent_manager.php: Implemented new server assigment
and edition.
* godmode/agentes/configurar_agente.php: Small changes that affects
module management, visualization and agent management.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@739 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-03-07 17:22:16 +01:00
|
|
|
// Check if there is at least one server of each type available to assign that
|
2020-07-06 10:09:36 +02:00
|
|
|
// kind of modules. If not, do not show server type in combo.
|
2019-01-30 16:18:44 +01:00
|
|
|
$network_available = db_get_sql(
|
|
|
|
'SELECT count(*)
|
2013-02-13 18:47:43 +01:00
|
|
|
FROM tserver
|
2021-03-22 17:39:24 +01:00
|
|
|
WHERE server_type = '.SERVER_TYPE_NETWORK
|
2019-01-30 16:18:44 +01:00
|
|
|
);
|
2020-07-06 10:09:36 +02:00
|
|
|
// POSTGRESQL AND ORACLE COMPATIBLE.
|
2019-01-30 16:18:44 +01:00
|
|
|
$wmi_available = db_get_sql(
|
|
|
|
'SELECT count(*)
|
2013-02-13 18:47:43 +01:00
|
|
|
FROM tserver
|
2021-03-22 17:39:24 +01:00
|
|
|
WHERE server_type = '.SERVER_TYPE_WMI
|
2019-01-30 16:18:44 +01:00
|
|
|
);
|
2020-07-06 10:09:36 +02:00
|
|
|
// POSTGRESQL AND ORACLE COMPATIBLE.
|
2019-01-30 16:18:44 +01:00
|
|
|
$plugin_available = db_get_sql(
|
|
|
|
'SELECT count(*)
|
2013-02-13 18:47:43 +01:00
|
|
|
FROM tserver
|
2021-03-22 17:39:24 +01:00
|
|
|
WHERE server_type = '.SERVER_TYPE_PLUGIN
|
2019-01-30 16:18:44 +01:00
|
|
|
);
|
2020-07-06 10:09:36 +02:00
|
|
|
// POSTGRESQL AND ORACLE COMPATIBLE.
|
2019-01-30 16:18:44 +01:00
|
|
|
$prediction_available = db_get_sql(
|
|
|
|
'SELECT count(*)
|
2013-02-13 18:47:43 +01:00
|
|
|
FROM tserver
|
2021-03-22 17:39:24 +01:00
|
|
|
WHERE server_type = '.SERVER_TYPE_PREDICTION
|
|
|
|
);
|
|
|
|
// POSTGRESQL AND ORACLE COMPATIBLE.
|
|
|
|
$web_available = db_get_sql(
|
|
|
|
'SELECT count(*)
|
|
|
|
FROM tserver
|
|
|
|
WHERE server_type = '.SERVER_TYPE_WEB
|
2019-01-30 16:18:44 +01:00
|
|
|
);
|
2020-07-06 10:09:36 +02:00
|
|
|
// POSTGRESQL AND ORACLE COMPATIBLE.
|
|
|
|
// Development mode to use all servers.
|
2018-07-13 11:56:37 +02:00
|
|
|
if ($develop_bypass || is_metaconsole()) {
|
2019-01-30 16:18:44 +01:00
|
|
|
$network_available = 1;
|
|
|
|
$wmi_available = 1;
|
|
|
|
$plugin_available = 1;
|
2020-07-06 10:09:36 +02:00
|
|
|
// FIXME when prediction predictions server modules can be configured.
|
|
|
|
// on metaconsole.
|
2022-11-23 17:42:53 +01:00
|
|
|
$prediction_available = (is_metaconsole() === true) ? 0 : 1;
|
2007-03-12 18:58:52 +01:00
|
|
|
}
|
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
$modules = [];
|
2009-03-24 Esteban Sanchez <estebans@artica.es>
* general/pandora_help.php: Added support for enterprise help files.
* include/javascript/pandora.js: Renamed pandora_help() to
open_help().
* include/functions_ui.php: Renamed event function on
print_help_icon(). Removed deprecated pandora_help().
* godmode/agentes/module_manager.php: Added enterprise hooks.
* godmode/agentes/module_manager_editor.php: Added categories
construction here. Added enterprise hooks.
* godmode/agentes/module_manager_editor_common.php: Replaced
deprecated pandora_help() with print_help_icon(). Moved categories
construction to module_manager_editor.
* include/config_process.php: Updated build version.
* include/styles/pandora.css: Fixed textarea height.
* godmode/agentes/manage_config_remote.php,
godmode/agentes/massive_config.php,
godmode/agentes/massive_edit_modules.php,
godmode/agentes/module_manager_editor_network.php,
godmode/agentes/module_manager_editor_plugin.php,
godmode/agentes/module_manager_editor_prediction.php,
godmode/agentes/module_manager_editor_wmi.php,
godmode/agentes/planned_downtime.php, godmode/alerts/alert_list.php,
godmode/alerts/configure_alert_compound.php,
godmode/modules/manage_network_components_form_network.php,
godmode/modules/manage_network_components_form_wmi.php,
godmode/reporting/map_builder.php,
godmode/servers/manage_export_form.php,
godmode/servers/manage_recontask_form.php, godmode/servers/plugin.php,
godmode/setup/setup.php, operation/agentes/alerts_status.php,
operation/agentes/tactical.php,
godmode/agentes/agent_manager.php: Replaced deprecated pandora_help()
with print_help_icon().
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1557 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-03-24 16:38:54 +01:00
|
|
|
$modules['dataserver'] = __('Create a new data server module');
|
2019-01-30 16:18:44 +01:00
|
|
|
if ($network_available) {
|
|
|
|
$modules['networkserver'] = __('Create a new network server module');
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($plugin_available) {
|
|
|
|
$modules['pluginserver'] = __('Create a new plugin server module');
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($wmi_available) {
|
|
|
|
$modules['wmiserver'] = __('Create a new WMI server module');
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($prediction_available) {
|
|
|
|
$modules['predictionserver'] = __('Create a new prediction server module');
|
|
|
|
}
|
2009-05-07 16:44:26 +02:00
|
|
|
|
2022-02-08 11:56:12 +01:00
|
|
|
if (is_metaconsole() === true || $web_available >= '1') {
|
2021-03-22 17:39:24 +01:00
|
|
|
$modules['webserver'] = __('Create a new web Server module');
|
|
|
|
}
|
|
|
|
|
2022-11-23 17:42:53 +01:00
|
|
|
if (enterprise_installed() === true) {
|
2019-01-30 16:18:44 +01:00
|
|
|
set_enterprise_module_types($modules);
|
2013-08-07 10:26:26 +02:00
|
|
|
}
|
2011-02-15 12:41:28 +01:00
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
if (strstr($sec2, 'enterprise/godmode/policies/policies') !== false) {
|
|
|
|
// It is unset because the policies haven't a table tmodule_synth and the
|
|
|
|
// some part of code to apply this kind of modules in policy agents.
|
|
|
|
// But in the future maybe will be good to make this feature, but remember
|
|
|
|
// the modules to show in syntetic module policy form must be the policy
|
|
|
|
// modules from the same policy.
|
|
|
|
unset($modules['predictionserver']);
|
2022-11-23 17:42:53 +01:00
|
|
|
if (enterprise_installed() === true) {
|
2019-01-30 16:18:44 +01:00
|
|
|
unset($modules['webux']);
|
|
|
|
}
|
2011-02-15 12:41:28 +01:00
|
|
|
}
|
|
|
|
|
2022-11-23 17:42:53 +01:00
|
|
|
if (($policy_page === true) || (isset($agent) === true)) {
|
|
|
|
if ($policy_page === true) {
|
2021-06-03 10:16:29 +02:00
|
|
|
$show_creation = is_management_allowed();
|
2019-01-30 16:18:44 +01:00
|
|
|
} else {
|
2021-06-03 10:16:29 +02:00
|
|
|
if (isset($all_groups) === false) {
|
2019-01-30 16:18:44 +01:00
|
|
|
$all_groups = agents_get_all_groups_agent(
|
|
|
|
$agent['id_agente'],
|
|
|
|
$agent['id_grupo']
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-11-23 17:42:53 +01:00
|
|
|
$show_creation = check_acl_one_of_groups($config['id_user'], $all_groups, 'AW') === true;
|
2019-01-30 16:18:44 +01:00
|
|
|
}
|
2022-11-23 17:42:53 +01:00
|
|
|
} else {
|
|
|
|
$show_creation = false;
|
|
|
|
}
|
2019-01-30 16:18:44 +01:00
|
|
|
|
2022-11-23 17:42:53 +01:00
|
|
|
if ($show_creation === true) {
|
|
|
|
// Create module/type combo.
|
|
|
|
$tableCreateModule = new stdClass();
|
|
|
|
$tableCreateModule->id = 'create';
|
2022-12-10 14:39:17 +01:00
|
|
|
$tableCreateModule->class = 'create_module_dialog';
|
2022-11-23 17:42:53 +01:00
|
|
|
$tableCreateModule->width = '100%';
|
|
|
|
$tableCreateModule->data = [];
|
|
|
|
$tableCreateModule->style = [];
|
|
|
|
|
2022-11-30 10:14:42 +01:00
|
|
|
$tableCreateModule->data['caption_type'] = html_print_input_hidden('edit_module', 1);
|
2022-11-23 17:42:53 +01:00
|
|
|
$tableCreateModule->data['caption_type'] .= __('Type');
|
|
|
|
$tableCreateModule->data['type'] = html_print_select(
|
|
|
|
$modules,
|
|
|
|
'moduletype',
|
|
|
|
'',
|
|
|
|
'',
|
|
|
|
'',
|
|
|
|
'',
|
|
|
|
true,
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
'',
|
|
|
|
false,
|
2022-11-30 10:14:42 +01:00
|
|
|
'width:380px;'
|
2022-11-23 17:42:53 +01:00
|
|
|
);
|
2019-01-30 16:18:44 +01:00
|
|
|
|
2022-11-30 10:14:42 +01:00
|
|
|
// Link for get more modules.
|
|
|
|
if ((bool) $config['disable_help'] === false) {
|
|
|
|
$tableCreateModule->data['get_more_modules'] = html_print_anchor(
|
|
|
|
[
|
|
|
|
'href' => 'https://pandorafms.com/Library/Library/',
|
|
|
|
'target' => '_blank',
|
|
|
|
'class' => 'color-black-grey',
|
|
|
|
'content' => __('Get more modules on Monitoring Library'),
|
|
|
|
],
|
|
|
|
true
|
|
|
|
);
|
2022-11-23 17:42:53 +01:00
|
|
|
}
|
2022-11-30 10:14:42 +01:00
|
|
|
}
|
2013-05-24 12:30:03 +02:00
|
|
|
|
2022-11-23 17:42:53 +01:00
|
|
|
if (isset($id_agente) === false) {
|
2019-01-30 16:18:44 +01:00
|
|
|
return;
|
|
|
|
}
|
2012-07-25 11:59:03 +02:00
|
|
|
|
2009-09-25 18:04:14 +02:00
|
|
|
|
2021-03-02 10:42:08 +01:00
|
|
|
$module_action = (string) get_parameter('module_action');
|
2009-09-25 18:04:14 +02:00
|
|
|
|
2021-03-02 10:42:08 +01:00
|
|
|
if ($module_action === 'delete') {
|
2019-01-30 16:18:44 +01:00
|
|
|
$id_agent_modules_delete = (array) get_parameter('id_delete');
|
|
|
|
|
2021-11-30 14:08:12 +01:00
|
|
|
$print_result_msg = true;
|
2019-01-30 16:18:44 +01:00
|
|
|
$count_correct_delete_modules = 0;
|
|
|
|
foreach ($id_agent_modules_delete as $id_agent_module_del) {
|
2022-12-21 08:44:11 +01:00
|
|
|
// Before delete the main module, check and delete the childrens from the original module.
|
|
|
|
module_check_childrens_and_delete($id_agent_module_del);
|
2019-01-30 16:18:44 +01:00
|
|
|
$id_grupo = (int) agents_get_agent_group($id_agente);
|
|
|
|
$all_groups = agents_get_all_groups_agent($id_agente, $id_grupo);
|
|
|
|
|
|
|
|
if (! check_acl_one_of_groups($config['id_user'], $all_groups, 'AW')) {
|
|
|
|
db_pandora_audit(
|
2022-01-20 10:55:23 +01:00
|
|
|
AUDIT_LOG_ACL_VIOLATION,
|
2019-01-30 16:18:44 +01:00
|
|
|
'Trying to delete a module without admin rights'
|
|
|
|
);
|
|
|
|
include 'general/noaccess.php';
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($id_agent_module_del < 1) {
|
2021-11-30 14:08:12 +01:00
|
|
|
if (count($id_agent_modules_delete) === 1) {
|
|
|
|
ui_print_error_message(
|
|
|
|
__('No modules selected')
|
|
|
|
);
|
|
|
|
|
|
|
|
$print_result_msg = false;
|
|
|
|
} else {
|
|
|
|
ui_print_error_message(
|
|
|
|
__('There was a problem completing the operation')
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
continue;
|
2019-01-30 16:18:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
enterprise_include_once('include/functions_config_agents.php');
|
2020-07-06 10:09:36 +02:00
|
|
|
enterprise_hook(
|
|
|
|
'config_agents_delete_module_in_conf',
|
|
|
|
[
|
|
|
|
modules_get_agentmodule_agent($id_agent_module_del),
|
|
|
|
modules_get_agentmodule_name($id_agent_module_del),
|
|
|
|
]
|
|
|
|
);
|
2019-01-30 16:18:44 +01:00
|
|
|
|
|
|
|
$error = 0;
|
|
|
|
|
|
|
|
// First delete from tagente_modulo -> if not successful, increment
|
|
|
|
// error. NOTICE that we don't delete all data here, just marking for deletion
|
|
|
|
// and delete some simple data.
|
|
|
|
$status = '';
|
2020-07-06 10:09:36 +02:00
|
|
|
$agent_id_of_module = db_get_value(
|
|
|
|
'id_agente',
|
|
|
|
'tagente_modulo',
|
|
|
|
'id_agente_modulo',
|
|
|
|
(int) $id_agent_module_del
|
|
|
|
);
|
2019-01-30 16:18:44 +01:00
|
|
|
|
|
|
|
if (db_process_sql(
|
|
|
|
"UPDATE tagente_modulo
|
2013-06-07 11:36:26 +02:00
|
|
|
SET nombre = 'pendingdelete', disabled = 1, delete_pending = 1
|
2019-01-30 16:18:44 +01:00
|
|
|
WHERE id_agente_modulo = ".$id_agent_module_del,
|
|
|
|
'affected_rows',
|
|
|
|
'',
|
|
|
|
true,
|
|
|
|
$status,
|
|
|
|
false
|
|
|
|
) === false
|
|
|
|
) {
|
|
|
|
$error++;
|
|
|
|
} else {
|
2020-07-06 10:09:36 +02:00
|
|
|
// Set flag to update module status count.
|
2019-01-30 16:18:44 +01:00
|
|
|
if ($agent_id_of_module !== false) {
|
|
|
|
db_process_sql(
|
|
|
|
'UPDATE tagente
|
2013-09-05 18:35:49 +02:00
|
|
|
SET update_module_count = 1, update_alert_count = 1
|
2019-01-30 16:18:44 +01:00
|
|
|
WHERE id_agente = '.$agent_id_of_module
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-24 10:00:42 +01:00
|
|
|
$result = db_process_sql_delete(
|
|
|
|
'tagente_estado',
|
|
|
|
['id_agente_modulo' => $id_agent_module_del]
|
|
|
|
);
|
|
|
|
if ($result === false) {
|
|
|
|
$error++;
|
|
|
|
}
|
2019-01-30 16:18:44 +01:00
|
|
|
|
2022-11-24 10:00:42 +01:00
|
|
|
$result = db_process_sql_delete(
|
|
|
|
'tagente_datos_inc',
|
|
|
|
['id_agente_modulo' => $id_agent_module_del]
|
|
|
|
);
|
|
|
|
if ($result === false) {
|
|
|
|
$error++;
|
2019-01-30 16:18:44 +01:00
|
|
|
}
|
|
|
|
|
2020-07-06 10:09:36 +02:00
|
|
|
// Trick to detect if we are deleting a synthetic module (avg or arithmetic).
|
|
|
|
// If result is empty then module doesn't have this type of submodules.
|
|
|
|
$ops_json = enterprise_hook(
|
|
|
|
'modules_get_synthetic_operations',
|
|
|
|
[$id_agent_module_del]
|
|
|
|
);
|
2019-01-30 16:18:44 +01:00
|
|
|
$result_ops_synthetic = json_decode($ops_json);
|
2022-11-24 10:00:42 +01:00
|
|
|
if (empty($result_ops_synthetic) === false) {
|
2020-07-06 10:09:36 +02:00
|
|
|
$result = enterprise_hook(
|
|
|
|
'modules_delete_synthetic_operations',
|
|
|
|
[$id_agent_module_del]
|
|
|
|
);
|
2019-01-30 16:18:44 +01:00
|
|
|
if ($result === false) {
|
|
|
|
$error++;
|
|
|
|
}
|
2020-07-06 10:09:36 +02:00
|
|
|
} else {
|
|
|
|
$result_components = enterprise_hook(
|
|
|
|
'modules_get_synthetic_components',
|
|
|
|
[$id_agent_module_del]
|
|
|
|
);
|
2019-01-30 16:18:44 +01:00
|
|
|
$count_components = 1;
|
2022-11-24 10:00:42 +01:00
|
|
|
if (empty($result_components) === false) {
|
2020-07-06 10:09:36 +02:00
|
|
|
// Get number of components pending to delete to know when it's needed to update orders.
|
2019-01-30 16:18:44 +01:00
|
|
|
$num_components = count($result_components);
|
|
|
|
$last_target_module = 0;
|
|
|
|
foreach ($result_components as $id_target_module) {
|
2020-07-06 10:09:36 +02:00
|
|
|
// Detects change of component or last component to update orders.
|
2022-11-24 10:00:42 +01:00
|
|
|
if (($count_components === $num_components) || ($last_target_module !== $id_target_module)
|
2020-07-06 10:09:36 +02:00
|
|
|
) {
|
2019-01-30 16:18:44 +01:00
|
|
|
$update_orders = true;
|
|
|
|
} else {
|
|
|
|
$update_orders = false;
|
|
|
|
}
|
|
|
|
|
2020-07-06 10:09:36 +02:00
|
|
|
$result = enterprise_hook(
|
|
|
|
'modules_delete_synthetic_operations',
|
|
|
|
[
|
|
|
|
$id_target_module,
|
|
|
|
$id_agent_module_del,
|
|
|
|
$update_orders,
|
|
|
|
]
|
|
|
|
);
|
2019-01-30 16:18:44 +01:00
|
|
|
if ($result === false) {
|
|
|
|
$error++;
|
|
|
|
}
|
|
|
|
|
|
|
|
$count_components++;
|
|
|
|
$last_target_module = $id_target_module;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-06 10:09:36 +02:00
|
|
|
// Check for errors.
|
2022-11-24 10:00:42 +01:00
|
|
|
if ((int) $error === 0) {
|
2019-01-30 16:18:44 +01:00
|
|
|
$count_correct_delete_modules++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-30 14:08:12 +01:00
|
|
|
if ($print_result_msg === true) {
|
|
|
|
$count_modules_to_delete = count($id_agent_modules_delete);
|
2022-11-24 10:00:42 +01:00
|
|
|
if ($count_correct_delete_modules === 0) {
|
2019-01-30 16:18:44 +01:00
|
|
|
ui_print_error_message(
|
|
|
|
sprintf(
|
2021-11-30 14:08:12 +01:00
|
|
|
__('There was a problem completing the operation. Applied to 0/%d modules.'),
|
2019-01-30 16:18:44 +01:00
|
|
|
$count_modules_to_delete
|
|
|
|
)
|
|
|
|
);
|
2021-11-30 14:08:12 +01:00
|
|
|
} else {
|
2022-11-24 10:00:42 +01:00
|
|
|
if ($count_correct_delete_modules === $count_modules_to_delete) {
|
2021-11-30 14:08:12 +01:00
|
|
|
ui_print_success_message(__('Operation finished successfully.'));
|
|
|
|
} else {
|
|
|
|
ui_print_error_message(
|
|
|
|
sprintf(
|
|
|
|
__('There was a problem completing the operation. Applied to %d/%d modules.'),
|
|
|
|
$count_correct_delete_modules,
|
|
|
|
$count_modules_to_delete
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
2019-01-30 16:18:44 +01:00
|
|
|
}
|
|
|
|
}
|
2021-03-02 10:42:08 +01:00
|
|
|
} else if ($module_action === 'disable') {
|
|
|
|
$id_agent_modules_disable = (array) get_parameter('id_delete');
|
|
|
|
$updated_count = 0;
|
|
|
|
|
|
|
|
foreach ($id_agent_modules_disable as $id_agent_module_disable) {
|
|
|
|
$sql = sprintf(
|
|
|
|
'UPDATE tagente_modulo
|
|
|
|
SET disabled = 1
|
|
|
|
WHERE id_agente_modulo = %d',
|
|
|
|
$id_agent_module_disable
|
|
|
|
);
|
|
|
|
|
2022-08-30 14:58:19 +02:00
|
|
|
$id_agent_changed[] = modules_get_agentmodule_agent($id_agent_module_disable);
|
|
|
|
$agent_update_result = db_process_sql_update(
|
|
|
|
'tagente',
|
|
|
|
['update_module_count' => 1],
|
|
|
|
['id_agente' => $id_agent_changed]
|
|
|
|
);
|
|
|
|
|
|
|
|
if (db_process_sql($sql) !== false && $agent_update_result !== false) {
|
2021-03-02 10:42:08 +01:00
|
|
|
$updated_count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$count_modules_to_disable = count($id_agent_modules_disable);
|
|
|
|
if ($updated_count === 0) {
|
|
|
|
ui_print_error_message(
|
|
|
|
sprintf(
|
|
|
|
__('There was a problem completing the operation. Applied to 0/%d modules.'),
|
|
|
|
$count_modules_to_disable
|
|
|
|
)
|
|
|
|
);
|
|
|
|
} else {
|
2022-11-24 10:00:42 +01:00
|
|
|
if ($updated_count === $count_modules_to_disable) {
|
2021-03-02 10:42:08 +01:00
|
|
|
ui_print_success_message(__('Operation finished successfully.'));
|
|
|
|
} else {
|
|
|
|
ui_print_error_message(
|
|
|
|
sprintf(
|
|
|
|
__('There was a problem completing the operation. Applied to %d/%d modules.'),
|
|
|
|
$updated_count,
|
|
|
|
$count_modules_to_disable
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2022-10-25 15:52:30 +02:00
|
|
|
} else if ($module_action === 'enable') {
|
|
|
|
$id_agent_modules_enable = (array) get_parameter('id_delete');
|
|
|
|
$updated_count = 0;
|
|
|
|
|
|
|
|
foreach ($id_agent_modules_enable as $id_agent_module_enable) {
|
|
|
|
$sql = sprintf(
|
|
|
|
'UPDATE tagente_modulo
|
|
|
|
SET disabled = 0
|
|
|
|
WHERE id_agente_modulo = %d',
|
|
|
|
$id_agent_module_enable
|
|
|
|
);
|
|
|
|
|
|
|
|
$id_agent_changed[] = modules_get_agentmodule_agent($id_agent_module_enable);
|
|
|
|
$agent_update_result = db_process_sql_update(
|
|
|
|
'tagente',
|
|
|
|
['update_module_count' => 1],
|
|
|
|
['id_agente' => $id_agent_changed]
|
|
|
|
);
|
|
|
|
|
|
|
|
if (db_process_sql($sql) !== false && $agent_update_result !== false) {
|
|
|
|
$updated_count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$count_modules_to_enable = count($id_agent_modules_enable);
|
|
|
|
|
|
|
|
if ($updated_count === 0) {
|
|
|
|
ui_print_error_message(
|
|
|
|
sprintf(
|
|
|
|
__('There was a problem completing the operation. Applied to 0/%d modules.'),
|
|
|
|
$count_modules_to_enable
|
|
|
|
)
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
if ($updated_count == $count_modules_to_enable) {
|
|
|
|
ui_print_success_message(__('Operation finished successfully.'));
|
|
|
|
} else {
|
|
|
|
ui_print_error_message(
|
|
|
|
sprintf(
|
|
|
|
__('There was a problem completing the operation. Applied to %d/%d modules.'),
|
|
|
|
$updated_count,
|
|
|
|
$count_modules_to_enable
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2009-09-25 18:04:14 +02:00
|
|
|
}
|
|
|
|
|
2010-10-14 17:09:29 +02:00
|
|
|
|
2012-08-21 Miguel de Dios <miguel.dedios@artica.es>
* extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql,
godmode/agentes/module_manager_editor_common.php,
godmode/agentes/module_manager.php,
godmode/agentes/configurar_agente.php,
godmode/agentes/module_manager_editor.php, pandoradb.sql,
pandoradb.postgreSQL.sql, pandoradb.oracle.sql,
operation/agentes/estado_ultimopaquete.php,
operation/agentes/estado_monitores.php,
operation/agentes/ver_agente.php: added in the modules the same
feature to set agent in "Quiet" mode.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6898 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-08-21 20:57:48 +02:00
|
|
|
// ==================
|
|
|
|
// TABLE LIST MODULES
|
|
|
|
// ==================
|
2019-01-30 16:18:44 +01:00
|
|
|
$url = 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=module&id_agente='.$id_agente;
|
2019-04-05 13:18:38 +02:00
|
|
|
$selectNameUp = false;
|
|
|
|
$selectNameDown = false;
|
|
|
|
$selectServerUp = false;
|
|
|
|
$selectServerDown = false;
|
|
|
|
$selectTypeUp = false;
|
|
|
|
$selectTypeDown = false;
|
|
|
|
$selectIntervalUp = false;
|
|
|
|
$selectIntervalDown = false;
|
2010-07-21 20:07:21 +02:00
|
|
|
$sortField = get_parameter('sort_field');
|
|
|
|
$sort = get_parameter('sort', 'none');
|
2019-04-05 13:18:38 +02:00
|
|
|
$selected = true;
|
2010-07-21 20:07:21 +02:00
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
$order[] = [
|
|
|
|
'field' => 'tmodule_group.name',
|
|
|
|
'order' => 'ASC',
|
|
|
|
];
|
2010-07-21 20:07:21 +02:00
|
|
|
|
|
|
|
switch ($sortField) {
|
2019-01-30 16:18:44 +01:00
|
|
|
case 'name':
|
|
|
|
switch ($sort) {
|
|
|
|
case 'up':
|
2022-11-24 10:00:42 +01:00
|
|
|
default:
|
2019-01-30 16:18:44 +01:00
|
|
|
$selectNameUp = $selected;
|
2022-11-24 10:00:42 +01:00
|
|
|
$order[] = [
|
|
|
|
'field' => 'tagente_modulo.nombre',
|
|
|
|
'order' => 'ASC',
|
|
|
|
];
|
2019-01-30 16:18:44 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'down':
|
|
|
|
$selectNameDown = $selected;
|
2022-11-24 10:00:42 +01:00
|
|
|
$order[] = [
|
|
|
|
'field' => 'tagente_modulo.nombre',
|
|
|
|
'order' => 'DESC',
|
|
|
|
];
|
2021-03-22 17:39:24 +01:00
|
|
|
break;
|
2019-01-30 16:18:44 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'server':
|
|
|
|
switch ($sort) {
|
|
|
|
case 'up':
|
2022-11-24 10:00:42 +01:00
|
|
|
default:
|
2019-01-30 16:18:44 +01:00
|
|
|
$selectServerUp = $selected;
|
|
|
|
$order[] = [
|
|
|
|
'field' => 'id_modulo',
|
|
|
|
'order' => 'ASC',
|
|
|
|
];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'down':
|
|
|
|
$selectServerDown = $selected;
|
|
|
|
$order[] = [
|
|
|
|
'field' => 'id_modulo',
|
|
|
|
'order' => 'DESC',
|
|
|
|
];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'type':
|
|
|
|
switch ($sort) {
|
|
|
|
case 'up':
|
2022-11-24 10:00:42 +01:00
|
|
|
default:
|
2019-01-30 16:18:44 +01:00
|
|
|
$selectTypeUp = $selected;
|
|
|
|
$order[] = [
|
|
|
|
'field' => 'id_tipo_modulo',
|
|
|
|
'order' => 'ASC',
|
|
|
|
];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'down':
|
|
|
|
$selectTypeDown = $selected;
|
|
|
|
$order[] = [
|
|
|
|
'field' => 'id_tipo_modulo',
|
|
|
|
'order' => 'DESC',
|
|
|
|
];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'interval':
|
|
|
|
switch ($sort) {
|
|
|
|
case 'up':
|
2022-11-24 10:00:42 +01:00
|
|
|
default:
|
2019-01-30 16:18:44 +01:00
|
|
|
$selectIntervalUp = $selected;
|
|
|
|
$order[] = [
|
|
|
|
'field' => 'module_interval',
|
|
|
|
'order' => 'ASC',
|
|
|
|
];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'down':
|
|
|
|
$selectIntervalDown = $selected;
|
|
|
|
$order[] = [
|
|
|
|
'field' => 'module_interval',
|
|
|
|
'order' => 'DESC',
|
|
|
|
];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
$selectNameUp = $selected;
|
2019-04-05 13:18:38 +02:00
|
|
|
$selectNameDown = false;
|
|
|
|
$selectServerUp = false;
|
|
|
|
$selectServerDown = false;
|
|
|
|
$selectTypeUp = false;
|
|
|
|
$selectTypeDown = false;
|
|
|
|
$selectIntervalUp = false;
|
|
|
|
$selectIntervalDown = false;
|
2022-11-24 10:00:42 +01:00
|
|
|
$order[] = [
|
|
|
|
'field' => 'nombre',
|
|
|
|
'order' => 'ASC',
|
|
|
|
];
|
2019-01-30 16:18:44 +01:00
|
|
|
break;
|
2010-07-21 20:07:21 +02:00
|
|
|
}
|
|
|
|
|
2013-08-07 12:59:09 +02:00
|
|
|
|
2020-07-06 10:09:36 +02:00
|
|
|
// Build the order sql.
|
2022-11-24 10:00:42 +01:00
|
|
|
if (empty($order) === false) {
|
2019-01-30 16:18:44 +01:00
|
|
|
$order_sql = ' ORDER BY ';
|
2011-11-24 19:19:09 +01:00
|
|
|
}
|
2019-01-30 16:18:44 +01:00
|
|
|
|
2011-11-24 19:19:09 +01:00
|
|
|
$first = true;
|
2012-07-25 11:59:03 +02:00
|
|
|
foreach ($order as $ord) {
|
2021-03-22 17:39:24 +01:00
|
|
|
if ($first === true) {
|
2019-01-30 16:18:44 +01:00
|
|
|
$first = false;
|
|
|
|
} else {
|
|
|
|
$order_sql .= ',';
|
|
|
|
}
|
|
|
|
|
|
|
|
$order_sql .= $ord['field'].' '.$ord['order'];
|
2011-11-24 19:19:09 +01:00
|
|
|
}
|
|
|
|
|
2020-07-06 10:09:36 +02:00
|
|
|
// Get limit and offset parameters.
|
2019-01-30 16:18:44 +01:00
|
|
|
$limit = (int) $config['block_size'];
|
|
|
|
$offset = (int) get_parameter('offset');
|
|
|
|
|
2021-03-22 17:39:24 +01:00
|
|
|
if ((bool) $checked === true) {
|
|
|
|
$params = 'tagente_modulo.*, tmodule_group.*';
|
|
|
|
} else {
|
|
|
|
$params = implode(
|
|
|
|
',',
|
|
|
|
[
|
|
|
|
'tagente_modulo.id_agente_modulo',
|
|
|
|
'id_tipo_modulo',
|
|
|
|
'descripcion',
|
|
|
|
'nombre',
|
|
|
|
'max',
|
|
|
|
'min',
|
|
|
|
'module_interval',
|
|
|
|
'id_modulo',
|
|
|
|
'id_module_group',
|
|
|
|
'disabled',
|
|
|
|
'max_warning',
|
|
|
|
'min_warning',
|
|
|
|
'str_warning',
|
|
|
|
'max_critical',
|
|
|
|
'min_critical',
|
|
|
|
'str_critical',
|
|
|
|
'quiet',
|
|
|
|
'critical_inverse',
|
|
|
|
'warning_inverse',
|
2021-11-24 11:33:36 +01:00
|
|
|
'percentage_critical',
|
|
|
|
'percentage_warning',
|
2021-03-22 17:39:24 +01:00
|
|
|
'id_policy_module',
|
|
|
|
]
|
|
|
|
);
|
|
|
|
}
|
2019-01-30 16:18:44 +01:00
|
|
|
|
|
|
|
$where = sprintf('delete_pending = 0 AND id_agente = %s', $id_agente);
|
2012-05-14 16:24:29 +02:00
|
|
|
|
|
|
|
$search_string_entities = io_safe_input($search_string);
|
|
|
|
|
2020-07-06 10:09:36 +02:00
|
|
|
$basic_where = sprintf(
|
|
|
|
"(nombre LIKE '%%%s%%' OR nombre LIKE '%%%s%%' OR descripcion LIKE '%%%s%%' OR descripcion LIKE '%%%s%%') AND",
|
|
|
|
$search_string,
|
|
|
|
$search_string_entities,
|
|
|
|
$search_string,
|
|
|
|
$search_string_entities
|
|
|
|
);
|
2018-10-03 11:13:25 +02:00
|
|
|
|
2020-07-06 10:09:36 +02:00
|
|
|
// Tags acl.
|
2018-10-03 11:13:25 +02:00
|
|
|
$agent_tags = tags_get_user_applied_agent_tags($id_agente);
|
|
|
|
if ($agent_tags !== true) {
|
2019-01-30 16:18:44 +01:00
|
|
|
$where_tags = ' AND ttag_module.id_tag IN ('.implode(',', $agent_tags).')';
|
2018-10-03 11:13:25 +02:00
|
|
|
}
|
2013-01-10 17:00:30 +01:00
|
|
|
|
2014-05-27 10:57:20 +02:00
|
|
|
$paginate_module = false;
|
2022-11-24 10:00:42 +01:00
|
|
|
if (isset($config['paginate_module']) === true) {
|
|
|
|
$paginate_module = (bool) $config['paginate_module'];
|
2019-01-30 16:18:44 +01:00
|
|
|
}
|
2014-05-27 10:57:20 +02:00
|
|
|
|
2022-11-24 10:00:42 +01:00
|
|
|
if ($paginate_module === true) {
|
|
|
|
if (isset($limit_sql) === false) {
|
2021-03-22 17:39:24 +01:00
|
|
|
$limit_sql = sprintf(
|
|
|
|
'LIMIT %s, %s',
|
|
|
|
$offset,
|
|
|
|
$limit
|
|
|
|
);
|
2019-01-30 16:18:44 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$limit_sql = '';
|
2018-10-03 11:13:25 +02:00
|
|
|
}
|
2019-01-30 16:18:44 +01:00
|
|
|
|
|
|
|
$sql = sprintf(
|
|
|
|
'SELECT tagente_modulo.*, tmodule_group.*
|
2018-10-03 11:13:25 +02:00
|
|
|
FROM tagente_modulo
|
|
|
|
LEFT JOIN tmodule_group
|
|
|
|
ON tagente_modulo.id_module_group = tmodule_group.id_mg
|
|
|
|
LEFT JOIN ttag_module
|
|
|
|
ON ttag_module.id_agente_modulo = tagente_modulo.id_agente_modulo
|
|
|
|
WHERE %s %s %s
|
|
|
|
GROUP BY tagente_modulo.id_agente_modulo
|
2019-01-30 16:18:44 +01:00
|
|
|
%s %s',
|
|
|
|
$basic_where,
|
|
|
|
$where,
|
|
|
|
$where_tags,
|
|
|
|
$order_sql,
|
|
|
|
$limit_sql
|
2018-10-03 11:13:25 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
$modules = db_get_all_rows_sql($sql);
|
|
|
|
|
|
|
|
$sql_total_modules = sprintf(
|
2019-01-30 16:18:44 +01:00
|
|
|
'SELECT count(DISTINCT(tagente_modulo.id_agente_modulo))
|
2012-07-25 11:59:03 +02:00
|
|
|
FROM tagente_modulo
|
2018-10-03 11:13:25 +02:00
|
|
|
LEFT JOIN ttag_module
|
|
|
|
ON ttag_module.id_agente_modulo = tagente_modulo.id_agente_modulo
|
2019-01-30 16:18:44 +01:00
|
|
|
WHERE %s %s %s',
|
|
|
|
$basic_where,
|
|
|
|
$where,
|
|
|
|
$where_tags
|
2018-10-03 11:13:25 +02:00
|
|
|
);
|
2011-11-24 19:19:09 +01:00
|
|
|
|
|
|
|
$total_modules = db_get_value_sql($sql_total_modules);
|
|
|
|
|
2022-11-24 10:00:42 +01:00
|
|
|
$total_modules = (isset($total_modules) === true) ? $total_modules : 0;
|
2009-03-17 16:15:55 +01:00
|
|
|
|
2023-01-17 15:21:07 +01:00
|
|
|
if ($modules !== false) {
|
|
|
|
// Prepare pagination.
|
|
|
|
$url = sprintf(
|
|
|
|
'?sec=gagente&tab=module&sec2=godmode/agentes/configurar_agente&id_agente=%s&sort_field=%s&sort=%s&search_string=%s',
|
|
|
|
$id_agente,
|
|
|
|
$sortField,
|
|
|
|
$sort,
|
|
|
|
urlencode($search_string)
|
|
|
|
);
|
2017-01-18 17:33:28 +01:00
|
|
|
|
2023-01-17 15:21:07 +01:00
|
|
|
if ($paginate_module === true) {
|
|
|
|
ui_pagination($total_modules, $url);
|
|
|
|
}
|
2017-01-18 17:33:28 +01:00
|
|
|
|
2023-01-17 15:21:07 +01:00
|
|
|
$url_name = $url.'&sort_field=name&sort=';
|
|
|
|
$url_server = $url.'&sort_field=server&sort=';
|
|
|
|
$url_type = $url.'&sort_field=type&sort=';
|
|
|
|
$url_interval = $url.'&sort_field=interval&sort=';
|
|
|
|
|
|
|
|
$table = new stdClass();
|
|
|
|
$table->width = '100%';
|
|
|
|
$table->class = 'tactical_table info_table';
|
|
|
|
$table->head = [];
|
|
|
|
$table->head['checkbox'] = html_print_checkbox(
|
|
|
|
'all_delete',
|
|
|
|
0,
|
|
|
|
false,
|
|
|
|
true,
|
|
|
|
false
|
|
|
|
);
|
|
|
|
$table->head[0] = '<span>'.__('Name').'</span>'.ui_get_sorting_arrows(
|
|
|
|
$url_name.'up',
|
|
|
|
$url_name.'down',
|
|
|
|
$selectNameUp,
|
|
|
|
$selectNameDown
|
|
|
|
);
|
2017-01-18 17:33:28 +01:00
|
|
|
|
2023-01-17 15:21:07 +01:00
|
|
|
// The access to the policy is granted only with AW permission.
|
|
|
|
if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK && (bool) check_acl(
|
2020-07-06 10:09:36 +02:00
|
|
|
$config['id_user'],
|
2023-01-17 15:21:07 +01:00
|
|
|
$agent['id_grupo'],
|
2020-07-06 10:09:36 +02:00
|
|
|
'AW'
|
2023-01-17 15:21:07 +01:00
|
|
|
) === true
|
2020-07-06 10:09:36 +02:00
|
|
|
) {
|
2023-01-17 15:21:07 +01:00
|
|
|
$table->head[1] = "<span title='".__('Policy')."'>".__('P').'</span>';
|
|
|
|
$table->headstyle[1] = 'width: 4%';
|
2019-01-30 16:18:44 +01:00
|
|
|
}
|
|
|
|
|
2023-01-17 15:21:07 +01:00
|
|
|
$table->head[2] = '<span title=\''.__('Server').'\'>'.__('S').'</span>'.ui_get_sorting_arrows(
|
|
|
|
$url_server.'up',
|
|
|
|
$url_server.'down',
|
|
|
|
$selectServerUp,
|
|
|
|
$selectServerDown
|
|
|
|
);
|
|
|
|
$table->headstyle[2] = 'width: 8%';
|
|
|
|
$table->head[3] = '<span>'.__('Type').'</span>'.ui_get_sorting_arrows(
|
|
|
|
$url_type.'up',
|
|
|
|
$url_type.'down',
|
|
|
|
$selectTypeUp,
|
|
|
|
$selectTypeDown
|
|
|
|
);
|
|
|
|
$table->headstyle[3] = 'width: 10%';
|
|
|
|
$table->head[4] = '<span>'.__('Interval').'</span>'.ui_get_sorting_arrows(
|
|
|
|
$url_interval.'up',
|
|
|
|
$url_interval.'down',
|
|
|
|
$selectIntervalUp,
|
|
|
|
$selectIntervalDown
|
|
|
|
);
|
|
|
|
$table->headstyle[4] = 'width: 100px';
|
|
|
|
$table->head[5] = '<span>'.__('Description').'</span>';
|
|
|
|
$table->head[6] = '<span>'.__('Status').'</span>';
|
|
|
|
$table->head[7] = '<span>'.__('Warn').'</span>';
|
|
|
|
$table->head[8] = '<span>'.__('Action').'</span>';
|
|
|
|
$table->headstyle[8] = 'width: 15%';
|
|
|
|
|
|
|
|
$table->rowstyle = [];
|
|
|
|
$table->style = [];
|
|
|
|
$table->style[0] = 'font-weight: bold';
|
|
|
|
$table->size = [];
|
|
|
|
$table->size['checkbox'] = '20px';
|
|
|
|
$table->size[2] = '70px';
|
|
|
|
$table->align = [];
|
|
|
|
$table->align[2] = 'left';
|
|
|
|
$table->align[8] = 'left';
|
|
|
|
$table->align[9] = 'left';
|
|
|
|
$table->data = [];
|
|
|
|
|
|
|
|
$agent_interval = agents_get_interval($id_agente);
|
|
|
|
$last_modulegroup = '0';
|
|
|
|
|
|
|
|
// Extract the ids only numeric modules for after show the normalize link.
|
|
|
|
$tempRows = db_get_all_rows_sql(
|
|
|
|
"SELECT *
|
|
|
|
FROM ttipo_modulo
|
|
|
|
WHERE nombre NOT LIKE '%string%' AND nombre NOT LIKE '%proc%'"
|
|
|
|
);
|
|
|
|
$numericModules = [];
|
|
|
|
foreach ($tempRows as $row) {
|
|
|
|
$numericModules[$row['id_tipo']] = true;
|
2020-05-25 17:06:20 +02:00
|
|
|
}
|
|
|
|
|
2023-01-17 15:21:07 +01:00
|
|
|
if ($checked === true) {
|
|
|
|
$modules_hierachy = [];
|
|
|
|
$modules_hierachy = get_hierachy_modules_tree($modules);
|
2019-01-30 16:18:44 +01:00
|
|
|
|
2023-01-17 15:21:07 +01:00
|
|
|
$modules_dt = get_dt_from_modules_tree($modules_hierachy);
|
2019-01-30 16:18:44 +01:00
|
|
|
|
2023-01-17 15:21:07 +01:00
|
|
|
$modules = $modules_dt;
|
2019-04-05 13:18:38 +02:00
|
|
|
}
|
|
|
|
|
2023-01-17 15:21:07 +01:00
|
|
|
foreach ($modules as $module) {
|
|
|
|
if (! check_acl_one_of_groups(
|
|
|
|
$config['id_user'],
|
|
|
|
$all_groups,
|
|
|
|
'AW'
|
|
|
|
) && ! check_acl_one_of_groups(
|
|
|
|
$config['id_user'],
|
|
|
|
$all_groups,
|
|
|
|
'AD'
|
|
|
|
)
|
|
|
|
) {
|
|
|
|
continue;
|
|
|
|
}
|
2019-01-30 16:18:44 +01:00
|
|
|
|
2023-01-17 15:21:07 +01:00
|
|
|
$type = $module['id_tipo_modulo'];
|
|
|
|
$id_module = $module['id_modulo'];
|
|
|
|
$nombre_modulo = $module['nombre'];
|
|
|
|
$descripcion = $module['descripcion'];
|
|
|
|
$module_max = $module['max'];
|
|
|
|
$module_min = $module['min'];
|
|
|
|
$module_interval2 = $module['module_interval'];
|
|
|
|
$module_group2 = $module['id_module_group'];
|
|
|
|
|
|
|
|
if ((int) $module['id_modulo'] === MODULE_DATA && (int) $module['id_policy_module'] !== 0) {
|
|
|
|
$nombre_modulo = utf8_decode($module['nombre']);
|
|
|
|
}
|
2019-01-30 16:18:44 +01:00
|
|
|
|
2023-01-17 15:21:07 +01:00
|
|
|
$data = [];
|
|
|
|
|
|
|
|
if ($checked === false) {
|
|
|
|
if ($module['id_module_group'] != $last_modulegroup) {
|
|
|
|
$last_modulegroup = $module['id_module_group'];
|
|
|
|
$data[0] = '<strong>'.modules_get_modulegroup_name(
|
|
|
|
$last_modulegroup
|
|
|
|
).'</strong>';
|
|
|
|
$i = array_push($table->data, $data);
|
|
|
|
$table->rowstyle[($i - 1)] = 'text-align: center';
|
|
|
|
$table->rowclass[($i - 1)] = 'datos3';
|
|
|
|
if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) {
|
|
|
|
$table->colspan[($i - 1)][0] = 11;
|
|
|
|
} else {
|
|
|
|
$table->colspan[($i - 1)][0] = 10;
|
|
|
|
}
|
2019-01-30 16:18:44 +01:00
|
|
|
|
2023-01-17 15:21:07 +01:00
|
|
|
$data = [];
|
|
|
|
}
|
|
|
|
}
|
2019-01-30 16:18:44 +01:00
|
|
|
|
2023-01-17 15:21:07 +01:00
|
|
|
if (check_acl_one_of_groups($config['id_user'], $all_groups, 'AW') === true) {
|
|
|
|
$data['checkbox'] = html_print_checkbox(
|
|
|
|
'id_delete[]',
|
|
|
|
$module['id_agente_modulo'],
|
|
|
|
false,
|
|
|
|
true,
|
|
|
|
false,
|
|
|
|
'',
|
|
|
|
true
|
|
|
|
);
|
|
|
|
}
|
2022-08-31 16:14:38 +02:00
|
|
|
|
2023-01-17 15:21:07 +01:00
|
|
|
$data[0] = '';
|
2022-08-31 16:14:38 +02:00
|
|
|
|
2023-01-17 15:21:07 +01:00
|
|
|
if (isset($module['deep']) === true && ((int) $module['deep'] !== 0)) {
|
|
|
|
$data[0] .= str_repeat(' ', $module['deep']);
|
|
|
|
$data[0] .= html_print_image(
|
|
|
|
'images/icono_escuadra.png',
|
2022-08-31 16:14:38 +02:00
|
|
|
true,
|
2023-01-17 15:21:07 +01:00
|
|
|
[
|
|
|
|
'style' => 'padding-bottom: inherit;',
|
|
|
|
'class' => 'invert_filter',
|
|
|
|
]
|
|
|
|
).' ';
|
2022-08-31 16:14:38 +02:00
|
|
|
}
|
|
|
|
|
2023-01-17 15:21:07 +01:00
|
|
|
if ((bool) $module['quiet'] === true) {
|
|
|
|
$data[0] .= html_print_image(
|
|
|
|
'images/dot_blue.png',
|
|
|
|
true,
|
|
|
|
[
|
|
|
|
'border' => '0',
|
|
|
|
'title' => __('Quiet'),
|
|
|
|
'alt' => '',
|
|
|
|
]
|
|
|
|
).' ';
|
|
|
|
}
|
2019-01-30 16:18:44 +01:00
|
|
|
|
2023-01-17 15:21:07 +01:00
|
|
|
if (check_acl_one_of_groups($config['id_user'], $all_groups, 'AW') === true) {
|
|
|
|
$data[0] .= '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.'&tab=module&edit_module=1&id_agent_module='.$module['id_agente_modulo'].'">';
|
|
|
|
}
|
2019-01-30 16:18:44 +01:00
|
|
|
|
2023-01-17 15:21:07 +01:00
|
|
|
if ((bool) $module['disabled'] === true) {
|
|
|
|
$dt_disabled_icon = '';
|
|
|
|
|
|
|
|
$in_planned_downtime = db_get_sql(
|
|
|
|
'SELECT executed FROM tplanned_downtime
|
|
|
|
INNER JOIN tplanned_downtime_modules ON tplanned_downtime.id = tplanned_downtime_modules.id_downtime
|
|
|
|
WHERE tplanned_downtime.executed = 1
|
|
|
|
AND tplanned_downtime.type_downtime = "disable_agent_modules"
|
|
|
|
AND tplanned_downtime_modules.id_agent_module = '.$module['id_agente_modulo']
|
|
|
|
);
|
|
|
|
|
|
|
|
if ($in_planned_downtime !== false) {
|
|
|
|
$dt_disabled_icon = ui_print_help_tip(
|
|
|
|
__('Module in scheduled downtime'),
|
|
|
|
true,
|
|
|
|
'images/minireloj-16.png'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$data[0] .= '<em class="disabled_module">'.ui_print_truncate_text(
|
|
|
|
$module['nombre'],
|
|
|
|
'module_medium',
|
|
|
|
false,
|
|
|
|
true,
|
|
|
|
true,
|
|
|
|
'[…]',
|
|
|
|
''
|
|
|
|
).$dt_disabled_icon.'</em>';
|
2019-01-30 16:18:44 +01:00
|
|
|
} else {
|
2023-01-17 15:21:07 +01:00
|
|
|
$data[0] .= ui_print_truncate_text(
|
|
|
|
$module['nombre'],
|
|
|
|
'module_medium',
|
|
|
|
false,
|
|
|
|
true,
|
|
|
|
true,
|
|
|
|
'[…]',
|
|
|
|
''
|
|
|
|
);
|
|
|
|
}
|
2019-01-30 16:18:44 +01:00
|
|
|
|
2023-01-17 15:21:07 +01:00
|
|
|
if (check_acl_one_of_groups($config['id_user'], $all_groups, 'AW') === true) {
|
|
|
|
$data[0] .= '</a>';
|
|
|
|
}
|
|
|
|
|
|
|
|
// The access to the policy is granted only with AW permission.
|
|
|
|
if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK && (bool) check_acl(
|
|
|
|
$config['id_user'],
|
|
|
|
$agent['id_grupo'],
|
|
|
|
'AW'
|
|
|
|
) === true
|
|
|
|
) {
|
|
|
|
$policyInfo = policies_info_module_policy($module['id_agente_modulo']);
|
|
|
|
if ($policyInfo === false) {
|
|
|
|
$data[1] = '';
|
2019-01-30 16:18:44 +01:00
|
|
|
} else {
|
2023-01-17 15:21:07 +01:00
|
|
|
$linked = policies_is_module_linked($module['id_agente_modulo']);
|
|
|
|
$adopt = policies_is_module_adopt($module['id_agente_modulo']);
|
|
|
|
|
|
|
|
if ($linked !== false) {
|
|
|
|
if ($adopt === true) {
|
|
|
|
$img = 'images/policies_brick.png';
|
|
|
|
$title = '('.__('Adopted').') '.$policyInfo['name_policy'];
|
|
|
|
} else {
|
|
|
|
$img = 'images/policies_mc.png';
|
|
|
|
$title = $policyInfo['name_policy'];
|
|
|
|
}
|
2019-01-30 16:18:44 +01:00
|
|
|
} else {
|
2023-01-17 15:21:07 +01:00
|
|
|
if ($adopt === true) {
|
|
|
|
$img = 'images/policies_not_brick.png';
|
|
|
|
$title = '('.__('Unlinked').') ('.__('Adopted').') '.$policyInfo['name_policy'];
|
|
|
|
} else {
|
|
|
|
$img = 'images/unlinkpolicy.png';
|
|
|
|
$title = '('.__('Unlinked').') '.$policyInfo['name_policy'];
|
|
|
|
}
|
2019-01-30 16:18:44 +01:00
|
|
|
}
|
2023-01-17 15:21:07 +01:00
|
|
|
|
|
|
|
$data[1] = '<a href="?sec=gmodules&sec2=enterprise/godmode/policies/policies&id='.$policyInfo['id_policy'].'">'.html_print_image($img, true, ['title' => $title]).'</a>';
|
2019-01-30 16:18:44 +01:00
|
|
|
}
|
2023-01-17 15:21:07 +01:00
|
|
|
}
|
2019-01-30 16:18:44 +01:00
|
|
|
|
2023-01-17 15:21:07 +01:00
|
|
|
// Module type (by server type ).
|
|
|
|
$data[2] = '';
|
|
|
|
if ($module['id_modulo'] > 0) {
|
|
|
|
$data[2] = ui_print_servertype_icon((int) $module['id_modulo']);
|
2019-01-30 16:18:44 +01:00
|
|
|
}
|
|
|
|
|
2023-01-17 15:21:07 +01:00
|
|
|
$module_status = db_get_row(
|
|
|
|
'tagente_estado',
|
|
|
|
'id_agente_modulo',
|
|
|
|
$module['id_agente_modulo']
|
|
|
|
);
|
2019-01-30 16:18:44 +01:00
|
|
|
|
2023-01-17 15:21:07 +01:00
|
|
|
modules_get_status(
|
|
|
|
$module['id_agente_modulo'],
|
|
|
|
$module_status['estado'],
|
|
|
|
$module_status['datos'],
|
|
|
|
$status,
|
|
|
|
$title
|
|
|
|
);
|
2020-07-06 10:09:36 +02:00
|
|
|
|
2023-01-17 15:21:07 +01:00
|
|
|
// This module is initialized ? (has real data).
|
|
|
|
if ($status === STATUS_MODULE_NO_DATA) {
|
|
|
|
$data[2] .= html_print_image(
|
|
|
|
'images/alert-yellow@svg.svg',
|
|
|
|
true,
|
|
|
|
[
|
|
|
|
'title' => __('Non initialized module'),
|
|
|
|
'class' => 'main_menu_icon',
|
|
|
|
]
|
|
|
|
);
|
|
|
|
}
|
2020-07-06 10:09:36 +02:00
|
|
|
|
2023-01-17 15:21:07 +01:00
|
|
|
// Module type (by data type).
|
|
|
|
$data[3] = '';
|
|
|
|
if ($type) {
|
|
|
|
$data[3] = ui_print_moduletype_icon($type, true);
|
|
|
|
}
|
2019-01-30 16:18:44 +01:00
|
|
|
|
2023-01-17 15:21:07 +01:00
|
|
|
// Module interval.
|
|
|
|
if ($module['module_interval']) {
|
|
|
|
$data[4] = human_time_description_raw($module['module_interval']);
|
|
|
|
} else {
|
|
|
|
$data[4] = human_time_description_raw($agent_interval);
|
|
|
|
}
|
2019-01-30 16:18:44 +01:00
|
|
|
|
2023-01-17 15:21:07 +01:00
|
|
|
if ((int) $module['id_modulo'] === MODULE_DATA && (int) $module['id_policy_module'] !== 0) {
|
|
|
|
$data[4] .= ui_print_help_tip(
|
|
|
|
__('The policy modules of data type will only update their intervals when policy is applied.'),
|
|
|
|
true
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$data[5] = ui_print_truncate_text(
|
|
|
|
$module['descripcion'],
|
|
|
|
'description',
|
|
|
|
false
|
|
|
|
);
|
2019-01-30 16:18:44 +01:00
|
|
|
|
2023-01-17 15:21:07 +01:00
|
|
|
$data[6] = ui_print_status_image(
|
|
|
|
$status,
|
|
|
|
htmlspecialchars($title),
|
2020-07-06 10:09:36 +02:00
|
|
|
true
|
|
|
|
);
|
2019-01-30 16:18:44 +01:00
|
|
|
|
2023-01-17 15:21:07 +01:00
|
|
|
// MAX / MIN values.
|
|
|
|
if ($module['id_tipo_modulo'] != 25) {
|
|
|
|
$data[7] = ui_print_module_warn_value(
|
|
|
|
$module['max_warning'],
|
|
|
|
$module['min_warning'],
|
|
|
|
$module['str_warning'],
|
|
|
|
$module['max_critical'],
|
|
|
|
$module['min_critical'],
|
|
|
|
$module['str_critical'],
|
|
|
|
$module['warning_inverse'],
|
|
|
|
$module['critical_inverse']
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
$data[7] = '';
|
|
|
|
}
|
2019-01-30 16:18:44 +01:00
|
|
|
|
2023-01-17 15:21:07 +01:00
|
|
|
if ((bool) $module['disabled'] === true) {
|
|
|
|
$data[8] = html_print_menu_button(
|
|
|
|
[
|
|
|
|
'href' => 'index.php?sec=gagente&tab=module&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.'&enable_module='.$module['id_agente_modulo'],
|
|
|
|
'image' => 'images/change-active.svg',
|
|
|
|
'title' => __('Enable module'),
|
|
|
|
],
|
|
|
|
true
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
$data[8] = html_print_menu_button(
|
|
|
|
[
|
|
|
|
'href' => 'index.php?sec=gagente&tab=module&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.'&disable_module='.$module['id_agente_modulo'],
|
|
|
|
'image' => 'images/change-pause.svg',
|
|
|
|
'title' => __('Disable module'),
|
|
|
|
],
|
|
|
|
true
|
|
|
|
);
|
|
|
|
}
|
2019-01-30 16:18:44 +01:00
|
|
|
|
2023-01-17 15:21:07 +01:00
|
|
|
if (check_acl_one_of_groups($config['id_user'], $all_groups, 'AW') === true && $module['id_tipo_modulo'] !== 25) {
|
|
|
|
$data[8] .= html_print_menu_button(
|
|
|
|
[
|
|
|
|
'href' => 'index.php?sec=gagente&tab=module&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.'&duplicate_module='.$module['id_agente_modulo'],
|
|
|
|
'onClick' => "if (!confirm(\' '.__('Are you sure?').'\')) return false;",
|
|
|
|
'image' => 'images/copy.svg',
|
|
|
|
'title' => __('Duplicate'),
|
|
|
|
],
|
|
|
|
true
|
|
|
|
);
|
2019-01-30 16:18:44 +01:00
|
|
|
|
2023-01-17 15:21:07 +01:00
|
|
|
// Make a data normalization.
|
|
|
|
$data[8] .= html_print_menu_button(
|
|
|
|
[
|
|
|
|
'href' => 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.'&tab=module&fix_module='.$module['id_agente_modulo'],
|
|
|
|
'onClick' => "if (!confirm(\' '.__('Are you sure?').'\')) return false;",
|
|
|
|
'image' => 'images/module-graph.svg',
|
|
|
|
'title' => __('Normalize'),
|
|
|
|
'disabled' => (isset($numericModules[$type]) === false || $numericModules[$type] === false),
|
|
|
|
'disabled_title' => ' ('.__('Disabled').')',
|
|
|
|
],
|
|
|
|
true
|
|
|
|
);
|
2019-01-30 16:18:44 +01:00
|
|
|
|
2023-01-17 15:21:07 +01:00
|
|
|
// Create network component action.
|
|
|
|
$data[8] .= html_print_menu_button(
|
|
|
|
[
|
|
|
|
'href' => 'index.php?sec=gmodules&sec2=godmode/modules/manage_network_components&create_network_from_module=1&id_agente='.$id_agente.'&create_module_from='.$module['id_agente_modulo'],
|
|
|
|
'onClick' => "if (!confirm(\' '.__('Are you sure?').'\')) return false;",
|
2023-02-21 14:14:13 +01:00
|
|
|
'image' => 'images/cluster@os.svg',
|
2023-01-17 15:21:07 +01:00
|
|
|
'title' => __('Create network component'),
|
|
|
|
'disabled' => ((is_user_admin($config['id_user']) === true) && (int) $module['id_modulo'] === MODULE_NETWORK) === false,
|
|
|
|
'disabled_title' => ' ('.__('Disabled').')',
|
|
|
|
],
|
|
|
|
true
|
|
|
|
);
|
|
|
|
}
|
2019-01-30 16:18:44 +01:00
|
|
|
|
2023-01-17 15:21:07 +01:00
|
|
|
if (check_acl_one_of_groups($config['id_user'], $all_groups, 'AW') === true) {
|
|
|
|
// Delete module.
|
|
|
|
$data[8] .= html_print_menu_button(
|
|
|
|
[
|
|
|
|
'href' => 'index.php?sec=gagente&tab=module&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.'&delete_module='.$module['id_agente_modulo'],
|
|
|
|
'onClick' => "if (!confirm(\' '.__('Are you sure?').'\')) return false;",
|
|
|
|
'image' => 'images/delete.svg',
|
|
|
|
'title' => __('Delete'),
|
|
|
|
],
|
|
|
|
true
|
|
|
|
);
|
|
|
|
}
|
2019-01-30 16:18:44 +01:00
|
|
|
|
2023-01-17 15:21:07 +01:00
|
|
|
// TODO. REVIEW THIS ANNOYING BEHAVIOR.
|
|
|
|
$table->cellclass[] = [8 => 'table_action_buttons'];
|
|
|
|
array_push($table->data, $data);
|
|
|
|
$table->cellclass[] = [8 => 'table_action_buttons'];
|
2019-01-30 16:18:44 +01:00
|
|
|
}
|
|
|
|
|
2022-12-15 12:42:35 +01:00
|
|
|
if (check_acl_one_of_groups($config['id_user'], $all_groups, 'AW') === true) {
|
2023-02-24 12:05:53 +01:00
|
|
|
echo '<form method="post" action="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.'&tab=module"
|
2023-01-17 15:21:07 +01:00
|
|
|
onsubmit="if (! confirm (\''.__('Are you sure?').'\')) return false">';
|
2019-01-30 16:18:44 +01:00
|
|
|
}
|
|
|
|
|
2023-01-17 15:21:07 +01:00
|
|
|
// Print module table.
|
|
|
|
html_print_table($table);
|
|
|
|
} else {
|
|
|
|
ui_print_empty_data(__('No available data to show'));
|
2013-01-14 16:11:07 +01:00
|
|
|
}
|
2013-02-05 10:13:41 +01:00
|
|
|
|
2022-10-25 13:13:52 +02:00
|
|
|
if ((bool) check_acl_one_of_groups($config['id_user'], $all_groups, 'AW') === true) {
|
2021-03-02 10:42:08 +01:00
|
|
|
html_print_input_hidden('submit_modules_action', 1);
|
|
|
|
|
2022-11-23 17:42:53 +01:00
|
|
|
$actionButtons = html_print_button(
|
|
|
|
__('Create module'),
|
|
|
|
'create_module',
|
|
|
|
false,
|
|
|
|
'create_module_dialog()',
|
|
|
|
[ 'icon' => 'wand' ],
|
|
|
|
true
|
|
|
|
);
|
|
|
|
|
2023-01-17 15:21:07 +01:00
|
|
|
if ($modules !== false) {
|
|
|
|
$actionButtons .= html_print_submit_button(
|
|
|
|
__('Execute action'),
|
|
|
|
'submit_modules_action',
|
|
|
|
false,
|
|
|
|
[
|
|
|
|
'icon' => 'next',
|
|
|
|
'mode' => 'link',
|
|
|
|
],
|
|
|
|
true
|
|
|
|
);
|
2022-11-23 17:42:53 +01:00
|
|
|
|
2023-01-17 15:21:07 +01:00
|
|
|
$actionButtons .= html_print_select(
|
|
|
|
[
|
|
|
|
'disable' => 'Disable selected modules',
|
|
|
|
'enable' => 'Enable selected modules',
|
|
|
|
'delete' => 'Delete selected modules',
|
|
|
|
],
|
|
|
|
'module_action',
|
|
|
|
'',
|
|
|
|
'',
|
|
|
|
'',
|
|
|
|
0,
|
|
|
|
true,
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
'',
|
|
|
|
false,
|
|
|
|
'width: 260px;',
|
|
|
|
);
|
|
|
|
}
|
2022-11-23 17:42:53 +01:00
|
|
|
|
|
|
|
html_print_action_buttons(
|
|
|
|
$actionButtons,
|
|
|
|
[ 'type' => 'data_table' ]
|
|
|
|
);
|
|
|
|
echo '</form>';
|
|
|
|
|
|
|
|
|
|
|
|
$modalCreateModule = '<form name="create_module_form" method="post">';
|
|
|
|
$modalCreateModule .= html_print_table($tableCreateModule, true);
|
|
|
|
$modalCreateModule .= html_print_div(
|
2021-03-02 10:42:08 +01:00
|
|
|
[
|
2022-10-25 13:13:52 +02:00
|
|
|
'class' => 'action-buttons',
|
|
|
|
'content' => html_print_submit_button(
|
2022-11-30 10:14:42 +01:00
|
|
|
__('Create'),
|
|
|
|
'create_module',
|
2022-10-25 13:13:52 +02:00
|
|
|
false,
|
|
|
|
[
|
2022-11-30 10:14:42 +01:00
|
|
|
'icon' => 'next',
|
|
|
|
'mode' => 'mini secondary',
|
2022-10-25 13:13:52 +02:00
|
|
|
],
|
|
|
|
true
|
|
|
|
),
|
2022-11-23 17:42:53 +01:00
|
|
|
],
|
|
|
|
true
|
2021-03-02 10:42:08 +01:00
|
|
|
);
|
2022-11-23 17:42:53 +01:00
|
|
|
$modalCreateModule .= '</form>';
|
2021-03-02 10:42:08 +01:00
|
|
|
|
2022-11-23 17:42:53 +01:00
|
|
|
html_print_div(
|
|
|
|
[
|
|
|
|
'id' => 'modal',
|
|
|
|
'style' => 'display: none',
|
|
|
|
'content' => $modalCreateModule,
|
|
|
|
]
|
|
|
|
);
|
2013-01-14 16:11:07 +01:00
|
|
|
}
|
2012-11-14 19:54:27 +01:00
|
|
|
?>
|
2017-01-18 17:33:28 +01:00
|
|
|
|
|
|
|
<script type="text/javascript">
|
2017-02-27 14:28:09 +01:00
|
|
|
|
2022-11-23 17:42:53 +01:00
|
|
|
function create_module_dialog(){
|
|
|
|
$('#modal')
|
|
|
|
.dialog({
|
|
|
|
title: '<?php echo __('Create Module'); ?>',
|
|
|
|
resizable: true,
|
|
|
|
draggable: true,
|
|
|
|
modal: true,
|
|
|
|
close: false,
|
2022-12-15 12:42:35 +01:00
|
|
|
height: 222,
|
2022-11-23 17:42:53 +01:00
|
|
|
width: 480,
|
|
|
|
overlay: {
|
|
|
|
opacity: 0.5,
|
|
|
|
background: "black"
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.show();
|
|
|
|
}
|
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
$(document).ready (function () {
|
2022-11-23 17:42:53 +01:00
|
|
|
$('#button-create_module_dialog').click(function(){
|
|
|
|
$('#modal').dialog("close");
|
|
|
|
});
|
2022-10-25 13:13:52 +02:00
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
$('[id^=checkbox-id_delete]').change(function(){
|
|
|
|
if($(this).parent().parent().hasClass('checkselected')){
|
|
|
|
$(this).parent().parent().removeClass('checkselected');
|
|
|
|
}
|
|
|
|
else{
|
2022-11-23 17:42:53 +01:00
|
|
|
$(this).parent().parent().addClass('checkselected');
|
2019-01-30 16:18:44 +01:00
|
|
|
}
|
2022-11-23 17:42:53 +01:00
|
|
|
});
|
2019-01-30 16:18:44 +01:00
|
|
|
|
|
|
|
|
2022-11-23 17:42:53 +01:00
|
|
|
$('[id^=checkbox-all_delete]').change(function(){
|
2019-01-30 16:18:44 +01:00
|
|
|
if ($("#checkbox-all_delete").prop("checked")) {
|
|
|
|
$('[id^=checkbox-id_delete]').parent().parent().addClass('checkselected');
|
|
|
|
$("[name^=id_delete").prop("checked", true);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
$('[id^=checkbox-id_delete]').parent().parent().removeClass('checkselected');
|
|
|
|
$("[name^=id_delete").prop("checked", false);
|
2022-11-23 17:42:53 +01:00
|
|
|
}
|
2019-01-30 16:18:44 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
function change_mod_filter() {
|
|
|
|
var checked = $("#checkbox-status_hierachy_mode").is(":checked");
|
|
|
|
|
|
|
|
if (/checked/.test(window.location)) {
|
|
|
|
var url = window.location.toString();
|
|
|
|
if (checked) {
|
|
|
|
window.location = url.replace("checked=false", "checked=true");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
window.location = url.replace("checked=true", "checked=false");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
window.location = window.location + "&checked=true";
|
|
|
|
}
|
|
|
|
}
|
2023-01-19 10:34:13 +01:00
|
|
|
|
2023-01-24 12:26:49 +01:00
|
|
|
function get_children_modules(multiple, id_module, url) {
|
|
|
|
var selected_modules = [];
|
|
|
|
|
|
|
|
if(typeof(id_module) === 'undefined' && multiple === true) {
|
|
|
|
$("input[id^='checkbox-id_delete']:checked").each(function () {
|
|
|
|
selected_modules.push(this.value);
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
selected_modules = [id_module];
|
|
|
|
}
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
type: "POST",
|
|
|
|
url: "ajax.php",
|
|
|
|
dataType: "json",
|
|
|
|
data: {
|
|
|
|
page: 'include/ajax/module',
|
|
|
|
get_children_modules: true,
|
|
|
|
parent_modulues: JSON.parse(JSON.stringify(selected_modules)),
|
|
|
|
},
|
|
|
|
success: function (data) {
|
|
|
|
delete_module_warning(data, multiple, id_module, url);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function delete_module_warning(children, multiple, id_module, url) {
|
2023-01-19 10:34:13 +01:00
|
|
|
var message = '<?php echo __('Are you sure?'); ?>';
|
|
|
|
var ret = false;
|
|
|
|
|
|
|
|
if(children != false) {
|
2023-01-24 12:26:49 +01:00
|
|
|
message += '<br><strong>' + '<?php echo __('This module has children modules.The following modules will also be deleted: '); ?>' + '</strong><ul>';
|
2023-01-19 10:34:13 +01:00
|
|
|
$.each(children, function (key, value) {
|
|
|
|
message += '<li>' + value['nombre'] + '</li>';
|
|
|
|
});
|
|
|
|
message += '</ul>';
|
2023-01-24 12:26:49 +01:00
|
|
|
}
|
2023-01-19 10:34:13 +01:00
|
|
|
|
2023-01-24 12:26:49 +01:00
|
|
|
confirmDialog({
|
2023-01-19 10:34:13 +01:00
|
|
|
title: "<?php echo __('Delete module'); ?>",
|
|
|
|
message: message,
|
|
|
|
onAccept: function() {
|
2023-01-24 12:26:49 +01:00
|
|
|
if(multiple === true) {
|
|
|
|
$("#form_multiple_delete").submit();
|
|
|
|
return true;
|
|
|
|
} else {
|
2023-01-19 10:34:13 +01:00
|
|
|
window.location.href = url;
|
|
|
|
}
|
2023-01-24 12:26:49 +01:00
|
|
|
}
|
2023-01-19 10:34:13 +01:00
|
|
|
});
|
|
|
|
|
2023-01-24 12:26:49 +01:00
|
|
|
return true;
|
2023-01-19 10:34:13 +01:00
|
|
|
|
|
|
|
|
|
|
|
}
|
2017-01-18 17:33:28 +01:00
|
|
|
</script>
|