diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 8c14b30b90..0fc5a4ffac 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,12 @@ +2013-02-28 Miguel de Dios + + * include/functions_config.php: added code to set the config options + for the history actions. + + Fixes: #3606285 + + * include/functions_api.php: improved the source code style. + 2013-02-27 Sergio Martin * include/functions_config.php: Include a library in diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 48e8b99407..da8b03020e 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -3191,44 +3191,51 @@ function api_set_add_plugin_module_policy($id, $thrash1, $other, $thrash3) { * @param $thrash3 Don't use */ function api_set_update_plugin_module_policy($id, $thrash1, $other, $thrash3) { - if ($id == ""){ - returnError('error_update_plugin_module_policy', __('Error updating plugin module in policy. Id_policy cannot be left blank.')); - return; + if ($id == "") { + returnError('error_update_plugin_module_policy', + __('Error updating plugin module in policy. Id_policy cannot be left blank.')); + return; } - if ($other['data'][0] == ""){ - returnError('error_update_plugin_module_policy', __('Error updating plugin module in policy. Id_policy_module cannot be left blank.')); - return; - } + if ($other['data'][0] == "") { + returnError('error_update_plugin_module_policy', + __('Error updating plugin module in policy. Id_policy_module cannot be left blank.')); + return; + } // Check if the module exists $module_policy = enterprise_hook('policies_get_modules', array($id, array('id' => $other['data'][0]), 'id_module')); - + if ($module_policy === false) { - returnError('error_updating_plugin_module_policy', __('Error updating plugin module in policy. Module doesn\'t exists.')); - return; + returnError('error_updating_plugin_module_policy', + __('Error updating plugin module in policy. Module doesn\'t exists.')); + return; } - if ($module_policy[0]['id_module'] != 4){ - returnError('error_updating_plugin_module_policy', __('Error updating plugin module in policy. Module type is not network type.')); - return; + if ($module_policy[0]['id_module'] != 4) { + returnError('error_updating_plugin_module_policy', + __('Error updating plugin module in policy. Module type is not network type.')); + return; } - $fields_plugin_module = array('id','disabled', 'id_module_group', 'min_warning', 'max_warning', 'str_warning', 'min_critical', - 'max_critical', 'str_critical', 'min_ff_event', 'history_data', 'tcp_port', 'snmp_community', - 'snmp_oid', 'module_interval', 'post_process', 'min', 'max', 'custom_id', 'description', 'id_plugin', 'plugin_user', - 'plugin_pass', 'plugin_parameter'); + $fields_plugin_module = array('id','disabled', 'id_module_group', + 'min_warning', 'max_warning', 'str_warning', 'min_critical', + 'max_critical', 'str_critical', 'min_ff_event', 'history_data', + 'tcp_port', 'snmp_community', 'snmp_oid', 'module_interval', + 'post_process', 'min', 'max', 'custom_id', 'description', + 'id_plugin', 'plugin_user', 'plugin_pass', 'plugin_parameter'); $cont = 0; - foreach ($fields_plugin_module as $field){ - if ($other['data'][$cont] != "" and $field != 'id'){ + foreach ($fields_plugin_module as $field) { + if ($other['data'][$cont] != "" and $field != 'id') { $values[$field] = $other['data'][$cont]; } $cont++; } - - $result_update = enterprise_hook('policies_update_module', array($other['data'][0], $values, false)); + + $result_update = enterprise_hook('policies_update_module', + array($other['data'][0], $values, false)); if ($result_update < 0) @@ -3519,27 +3526,27 @@ function api_set_add_snmp_module_policy($id, $thrash1, $other, $thrash3) { * @param $thrash3 Don't use */ function api_set_update_snmp_module_policy($id, $thrash1, $other, $thrash3) { - if ($id == ""){ + if ($id == "") { returnError('error_update_snmp_module_policy', __('Error updating SNMP module in policy. Id_policy cannot be left blank.')); - return; + return; } - if ($other['data'][0] == ""){ + if ($other['data'][0] == "") { returnError('error_update_snmp_module_policy', __('Error updating SNMP module in policy. Id_policy_module cannot be left blank.')); - return; - } + return; + } // Check if the module exists $module_policy = enterprise_hook('policies_get_modules', array($id, array('id' => $other['data'][0]), 'id_module')); - + if ($module_policy === false) { returnError('error_update_snmp_module_policy', __('Error updating SNMP 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_snmp_module_policy', __('Error updating SNMP module in policy. Module type is not SNMP type.')); - return; + return; } @@ -3576,8 +3583,8 @@ function api_set_update_snmp_module_policy($id, $thrash1, $other, $thrash3) { } $cont = 0; - foreach ($fields_snmp_module as $field){ - if ($other['data'][$cont] != "" and $field != 'id'){ + foreach ($fields_snmp_module as $field) { + if ($other['data'][$cont] != "" and $field != 'id') { $values[$field] = $other['data'][$cont]; } diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 6e9c1bcf1e..5ba648a340 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -470,6 +470,26 @@ function config_update_config () { if (!config_update_value ('log_max_lifetime', (int)get_parameter('log_max_lifetime'))) $error_update[] = __('Log max lifetime'); break; + case 'hist_db': + if (!config_update_value ('history_db_enabled', get_parameter ('history_db_enabled'))) + $error_update[] = __('Enable history database'); + if (!config_update_value ('history_db_host', get_parameter ('history_db_host'))) + $error_update[] = __('Host'); + if (!config_update_value ('history_db_port', get_parameter ('history_db_port'))) + $error_update[] = __('Port'); + if (!config_update_value ('history_db_name', get_parameter ('history_db_name'))) + $error_update[] = __('Database name'); + if (!config_update_value ('history_db_user', get_parameter ('history_db_user'))) + $error_update[] = __('Database user'); + if (!config_update_value ('history_db_pass', get_parameter ('history_db_pass'))) + $error_update[] = __('Database password'); + if (!config_update_value ('history_db_days', get_parameter ('history_db_days'))) + $error_update[] = __('Days'); + if (!config_update_value ('history_db_step', get_parameter ('history_db_step'))) + $error_update[] = __('Step'); + if (!config_update_value ('history_db_delay', get_parameter ('history_db_delay'))) + $error_update[] = __('Delay'); + break; }