2013-08-29 Miguel de Dios <miguel.dedios@artica.es>

* include/functions_api.php: added supoport for disabled unknown
	events modules, components and policies.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8711 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2013-08-29 07:48:10 +00:00
parent a87218f09e
commit 967e978fea
2 changed files with 341 additions and 136 deletions

View File

@ -1,3 +1,8 @@
2013-08-29 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_api.php: added supoport for disabled unknown
events modules, components and policies.
2013-08-28 Miguel de Dios <miguel.dedios@artica.es> 2013-08-28 Miguel de Dios <miguel.dedios@artica.es>
* godmode/agentes/module_manager_editor_common.php: added code to * godmode/agentes/module_manager_editor_common.php: added code to

View File

@ -1229,17 +1229,23 @@ function api_set_create_network_module($id, $thrash1, $other, $thrash3) {
$idAgent = agents_get_agent_id($agentName); $idAgent = agents_get_agent_id($agentName);
if (!$idAgent) { if (!$idAgent) {
returnError('error_create_network_module', __('Error in creation network module. Agent name doesn\'t exists.')); returnError('error_create_network_module',
__('Error in creation network module. Agent name doesn\'t exists.'));
return; return;
} }
if ($other['data'][2] < 6 or $other['data'][2] > 18) { if ($other['data'][2] < 6 or $other['data'][2] > 18) {
returnError('error_create_network_module', __('Error in creation network module. Id_module_type is not correct for network modules.')); returnError('error_create_network_module',
__('Error in creation network module. Id_module_type is not correct for network modules.'));
return; return;
} }
$name = $other['data'][0]; $name = $other['data'][0];
$disabled_types_event = array();
$disabled_types_event[EVENTS_GOING_UNKNOWN] = (int)!$other['data'][22]);
$disabled_types_event = json_encode($disabled_types_event);
$values = array( $values = array(
'id_agente' => $idAgent, 'id_agente' => $idAgent,
'disabled' => $other['data'][1], 'disabled' => $other['data'][1],
@ -1263,7 +1269,8 @@ function api_set_create_network_module($id, $thrash1, $other, $thrash3) {
'max' => $other['data'][19], 'max' => $other['data'][19],
'custom_id' => $other['data'][20], 'custom_id' => $other['data'][20],
'descripcion' => $other['data'][21], 'descripcion' => $other['data'][21],
'id_modulo' => 2 'id_modulo' => 2,
'disabled_types_event' => $disabled_types_event
); );
$idModule = modules_create_agent_module($idAgent, $name, $values, true); $idModule = modules_create_agent_module($idAgent, $name, $values, true);
@ -1316,15 +1323,35 @@ function api_set_update_network_module($id_module, $thrash1, $other, $thrash3){
$id_module_exists = db_get_value_filter ('id_agente_modulo', 'tagente_modulo', array('nombre' => $module_name, 'id_agente' => $other['data'][0])); $id_module_exists = db_get_value_filter ('id_agente_modulo', 'tagente_modulo', array('nombre' => $module_name, 'id_agente' => $other['data'][0]));
if ($id_module_exists){ if ($id_module_exists){
returnError('error_update_network_module', __('Error updating network module. Id_module exists in the new agent.')); returnError('error_update_network_module',
__('Error updating network module. Id_module exists in the new agent.'));
return; return;
} }
} }
} }
$network_module_fields = array('id_agente', 'disabled', 'id_module_group', 'min_warning', 'max_warning', 'str_warning', $network_module_fields = array('id_agente',
'min_critical', 'max_critical', 'str_critical', 'min_ff_event', 'history_data', 'ip_target', 'tcp_port', 'snmp_community', 'disabled',
'snmp_oid', 'module_interval', 'post_process', 'min', 'max', 'custom_id', 'descripcion'); 'id_module_group',
'min_warning',
'max_warning',
'str_warning',
'min_critical',
'max_critical',
'str_critical',
'min_ff_event',
'history_data',
'ip_target',
'tcp_port',
'snmp_community',
'snmp_oid',
'module_interval',
'post_process',
'min',
'max',
'custom_id',
'descripcion',
'disabled_types_event');
$values = array(); $values = array();
$cont = 0; $cont = 0;
@ -1375,6 +1402,10 @@ function api_set_create_plugin_module($id, $thrash1, $other, $thrash3) {
return; return;
} }
$disabled_types_event = array();
$disabled_types_event[EVENTS_GOING_UNKNOWN] = (int)!$other['data'][26]);
$disabled_types_event = json_encode($disabled_types_event);
$name = $other['data'][0]; $name = $other['data'][0];
$values = array( $values = array(
@ -1404,7 +1435,8 @@ function api_set_create_plugin_module($id, $thrash1, $other, $thrash3) {
'id_plugin' => $other['data'][22], 'id_plugin' => $other['data'][22],
'plugin_user' => $other['data'][23], 'plugin_user' => $other['data'][23],
'plugin_pass' => $other['data'][24], 'plugin_pass' => $other['data'][24],
'plugin_parameter' => $other['data'][25] 'plugin_parameter' => $other['data'][25],
'disabled_types_event' => $disabled_types_event
); );
$idModule = modules_create_agent_module($idAgent, $name, $values, true); $idModule = modules_create_agent_module($idAgent, $name, $values, true);
@ -1462,10 +1494,32 @@ function api_set_update_plugin_module($id_module, $thrash1, $other, $thrash3){
} }
} }
$plugin_module_fields = array('id_agente', 'disabled', 'id_module_group', 'min_warning', 'max_warning', 'str_warning', $plugin_module_fields = array('id_agente',
'min_critical', 'max_critical', 'str_critical', 'min_ff_event', 'history_data', 'ip_target', 'disabled',
'tcp_port', 'snmp_community', 'snmp_oid', 'module_interval', 'post_process', 'min', 'max', 'id_module_group',
'custom_id', 'descripcion', 'id_plugin', 'plugin_user', 'plugin_pass', 'plugin_parameter'); 'min_warning',
'max_warning',
'str_warning',
'min_critical',
'max_critical',
'str_critical',
'min_ff_event',
'history_data',
'ip_target',
'tcp_port',
'snmp_community',
'snmp_oid',
'module_interval',
'post_process',
'min',
'max',
'custom_id',
'descripcion',
'id_plugin',
'plugin_user',
'plugin_pass',
'plugin_parameter',
'disabled_types_event');
$values = array(); $values = array();
$cont = 0; $cont = 0;
@ -1518,6 +1572,10 @@ function api_set_create_data_module($id, $thrash1, $other, $thrash3) {
$name = $other['data'][0]; $name = $other['data'][0];
$disabled_types_event = array();
$disabled_types_event[EVENTS_GOING_UNKNOWN] = (int)!$other['data'][16]);
$disabled_types_event = json_encode($disabled_types_event);
$values = array( $values = array(
'id_agente' => $idAgent, 'id_agente' => $idAgent,
'disabled' => $other['data'][1], 'disabled' => $other['data'][1],
@ -1535,7 +1593,8 @@ function api_set_create_data_module($id, $thrash1, $other, $thrash3) {
'max_critical' => $other['data'][13], 'max_critical' => $other['data'][13],
'str_critical' => $other['data'][14], 'str_critical' => $other['data'][14],
'history_data' => $other['data'][15], 'history_data' => $other['data'][15],
'id_modulo' => 1 'id_modulo' => 1,
'disabled_types_event' => $disabled_types_event
); );
$idModule = modules_create_agent_module($idAgent, $name, $values, true); $idModule = modules_create_agent_module($idAgent, $name, $values, true);
@ -1594,9 +1653,22 @@ function api_set_update_data_module($id_module, $thrash1, $other, $thrash3){
} }
} }
$data_module_fields = array('id_agente', 'disabled', 'descripcion', 'id_module_group', 'min', 'max', $data_module_fields = array('id_agente',
'post_process', 'module_interval', 'min_warning', 'max_warning', 'str_warning', 'min_critical', 'max_critical', 'str_critical', 'disabled',
'history_data'); 'descripcion',
'id_module_group',
'min',
'max',
'post_process',
'module_interval',
'min_warning',
'max_warning',
'str_warning',
'min_critical',
'max_critical',
'str_critical',
'history_data',
'disabled_types_event');
$values = array(); $values = array();
$cont = 0; $cont = 0;
@ -1662,6 +1734,11 @@ function api_set_create_snmp_module($id, $thrash1, $other, $thrash3) {
$name = $other['data'][0]; $name = $other['data'][0];
$disabled_types_event = array();
$disabled_types_event[EVENTS_GOING_UNKNOWN] = (int)!$other['data'][27]);
$disabled_types_event = json_encode($disabled_types_event);
# SNMP version 3 # SNMP version 3
if ($other['data'][14] == "3") { if ($other['data'][14] == "3") {
@ -1710,7 +1787,8 @@ function api_set_create_snmp_module($id, $thrash1, $other, $thrash3) {
'custom_string_3' => $other['data'][25], 'custom_string_3' => $other['data'][25],
'plugin_parameter' => $other['data'][26], 'plugin_parameter' => $other['data'][26],
'plugin_user' => $other['data'][27], 'plugin_user' => $other['data'][27],
'plugin_pass' => $other['data'][28] 'plugin_pass' => $other['data'][28],
'disabled_types_event' => $disabled_types_event
); );
} }
else { else {
@ -1738,7 +1816,8 @@ function api_set_create_snmp_module($id, $thrash1, $other, $thrash3) {
'max' => $other['data'][20], 'max' => $other['data'][20],
'custom_id' => $other['data'][21], 'custom_id' => $other['data'][21],
'descripcion' => $other['data'][22], 'descripcion' => $other['data'][22],
'id_modulo' => 2 'id_modulo' => 2,
'disabled_types_event' => $disabled_types_event
); );
} }
@ -1818,15 +1897,60 @@ function api_set_update_snmp_module($id_module, $thrash1, $other, $thrash3) {
return; return;
} }
$snmp_module_fields = array('id_agente', 'disabled', 'id_module_group', 'min_warning', 'max_warning', 'str_warning', $snmp_module_fields = array('id_agente',
'min_critical', 'max_critical', 'str_critical', 'min_ff_event', 'history_data', 'ip_target', 'tcp_port', 'tcp_send', 'disabled',
'snmp_community', 'snmp_oid', 'module_interval', 'post_process', 'min', 'max', 'custom_id', 'descripcion', 'custom_string_1', 'id_module_group',
'custom_string_2', 'custom_string_3', 'plugin_parameter', 'plugin_user', 'plugin_pass'); 'min_warning',
'max_warning',
'str_warning',
'min_critical',
'max_critical',
'str_critical',
'min_ff_event',
'history_data',
'ip_target',
'tcp_port',
'tcp_send',
'snmp_community',
'snmp_oid',
'module_interval',
'post_process',
'min',
'max',
'custom_id',
'descripcion',
'custom_string_1',
'custom_string_2',
'custom_string_3',
'plugin_parameter',
'plugin_user',
'plugin_pass',
'disabled_types_event');
} }
else { else {
$snmp_module_fields = array('id_agente', 'disabled', 'id_module_group', 'min_warning', 'max_warning', 'str_warning', $snmp_module_fields = array('id_agente',
'min_critical', 'max_critical', 'str_critical', 'min_ff_event', 'history_data', 'ip_target', 'tcp_port', 'tcp_send', 'disabled',
'snmp_community', 'snmp_oid', 'module_interval', 'post_process', 'min', 'max', 'custom_id', 'descripcion'); 'id_module_group',
'min_warning',
'max_warning',
'str_warning',
'min_critical',
'max_critical',
'str_critical',
'min_ff_event',
'history_data',
'ip_target',
'tcp_port',
'tcp_send',
'snmp_community',
'snmp_oid',
'module_interval',
'post_process',
'min',
'max',
'custom_id',
'descripcion',
'disabled_types_event');
} }
$values = array(); $values = array();
@ -1882,6 +2006,10 @@ function api_set_new_network_component($id, $thrash1, $other, $thrash2) {
return; return;
} }
$disabled_types_event = array();
$disabled_types_event[EVENTS_GOING_UNKNOWN] = (int)!$other['data'][18]);
$disabled_types_event = json_encode($disabled_types_event);
$values = array ( $values = array (
'description' => $other['data'][1], 'description' => $other['data'][1],
'module_interval' => $other['data'][2], 'module_interval' => $other['data'][2],
@ -1901,7 +2029,7 @@ function api_set_new_network_component($id, $thrash1, $other, $thrash2) {
'min_ff_event' => $other['data'][15], 'min_ff_event' => $other['data'][15],
'post_process' => $other['data'][16], 'post_process' => $other['data'][16],
'max_retries' => $other['data'][17], 'max_retries' => $other['data'][17],
); 'disabled_types_event' => $disabled_types_event);
$name_check = db_get_value ('name', 'tnetwork_component', 'name', $id); $name_check = db_get_value ('name', 'tnetwork_component', 'name', $id);
@ -1953,6 +2081,10 @@ function api_set_new_plugin_component($id, $thrash1, $other, $thrash2) {
return; return;
} }
$disabled_types_event = array();
$disabled_types_event[EVENTS_GOING_UNKNOWN] = (int)!$other['data'][12]);
$disabled_types_event = json_encode($disabled_types_event);
$values = array ( $values = array (
'description' => $other['data'][1], 'description' => $other['data'][1],
'module_interval' => $other['data'][2], 'module_interval' => $other['data'][2],
@ -1975,7 +2107,8 @@ function api_set_new_plugin_component($id, $thrash1, $other, $thrash2) {
'str_critical' => $other['data'][18], 'str_critical' => $other['data'][18],
'min_ff_event' => $other['data'][19], 'min_ff_event' => $other['data'][19],
'post_process' => $other['data'][20], 'post_process' => $other['data'][20],
'max_retries' => $other['data'][11]); 'max_retries' => $other['data'][11],
'disabled_types_event' => $disabled_types_event);
$name_check = db_get_value ('name', 'tnetwork_component', 'name', $id); $name_check = db_get_value ('name', 'tnetwork_component', 'name', $id);
@ -2028,6 +2161,10 @@ function api_set_new_snmp_component($id, $thrash1, $other, $thrash2) {
return; return;
} }
$disabled_types_event = array();
$disabled_types_event[EVENTS_GOING_UNKNOWN] = (int)!$other['data'][27]);
$disabled_types_event = json_encode($disabled_types_event);
# SNMP version 3 # SNMP version 3
if ($other['data'][16] == "3") { if ($other['data'][16] == "3") {
@ -2074,6 +2211,7 @@ function api_set_new_snmp_component($id, $thrash1, $other, $thrash2) {
'plugin_parameter' => $other['data'][24], // snmp3_auth_method 'plugin_parameter' => $other['data'][24], // snmp3_auth_method
'custom_string_3' => $other['data'][25], // snmp3_security_level 'custom_string_3' => $other['data'][25], // snmp3_security_level
'max_retries' => $other['data'][26], 'max_retries' => $other['data'][26],
'disabled_types_event' => $disabled_types_event
); );
} }
else { else {
@ -2101,6 +2239,7 @@ function api_set_new_snmp_component($id, $thrash1, $other, $thrash2) {
'tcp_port' => $other['data'][21], 'tcp_port' => $other['data'][21],
'id_modulo' => 2, 'id_modulo' => 2,
'max_retries' => $other['data'][22], 'max_retries' => $other['data'][22],
'disabled_types_event' => $disabled_types_event
); );
} }
@ -2138,33 +2277,43 @@ function api_set_new_snmp_component($id, $thrash1, $other, $thrash2) {
function api_set_new_local_component($id, $thrash1, $other, $thrash2) { function api_set_new_local_component($id, $thrash1, $other, $thrash2) {
if ($id == "") { if ($id == "") {
returnError('error_set_new_local_component', __('Error creating local component. Local component name cannot be left blank.')); returnError('error_set_new_local_component',
__('Error creating local component. Local component name cannot be left blank.'));
return; return;
} }
if ($other['data'][1] == "") { if ($other['data'][1] == "") {
returnError('error_set_new_local_component', __('Error creating local component. Local component group cannot be left blank.')); returnError('error_set_new_local_component',
__('Error creating local component. Local component group cannot be left blank.'));
return; return;
} }
$disabled_types_event = array();
$disabled_types_event[EVENTS_GOING_UNKNOWN] = (int)!$other['data'][4]);
$disabled_types_event = json_encode($disabled_types_event);
$values = array ( $values = array (
'description' => $other['data'][0], 'description' => $other['data'][0],
'id_network_component_group' => $other['data'][1] 'id_network_component_group' => $other['data'][1],
); 'disabled_types_event' => $disabled_types_event);
$name_check = enterprise_hook('local_components_get_local_components', array(array('name' => $id), 'name')); $name_check = enterprise_hook('local_components_get_local_components',
array(array('name' => $id), 'name'));
if ($name_check === ENTERPRISE_NOT_HOOK) { if ($name_check === ENTERPRISE_NOT_HOOK) {
returnError('error_set_new_local_component', __('Error creating local component.')); returnError('error_set_new_local_component',
__('Error creating local component.'));
return; return;
} }
if ($name_check !== false) { if ($name_check !== false) {
returnError('error_set_new_local_component', __('Error creating local component. This local component already exists.')); returnError('error_set_new_local_component',
__('Error creating local component. This local component already exists.'));
return; return;
} }
$id = enterprise_hook('local_components_create_local_component', array($id, $other['data'][3], $other['data'][1], $values)); $id = enterprise_hook('local_components_create_local_component',
array($id, $other['data'][3], $other['data'][1], $values));
if (!$id) if (!$id)
returnError('error_set_new_local_component', 'Error creating local component.'); returnError('error_set_new_local_component', 'Error creating local component.');
@ -2997,6 +3146,10 @@ function api_set_add_data_module_policy($id, $thrash1, $other, $thrash3) {
return; return;
} }
$disabled_types_event = array();
$disabled_types_event[EVENTS_GOING_UNKNOWN] = (int)!$other['data'][16]);
$disabled_types_event = json_encode($disabled_types_event);
$values = array(); $values = array();
$values['id_tipo_modulo'] = $other['data'][1]; $values['id_tipo_modulo'] = $other['data'][1];
$values['description'] = $other['data'][2]; $values['description'] = $other['data'][2];
@ -3013,15 +3166,18 @@ function api_set_add_data_module_policy($id, $thrash1, $other, $thrash3) {
$values['str_critical'] = $other['data'][13]; $values['str_critical'] = $other['data'][13];
$values['history_data'] = $other['data'][14]; $values['history_data'] = $other['data'][14];
$values['configuration_data'] = $other['data'][15]; $values['configuration_data'] = $other['data'][15];
$values['disabled_types_event'] = $disabled_types_event;
if ($name_module_policy !== false) { if ($name_module_policy !== false) {
if ($name_module_policy[0]['name'] == $other['data'][0]) { if ($name_module_policy[0]['name'] == $other['data'][0]) {
returnError('error_add_data_module_policy', __('Error adding data module to policy. The module is already in the policy.')); returnError('error_add_data_module_policy',
__('Error adding data module to policy. The module is already in the policy.'));
return; return;
} }
} }
$success = enterprise_hook('policies_create_module', array($other['data'][0], $id, 1, $values, false)); $success = enterprise_hook('policies_create_module',
array($other['data'][0], $id, 1, $values, false));
if ($success) if ($success)
//returnData('string', array('type' => 'string', 'data' => __('Data module added to policy. Is necessary to apply the policy in order to changes take effect.'))); //returnData('string', array('type' => 'string', 'data' => __('Data module added to policy. Is necessary to apply the policy in order to changes take effect.')));
@ -3115,28 +3271,37 @@ function api_set_update_data_module_policy($id, $thrash1, $other, $thrash3) {
*/ */
function api_set_add_network_module_policy($id, $thrash1, $other, $thrash3) { function api_set_add_network_module_policy($id, $thrash1, $other, $thrash3) {
if ($id == "") { if ($id == "") {
returnError('error_network_data_module_policy', __('Error adding network module to policy. Id_policy cannot be left blank.')); returnError('error_network_data_module_policy',
__('Error adding network module to policy. Id_policy cannot be left blank.'));
return; return;
} }
if ($other['data'][0] == "") { if ($other['data'][0] == "") {
returnError('error_network_data_module_policy', __('Error adding network module to policy. Module_name cannot be left blank.')); returnError('error_network_data_module_policy',
__('Error adding network module to policy. Module_name cannot be left blank.'));
return; return;
} }
if ($other['data'][1] < 6 or $other['data'][1] > 18) { if ($other['data'][1] < 6 or $other['data'][1] > 18) {
returnError('error_network_data_module_policy', __('Error adding network module to policy. Id_module_type is not correct for network modules.')); returnError('error_network_data_module_policy',
__('Error adding network module to policy. Id_module_type is not correct for network modules.'));
return; return;
} }
// Check if the module is already in the policy // Check if the module is already in the policy
$name_module_policy = enterprise_hook('policies_get_modules', array($id, array('name'=>$other['data'][0]), 'name')); $name_module_policy = enterprise_hook('policies_get_modules',
array($id, array('name'=>$other['data'][0]), 'name'));
if ($name_module_policy === ENTERPRISE_NOT_HOOK) { if ($name_module_policy === ENTERPRISE_NOT_HOOK) {
returnError('error_network_data_module_policy', __('Error adding network module to policy.')); returnError('error_network_data_module_policy',
__('Error adding network module to policy.'));
return; return;
} }
$disabled_types_event = array();
$disabled_types_event[EVENTS_GOING_UNKNOWN] = (int)!$other['data'][21]);
$disabled_types_event = json_encode($disabled_types_event);
$values = array(); $values = array();
$values['id_tipo_modulo'] = $other['data'][1]; $values['id_tipo_modulo'] = $other['data'][1];
$values['description'] = $other['data'][2]; $values['description'] = $other['data'][2];
@ -3158,6 +3323,7 @@ function api_set_add_network_module_policy($id, $thrash1, $other, $thrash3) {
$values['snmp_community'] = $other['data'][18]; $values['snmp_community'] = $other['data'][18];
$values['snmp_oid'] = $other['data'][19]; $values['snmp_oid'] = $other['data'][19];
$values['custom_id'] = $other['data'][20]; $values['custom_id'] = $other['data'][20];
$values['disabled_types_event'] = $disabled_types_event;
if ($name_module_policy !== false) { if ($name_module_policy !== false) {
if ($name_module_policy[0]['name'] == $other['data'][0]){ if ($name_module_policy[0]['name'] == $other['data'][0]){
@ -3194,12 +3360,14 @@ function api_set_add_network_module_policy($id, $thrash1, $other, $thrash3) {
*/ */
function api_set_update_network_module_policy($id, $thrash1, $other, $thrash3) { function api_set_update_network_module_policy($id, $thrash1, $other, $thrash3) {
if ($id == "") { if ($id == "") {
returnError('error_update_network_module_policy', __('Error updating network module in policy. Id_policy cannot be left blank.')); returnError('error_update_network_module_policy',
__('Error updating network module in policy. Id_policy cannot be left blank.'));
return; return;
} }
if ($other['data'][0] == "") { if ($other['data'][0] == "") {
returnError('error_update_network_module_policy', __('Error updating network module in policy. Id_policy_module cannot be left blank.')); returnError('error_update_network_module_policy',
__('Error updating network module in policy. Id_policy_module cannot be left blank.'));
return; return;
} }
@ -3207,12 +3375,14 @@ function api_set_update_network_module_policy($id, $thrash1, $other, $thrash3) {
$module_policy = enterprise_hook('policies_get_modules', array($id, array('id' => $other['data'][0]), 'id_module')); $module_policy = enterprise_hook('policies_get_modules', array($id, array('id' => $other['data'][0]), 'id_module'));
if ($module_policy === false) { if ($module_policy === false) {
returnError('error_update_network_module_policy', __('Error updating network module in policy. Module doesn\'t exists.')); returnError('error_update_network_module_policy',
__('Error updating network module in policy. Module doesn\'t exists.'));
return; return;
} }
if ($module_policy[0]['id_module'] != 2) { if ($module_policy[0]['id_module'] != 2) {
returnError('error_update_network_module_policy', __('Error updating network module in policy. Module type is not network type.')); returnError('error_update_network_module_policy',
__('Error updating network module in policy. Module type is not network type.'));
return; return;
} }
@ -3281,6 +3451,10 @@ function api_set_add_plugin_module_policy($id, $thrash1, $other, $thrash3) {
return; return;
} }
$disabled_types_event = array();
$disabled_types_event[EVENTS_GOING_UNKNOWN] = (int)!$other['data'][25]);
$disabled_types_event = json_encode($disabled_types_event);
$values = array(); $values = array();
$values['disabled'] = $other['data'][1]; $values['disabled'] = $other['data'][1];
$values['id_tipo_modulo'] = $other['data'][2]; $values['id_tipo_modulo'] = $other['data'][2];
@ -3306,6 +3480,7 @@ function api_set_add_plugin_module_policy($id, $thrash1, $other, $thrash3) {
$values['plugin_user'] = $other['data'][22]; $values['plugin_user'] = $other['data'][22];
$values['plugin_pass'] = $other['data'][23]; $values['plugin_pass'] = $other['data'][23];
$values['plugin_parameter'] = $other['data'][24]; $values['plugin_parameter'] = $other['data'][24];
$values['disabled_types_event'] = $disabled_types_event;
if ($name_module_policy !== false) { if ($name_module_policy !== false) {
if ($name_module_policy[0]['name'] == $other['data'][0]) { if ($name_module_policy[0]['name'] == $other['data'][0]) {
@ -3566,6 +3741,10 @@ function api_set_add_snmp_module_policy($id, $thrash1, $other, $thrash3) {
return; return;
} }
$disabled_types_event = array();
$disabled_types_event[EVENTS_GOING_UNKNOWN] = (int)!$other['data'][28]);
$disabled_types_event = json_encode($disabled_types_event);
# SNMP version 3 # SNMP version 3
if ($other['data'][13] == "3") { if ($other['data'][13] == "3") {
@ -3611,7 +3790,8 @@ function api_set_add_snmp_module_policy($id, $thrash1, $other, $thrash3) {
'custom_string_3' => $other['data'][24], 'custom_string_3' => $other['data'][24],
'plugin_parameter' => $other['data'][25], 'plugin_parameter' => $other['data'][25],
'plugin_user' => $other['data'][26], 'plugin_user' => $other['data'][26],
'plugin_pass' => $other['data'][27] 'plugin_pass' => $other['data'][27],
'disabled_types_event' => $disabled_types_event
); );
} }
else { else {
@ -3636,7 +3816,8 @@ function api_set_add_snmp_module_policy($id, $thrash1, $other, $thrash3) {
'min' => $other['data'][18], 'min' => $other['data'][18],
'max' => $other['data'][19], 'max' => $other['data'][19],
'custom_id' => $other['data'][20], 'custom_id' => $other['data'][20],
'description' => $other['data'][21] 'description' => $other['data'][21],
'disabled_types_event' => $disabled_types_event
); );
} }
@ -4139,19 +4320,31 @@ function api_set_new_user($id, $thrash2, $other, $thrash3) {
*/ */
function api_set_update_user($id, $thrash2, $other, $thrash3) { function api_set_update_user($id, $thrash2, $other, $thrash3) {
$fields_user = array('fullname', 'firstname', 'lastname', 'middlename', 'password', 'email', $fields_user = array('fullname',
'phone', 'language', 'comments', 'is_admin', 'block_size', 'flash_chart'); 'firstname',
'lastname',
'middlename',
'password',
'email',
'phone',
'language',
'comments',
'is_admin',
'block_size',
'flash_chart');
if ($id == "") { if ($id == "") {
returnError('error_update_user', __('Error updating user. Id_user cannot be left blank.')); returnError('error_update_user',
__('Error updating user. Id_user cannot be left blank.'));
return; return;
} }
$result_user = users_get_user_by_id($id); $result_user = users_get_user_by_id($id);
if (!$result_user) { if (!$result_user) {
returnError('error_update_user', __('Error updating user. Id_user doesn\'t exists.')); returnError('error_update_user',
__('Error updating user. Id_user doesn\'t exists.'));
return; return;
} }
@ -4625,9 +4818,15 @@ function api_set_new_module($id, $id2, $other, $trash1) {
$values['history_data'] = $other['data'][14]; $values['history_data'] = $other['data'][14];
} }
$disabled_types_event = array();
$disabled_types_event[EVENTS_GOING_UNKNOWN] = (int)!$other['data'][15]);
$disabled_types_event = json_encode($disabled_types_event);
$values['disabled_types_event'] = $disabled_types_event;
$values['id_modulo'] = 2; $values['id_modulo'] = 2;
$return = modules_create_agent_module($values['id_agente'], $values['nombre'], $values); $return = modules_create_agent_module($values['id_agente'],
$values['nombre'], $values);
$data['type'] = 'string'; $data['type'] = 'string';
if ($return === false) { if ($return === false) {
@ -4824,7 +5023,8 @@ function api_set_new_event($trash1, $trash2, $other, $trash3) {
FROM talert_template_modules AS t1 FROM talert_template_modules AS t1
INNER JOIN talert_templates AS t2 INNER JOIN talert_templates AS t2
ON t1.id_alert_template = t2.id ON t1.id_alert_template = t2.id
WHERE t1.id_agent_module = 1 AND t2.name LIKE '" . $other['data'][7] . "'"); WHERE t1.id_agent_module = 1
AND t2.name LIKE '" . $other['data'][7] . "'");
if ($idAlert === false) { if ($idAlert === false) {
returnError('error_parameter', 'Error in the parameters.'); returnError('error_parameter', 'Error in the parameters.');