2010-09-29 12:28:10 +02:00
|
|
|
<?php
|
2021-02-12 11:28:13 +01:00
|
|
|
/**
|
|
|
|
* View for edit agents in Massive Operations
|
|
|
|
*
|
|
|
|
* @category Configuration
|
|
|
|
* @package Pandora FMS
|
|
|
|
* @subpackage Massive Operations
|
|
|
|
* @version 1.0.0
|
|
|
|
* @license See below
|
|
|
|
*
|
|
|
|
* ______ ___ _______ _______ ________
|
|
|
|
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
|
|
|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
|
|
|
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
|
|
|
*
|
|
|
|
* ============================================================================
|
2022-02-03 12:56:36 +01:00
|
|
|
* Copyright (c) 2005-2022 Artica Soluciones Tecnologicas
|
2021-02-12 11:28:13 +01:00
|
|
|
* 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.
|
|
|
|
* ============================================================================
|
|
|
|
*/
|
|
|
|
|
2022-07-14 16:06:51 +02:00
|
|
|
use PandoraFMS\Agent;
|
|
|
|
use PandoraFMS\Enterprise\Metaconsole\Node;
|
|
|
|
|
2021-02-12 11:28:13 +01:00
|
|
|
// Begin.
|
2019-01-30 16:18:44 +01:00
|
|
|
check_login();
|
|
|
|
|
|
|
|
if (! check_acl($config['id_user'], 0, '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 access massive agent deletion section'
|
|
|
|
);
|
|
|
|
include 'general/noaccess.php';
|
|
|
|
return;
|
2010-09-29 12:28:10 +02:00
|
|
|
}
|
|
|
|
|
2022-01-24 12:19:09 +01:00
|
|
|
require_once $config['homedir'].'/include/functions_agents.php';
|
|
|
|
require_once $config['homedir'].'/include/functions_ui.php';
|
|
|
|
require_once $config['homedir'].'/include/functions_alerts.php';
|
|
|
|
require_once $config['homedir'].'/include/functions_modules.php';
|
|
|
|
require_once $config['homedir'].'/include/functions_servers.php';
|
|
|
|
require_once $config['homedir'].'/include/functions_gis.php';
|
|
|
|
require_once $config['homedir'].'/include/functions_users.php';
|
2018-09-24 17:32:58 +02:00
|
|
|
enterprise_include_once('include/functions_config_agents.php');
|
2010-09-29 12:28:10 +02:00
|
|
|
|
2022-03-10 20:06:45 +01:00
|
|
|
if (is_ajax() === true) {
|
2022-07-14 16:06:51 +02:00
|
|
|
$get_n_conf_files = (bool) get_parameter(
|
|
|
|
'get_n_conf_files',
|
|
|
|
false
|
|
|
|
);
|
|
|
|
|
|
|
|
$groups_secondary_selected = (bool) get_parameter(
|
|
|
|
'groups_secondary_selected',
|
|
|
|
false
|
|
|
|
);
|
2022-03-10 20:06:45 +01:00
|
|
|
|
|
|
|
if ($get_n_conf_files === true) {
|
2019-01-30 16:18:44 +01:00
|
|
|
$id_agents = get_parameter('id_agents');
|
|
|
|
$cont = 0;
|
|
|
|
foreach ($id_agents as $id_agent) {
|
2022-07-14 16:06:51 +02:00
|
|
|
if (is_metaconsole() === true) {
|
|
|
|
$array_id = explode('|', $id_agent);
|
|
|
|
try {
|
|
|
|
$node = new Node((int) $array_id[0]);
|
|
|
|
$node->connect();
|
|
|
|
|
|
|
|
$agent = new Agent((int) $array_id[1]);
|
|
|
|
if ($agent->hasRemoteConf() === true) {
|
|
|
|
$cont++;
|
|
|
|
}
|
|
|
|
|
|
|
|
$node->disconnect();
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
// Unexistent agent.
|
|
|
|
$cont = 0;
|
|
|
|
$node->disconnect();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
try {
|
|
|
|
$agent = new Agent((int) $array_id[1]);
|
|
|
|
if ($agent->hasRemoteConf() === true) {
|
|
|
|
$cont++;
|
|
|
|
}
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
// Unexistent agent.
|
|
|
|
$cont = 0;
|
|
|
|
}
|
2019-01-30 16:18:44 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
echo $cont;
|
|
|
|
return;
|
|
|
|
}
|
2022-03-10 20:06:45 +01:00
|
|
|
|
|
|
|
if ($groups_secondary_selected === true) {
|
|
|
|
$groups = get_parameter('groups', []);
|
|
|
|
$groups_selected = get_parameter('groups_selected', []);
|
|
|
|
|
|
|
|
$user_groups = users_get_groups($config['user'], 'AR', false);
|
|
|
|
$ret = [];
|
|
|
|
foreach ($user_groups as $id_gr => $name_group) {
|
|
|
|
if (in_array($id_gr, $groups) === false) {
|
|
|
|
$ret[$id_gr] = $name_group;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
echo json_encode($ret);
|
|
|
|
return;
|
|
|
|
}
|
2010-09-29 12:28:10 +02:00
|
|
|
}
|
|
|
|
|
2014-03-25 13:39:26 +01:00
|
|
|
$update_agents = get_parameter('update_agents', 0);
|
|
|
|
$recursion = get_parameter('recursion');
|
2010-09-29 12:28:10 +02:00
|
|
|
|
|
|
|
if ($update_agents) {
|
2019-01-30 16:18:44 +01:00
|
|
|
$values = [];
|
2022-07-14 16:06:51 +02:00
|
|
|
|
|
|
|
if ((int) get_parameter('group', '') !== -1) {
|
2019-01-30 16:18:44 +01:00
|
|
|
$values['id_grupo'] = get_parameter('group');
|
|
|
|
}
|
|
|
|
|
2022-07-14 16:06:51 +02:00
|
|
|
if (!(get_parameter('interval_select') === -1
|
|
|
|
&& empty(get_parameter('interval_text')))
|
|
|
|
) {
|
|
|
|
if (get_parameter('interval') != -2) {
|
2019-10-10 13:37:01 +02:00
|
|
|
$values['intervalo'] = get_parameter('interval');
|
|
|
|
}
|
2019-01-30 16:18:44 +01:00
|
|
|
}
|
2018-09-24 17:32:58 +02:00
|
|
|
|
2019-02-12 14:52:18 +01:00
|
|
|
if (get_parameter('id_os', '') != -1) {
|
|
|
|
$values['id_os'] = get_parameter('id_os');
|
|
|
|
}
|
2018-09-24 17:32:58 +02:00
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
if (get_parameter('id_parent', '') != '') {
|
|
|
|
$values['id_parent'] = get_parameter('id_agent_parent', 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (get_parameter('server_name', '') != -1) {
|
|
|
|
$values['server_name'] = get_parameter('server_name');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (get_parameter('description', '') != '') {
|
|
|
|
$values['comentarios'] = get_parameter('description');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (get_parameter('mode', '') != -1) {
|
|
|
|
$values['modo'] = get_parameter('mode');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (get_parameter('disabled', '') != -1) {
|
|
|
|
$values['disabled'] = get_parameter('disabled');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (get_parameter('icon_path', '') != '') {
|
|
|
|
$values['icon_path'] = get_parameter('icon_path');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (get_parameter('update_gis_data', -1) != -1) {
|
|
|
|
$values['update_gis_data'] = get_parameter('update_gis_data');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (get_parameter('custom_id', '') != '') {
|
|
|
|
$values['custom_id'] = get_parameter('custom_id');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (get_parameter('cascade_protection', -1) != -1) {
|
|
|
|
$values['cascade_protection'] = get_parameter('cascade_protection');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (get_parameter('cascade_protection_module', -1) != -1) {
|
|
|
|
$values['cascade_protection_module'] = get_parameter('cascade_protection_module');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (get_parameter('delete_conf', 0) != 0) {
|
|
|
|
$values['delete_conf'] = get_parameter('delete_conf');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (get_parameter('quiet_select', -1) != -1) {
|
|
|
|
$values['quiet'] = get_parameter('quiet_select');
|
|
|
|
}
|
|
|
|
|
2019-11-26 16:44:53 +01:00
|
|
|
if (get_parameter('safe_mode_change', -1) == 1 && get_parameter('safe_mode_module', '') != '') {
|
|
|
|
// Get the module name.
|
|
|
|
$values['safe_mode_module'] = get_parameter('safe_mode_module');
|
|
|
|
} else if (get_parameter('safe_mode_change', -1) == 0) {
|
|
|
|
// Disabled Safe Operation Mode.
|
|
|
|
$values['safe_mode_module'] = '0';
|
|
|
|
}
|
|
|
|
|
2022-07-14 16:06:51 +02:00
|
|
|
$secondary_groups_added = (array) get_parameter(
|
|
|
|
'secondary_groups_added',
|
|
|
|
[]
|
|
|
|
);
|
|
|
|
$secondary_groups_removed = (array) get_parameter(
|
|
|
|
'secondary_groups_removed',
|
|
|
|
[]
|
|
|
|
);
|
2022-02-03 12:56:36 +01:00
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
$fields = db_get_all_fields_in_table('tagent_custom_fields');
|
|
|
|
|
|
|
|
if ($fields === false) {
|
|
|
|
$fields = [];
|
|
|
|
}
|
|
|
|
|
|
|
|
$id_agents = get_parameter('id_agents', false);
|
|
|
|
if (!$id_agents) {
|
|
|
|
ui_print_error_message(__('No agents selected'));
|
|
|
|
$id_agents = [];
|
|
|
|
} else {
|
|
|
|
if (empty($values) && empty($fields)) {
|
|
|
|
ui_print_error_message(__('No values changed'));
|
|
|
|
$id_agents = [];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-14 16:06:51 +02:00
|
|
|
$id_module_safe = [];
|
|
|
|
if (is_metaconsole() === false) {
|
|
|
|
// Get the id_agente_modulo to update the 'safe_operation_mode' field.
|
|
|
|
if (isset($values['safe_mode_module']) === true
|
|
|
|
&& ($values['safe_mode_module'] != '0')
|
|
|
|
) {
|
|
|
|
foreach ($id_agents as $id_agent) {
|
|
|
|
$id_module_safe[$id_agent] = db_get_value_filter(
|
|
|
|
'id_agente_modulo',
|
|
|
|
'tagente_modulo',
|
|
|
|
[
|
|
|
|
'id_agente' => $id_agent,
|
|
|
|
'nombre' => $values['safe_mode_module'],
|
|
|
|
]
|
|
|
|
);
|
|
|
|
}
|
2019-11-26 16:44:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-24 12:19:09 +01:00
|
|
|
// CONF FILE DELETION.
|
2022-07-26 09:53:30 +02:00
|
|
|
if (isset($values['delete_conf']) === true) {
|
2019-01-30 16:18:44 +01:00
|
|
|
unset($values['delete_conf']);
|
|
|
|
$n_deleted = 0;
|
|
|
|
foreach ($id_agents as $id_agent) {
|
|
|
|
$agent_md5 = md5(agents_get_name($id_agent));
|
|
|
|
@unlink(
|
|
|
|
$config['remote_config'].'/md5/'.$agent_md5.'.md5'
|
|
|
|
);
|
|
|
|
$result = @unlink(
|
|
|
|
$config['remote_config'].'/conf/'.$agent_md5.'.conf'
|
|
|
|
);
|
|
|
|
|
|
|
|
$n_deleted += (int) $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ($n_deleted > 0) {
|
2022-02-01 13:39:18 +01:00
|
|
|
db_pandora_audit(
|
|
|
|
AUDIT_LOG_MASSIVE_MANAGEMENT,
|
|
|
|
'Delete conf file '.$id_agent
|
|
|
|
);
|
2019-01-30 16:18:44 +01:00
|
|
|
} else {
|
2022-02-01 13:39:18 +01:00
|
|
|
db_pandora_audit(
|
|
|
|
AUDIT_LOG_MASSIVE_MANAGEMENT,
|
|
|
|
'Try to delete conf file '.$id_agent
|
|
|
|
);
|
2019-01-30 16:18:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ui_print_result_message(
|
|
|
|
$n_deleted > 0,
|
|
|
|
__('Configuration files deleted successfully').'('.$n_deleted.')',
|
|
|
|
__('Configuration files cannot be deleted')
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-07-14 16:06:51 +02:00
|
|
|
if (empty($values) === true
|
|
|
|
&& empty($fields) === true
|
|
|
|
) {
|
2019-01-30 16:18:44 +01:00
|
|
|
$id_agents = [];
|
|
|
|
}
|
|
|
|
|
2022-03-09 15:12:26 +01:00
|
|
|
$result = [];
|
2019-01-30 16:18:44 +01:00
|
|
|
foreach ($id_agents as $id_agent) {
|
2022-07-14 16:06:51 +02:00
|
|
|
if (is_metaconsole() === true) {
|
|
|
|
$array_id = explode('|', $id_agent);
|
|
|
|
try {
|
|
|
|
$node = new Node((int) $array_id[0]);
|
|
|
|
$node->connect();
|
|
|
|
$result[$id_agent] = edit_massive_agent(
|
|
|
|
(int) $array_id[1],
|
|
|
|
$values,
|
|
|
|
$id_module_safe,
|
|
|
|
$fields,
|
|
|
|
$secondary_groups_added,
|
|
|
|
$secondary_groups_removed
|
2019-07-15 11:46:35 +02:00
|
|
|
);
|
|
|
|
|
2022-07-14 16:06:51 +02:00
|
|
|
$agents_values = agents_get_agent((int) $array_id[1]);
|
|
|
|
$node->disconnect();
|
2019-01-30 16:18:44 +01:00
|
|
|
|
2022-07-14 16:06:51 +02:00
|
|
|
if (empty($values) === false) {
|
|
|
|
update_agents_in_metaconsole(
|
|
|
|
(int) $array_id[1],
|
|
|
|
$values,
|
|
|
|
$agents_values
|
2019-01-30 16:18:44 +01:00
|
|
|
);
|
|
|
|
}
|
2022-07-14 16:06:51 +02:00
|
|
|
} catch (\Exception $e) {
|
|
|
|
// Unexistent agent.
|
|
|
|
$result = [];
|
|
|
|
$node->disconnect();
|
2019-01-30 16:18:44 +01:00
|
|
|
}
|
2022-07-14 16:06:51 +02:00
|
|
|
} else {
|
|
|
|
try {
|
|
|
|
$result[$id_agent] = edit_massive_agent(
|
2022-02-03 12:56:36 +01:00
|
|
|
$id_agent,
|
2022-07-14 16:06:51 +02:00
|
|
|
$values,
|
|
|
|
$id_module_safe,
|
|
|
|
$fields,
|
2022-02-03 13:52:40 +01:00
|
|
|
$secondary_groups_added,
|
2022-07-14 16:06:51 +02:00
|
|
|
$secondary_groups_removed
|
2022-03-09 15:12:26 +01:00
|
|
|
);
|
2022-07-14 16:06:51 +02:00
|
|
|
} catch (\Exception $e) {
|
|
|
|
// Unexistent agent.
|
|
|
|
$result = [];
|
2022-03-09 15:12:26 +01:00
|
|
|
}
|
2019-01-30 16:18:44 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-09 15:12:26 +01:00
|
|
|
$ret = [];
|
|
|
|
foreach ($result as $id_agent => $item) {
|
|
|
|
if ($item['db'] !== false) {
|
|
|
|
$ret['db']['edited'] += 1;
|
|
|
|
$ret['db']['edited_agent'][] = $id_agent;
|
|
|
|
} else {
|
|
|
|
$ret['db']['failed'] += 1;
|
|
|
|
$ret['db']['failed_agent'][] = $id_agent;
|
|
|
|
}
|
2019-01-30 16:18:44 +01:00
|
|
|
|
2022-03-09 15:12:26 +01:00
|
|
|
if (isset($item['fields']) === true
|
|
|
|
&& empty($item['fields']) === false
|
|
|
|
) {
|
|
|
|
foreach ($item['fields'] as $kfield => $vfield) {
|
|
|
|
if ($vfield !== false) {
|
|
|
|
$ret['fields'][$id_agent]['edited'] += 1;
|
|
|
|
$ret['fields'][$id_agent]['edited_field'][] = $kfield;
|
|
|
|
} else {
|
|
|
|
$ret['fields'][$id_agent]['failed'] += 1;
|
|
|
|
$ret['fields'][$id_agent]['failed_field'][] = $kfield;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($item['secondary']) === true
|
|
|
|
&& empty($item['secondary']) === false
|
|
|
|
) {
|
|
|
|
foreach ($item['secondary'] as $type_action => $values_secondary) {
|
|
|
|
foreach ($values_secondary as $kgr => $vgr) {
|
|
|
|
if ($vgr !== false) {
|
|
|
|
$ret['secondary'][$type_action][$id_agent]['edited'] += 1;
|
|
|
|
$ret['secondary'][$type_action][$id_agent]['edited_gr'][] = $kgr;
|
|
|
|
} else {
|
|
|
|
$ret['secondary'][$type_action][$id_agent]['failed'] += 1;
|
|
|
|
$ret['secondary'][$type_action][$id_agent]['failed_gr'][] = $kgr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($ret as $type => $ret_val) {
|
|
|
|
switch ($type) {
|
|
|
|
case 'db':
|
|
|
|
if (isset($ret_val['edited']) === true
|
|
|
|
&& $ret_val['edited'] > 0
|
|
|
|
) {
|
|
|
|
ui_print_success_message(
|
|
|
|
__(
|
|
|
|
'Agents updated successfully (%d)',
|
|
|
|
$ret_val['edited'],
|
|
|
|
implode(
|
|
|
|
',',
|
|
|
|
$ret_val['edited_agent']
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($ret_val['failed']) === true
|
|
|
|
&& $ret_val['failed'] > 0
|
|
|
|
) {
|
|
|
|
ui_print_error_message(
|
|
|
|
__(
|
|
|
|
'Agents cannot be updated (%d), ids (%s)',
|
|
|
|
$ret_val['failed'],
|
|
|
|
implode(',', $ret_val['failed_agent'])
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'fields':
|
|
|
|
$str = '';
|
|
|
|
foreach ($ret_val as $kag => $vag) {
|
|
|
|
if (isset($vag['failed']) === true
|
|
|
|
&& $vag['failed'] > 0
|
|
|
|
) {
|
|
|
|
$str .= __(
|
|
|
|
'Agent ID: %s cannot be updated custom fields (%s)',
|
|
|
|
$kag,
|
|
|
|
implode(',', $vag['failed_field'])
|
|
|
|
).'<br>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (empty($str) === false) {
|
|
|
|
ui_print_error_message($str);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'secondary':
|
|
|
|
$str = '';
|
|
|
|
foreach ($ret_val as $type => $values_secondary) {
|
|
|
|
foreach ($values_secondary as $kag => $vag) {
|
|
|
|
if (isset($vag['failed']) === true
|
|
|
|
&& $vag['failed'] > 0
|
|
|
|
) {
|
|
|
|
$str .= __(
|
|
|
|
'Agent ID: %s cannot be updated %s secondary groups (%s)',
|
|
|
|
$kag,
|
|
|
|
$type,
|
|
|
|
implode(',', $vag['failed_gr'])
|
|
|
|
).'<br>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (empty($str) === false) {
|
|
|
|
ui_print_error_message($str);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
// Not posible.
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2010-09-29 12:28:10 +02:00
|
|
|
}
|
2019-01-30 16:18:44 +01:00
|
|
|
|
2010-09-29 12:28:10 +02:00
|
|
|
|
2022-07-14 16:06:51 +02:00
|
|
|
/**
|
|
|
|
* Edit massive agent.
|
|
|
|
*
|
|
|
|
* @param integer $id_agent
|
|
|
|
* @param array $values
|
|
|
|
* @param array $id_module_safe
|
|
|
|
* @param array $fields
|
|
|
|
* @param array $secondary_groups_added
|
|
|
|
* @param array $secondary_groups_removed
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
function edit_massive_agent(
|
|
|
|
int $id_agent,
|
|
|
|
array $values,
|
|
|
|
array $id_module_safe,
|
|
|
|
array $fields,
|
|
|
|
array $secondary_groups_added,
|
|
|
|
array $secondary_groups_removed
|
|
|
|
) {
|
|
|
|
global $config;
|
|
|
|
$result = false;
|
|
|
|
|
|
|
|
if (empty($values) === false) {
|
|
|
|
$agent = new Agent($id_agent);
|
|
|
|
$disabled_old = $agent->disabled();
|
|
|
|
|
|
|
|
foreach ($values as $key => $value) {
|
|
|
|
$agent->{$key}($value);
|
|
|
|
}
|
2010-09-29 12:28:10 +02:00
|
|
|
|
2022-07-14 16:06:51 +02:00
|
|
|
if (is_metaconsole() === false) {
|
|
|
|
// Get the id_agent_module for this agent to update the 'safe_operation_mode' field.
|
|
|
|
if (isset($values['safe_mode_module']) === true
|
|
|
|
&& ($values['safe_mode_module'] != '0')
|
|
|
|
) {
|
|
|
|
$values['safe_mode_module'] = $id_module_safe[$id_agent];
|
|
|
|
}
|
|
|
|
}
|
2010-09-29 12:28:10 +02:00
|
|
|
|
2022-07-14 16:06:51 +02:00
|
|
|
$result['db'] = $agent->save();
|
2014-03-24 12:41:54 +01:00
|
|
|
|
2022-07-14 16:06:51 +02:00
|
|
|
if (is_metaconsole() === false) {
|
|
|
|
if ($result['db'] !== false
|
|
|
|
&& (bool) $config['metaconsole_agent_cache'] === true
|
|
|
|
) {
|
|
|
|
// Force an update of the agent cache.
|
|
|
|
$agent->updateFromCache();
|
|
|
|
}
|
|
|
|
}
|
2022-01-21 11:49:30 +01:00
|
|
|
|
2022-07-14 16:06:51 +02:00
|
|
|
if ($disabled_old !== $values['disabled']) {
|
|
|
|
// Validate alerts for disabled agents.
|
|
|
|
if ($values['disabled'] == 1) {
|
|
|
|
alerts_validate_alert_agent($id_agent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-01-30 16:18:44 +01:00
|
|
|
|
2022-07-14 16:06:51 +02:00
|
|
|
$info = [];
|
|
|
|
// Update Custom Fields.
|
|
|
|
if (isset($fields) === true
|
|
|
|
&& empty($fields) === false
|
|
|
|
) {
|
|
|
|
foreach ($fields as $field) {
|
|
|
|
$info[$field['id_field']] = $field['name'];
|
|
|
|
$value = get_parameter('customvalue_'.$field['id_field']);
|
|
|
|
if (empty($value) === false) {
|
|
|
|
$key = $field['id_field'];
|
|
|
|
$old_value = db_get_all_rows_filter(
|
|
|
|
'tagent_custom_data',
|
|
|
|
[
|
|
|
|
'id_agent' => $id_agent,
|
|
|
|
'id_field' => $key,
|
|
|
|
]
|
|
|
|
);
|
2010-09-29 12:28:10 +02:00
|
|
|
|
2022-07-14 16:06:51 +02:00
|
|
|
if ($old_value === false) {
|
|
|
|
// Create custom field if not exist.
|
|
|
|
$result['fields'][$field['id_field']] = db_process_sql_insert(
|
|
|
|
'tagent_custom_data',
|
|
|
|
[
|
|
|
|
'id_field' => $key,
|
|
|
|
'id_agent' => $id_agent,
|
|
|
|
'description' => $value,
|
|
|
|
]
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
if ($old_value[0]['description'] !== $value) {
|
|
|
|
$result['fields'][$field['id_field']] = db_process_sql_update(
|
|
|
|
'tagent_custom_data',
|
|
|
|
['description' => $value],
|
|
|
|
[
|
|
|
|
'id_field' => $key,
|
|
|
|
'id_agent' => $id_agent,
|
|
|
|
]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-01-26 12:17:07 +01:00
|
|
|
|
2022-07-14 16:06:51 +02:00
|
|
|
// Create or Remove the secondary groups.
|
|
|
|
if (empty($secondary_groups_added) === false
|
|
|
|
|| empty($secondary_groups_removed) === false
|
|
|
|
) {
|
|
|
|
$result['secondary'] = enterprise_hook(
|
|
|
|
'agents_update_secondary_groups',
|
|
|
|
[
|
|
|
|
$id_agent,
|
|
|
|
$secondary_groups_added,
|
|
|
|
$secondary_groups_removed,
|
|
|
|
true,
|
|
|
|
]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($result['db'] !== false) {
|
|
|
|
db_pandora_audit(
|
|
|
|
AUDIT_LOG_MASSIVE_MANAGEMENT,
|
|
|
|
'Update agent '.$id_agent,
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
json_encode($info)
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
if (isset($id_agent) === true) {
|
|
|
|
db_pandora_audit(
|
|
|
|
AUDIT_LOG_MASSIVE_MANAGEMENT,
|
|
|
|
'Try to update agent '.$id_agent,
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
json_encode($info)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$url = 'index.php?sec=gmassive&sec2=godmode/massive/massive_operations&option=edit_agents';
|
|
|
|
if (is_metaconsole() === true) {
|
|
|
|
$url = 'index.php?sec=advanced&sec2=advanced/massive_operations&tab=massive_agents&pure=0&option=edit_agents';
|
|
|
|
}
|
|
|
|
|
|
|
|
echo '<form method="post" autocomplete="off" id="form_agent" action="'.$url.'">';
|
|
|
|
echo html_print_avoid_autocomplete();
|
|
|
|
$params = [
|
|
|
|
'id_group' => $id_group,
|
|
|
|
'recursion' => $recursion,
|
|
|
|
];
|
|
|
|
echo get_table_inputs_masive_agents($params);
|
2010-09-29 12:28:10 +02:00
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
$nombre_agente = '';
|
|
|
|
$direccion_agente = '';
|
2010-09-29 12:28:10 +02:00
|
|
|
$id_agente = 0;
|
|
|
|
$id_parent = 0;
|
|
|
|
$cascade_protection = 0;
|
|
|
|
$group = 0;
|
|
|
|
$interval = '';
|
|
|
|
$id_os = 0;
|
|
|
|
$server_name = 0;
|
2019-01-30 16:18:44 +01:00
|
|
|
$description = '';
|
2010-09-29 12:28:10 +02:00
|
|
|
|
2021-04-06 08:55:06 +02:00
|
|
|
echo '<div id="form_agents" style="display:none">';
|
2010-09-29 12:28:10 +02:00
|
|
|
|
2015-10-06 13:52:45 +02:00
|
|
|
$table = new StdClass();
|
2015-06-15 15:50:28 +02:00
|
|
|
$table->width = '100%';
|
2019-01-30 16:18:44 +01:00
|
|
|
$table->class = 'databox filters';
|
|
|
|
$table->head = [];
|
|
|
|
$table->style = [];
|
2010-09-29 12:28:10 +02:00
|
|
|
$table->style[0] = 'font-weight: bold; width: 150px;';
|
2015-10-06 13:52:45 +02:00
|
|
|
$table->size[0] = '15%';
|
|
|
|
$table->size[1] = '35%';
|
|
|
|
$table->size[2] = '15%';
|
|
|
|
$table->size[3] = '35%';
|
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
$table->data = [];
|
2010-09-29 12:28:10 +02:00
|
|
|
|
2022-07-14 16:06:51 +02:00
|
|
|
if (is_metaconsole() === false) {
|
|
|
|
$modules = db_get_all_rows_sql(
|
|
|
|
sprintf(
|
|
|
|
'SELECT id_agente_modulo as id_module,
|
|
|
|
nombre as name
|
|
|
|
FROM tagente_modulo
|
|
|
|
WHERE id_agente = %d',
|
|
|
|
$id_parent
|
|
|
|
)
|
|
|
|
);
|
2017-01-25 13:59:14 +01:00
|
|
|
|
2022-07-14 16:06:51 +02:00
|
|
|
if ($modules === false) {
|
|
|
|
$modules = [];
|
|
|
|
}
|
2017-01-25 13:59:14 +01:00
|
|
|
|
2022-07-14 16:06:51 +02:00
|
|
|
$modules_values = [];
|
|
|
|
$modules_values[0] = __('Any');
|
|
|
|
foreach ($modules as $m) {
|
|
|
|
$modules_values[$m['id_module']] = $m['name'];
|
|
|
|
}
|
2019-01-30 16:18:44 +01:00
|
|
|
|
2022-07-14 16:06:51 +02:00
|
|
|
$table->data[0][0] = __('Parent');
|
|
|
|
$params = [];
|
|
|
|
$params['return'] = true;
|
|
|
|
$params['show_helptip'] = true;
|
|
|
|
$params['input_name'] = 'id_parent';
|
|
|
|
$params['print_hidden_input_idagent'] = true;
|
|
|
|
$params['hidden_input_idagent_name'] = 'id_agent_parent';
|
|
|
|
$params['hidden_input_idagent_value'] = $id_parent;
|
|
|
|
$params['value'] = db_get_value('alias', 'tagente', 'id_agente', $id_parent);
|
|
|
|
$params['selectbox_id'] = 'cascade_protection_module';
|
|
|
|
$params['javascript_is_function_select'] = true;
|
|
|
|
$table->data[0][1] = ui_print_agent_autocomplete_input($params);
|
|
|
|
|
|
|
|
$table->data[0][1] .= '<b>'.__('Cascade protection').'</b>';
|
|
|
|
$table->data[0][1] .= html_print_select(
|
|
|
|
[
|
|
|
|
1 => __('Yes'),
|
|
|
|
0 => __('No'),
|
|
|
|
],
|
|
|
|
'cascade_protection',
|
|
|
|
-1,
|
|
|
|
'',
|
|
|
|
__('No change'),
|
|
|
|
-1,
|
|
|
|
true
|
|
|
|
);
|
|
|
|
|
|
|
|
$table->data[0][1] .= ' '.__('Module').' ';
|
|
|
|
$table->data[0][1] .= html_print_select(
|
|
|
|
$modules,
|
|
|
|
'cascade_protection_module',
|
|
|
|
$cascade_protection_module,
|
|
|
|
'',
|
|
|
|
'',
|
|
|
|
0,
|
|
|
|
true
|
|
|
|
);
|
|
|
|
}
|
2017-01-25 13:59:14 +01:00
|
|
|
|
2010-10-07 10:13:36 +02:00
|
|
|
$table->data[1][0] = __('Group');
|
2020-10-08 16:41:26 +02:00
|
|
|
$table->data[1][1] = '<div class="w290px inline">';
|
|
|
|
$table->data[1][1] .= html_print_select_groups(
|
|
|
|
false,
|
|
|
|
'AR',
|
|
|
|
false,
|
|
|
|
'group',
|
|
|
|
$group,
|
|
|
|
'',
|
|
|
|
__('No change'),
|
|
|
|
-1,
|
|
|
|
true,
|
|
|
|
false,
|
|
|
|
true,
|
|
|
|
'',
|
|
|
|
false,
|
|
|
|
'width: 150px;'
|
|
|
|
);
|
|
|
|
$table->data[1][1] .= '</div>';
|
2010-09-29 12:28:10 +02:00
|
|
|
|
2010-10-07 10:13:36 +02:00
|
|
|
$table->data[2][0] = __('Interval');
|
2010-09-29 12:28:10 +02:00
|
|
|
|
2022-02-03 12:56:36 +01:00
|
|
|
$table->data[2][1] = html_print_extended_select_for_time(
|
|
|
|
'interval',
|
2022-07-14 16:06:51 +02:00
|
|
|
-2,
|
|
|
|
'',
|
2022-02-03 12:56:36 +01:00
|
|
|
'',
|
|
|
|
'0',
|
|
|
|
10,
|
|
|
|
true,
|
|
|
|
'width: 150px',
|
2022-07-14 16:06:51 +02:00
|
|
|
false,
|
|
|
|
'',
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
'',
|
|
|
|
true
|
2022-02-03 12:56:36 +01:00
|
|
|
);
|
2010-09-29 12:28:10 +02:00
|
|
|
|
2010-10-07 10:13:36 +02:00
|
|
|
$table->data[3][0] = __('OS');
|
2019-01-30 16:18:44 +01:00
|
|
|
$table->data[3][1] = html_print_select_from_sql(
|
|
|
|
'SELECT id_os, name FROM tconfig_os',
|
|
|
|
'id_os',
|
|
|
|
$id_os,
|
|
|
|
'',
|
|
|
|
__('No change'),
|
|
|
|
-1,
|
|
|
|
true,
|
|
|
|
false,
|
|
|
|
true,
|
|
|
|
false,
|
|
|
|
'width: 105px;'
|
|
|
|
);
|
2010-10-07 10:13:36 +02:00
|
|
|
$table->data[3][1] .= ' <span id="os_preview">';
|
2019-01-30 16:18:44 +01:00
|
|
|
$table->data[3][1] .= ui_print_os_icon($id_os, false, true);
|
2010-10-07 10:13:36 +02:00
|
|
|
$table->data[3][1] .= '</span>';
|
2010-09-29 12:28:10 +02:00
|
|
|
|
2022-01-24 12:19:09 +01:00
|
|
|
// Network server.
|
2010-09-29 12:28:10 +02:00
|
|
|
$none = '';
|
2019-01-30 16:18:44 +01:00
|
|
|
if ($server_name == '' && $id_agente) {
|
|
|
|
$none = __('None');
|
|
|
|
}
|
|
|
|
|
2010-10-07 10:13:36 +02:00
|
|
|
$table->data[4][0] = __('Server');
|
2019-01-30 16:18:44 +01:00
|
|
|
$table->data[4][1] = html_print_select(
|
|
|
|
servers_get_names(),
|
|
|
|
'server_name',
|
|
|
|
$server_name,
|
|
|
|
'',
|
|
|
|
__('No change'),
|
|
|
|
-1,
|
|
|
|
true,
|
|
|
|
false,
|
|
|
|
true,
|
|
|
|
'',
|
|
|
|
false,
|
|
|
|
'width: 150px;'
|
|
|
|
);
|
2010-09-29 12:28:10 +02:00
|
|
|
|
2022-01-24 12:19:09 +01:00
|
|
|
// Description.
|
2010-10-07 10:13:36 +02:00
|
|
|
$table->data[5][0] = __('Description');
|
2022-02-03 12:56:36 +01:00
|
|
|
$table->data[5][1] = html_print_input_text(
|
|
|
|
'description',
|
|
|
|
$description,
|
|
|
|
'',
|
|
|
|
45,
|
|
|
|
255,
|
|
|
|
true
|
|
|
|
);
|
2010-09-29 12:28:10 +02:00
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
html_print_table($table);
|
2010-09-29 12:28:10 +02:00
|
|
|
unset($table);
|
|
|
|
|
|
|
|
$custom_id = '';
|
|
|
|
$mode = -1;
|
|
|
|
$disabled = -1;
|
|
|
|
$new_agent = true;
|
|
|
|
$icon_path = '';
|
|
|
|
$update_gis_data = -1;
|
|
|
|
$cascade_protection = -1;
|
2017-01-25 13:59:14 +01:00
|
|
|
$cascade_protection_module = -1;
|
2012-08-22 16:09:05 +02:00
|
|
|
$quiet_select = -1;
|
2010-09-29 12:28:10 +02:00
|
|
|
|
2015-10-06 13:52:45 +02:00
|
|
|
$table = new StdClass();
|
2015-06-15 15:50:28 +02:00
|
|
|
$table->width = '100%';
|
2019-01-30 16:18:44 +01:00
|
|
|
$table->class = 'databox filters';
|
2010-09-29 12:28:10 +02:00
|
|
|
|
2015-10-06 13:52:45 +02:00
|
|
|
$table->size[0] = '15%';
|
|
|
|
$table->size[1] = '35%';
|
|
|
|
$table->size[2] = '15%';
|
|
|
|
$table->size[3] = '35%';
|
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
$table->head = [];
|
|
|
|
$table->style = [];
|
2010-09-29 12:28:10 +02:00
|
|
|
$table->style[0] = 'font-weight: bold; width: 150px;';
|
2019-01-30 16:18:44 +01:00
|
|
|
$table->data = [];
|
2010-09-29 12:28:10 +02:00
|
|
|
|
2022-01-24 12:19:09 +01:00
|
|
|
// Custom ID.
|
2010-09-29 12:28:10 +02:00
|
|
|
$table->data[0][0] = __('Custom ID');
|
2022-07-14 16:06:51 +02:00
|
|
|
$table->data[0][1] = html_print_input_text(
|
|
|
|
'custom_id',
|
|
|
|
$custom_id,
|
|
|
|
'',
|
|
|
|
16,
|
|
|
|
255,
|
|
|
|
true
|
|
|
|
);
|
2010-09-29 12:28:10 +02:00
|
|
|
|
2022-02-03 12:56:36 +01:00
|
|
|
// Secondary Groups.
|
|
|
|
if (enterprise_installed() === true) {
|
2022-03-10 20:06:45 +01:00
|
|
|
$groups = users_get_groups($config['id_user'], 'AW', false);
|
|
|
|
$table->data['secondary_groups_added'][0] = __('Add secondary groups');
|
|
|
|
$table->data['secondary_groups_added'][1] = html_print_select(
|
|
|
|
$groups,
|
|
|
|
'secondary_groups_added[]',
|
|
|
|
0,
|
|
|
|
false,
|
|
|
|
'',
|
|
|
|
'',
|
|
|
|
true,
|
|
|
|
true,
|
|
|
|
true,
|
|
|
|
'',
|
|
|
|
false,
|
|
|
|
'min-width: 500px; max-width: 500px; max-height: 100px',
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
'',
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
true,
|
|
|
|
true
|
2022-02-03 12:56:36 +01:00
|
|
|
);
|
|
|
|
|
2022-03-11 09:20:20 +01:00
|
|
|
$table->data['secondary_groups_removed'][0] = __('Remove secondary groups');
|
2022-03-10 20:06:45 +01:00
|
|
|
$table->data['secondary_groups_removed'][1] = html_print_select(
|
|
|
|
$groups,
|
|
|
|
'secondary_groups_removed[]',
|
|
|
|
0,
|
|
|
|
false,
|
|
|
|
'',
|
|
|
|
'',
|
|
|
|
true,
|
|
|
|
true,
|
|
|
|
true,
|
|
|
|
'',
|
|
|
|
false,
|
|
|
|
'min-width: 500px; max-width: 500px; max-height: 100px',
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
'',
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
true,
|
|
|
|
true
|
2022-02-03 12:56:36 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-01-24 12:19:09 +01:00
|
|
|
// Learn mode / Normal mode.
|
2019-04-24 13:53:18 +02:00
|
|
|
$table->data[1][0] = __('Module definition');
|
2022-02-03 12:56:36 +01:00
|
|
|
$table->data[1][1] = __('No change').' ';
|
|
|
|
$table->data[1][1] .= html_print_radio_button_extended(
|
|
|
|
'mode',
|
|
|
|
-1,
|
|
|
|
'',
|
|
|
|
$mode,
|
|
|
|
false,
|
|
|
|
'',
|
|
|
|
'class="mrgn_right_40px"',
|
|
|
|
true
|
|
|
|
);
|
|
|
|
$table->data[1][1] .= __('Learning mode').' ';
|
|
|
|
$table->data[1][1] .= html_print_radio_button_extended(
|
|
|
|
'mode',
|
|
|
|
1,
|
|
|
|
'',
|
|
|
|
$mode,
|
|
|
|
false,
|
|
|
|
'',
|
|
|
|
'class="mrgn_right_40px"',
|
|
|
|
true
|
|
|
|
);
|
|
|
|
$table->data[1][1] .= __('Normal mode').' ';
|
|
|
|
$table->data[1][1] .= html_print_radio_button_extended(
|
|
|
|
'mode',
|
|
|
|
0,
|
|
|
|
'',
|
|
|
|
$mode,
|
|
|
|
false,
|
|
|
|
'',
|
|
|
|
'class="mrgn_right_40px"',
|
|
|
|
true
|
|
|
|
);
|
|
|
|
$table->data[1][1] .= __('Autodisable mode').' ';
|
|
|
|
$table->data[1][1] .= html_print_radio_button_extended(
|
|
|
|
'mode',
|
|
|
|
2,
|
|
|
|
'',
|
|
|
|
$mode,
|
|
|
|
false,
|
|
|
|
'',
|
|
|
|
'class="mrgn_right_40px"',
|
|
|
|
true
|
|
|
|
);
|
2010-09-29 12:28:10 +02:00
|
|
|
|
2022-01-24 12:19:09 +01:00
|
|
|
// Status (Disabled / Enabled).
|
2010-09-29 12:28:10 +02:00
|
|
|
$table->data[2][0] = __('Status');
|
2022-02-03 12:56:36 +01:00
|
|
|
$table->data[2][1] = __('No change').' ';
|
2022-07-26 09:53:30 +02:00
|
|
|
$table->data[2][1] .= html_print_radio_button_extended(
|
2022-02-03 12:56:36 +01:00
|
|
|
'disabled',
|
|
|
|
-1,
|
|
|
|
'',
|
|
|
|
$disabled,
|
|
|
|
false,
|
|
|
|
'',
|
|
|
|
'class="mrgn_right_40px"',
|
|
|
|
true
|
|
|
|
);
|
|
|
|
$table->data[2][1] .= __('Disabled').' ';
|
2022-07-26 09:53:30 +02:00
|
|
|
$table->data[2][1] .= ui_print_help_tip(
|
2022-02-03 12:56:36 +01:00
|
|
|
__('If the remote configuration is enabled, it will also go into standby mode when disabling it.'),
|
|
|
|
true
|
|
|
|
).' ';
|
2022-07-26 09:53:30 +02:00
|
|
|
$table->data[2][1] .= html_print_radio_button_extended(
|
2022-02-03 12:56:36 +01:00
|
|
|
'disabled',
|
|
|
|
1,
|
|
|
|
'',
|
|
|
|
$disabled,
|
|
|
|
false,
|
|
|
|
'',
|
|
|
|
'class="mrgn_right_40px"',
|
|
|
|
true
|
|
|
|
);
|
|
|
|
$table->data[2][1] .= __('Active').' ';
|
2022-07-26 09:53:30 +02:00
|
|
|
$table->data[2][1] .= html_print_radio_button_extended(
|
2022-02-03 12:56:36 +01:00
|
|
|
'disabled',
|
|
|
|
0,
|
|
|
|
'',
|
|
|
|
$disabled,
|
|
|
|
false,
|
|
|
|
'',
|
|
|
|
'class="mrgn_right_40px"',
|
|
|
|
true
|
|
|
|
);
|
2010-09-29 12:28:10 +02:00
|
|
|
|
2022-01-24 12:19:09 +01:00
|
|
|
// Remote configuration.
|
2010-09-29 12:28:10 +02:00
|
|
|
$table->data[3][0] = __('Remote configuration');
|
2022-01-24 12:19:09 +01:00
|
|
|
// Delete remote configuration.
|
2022-07-14 16:06:51 +02:00
|
|
|
$table->data[3][1] = '<div id="delete_configurations" class="invisible">';
|
|
|
|
$table->data[3][1] .= __('Delete available remote configurations');
|
|
|
|
$table->data[3][1] .= ' (';
|
2010-09-29 12:28:10 +02:00
|
|
|
$table->data[3][1] .= '<span id="n_configurations"></span>';
|
2022-07-14 16:06:51 +02:00
|
|
|
$table->data[3][1] .= ') ';
|
|
|
|
$table->data[3][1] .= html_print_checkbox_extended(
|
|
|
|
'delete_conf',
|
|
|
|
1,
|
|
|
|
0,
|
|
|
|
false,
|
|
|
|
'',
|
|
|
|
'class="mrgn_right_40px"',
|
|
|
|
true
|
|
|
|
);
|
|
|
|
$table->data[3][1] .= '</div>';
|
2010-09-29 12:28:10 +02:00
|
|
|
|
2022-07-14 16:06:51 +02:00
|
|
|
$table->data[3][1] .= '<div id="not_available_configurations" class="invisible"><em>';
|
|
|
|
$table->data[3][1] .= __('Not available');
|
|
|
|
$table->data[3][1] .= '</em></div>';
|
2012-08-22 16:09:05 +02:00
|
|
|
|
2011-04-27 15:43:31 +02:00
|
|
|
$listIcons = gis_get_array_list_icons();
|
2010-09-29 12:28:10 +02:00
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
$arraySelectIcon = [];
|
|
|
|
foreach ($listIcons as $index => $value) {
|
|
|
|
$arraySelectIcon[$index] = $index;
|
|
|
|
}
|
2010-09-29 12:28:10 +02:00
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
$path = 'images/gis_map/icons/';
|
2022-07-26 09:53:30 +02:00
|
|
|
// TODO set better method the path.
|
2012-08-22 16:09:05 +02:00
|
|
|
if ($icon_path == '') {
|
2019-01-30 16:18:44 +01:00
|
|
|
$display_icons = 'none';
|
2022-01-24 12:19:09 +01:00
|
|
|
// Hack to show no icon. Use any given image to fix not found image errors.
|
2019-01-30 16:18:44 +01:00
|
|
|
$path_without = 'images/spinner.png';
|
|
|
|
$path_default = 'images/spinner.png';
|
|
|
|
$path_ok = 'images/spinner.png';
|
|
|
|
$path_bad = 'images/spinner.png';
|
|
|
|
$path_warning = 'images/spinner.png';
|
|
|
|
} else {
|
|
|
|
$display_icons = '';
|
|
|
|
$path_without = $path.$icon_path.'.default.png';
|
|
|
|
$path_default = $path.$icon_path.'.default.png';
|
|
|
|
$path_ok = $path.$icon_path.'.ok.png';
|
|
|
|
$path_bad = $path.$icon_path.'.bad.png';
|
|
|
|
$path_warning = $path.$icon_path.'.warning.png';
|
2011-07-20 16:55:57 +02:00
|
|
|
}
|
2010-09-29 12:28:10 +02:00
|
|
|
|
|
|
|
$table->data[4][0] = __('Agent icon');
|
2022-07-14 16:06:51 +02:00
|
|
|
$table->data[4][1] = html_print_select(
|
|
|
|
$arraySelectIcon,
|
|
|
|
'icon_path',
|
|
|
|
$icon_path,
|
|
|
|
'changeIcons();',
|
|
|
|
__('No change'),
|
|
|
|
'',
|
|
|
|
true
|
|
|
|
);
|
|
|
|
$table->data[4][1] .= ' ';
|
|
|
|
$table->data[4][1] .= __('Without status').': ';
|
|
|
|
$table->data[4][1] .= html_print_image(
|
|
|
|
$path_without,
|
|
|
|
true,
|
|
|
|
[
|
|
|
|
'id' => 'icon_without_status',
|
|
|
|
'style' => 'display:'.$display_icons.';',
|
|
|
|
]
|
|
|
|
);
|
|
|
|
$table->data[4][1] .= ' '.__('Default').': ';
|
|
|
|
$table->data[4][1] .= html_print_image(
|
|
|
|
$path_default,
|
|
|
|
true,
|
|
|
|
[
|
|
|
|
'id' => 'icon_default',
|
|
|
|
'style' => 'display:'.$display_icons.';',
|
|
|
|
]
|
|
|
|
);
|
|
|
|
$table->data[4][1] .= ' '.__('Ok').': ';
|
|
|
|
$table->data[4][1] .= html_print_image(
|
|
|
|
$path_ok,
|
|
|
|
true,
|
|
|
|
[
|
|
|
|
'id' => 'icon_ok',
|
|
|
|
'style' => 'display:'.$display_icons.';',
|
|
|
|
]
|
|
|
|
);
|
|
|
|
$table->data[4][1] .= ' '.__('Bad').': ';
|
|
|
|
$table->data[4][1] .= html_print_image(
|
|
|
|
$path_bad,
|
|
|
|
true,
|
|
|
|
[
|
|
|
|
'id' => 'icon_bad',
|
|
|
|
'style' => 'display:'.$display_icons.';',
|
|
|
|
]
|
|
|
|
);
|
|
|
|
$table->data[4][1] .= ' '.__('Warning').': ';
|
|
|
|
$table->data[4][1] .= html_print_image(
|
|
|
|
$path_warning,
|
|
|
|
true,
|
|
|
|
[
|
|
|
|
'id' => 'icon_warning',
|
|
|
|
'style' => 'display:'.$display_icons.';',
|
|
|
|
]
|
|
|
|
);
|
2010-09-29 12:28:10 +02:00
|
|
|
|
|
|
|
if ($config['activate_gis']) {
|
2019-01-30 16:18:44 +01:00
|
|
|
$table->data[5][0] = __('Ignore new GIS data:');
|
2022-07-14 16:06:51 +02:00
|
|
|
$table->data[5][1] = __('No change').' ';
|
|
|
|
$table->data[5][1] .= html_print_radio_button_extended(
|
|
|
|
'update_gis_data',
|
|
|
|
-1,
|
|
|
|
'',
|
|
|
|
$update_gis_data,
|
|
|
|
false,
|
|
|
|
'',
|
|
|
|
'class="mrgn_right_40px"',
|
|
|
|
true
|
|
|
|
);
|
|
|
|
$table->data[5][1] .= __('Yes').' ';
|
|
|
|
$table->data[5][1] .= html_print_radio_button_extended(
|
|
|
|
'update_gis_data',
|
|
|
|
0,
|
|
|
|
'',
|
|
|
|
$update_gis_data,
|
|
|
|
false,
|
|
|
|
'',
|
|
|
|
'class="mrgn_right_40px"',
|
|
|
|
true
|
|
|
|
);
|
|
|
|
$table->data[5][1] .= __('No').' ';
|
|
|
|
$table->data[5][1] .= html_print_radio_button_extended(
|
|
|
|
'update_gis_data',
|
|
|
|
1,
|
|
|
|
'',
|
|
|
|
$update_gis_data,
|
|
|
|
false,
|
|
|
|
'',
|
|
|
|
'class="mrgn_right_40px"',
|
|
|
|
true
|
|
|
|
);
|
2010-09-29 12:28:10 +02:00
|
|
|
}
|
|
|
|
|
2012-08-22 16:09:05 +02:00
|
|
|
$table->data[6][0] = __('Quiet');
|
2022-07-14 16:06:51 +02:00
|
|
|
$table->data[6][0] .= ui_print_help_tip(
|
|
|
|
__('The agent still runs but the alerts and events will be stop'),
|
|
|
|
true
|
|
|
|
);
|
2019-01-30 16:18:44 +01:00
|
|
|
$table->data[6][1] = html_print_select(
|
|
|
|
[
|
|
|
|
-1 => __('No change'),
|
|
|
|
1 => __('Yes'),
|
|
|
|
0 => __('No'),
|
|
|
|
],
|
|
|
|
'quiet_select',
|
|
|
|
$quiet_select,
|
|
|
|
'',
|
|
|
|
'',
|
|
|
|
0,
|
|
|
|
true
|
|
|
|
);
|
|
|
|
|
2022-07-14 16:06:51 +02:00
|
|
|
if (is_metaconsole() === false) {
|
|
|
|
$table->data[7][0] = __('Safe operation mode').': '.ui_print_help_tip(
|
|
|
|
__(
|
|
|
|
'This mode allow %s to disable all modules of this agent while the selected module is on CRITICAL status',
|
|
|
|
get_product_name()
|
|
|
|
),
|
|
|
|
true
|
|
|
|
);
|
|
|
|
$table->data[7][1] .= html_print_select(
|
|
|
|
[
|
|
|
|
1 => __('Enabled'),
|
|
|
|
0 => __('Disabled'),
|
|
|
|
],
|
|
|
|
'safe_mode_change',
|
|
|
|
-1,
|
|
|
|
'',
|
|
|
|
__('No change'),
|
|
|
|
-1,
|
|
|
|
true
|
|
|
|
).' ';
|
|
|
|
$table->data[7][1] .= __('Module').' ';
|
|
|
|
$table->data[7][1] .= html_print_select(
|
|
|
|
'',
|
|
|
|
'safe_mode_module',
|
|
|
|
'',
|
|
|
|
'',
|
|
|
|
__('Any'),
|
|
|
|
-1,
|
|
|
|
true
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
ui_toggle(html_print_table($table, true), __('Advanced options'));
|
2010-09-29 12:28:10 +02:00
|
|
|
unset($table);
|
|
|
|
|
2015-10-06 13:52:45 +02:00
|
|
|
$table = new StdClass();
|
2015-06-15 15:50:28 +02:00
|
|
|
$table->width = '100%';
|
2019-01-30 16:18:44 +01:00
|
|
|
$table->class = 'databox filters';
|
2010-09-29 12:28:10 +02:00
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
$table->head = [];
|
|
|
|
$table->style = [];
|
2010-09-29 12:28:10 +02:00
|
|
|
$table->style[0] = 'font-weight: bold; width: 150px;';
|
2019-01-30 16:18:44 +01:00
|
|
|
$table->data = [];
|
2015-10-06 13:52:45 +02:00
|
|
|
$table->size[0] = '15%';
|
|
|
|
$table->size[1] = '35%';
|
|
|
|
$table->size[2] = '15%';
|
|
|
|
$table->size[3] = '35%';
|
2010-09-29 12:28:10 +02:00
|
|
|
|
* include/functions_graph.php
include/functions_html.php
include/functions_messages.php
include/db/postgresql.php
include/db/mysql.php
include/db/oracle.php
include/functions_reporting.php
include/functions_filemanager.php
include/functions_gis.php
include/auth/ldap.php
include/auth/mysql.php
include/functions_networkmap.php
include/functions_network_components.php
include/ajax/skins.ajax.php
include/ajax/reporting.ajax.php
include/ajax/visual_console_builder.ajax.php
include/ajax/alert_list.ajax.php
include/ajax/module.php
include/functions_config.php
include/functions_api.php
include/help/en/help_timesource.php
include/help/es/help_timesource.php
include/help/ja/help_timesource.php
include/config_process.php
include/functions_ui.php
include/functions_custom_graphs.php
include/fgraph.php
include/functions_incidents.php
include/api.php
include/functions_reports.php
include/functions_ui_renders.php
extensions/insert_data.php
extensions/system_info.php
extensions/extension_uploader.php
extensions/pandora_logs.php
extensions/agents_modules.php
extensions/update_manager.php
extensions/ssh_console.php
extensions/dbmanager.php
extensions/vnc_view.php
extensions/resource_registration.php
extensions/resource_exportation.php
extensions/users_connected.php
extensions/module_groups.php
extensions/update_manager/load_updatemanager.php
extensions/update_manager/lib/libupdate_manager_client.php
extensions/update_manager/lib/libupdate_manager.php
extensions/update_manager/lib/libupdate_manager_components.php
extensions/update_manager/lib/libupdate_manager_updates.php
extensions/update_manager/settings.php
extensions/update_manager/main.php
extensions/plugin_registration.php
operation/incidents/incident.php
operation/incidents/incident_detail.php
operation/incidents/incident_statistics.php
operation/search_modules.php
operation/visual_console/render_view.php
operation/visual_console/index.php
operation/extensions.php
operation/agentes/status_monitor.php
operation/agentes/export_csv.php
operation/agentes/estado_ultimopaquete.php
operation/agentes/datos_agente.php
operation/agentes/alerts_status.php
operation/agentes/estado_generalagente.php
operation/agentes/custom_fields.php
operation/agentes/estado_agente.php
operation/agentes/networkmap.topology.php
operation/agentes/networkmap.groups.php
operation/agentes/sla_view.php
operation/agentes/exportdata.php
operation/agentes/gis_view.php
operation/agentes/estado_monitores.php
operation/agentes/ver_agente.php
operation/agentes/graphs.php
operation/agentes/agent_fields.php
operation/agentes/tactical.php
operation/agentes/group_view.php
operation/agentes/networkmap.php
operation/agentes/stat_win.php
operation/servers/view_server.php
operation/servers/view_server_detail.php
operation/menu.php
operation/search_agents.php
operation/search_graphs.php
operation/snmpconsole/snmp_view.php
operation/users/user_edit.php
operation/gis_maps/render_view.php
operation/gis_maps/ajax.php
operation/integria_incidents/incident.php
operation/integria_incidents/incident_detail.php
operation/integria_incidents/incident_statistics.php
operation/events/event_statistics.php
operation/events/events_rss.php
operation/events/export_csv.php
operation/events/sound_events.php
operation/events/events_validate.php
operation/events/events_list.php
operation/events/events_marquee.php
operation/events/events.php
operation/search_alerts.php
operation/messages/message.php
operation/reporting/reporting_xml.php
operation/reporting/reporting_viewer.php
operation/reporting/graph_viewer.php
operation/search_reports.php
operation/search_maps.php
operation/search_users.php
extras/pandora_diag.php
mobile/operation/agents/monitor_status.php
mobile/operation/agents/view_agents.php
mobile/operation/agents/view_alerts.php
mobile/operation/agents/group_view.php
mobile/operation/events/events.php
mobile/index.php
general/error_authconfig.php
general/links_menu.php
general/logon_ok.php
general/error_dbconfig.php
general/ui/agents_list.php
general/header.php
godmode/groups/modu_group_list.php
godmode/groups/configure_group.php
godmode/groups/configure_modu_group.php
godmode/groups/group_list.php
godmode/admin_access_logs.php
godmode/db/db_main.php
godmode/db/db_audit.php
godmode/db/db_sanity.php
godmode/db/db_refine.php
godmode/db/db_info.php
godmode/db/db_event.php
godmode/db/db_purge.php
godmode/extensions.php
godmode/agentes/agent_template.php
godmode/agentes/module_manager_editor_common.php
godmode/agentes/fields_manager.php
godmode/agentes/agent_conf_gis.php
godmode/agentes/module_manager_editor_prediction.php
godmode/agentes/module_manager.php
godmode/agentes/modificar_agente.php
godmode/agentes/configurar_agente.php
godmode/agentes/configure_field.php
godmode/agentes/module_manager_editor.php
godmode/agentes/planned_downtime.php
godmode/agentes/manage_config_remote.php
godmode/agentes/agent_manager.php
godmode/servers/recon_script.php
godmode/servers/plugin.php
godmode/servers/manage_recontask.php
godmode/servers/modificar_server.php
godmode/servers/manage_recontask_form.php
godmode/alerts/alert_list.list.php
godmode/alerts/configure_alert_compound.php
godmode/alerts/alert_compounds.php
godmode/alerts/alert_list.php
godmode/alerts/configure_alert_template.php
godmode/alerts/alert_templates.php
godmode/alerts/configure_alert_action.php
godmode/alerts/configure_alert_command.php
godmode/alerts/alert_actions.php
godmode/alerts/alert_list.builder.php
godmode/alerts/alert_commands.php
godmode/setup/file_manager.php
godmode/setup/os.list.php
godmode/setup/news.php
godmode/setup/gis_step_2.php
godmode/setup/links.php
godmode/setup/setup.php
godmode/setup/os.php
godmode/setup/performance.php
godmode/setup/setup_auth.php
godmode/setup/gis.php
godmode/setup/os.builder.php
godmode/setup/setup_visuals.php
godmode/snmpconsole/snmp_alert.php
godmode/snmpconsole/snmp_filters.php
godmode/users/user_list.php
godmode/users/configure_profile.php
godmode/gis_maps/configure_gis_map.php
godmode/gis_maps/index.php
godmode/massive/massive_add_alerts.php
godmode/massive/massive_copy_modules.php
godmode/massive/massive_delete_agents.php
godmode/massive/massive_enable_disable_alerts.php
godmode/massive/massive_operations.php
godmode/massive/massive_delete_profiles.php
godmode/massive/massive_edit_agents.php
godmode/massive/massive_delete_action_alerts.php
godmode/massive/massive_delete_modules.php
godmode/massive/massive_add_profiles.php
godmode/massive/massive_delete_alerts.php
godmode/massive/massive_edit_modules.php
godmode/massive/massive_standby_alerts.php
godmode/massive/massive_add_action_alerts.php
godmode/modules/manage_network_components_form.php
godmode/modules/manage_nc_groups_form.php
godmode/modules/manage_network_templates.php
godmode/modules/module_list.php
godmode/modules/manage_network_components_form_common.php
godmode/modules/manage_network_components_form_network.php
godmode/modules/manage_network_templates_form.php
godmode/modules/manage_network_components_form_wmi.php
godmode/modules/manage_network_components.php
godmode/modules/manage_nc_groups.php
godmode/reporting/visual_console_builder.wizard.php
godmode/reporting/graph_builder.main.php
godmode/reporting/reporting_builder.list_items.php
godmode/reporting/visual_console_builder.php
godmode/reporting/reporting_builder.preview.php
godmode/reporting/reporting_builder.main.php
godmode/reporting/visual_console_builder.data.php
godmode/reporting/visual_console_builder.elements.php
godmode/reporting/graph_builder.php
godmode/reporting/visual_console_builder.preview.php
godmode/reporting/graph_builder.graph_editor.php
godmode/reporting/reporting_builder.php
godmode/reporting/visual_console_builder.editor.php
godmode/reporting/reporting_builder.item_editor.php
godmode/reporting/map_builder.php
godmode/reporting/graphs.php
godmode/reporting/graph_builder.preview.php
include/functions_db.php: Added some includes and functions of this code have "db_" prefix.
* include/functions.php: Moved function check_login(), check_acl(),
dame_nombre_pluginid(), get_os_name() from functions_db.php to functions.php.
* include/functions_groups.php: Moved functions get_childrens(), safe_acl_group()
and get_parents(), give_disabled_group(), isAllGroups(), get_group_icon(), get_all_groups(),
get_id_groups_recursive(), get_user_groups_tree_recursive(), get_group_status(),
get_group_name(), get_group_users() from functions_db.php to this code.
* include/functions_profile.php: New library with profile functions. Moved functions
get_profile_name(), get_profiles(), create_user_profile(), delete_user_profile(),
delete_profile() from functions_db.php to this code. Added new parameter in function
get_profile() to retrieve profiles with filter conditions applied.
* include/functions_users.php: New library with users functions. Moved functions
get_users_info(), get_all_model_groups(), get_user_groups(), get_user_groups_tree(),
get_user_first_group(), user_access_to_agent() from funtions_db.php to this code.
* godmode/users/configure_user.php: Changed get_profile_filter() function to get_profile().
* include/functions_agents.php: Moved functions get_group_agents(), get_agent_modules(),
get_agent_module_id(), get_agent_id(), get_agent_name(), get_agent_modules_data_count(),
check_alert_fired(), get_agent_interval(), get_agent_os(), give_agentmodule_flag(),
agent_add_address(), agent_delete_address(), get_agent_address(), get_agent_with_ip(),
get_agent_addresses(), get_agent_status(), delete_agent(), get_agentmodule_group(),
get_agent_group() from functions_db.php to this code.
* include/functions_modules.php: Moved functions get_agentmodule(), get_agentmodule_id(),
get_agentmodule_is_init(), get_agent_modules_count(), get_module_type_name(),
get_module_type_icon(), get_agentmodule_agent(), get_agentmodule_agent_name(),
get_agentmodule_name(), get_agentmodule_type(), get_monitor_downs_in_period(),
get_monitor_last_down_timestamp_in_period(), get_monitors_in_group(),
get_monitors_in_agent(), get_monitors_down(), get_moduletype_name(),
get_moduletype_description(), get_moduletypes(), get_module_interval(), show_icon_type(),
give_modulecategory_name(),
give_agent_id_from_module_id(), get_module_status(), get_agent_module_last_value(),
get_previous_data(), get_agentmodule_modulegroup(), get_modulegroups(),
get_modulegroup_name() from functions_db.php to this code.
* include/functions_alerts.php: Moved functions get_alert_type(), get_agent_alert_fired(),
get_module_alert_fired(), get_alert_fires_in_period(), get_group_alerts(), get_alerts_fired(),
get_alert_last_fire_timestamp_in_period(), get_agentmodule_status(),
get_agentmodule_last_status() from functions_db.php to this code.
* include/functions_exportserver.php: Moved function dame_nombre_servidorexportacion()
from functions_db.php to this code.
* include/functions_events.php: Moved functions get_group_events(), get_agent_events(),
get_module_events() from functions_db.php to this code.
* include/functions_servers.php: Moved functions get_server_name(), show_server_type(),
check_server_status(), server_status() from functions_db.php to this code.
* include/functions_network_profiles.php: Moved function get_networkprofile_name()
from functions_db.php to this code.
* include/functions_visual_map.php: Moved functions get_layoutdata_x(), get_layoutdata_y()
from fucntions_db.php to this code.
* include/functions_io.php: Moved function __() from functions_db.php to this code.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4258 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2011-04-19 20:42:49 +02:00
|
|
|
$fields = db_get_all_fields_in_table('tagent_custom_fields');
|
2010-09-29 12:28:10 +02:00
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
if ($fields === false) {
|
|
|
|
$fields = [];
|
|
|
|
}
|
2010-09-29 12:28:10 +02:00
|
|
|
|
|
|
|
foreach ($fields as $field) {
|
2019-01-30 16:18:44 +01:00
|
|
|
$data[0] = '<b>'.$field['name'].'</b>';
|
2019-03-07 13:37:36 +01:00
|
|
|
$combo = [];
|
|
|
|
$combo = $field['combo_values'];
|
|
|
|
$combo = explode(',', $combo);
|
|
|
|
$combo_values = [];
|
|
|
|
foreach ($combo as $value) {
|
|
|
|
$combo_values[$value] = $value;
|
|
|
|
}
|
2019-01-30 16:18:44 +01:00
|
|
|
|
2022-07-14 16:06:51 +02:00
|
|
|
$custom_value = db_get_value_filter(
|
|
|
|
'description',
|
|
|
|
'tagent_custom_data',
|
|
|
|
[
|
|
|
|
'id_field' => $field['id_field'],
|
|
|
|
'id_agent' => $id_agente,
|
|
|
|
]
|
|
|
|
);
|
2019-01-30 16:18:44 +01:00
|
|
|
|
|
|
|
if ($custom_value === false) {
|
|
|
|
$custom_value = '';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($field['is_password_type']) {
|
2022-01-26 12:17:07 +01:00
|
|
|
$data[1] = html_print_input_password_avoid_autocomplete();
|
|
|
|
$data[1] .= html_print_input_text_extended(
|
2019-01-30 16:18:44 +01:00
|
|
|
'customvalue_'.$field['id_field'],
|
|
|
|
$custom_value,
|
|
|
|
'customvalue_'.$field['id_field'],
|
|
|
|
'',
|
|
|
|
30,
|
|
|
|
100,
|
|
|
|
$view_mode,
|
|
|
|
'',
|
|
|
|
'',
|
|
|
|
true,
|
|
|
|
true
|
|
|
|
);
|
|
|
|
} else {
|
2022-07-14 16:06:51 +02:00
|
|
|
$data[1] = html_print_textarea(
|
|
|
|
'customvalue_'.$field['id_field'],
|
|
|
|
2,
|
|
|
|
65,
|
|
|
|
$custom_value,
|
|
|
|
'class="mrgn_right_30px"',
|
|
|
|
true
|
|
|
|
);
|
2019-01-30 16:18:44 +01:00
|
|
|
}
|
|
|
|
|
2019-03-07 13:37:36 +01:00
|
|
|
if ($field['combo_values'] !== '') {
|
2021-04-06 18:51:14 +02:00
|
|
|
$data[1] = html_print_input(
|
|
|
|
[
|
|
|
|
'type' => 'select_search',
|
|
|
|
'fields' => $combo_values,
|
|
|
|
'name' => 'customvalue_'.$field['id_field'],
|
|
|
|
'selected' => $custom_value,
|
|
|
|
'nothing' => __('No change'),
|
|
|
|
'nothing_value' => '',
|
|
|
|
'return' => true,
|
|
|
|
'sort' => false,
|
|
|
|
]
|
2019-03-07 13:37:36 +01:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
array_push($table->data, $data);
|
2010-09-29 12:28:10 +02:00
|
|
|
}
|
|
|
|
|
2022-07-14 16:06:51 +02:00
|
|
|
if (empty($fields) === false) {
|
|
|
|
ui_toggle(
|
|
|
|
html_print_table($table, true),
|
|
|
|
__('Custom fields')
|
|
|
|
);
|
2010-09-29 12:28:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
echo '<h3 class="error invisible" id="message"> </h3>';
|
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
html_print_input_hidden('id_agente', $id_agente);
|
2010-09-29 12:28:10 +02:00
|
|
|
|
2021-06-07 13:38:07 +02:00
|
|
|
attachActionButton('update_agents', 'update', $table->width);
|
2021-02-12 11:28:13 +01:00
|
|
|
|
2021-06-07 13:38:07 +02:00
|
|
|
// Shown and hide div.
|
2010-09-29 12:28:10 +02:00
|
|
|
echo '</div></form>';
|
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
ui_require_jquery_file('form');
|
|
|
|
ui_require_jquery_file('pandora.controls');
|
|
|
|
ui_require_jquery_file('ajaxqueue');
|
|
|
|
ui_require_jquery_file('bgiframe');
|
2010-09-29 12:28:10 +02:00
|
|
|
?>
|
|
|
|
<script type="text/javascript">
|
|
|
|
/* <![CDATA[ */
|
2014-12-02 16:38:07 +01:00
|
|
|
|
2015-02-04 11:18:34 +01:00
|
|
|
var limit_parameters_massive = <?php echo $config['limit_parameters_massive']; ?>;
|
|
|
|
|
2010-09-29 12:28:10 +02:00
|
|
|
//Use this function for change 3 icons when change the selectbox
|
|
|
|
$(document).ready (function () {
|
2022-07-14 16:06:51 +02:00
|
|
|
// Check Metaconsole.
|
|
|
|
var metaconsole = '<?php echo (is_metaconsole() === true) ? 1 : 0; ?>';
|
|
|
|
form_controls_massive_operations_agents(metaconsole);
|
|
|
|
|
|
|
|
$("#id_group").change (function () {
|
|
|
|
$("#form_agents").attr("style", "display: none");
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#id_agents').on('change', function() {
|
|
|
|
var idAgents = Array();
|
|
|
|
jQuery.each ($("#id_agents option:selected"), function (i, val) {
|
|
|
|
idAgents.push($(val).val());
|
|
|
|
});
|
|
|
|
jQuery.post (
|
|
|
|
"ajax.php",
|
|
|
|
{
|
|
|
|
"page" : "godmode/massive/massive_edit_agents",
|
|
|
|
"get_n_conf_files" : 1,
|
|
|
|
"id_agents[]" : idAgents
|
|
|
|
},
|
|
|
|
function (data, status) {
|
|
|
|
if (data == 0) {
|
|
|
|
$("#delete_configurations").attr("style", "display: none");
|
|
|
|
$("#not_available_configurations").attr("style", "");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$("#n_configurations").text(data);
|
|
|
|
$("#not_available_configurations").attr("style", "display: none");
|
|
|
|
$("#delete_configurations").attr("style", "");
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"json"
|
|
|
|
);
|
|
|
|
$("#form_agents").attr("style", "");
|
|
|
|
|
|
|
|
if($("#safe_mode_change").val() == 1) {
|
|
|
|
refreshSafeModules();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$("select#id_os").pandoraSelectOS();
|
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
var checked = $("#cascade_protection").val();
|
|
|
|
$("#cascade_protection_module").attr("disabled", 'disabled');
|
|
|
|
|
|
|
|
$("#cascade_protection").change(function () {
|
|
|
|
var checked = $("#cascade_protection").val();
|
|
|
|
|
|
|
|
if (checked == 1) {
|
|
|
|
$("#cascade_protection_module").removeAttr("disabled");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$("#cascade_protection_module").val(0);
|
|
|
|
$("#cascade_protection_module").attr("disabled", 'disabled');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-11-26 16:44:53 +01:00
|
|
|
// Enable Safe Operation Mode if 'Enabled' is selected.
|
|
|
|
$("#safe_mode_module").attr("disabled", "disabled");
|
|
|
|
$("#safe_mode_change").on('change', function() {
|
|
|
|
if ($("#safe_mode_change").val() == 1) {
|
|
|
|
$("#safe_mode_module").removeAttr("disabled");
|
|
|
|
refreshSafeModules();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$("#safe_mode_module").attr("disabled", "disabled");
|
|
|
|
$('#safe_mode_module').empty();
|
|
|
|
$("#safe_mode_module").append($("<option></option>").attr("value", 'Any').html('Any'));
|
2022-01-24 12:19:09 +01:00
|
|
|
}
|
2019-11-26 16:44:53 +01:00
|
|
|
});
|
2022-01-24 12:19:09 +01:00
|
|
|
|
2019-11-26 16:44:53 +01:00
|
|
|
// Fill modules in Safe Operation Mode.
|
|
|
|
function refreshSafeModules(){
|
|
|
|
var idAgents = Array();
|
|
|
|
jQuery.each ($("#id_agents option:selected"), function (i, val) {
|
|
|
|
idAgents.push($(val).val());
|
|
|
|
});
|
|
|
|
|
|
|
|
var params = {
|
|
|
|
"page" : "operation/agentes/ver_agente",
|
|
|
|
"get_agent_modules_json_for_multiple_agents" : 1,
|
|
|
|
"id_agent" : idAgents,
|
|
|
|
"selection_mode": "common"
|
|
|
|
};
|
2022-01-24 12:19:09 +01:00
|
|
|
|
2019-11-26 16:44:53 +01:00
|
|
|
jQuery.post ("ajax.php",
|
|
|
|
params,
|
|
|
|
function (data, status) {
|
|
|
|
$('#safe_mode_module').empty();
|
|
|
|
if($.type(data) === "object"){
|
|
|
|
jQuery.each (data, function (id, value) {
|
|
|
|
option = $("<option></option>").attr("value", value).html(value);
|
|
|
|
$("#safe_mode_module").append(option);
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
option = $("<option></option>").attr("value", 'None').html('None');
|
|
|
|
$("#safe_mode_module").append(option);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"json"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-07-14 16:06:51 +02:00
|
|
|
|
|
|
|
/*
|
2019-01-30 16:18:44 +01:00
|
|
|
$("#form_agent").submit(function() {
|
|
|
|
var get_parameters_count = window.location.href.slice(
|
|
|
|
window.location.href.indexOf('?') + 1).split('&').length;
|
|
|
|
var post_parameters_count = $("#form_agent").serializeArray().length;
|
2022-01-24 12:19:09 +01:00
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
var count_parameters =
|
|
|
|
get_parameters_count + post_parameters_count;
|
2022-01-24 12:19:09 +01:00
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
if (count_parameters > limit_parameters_massive) {
|
|
|
|
alert("<?php echo __('Unsucessful sending the data, please contact with your administrator or make with less elements.'); ?>");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
2022-07-14 16:06:51 +02:00
|
|
|
*/
|
2022-01-24 12:19:09 +01:00
|
|
|
|
2022-03-10 20:06:45 +01:00
|
|
|
$("#secondary_groups_added").change(
|
|
|
|
function() {
|
|
|
|
var groups = $("#secondary_groups_added").val();
|
|
|
|
var groups_selected = $("#secondary_groups_removed").val();
|
|
|
|
jQuery.post (
|
|
|
|
"ajax.php",
|
|
|
|
{
|
|
|
|
"page" : "godmode/massive/massive_edit_agents",
|
|
|
|
"groups_secondary_selected" : 1,
|
|
|
|
"groups" : groups
|
|
|
|
},
|
|
|
|
function (data, status) {
|
|
|
|
$('#secondary_groups_removed').empty();
|
|
|
|
$('#secondary_groups_removed').val(null).trigger("change");
|
|
|
|
if($.type(data) === "object"){
|
|
|
|
jQuery.each (data, function (id, value) {
|
|
|
|
option = $("<option></option>").attr("value", id).html(value);
|
|
|
|
if (inArray(id, groups_selected) === true) {
|
|
|
|
option.attr("selected", true);
|
|
|
|
}
|
|
|
|
$("#secondary_groups_removed").append(option).trigger("change");
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
option = $("<option></option>").attr("value", '').html('None');
|
|
|
|
$("#secondary_groups_removed").append(option).trigger("change");
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"json"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|
2010-09-29 12:28:10 +02:00
|
|
|
});
|
2012-04-04 14:58:46 +02:00
|
|
|
|
|
|
|
function changeIcons() {
|
2019-01-30 16:18:44 +01:00
|
|
|
var icon = $("#icon_path :selected").val();
|
2022-01-24 12:19:09 +01:00
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
$("#icon_without_status").attr("src", "images/spinner.png");
|
|
|
|
$("#icon_default").attr("src", "images/spinner.png");
|
|
|
|
$("#icon_ok").attr("src", "images/spinner.png");
|
|
|
|
$("#icon_bad").attr("src", "images/spinner.png");
|
|
|
|
$("#icon_warning").attr("src", "images/spinner.png");
|
2022-01-24 12:19:09 +01:00
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
if (icon.length == 0) {
|
|
|
|
$("#icon_without_status").attr("style", "display:none;");
|
|
|
|
$("#icon_default").attr("style", "display:none;");
|
|
|
|
$("#icon_ok").attr("style", "display:none;");
|
|
|
|
$("#icon_bad").attr("style", "display:none;");
|
|
|
|
$("#icon_warning").attr("style", "display:none;");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$("#icon_without_status").attr("src",
|
|
|
|
"<?php echo $path; ?>" + icon + ".default.png");
|
|
|
|
$("#icon_default").attr("src",
|
|
|
|
"<?php echo $path; ?>" + icon + ".default.png");
|
|
|
|
$("#icon_ok").attr("src",
|
|
|
|
"<?php echo $path; ?>" + icon + ".ok.png");
|
|
|
|
$("#icon_bad").attr("src",
|
|
|
|
"<?php echo $path; ?>" + icon + ".bad.png");
|
|
|
|
$("#icon_warning").attr("src",
|
|
|
|
"<?php echo $path; ?>" + icon + ".warning.png");
|
|
|
|
$("#icon_without_status").attr("style", "");
|
|
|
|
$("#icon_default").attr("style", "");
|
|
|
|
$("#icon_ok").attr("style", "");
|
|
|
|
$("#icon_bad").attr("style", "");
|
|
|
|
$("#icon_warning").attr("style", "");
|
|
|
|
}
|
2012-04-04 14:58:46 +02:00
|
|
|
}
|
2010-09-29 12:28:10 +02:00
|
|
|
</script>
|