2009-03-18 16:42:15 +01:00
< ? php
2009-06-08 20:21:21 +02:00
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2009 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
2009-03-18 16:42:15 +01:00
// 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.
2009-06-08 20:21:21 +02:00
// This program is distributed in the hope that it will be useful,
2009-03-18 16:42:15 +01:00
// 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.
2009-06-08 20:21:21 +02:00
2009-03-18 16:42:15 +01:00
// Load global vars
check_login ();
2009-04-02 Sancho Lerena <slerena@artica.es>
* pandoradb.sql: Final DB changes proposed for closing this month the DB
scheme. tagente-> new server_name field to assign server (old fields will
be removed). talert_templates has two new types (warning, critical).
tevento has "user_comment" new field. Tserver has three new fields,
server_type (so some old fields will be deleted), threads and queued_modules
this last two are for statistical options. Tusuario add language type to
override global language.
* update_manager/main.php: Minor changes for correct ACL usage. Non PM
users could see in what revision it the system, but only that.
* pandoradb_migrate_v2.x_to_v3.0.sql: Updated script for new DB changes.
* general/noaccess.php: Added footer and ending div. Page was very ugly
when showing noaccess errors, nobody see it ???.
* godmode/menu.php: A LOT of ACL fixes on several options.
* godmode/agentes/agent_manager.php: Fixed a crazy floating icon.
* godmode/agentes/manage_config_remote.php: A LOT of changes, rewriting
stuff, because was not working. This also adds a lot of ACL checks.
* godmode/agentes/massive_config.php, massive*: ACL changes.
* godmode/agentes/modificar_agente.php: Fixed ACL problems.
* godmode/agentes/module_manager_editor.php: Fixed bad module categories for
some types (data, plugin and prediction).
* godmode/alerts/alert_list.php: Fixed ACL problem.
* godmode/reporting/graph_builder.php: Added ACl restriction for
non-viewable agents for current user. Seems to be a problem with data
with more than 2 sources.
* godmode/reporting/map_builder.php: ACL checks improved.
* godmode/reporting/reporting_builder.php: ACL checks added (was missing),
some code ported from 2.1, other is new. New fields shown in list.
* include/functions.php: Fixed the annoying bug of "bad counters" in
function human_time_description_raw(). Function used,format_numeric() should
not be used never to calculate nothing, only to print formatted strings.
* include/functions_db.php: Added function user_access_to_agent() to know
if a given user has access to a given agent.
* include/functioins_report.php: get_report() should let admin to watch any
report. Fixed.
* agentes/alerts_status.php: Fixed ACL problem for view alert.
* operation/incidents/incident.php: Bad call for pagination() was giving
problems to pagination call. Somebody changes pagination() interface and
make this broken. Please if you change any interface, be sure that is compatible
with old code or make a post in the list about this !
* godmode/users/user_edit.php: Additional ACL check to do not let anybody
to watch non accesible users. Even for see the username or description.
* reporting/pchart_graph.php:Progress bar shown text in white when > 60%.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1594 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-04-02 21:16:59 +02:00
if ( ! give_acl ( $config [ 'id_user' ], 0 , " PM " )) {
2010-10-27 Miguel de Dios <miguel.dedios@artica.es>
* godmode/admin_access_logs.php: added hooks to enterprise code, and added
new filter with more options.
* include/functions_db.php: erase the deprecated function "audit_db", and
added in function "pandora_audit" two new parameters $user_id, $ip for
pass this values when it are differents to the default values. Finally
replaced the depecrated "audit_db" for "pandora_audit".
* include/functions_events.php, include/functions_filemanager.php,
include/ajax/reporting.ajax.php,
include/ajax/visual_console_builder.ajax.php,
include/ajax/alert_list.ajax.php, include/help/es/modu_group_list.php,
include/functions_incidents.php, index.php, extensions/agents_modules.php,
extensions/insert_data.php, extensions/system_info.php,
extensions/dbmanager.php, extensions/update_manager/settings.php,
extensions/pandora_logs.php, extensions/plugin_registration.php,
operation/incidents/incident.php, operation/incidents/incident_detail.php,
operation/incidents/incident_statistics.php, operation/extensions.php,
operation/visual_console/render_view.php,
operation/agentes/status_monitor.php, operation/agentes/export_csv.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/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/servers/view_server.php,operation/servers/view_server_detail.php,
operation/snmpconsole/snmp_view.php, operation/users/user_edit.php,
operation/gis_maps/render_view.php, operation/events/event_statistics.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/reporting/reporting_xml.php,
operation/reporting/reporting_viewer.php,
operation/reporting/graph_viewer.php,
mobile/operation/agents/view_agents.php, mobile/index.php,
godmode/groups/modu_group_list.php, godmode/groups/configure_group.php,
godmode/groups/configure_modu_group.php, godmode/groups/group_list.php,
godmode/extensions.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/agentes/fields_manager.php, godmode/agentes/module_manager.php,
godmode/agentes/modificar_agente.php, godmode/agentes/configurar_agente.php,
godmode/agentes/configure_field.php, godmode/agentes/planned_downtime.php,
godmode/agentes/manage_config_remote.php, godmode/agentes/agent_manager.php,
godmode/servers/manage_export.php, godmode/servers/recon_script.php,
godmode/servers/manage_export_form.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/snmpconsole/snmp_alert.php,
godmode/snmpconsole/snmp_filters.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/users/user_list.php,
godmode/users/configure_user.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/reporting_builder.list_items.php,
godmode/reporting/graph_builder.main.php,
godmode/reporting/visual_console_builder.wizard.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/map_builder_wizard.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/graphs.php, godmode/reporting/graph_builder.preview.php:
Replaced the depecrated "audit_db" for "pandora_audit".
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3467 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2010-10-27 12:47:07 +02:00
pandora_audit ( " ACL Violation " ,
2009-04-02 Sancho Lerena <slerena@artica.es>
* pandoradb.sql: Final DB changes proposed for closing this month the DB
scheme. tagente-> new server_name field to assign server (old fields will
be removed). talert_templates has two new types (warning, critical).
tevento has "user_comment" new field. Tserver has three new fields,
server_type (so some old fields will be deleted), threads and queued_modules
this last two are for statistical options. Tusuario add language type to
override global language.
* update_manager/main.php: Minor changes for correct ACL usage. Non PM
users could see in what revision it the system, but only that.
* pandoradb_migrate_v2.x_to_v3.0.sql: Updated script for new DB changes.
* general/noaccess.php: Added footer and ending div. Page was very ugly
when showing noaccess errors, nobody see it ???.
* godmode/menu.php: A LOT of ACL fixes on several options.
* godmode/agentes/agent_manager.php: Fixed a crazy floating icon.
* godmode/agentes/manage_config_remote.php: A LOT of changes, rewriting
stuff, because was not working. This also adds a lot of ACL checks.
* godmode/agentes/massive_config.php, massive*: ACL changes.
* godmode/agentes/modificar_agente.php: Fixed ACL problems.
* godmode/agentes/module_manager_editor.php: Fixed bad module categories for
some types (data, plugin and prediction).
* godmode/alerts/alert_list.php: Fixed ACL problem.
* godmode/reporting/graph_builder.php: Added ACl restriction for
non-viewable agents for current user. Seems to be a problem with data
with more than 2 sources.
* godmode/reporting/map_builder.php: ACL checks improved.
* godmode/reporting/reporting_builder.php: ACL checks added (was missing),
some code ported from 2.1, other is new. New fields shown in list.
* include/functions.php: Fixed the annoying bug of "bad counters" in
function human_time_description_raw(). Function used,format_numeric() should
not be used never to calculate nothing, only to print formatted strings.
* include/functions_db.php: Added function user_access_to_agent() to know
if a given user has access to a given agent.
* include/functioins_report.php: get_report() should let admin to watch any
report. Fixed.
* agentes/alerts_status.php: Fixed ACL problem for view alert.
* operation/incidents/incident.php: Bad call for pagination() was giving
problems to pagination call. Somebody changes pagination() interface and
make this broken. Please if you change any interface, be sure that is compatible
with old code or make a post in the list about this !
* godmode/users/user_edit.php: Additional ACL check to do not let anybody
to watch non accesible users. Even for see the username or description.
* reporting/pchart_graph.php:Progress bar shown text in white when > 60%.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1594 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-04-02 21:16:59 +02:00
" Trying to access massive module update " );
2009-03-18 16:42:15 +01:00
require ( " general/noaccess.php " );
return ;
}
require_once ( 'include/functions_modules.php' );
2010-10-04 17:58:05 +02:00
function process_manage_edit ( $module_name , $agents_select = null ) {
2009-03-18 16:42:15 +01:00
if ( is_int ( $module_name ) && $module_name <= 0 ) {
echo '<h3 class="error">' . __ ( 'No modules selected' ) . '</h3>' ;
return false ;
}
/* List of fields which can be updated */
2009-09-09 12:39:24 +02:00
$fields = array ( 'min_warning' , 'max_warning' , 'min_critical' , 'max_critical' , 'min_ff_event' , 'module_interval' ,
2010-05-10 12:24:35 +02:00
'disabled' , 'post_process' , 'snmp_community' , 'min' , 'max' , 'id_module_group' , 'plugin_user' , 'plugin_pass' , 'id_export' , 'history_data' );
2009-03-18 16:42:15 +01:00
$values = array ();
foreach ( $fields as $field ) {
2010-10-04 17:58:05 +02:00
$value = get_parameter ( $field , '' );
2009-03-18 16:42:15 +01:00
if ( $value != '' )
$values [ $field ] = $value ;
}
2009-09-18 17:14:44 +02:00
if ( strlen ( get_parameter ( 'history_data' )) > 0 ) {
$values [ 'history_data' ] = get_parameter ( 'history_data' );
}
2009-03-18 16:42:15 +01:00
$modules = get_db_all_rows_filter ( 'tagente_modulo' ,
2010-10-04 17:58:05 +02:00
array ( 'id_agente' => $agents_select ,
2009-03-18 16:42:15 +01:00
'nombre' => $module_name ),
array ( 'id_agente_modulo' ));
2009-05-04 Esteban Sánchez <estebans@artica.es>
* include/functions_agents.php: Added create_agent(),
* include/functions_db.php: Renamed dame_agente_id() to get_agent_id ().
Added process_sql_begin(), process_sql_rollback() and process_sql_commit()
and use MySQL functions directly because the Pandora cache was avoiding
more than one execution.
* include/functions_incidents.php, include/functions_messages.php,
godmode/agentes/massive_delete_agents.php,
godmode/agentes/massive_delete_alerts.php,
godmode/agentes/massive_delete_modules.php,
godmode/agentes/massive_edit_modules.php,
godmode/db/db_purge.php,
include/functions_events.php: Use new transaction functions.
* include/functions_modules.php: Sanitize some values. Added
create_agent_module_from_network_component(), create_agent_module()
and get_network_component().
* godmode/agentes/configurar_agente.php: Use get_agent_id() and transaction
functions.
* reporting/fgraph.php, operation/reporting/reporting_viewer.php: Use
get_agent_id().
* godmode/setup/file_manager.php: Removed unnecesary variable.
* operation/agentes/ver_agente.php: Replaced exit with return on ajax
operation.
* include/config_process.php: Updated build number.
* include/functions_network_profiles.php: Fixed documentation.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1672 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-05-04 12:10:19 +02:00
process_sql_begin ();
2010-10-04 17:58:05 +02:00
2009-03-18 16:42:15 +01:00
if ( $modules === false )
return false ;
2010-10-04 17:58:05 +02:00
2009-03-18 16:42:15 +01:00
foreach ( $modules as $module ) {
2009-09-18 17:14:44 +02:00
$result = update_agent_module ( $module [ 'id_agente_modulo' ], $values , true );
2009-05-29 12:32:26 +02:00
if ( $result === false ) {
process_sql_rollback ();
return false ;
}
2009-03-18 16:42:15 +01:00
}
2009-05-04 Esteban Sánchez <estebans@artica.es>
* include/functions_agents.php: Added create_agent(),
* include/functions_db.php: Renamed dame_agente_id() to get_agent_id ().
Added process_sql_begin(), process_sql_rollback() and process_sql_commit()
and use MySQL functions directly because the Pandora cache was avoiding
more than one execution.
* include/functions_incidents.php, include/functions_messages.php,
godmode/agentes/massive_delete_agents.php,
godmode/agentes/massive_delete_alerts.php,
godmode/agentes/massive_delete_modules.php,
godmode/agentes/massive_edit_modules.php,
godmode/db/db_purge.php,
include/functions_events.php: Use new transaction functions.
* include/functions_modules.php: Sanitize some values. Added
create_agent_module_from_network_component(), create_agent_module()
and get_network_component().
* godmode/agentes/configurar_agente.php: Use get_agent_id() and transaction
functions.
* reporting/fgraph.php, operation/reporting/reporting_viewer.php: Use
get_agent_id().
* godmode/setup/file_manager.php: Removed unnecesary variable.
* operation/agentes/ver_agente.php: Replaced exit with return on ajax
operation.
* include/config_process.php: Updated build number.
* include/functions_network_profiles.php: Fixed documentation.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1672 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-05-04 12:10:19 +02:00
process_sql_commit ();
2009-05-29 12:32:26 +02:00
return true ;
2009-03-18 16:42:15 +01:00
}
2009-03-23 16:22:19 +01:00
$module_type = ( int ) get_parameter ( 'module_type' );
2009-09-09 12:39:24 +02:00
$idGroupMassive = ( int ) get_parameter ( 'id_group_massive' );
$idAgentMassive = ( int ) get_parameter ( 'id_agent_massive' );
$group_select = get_parameter ( 'groups_select' );
2010-10-04 17:58:05 +02:00
$module_name = get_parameter ( 'module_name' );
$agents_select = get_parameter ( 'agents' );
$agents_id = get_parameter ( 'id_agents' );
$modules_select = get_parameter ( 'module' );
$selection_mode = get_parameter ( 'selection_mode' , 'modules' );
2009-03-18 16:42:15 +01:00
$update = ( bool ) get_parameter_post ( 'update' );
2010-10-04 17:58:05 +02:00
if ( $update ) {
if ( $selection_mode == 'modules' ) {
$force = get_parameter ( 'force_type' , false );
if ( $agents_select == false ) {
$agents_select = array ();
$agents_ = array ();
}
foreach ( $agents_select as $agent_name ) {
$agents_ [] = get_agent_id ( $agent_name );
}
$modules_ = $module_name ;
}
else if ( $selection_mode == 'agents' ) {
$force = get_parameter ( 'force_group' , false );
$agents_ = $agents_id ;
$modules_ = $modules_select ;
}
2009-05-29 12:32:26 +02:00
2010-10-04 17:58:05 +02:00
$success = 0 ;
$count = 0 ;
2009-05-29 12:32:26 +02:00
2010-10-04 17:58:05 +02:00
if ( $agents_ == false ) {
$agents_ = array ();
}
// If the option to select all of one group or module type is checked
if ( $force ) {
if ( $force == 'type' ) {
$condition = '' ;
if ( $module_type != 0 )
$condition = ' AND t2.id_tipo_modulo = ' . $module_type ;
$agents_ = get_db_all_rows_sql ( 'SELECT DISTINCT(t1.id_agente) FROM tagente t1, tagente_modulo t2 WHERE t1.id_agente = t2.id_agente' );
foreach ( $agents_ as $id_agent ) {
$module_name = get_db_all_rows_filter ( 'tagente_modulo' , array ( 'id_agente' => $id_agent , 'id_tipo_modulo' => $module_type ), 'nombre' );
if ( $module_name == false ) {
$module_name = array ();
}
foreach ( $module_name as $mod_name ) {
$result = process_manage_edit ( $mod_name [ 'nombre' ], $id_agent [ 'id_agente' ]);
$count ++ ;
$success += ( int ) $result ;
}
}
}
else if ( $force == 'group' ) {
$agents_ = array_keys ( get_group_agents ( $group_select , false , " none " ));
foreach ( $agents_ as $id_agent ) {
$module_name = get_db_all_rows_filter ( 'tagente_modulo' , array ( 'id_agente' => $id_agent ), 'nombre' );
if ( $module_name == false ) {
$module_name = array ();
}
foreach ( $module_name as $mod_name ) {
$result = process_manage_edit ( $mod_name [ 'nombre' ], $id_agent );
$count ++ ;
$success += ( int ) $result ;
}
}
}
// We empty the agents array to skip the standard procedure
$agents_ = array ();
}
foreach ( $agents_ as $agent_ ) {
if ( $modules_ == false ) {
$modules_ = array ();
}
foreach ( $modules_ as $module_ ) {
$result = process_manage_edit ( $module_ , $agents_ );
$count ++ ;
$success += ( int ) $result ;
}
}
print_result_message ( $success > 0 ,
__ ( 'Successfully updated' ) . " ( " . $success . " / " . $count . " ) " ,
__ ( 'Could not be updated' ));
2009-03-18 16:42:15 +01:00
}
$table -> id = 'delete_table' ;
$table -> width = '95%' ;
$table -> data = array ();
$table -> style = array ();
$table -> style [ 0 ] = 'font-weight: bold; vertical-align:top' ;
$table -> style [ 2 ] = 'font-weight: bold' ;
$table -> rowstyle = array ();
$table -> size = array ();
$table -> size [ 0 ] = '15%' ;
2009-03-23 16:22:19 +01:00
$table -> size [ 1 ] = '35%' ; /* Fixed using javascript */
2009-03-18 16:42:15 +01:00
$table -> size [ 2 ] = '15%' ;
$table -> size [ 3 ] = '35%' ;
2009-03-23 16:22:19 +01:00
if ( ! $module_type ) {
$table -> rowstyle [ 'edit1' ] = 'display: none' ;
$table -> rowstyle [ 'edit2' ] = 'display: none' ;
2009-09-09 12:39:24 +02:00
$table -> rowstyle [ 'edit3' ] = 'display: none' ;
$table -> rowstyle [ 'edit4' ] = 'display: none' ;
$table -> rowstyle [ 'edit5' ] = 'display: none' ;
2009-09-09 13:05:59 +02:00
$table -> rowstyle [ 'edit6' ] = 'display: none' ;
2009-09-09 13:23:19 +02:00
$table -> rowstyle [ 'edit7' ] = 'display: none' ;
2009-03-23 16:22:19 +01:00
}
2009-03-18 16:42:15 +01:00
$agents = get_group_agents ( array_keys ( get_user_groups ()), false , " none " );
2009-03-23 16:22:19 +01:00
$module_types = get_db_all_rows_filter ( 'tagente_modulo,ttipo_modulo' ,
array ( 'tagente_modulo.id_tipo_modulo = ttipo_modulo.id_tipo' ,
'id_agente' => array_keys ( $agents ),
'disabled' => 0 ,
'order' => 'ttipo_modulo.nombre' ),
array ( 'DISTINCT(id_tipo)' ,
'CONCAT(ttipo_modulo.descripcion," (",ttipo_modulo.nombre,")") AS description' ));
if ( $module_types === false )
$module_types = array ();
$types = '' ;
foreach ( $module_types as $type ) {
$types [ $type [ 'id_tipo' ]] = $type [ 'description' ];
2009-03-18 16:42:15 +01:00
}
$table -> data = array ();
2010-10-04 17:58:05 +02:00
$table -> data [ 0 ][ 0 ] = __ ( 'Selection mode' );
$table -> data [ 0 ][ 1 ] = __ ( 'Select modules first' ) . ' ' . print_radio_button_extended ( " selection_mode " , 'modules' , '' , $selection_mode , false , '' , 'style="margin-right: 40px;"' , true );
$table -> data [ 0 ][ 2 ] = '' ;
$table -> data [ 0 ][ 3 ] = __ ( 'Select agents first' ) . ' ' . print_radio_button_extended ( " selection_mode " , 'agents' , '' , $selection_mode , false , '' , 'style="margin-right: 40px;"' , true );
$table -> rowclass [ 1 ] = 'select_modules_row' ;
$table -> data [ 1 ][ 0 ] = __ ( 'Module type' );
$table -> data [ 1 ][ 0 ] .= '<span id="module_loading" class="invisible">' ;
$table -> data [ 1 ][ 0 ] .= '<img src="images/spinner.png" />' ;
$table -> data [ 1 ][ 0 ] .= '</span>' ;
$types [ 0 ] = __ ( 'All' );
$table -> colspan [ 1 ][ 1 ] = 2 ;
$table -> data [ 1 ][ 1 ] = print_select ( $types ,
'module_type' , '' , false , __ ( 'Select' ), - 1 , true , false , true );
$table -> data [ 1 ][ 3 ] = __ ( 'Select all modules of this type' ) . ' ' . print_checkbox_extended ( " force_type " , 'type' , '' , '' , false , '' , 'style="margin-right: 40px;"' , true );
2009-03-23 16:22:19 +01:00
$modules = array ();
if ( $module_type != '' ) {
2009-09-08 17:38:43 +02:00
$filter = array ( 'id_tipo_modulo' => $module_type );
}
else {
$filter = false ;
}
$names = get_agent_modules ( array_keys ( $agents ),
'DISTINCT(nombre)' , $filter , false );
foreach ( $names as $name ) {
$modules [ $name [ 'nombre' ]] = $name [ 'nombre' ];
2009-03-23 16:22:19 +01:00
}
2009-09-08 17:38:43 +02:00
2010-10-04 17:58:05 +02:00
$table -> rowclass [ 2 ] = 'select_agents_row' ;
$table -> data [ 2 ][ 0 ] = __ ( 'Agent group' );
$groups = get_all_groups ( true );
$groups [ 0 ] = __ ( 'All' );
$table -> colspan [ 2 ][ 1 ] = 2 ;
$table -> data [ 2 ][ 1 ] = print_select ( $groups , 'groups_select' ,
'' , true , __ ( 'Select' ), - 1 , true , false , true );
$table -> data [ 2 ][ 3 ] = __ ( 'Select all modules of this group' ) . ' ' . print_checkbox_extended ( " force_group " , 'group' , '' , '' , false , '' , 'style="margin-right: 40px;"' , true );
2009-03-18 16:42:15 +01:00
2010-10-04 17:58:05 +02:00
$table -> rowstyle [ 3 ] = 'vertical-align: top;' ;
$table -> rowclass [ 3 ] = 'select_modules_row select_modules_row_2' ;
$table -> data [ 3 ][ 0 ] = __ ( 'Modules' );
$table -> data [ 3 ][ 1 ] = print_select ( $modules , 'module_name[]' ,
$module_name , false , __ ( 'Select' ), - 1 , true , true , true );
$table -> data [ 3 ][ 2 ] = __ ( 'Agents' );
$table -> data [ 3 ][ 3 ] = print_select ( array (), 'agents[]' ,
$agents_select , false , __ ( 'None' ), 0 , true , true , false );
$table -> rowstyle [ 4 ] = 'vertical-align: top;' ;
$table -> rowclass [ 4 ] = 'select_agents_row select_agents_row_2' ;
$table -> data [ 4 ][ 0 ] = __ ( 'Agents' );
$table -> data [ 4 ][ 1 ] = print_select ( $agents , 'id_agents[]' ,
$agents_id , false , '' , '' , true , true , false );
$table -> data [ 4 ][ 2 ] = __ ( 'Modules' );
$table -> data [ 4 ][ 3 ] = print_select ( array (), 'module[]' ,
$modules_select , false , '' , '' , true , true , false );
2009-09-09 12:39:24 +02:00
2009-03-18 16:42:15 +01:00
$table -> data [ 'edit1' ][ 0 ] = __ ( 'Warning status' );
$table -> data [ 'edit1' ][ 1 ] = '<em>' . __ ( 'Min.' ) . '</em>' ;
$table -> data [ 'edit1' ][ 1 ] .= print_input_text ( 'min_warning' , '' , '' , 5 , 15 , true );
$table -> data [ 'edit1' ][ 1 ] .= '<br /><em>' . __ ( 'Max.' ) . '</em>' ;
$table -> data [ 'edit1' ][ 1 ] .= print_input_text ( 'max_warning' , '' , '' , 5 , 15 , true );
$table -> data [ 'edit1' ][ 2 ] = __ ( 'Critical status' );
$table -> data [ 'edit1' ][ 3 ] = '<em>' . __ ( 'Min.' ) . '</em>' ;
$table -> data [ 'edit1' ][ 3 ] .= print_input_text ( 'min_critical' , '' , '' , 5 , 15 , true );
$table -> data [ 'edit1' ][ 3 ] .= '<br /><em>' . __ ( 'Max.' ) . '</em>' ;
$table -> data [ 'edit1' ][ 3 ] .= print_input_text ( 'max_critical' , '' , '' , 5 , 15 , true );
2009-09-09 12:39:24 +02:00
$table -> data [ 'edit2' ][ 0 ] = __ ( 'Interval' );
$table -> data [ 'edit2' ][ 1 ] = print_input_text ( 'module_interval' , '' , '' , 5 , 15 , true );
$table -> data [ 'edit2' ][ 2 ] = __ ( 'Disabled' );
2009-09-18 17:14:44 +02:00
//$table->data['edit2'][3] = print_checkbox ("disabled", 1, '', true);
$table -> data [ 'edit2' ][ 3 ] = print_select ( array ( '' => '' , '1' => __ ( 'Yes' ), '0' => __ ( 'No' )), 'disabled' , '' , '' , '' , '' , true );
2009-09-09 12:39:24 +02:00
$table -> data [ 'edit3' ][ 0 ] = __ ( 'Post process' );
$table -> data [ 'edit3' ][ 1 ] = print_input_text ( 'post_process' , '' , '' , 10 , 15 , true );
$table -> data [ 'edit3' ][ 2 ] = __ ( 'SMNP community' );
$table -> data [ 'edit3' ][ 3 ] = print_input_text ( 'snmp_community' , '' , '' , 10 , 15 , true );
$table -> data [ 'edit4' ][ 0 ] = __ ( 'Value' );
$table -> data [ 'edit4' ][ 1 ] = '<em>' . __ ( 'Min.' ) . '</em>' ;
$table -> data [ 'edit4' ][ 1 ] .= print_input_text ( 'min' , '' , '' , 5 , 15 , true );
$table -> data [ 'edit4' ][ 1 ] .= '<br /><em>' . __ ( 'Max.' ) . '</em>' ;
$table -> data [ 'edit4' ][ 1 ] .= print_input_text ( 'max' , '' , '' , 5 , 15 , true );
2009-09-18 17:14:44 +02:00
$table -> data [ 'edit4' ][ 2 ] = __ ( 'Module group' );
2009-09-09 12:39:24 +02:00
$table -> data [ 'edit4' ][ 3 ] = print_select ( get_modulegroups (),
'id_module_group' , '' , '' , __ ( 'Select' ), 0 , true , false , false );
2009-09-09 13:05:59 +02:00
$table -> data [ 'edit5' ][ 0 ] = __ ( 'Username' );
$table -> data [ 'edit5' ][ 1 ] = print_input_text ( 'plugin_user' , '' , '' , 15 , 60 , true );
$table -> data [ 'edit5' ][ 2 ] = __ ( 'Password' );
$table -> data [ 'edit5' ][ 3 ] = print_input_password ( 'plugin_pass' , '' , '' , 15 , 60 , true );
2009-09-09 13:23:19 +02:00
$table -> data [ 'edit6' ][ 0 ] = __ ( 'Export target' );
$table -> data [ 'edit6' ][ 1 ] = print_select_from_sql ( 'SELECT id, name FROM tserver_export ORDER BY name' ,
'id_export' , '' , '' , __ ( 'None' ), '0' , true , false , false );
2009-09-09 13:05:59 +02:00
2009-03-18 16:42:15 +01:00
/* FF stands for Flip-flop */
2009-09-09 13:23:19 +02:00
$table -> data [ 'edit7' ][ 0 ] = __ ( 'FF threshold' ) . ' ' . print_help_icon ( 'ff_threshold' , true );
$table -> data [ 'edit7' ][ 1 ] = print_input_text ( 'min_ff_event' , '' , '' , 5 , 15 , true );
$table -> data [ 'edit7' ][ 2 ] = __ ( 'Historical data' );
2009-09-18 17:14:44 +02:00
$table -> data [ 'edit7' ][ 3 ] = print_select ( array ( '' => '' , '1' => __ ( 'Yes' ), '0' => __ ( 'No' )), 'history_data' , '' , '' , '' , '' , true );
2009-03-18 16:42:15 +01:00
2010-08-20 12:30:36 +02:00
echo '<form method="post" action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&option=edit_modules" id="form_edit" onsubmit="if (! confirm(\'' . __ ( 'Are you sure?' ) . '\')) return false;">' ;
2009-03-18 16:42:15 +01:00
print_table ( $table );
echo '<div class="action-buttons" style="width: ' . $table -> width . '" onsubmit="if (!confirm(\' ' . __ ( 'Are you sure?' ) . '\')) return false;">' ;
print_input_hidden ( 'update' , 1 );
print_submit_button ( __ ( 'Update' ), 'go' , false , 'class="sub upd"' );
echo '</div>' ;
echo '</form>' ;
echo '<h3 class="error invisible" id="message"> </h3>' ;
2010-10-04 17:58:05 +02:00
//Hack to translate text "none" in PHP to javascript
echo '<span id ="none_text" style="display: none;">' . __ ( 'None' ) . '</span>' ;
2009-03-18 16:42:15 +01:00
require_jquery_file ( 'pandora.controls' );
2010-10-04 17:58:05 +02:00
if ( $selection_mode == 'modules' ){
$modules_row = '' ;
$agents_row = 'none' ;
}
else {
$modules_row = 'none' ;
$agents_row = '' ;
}
2010-10-19 13:04:20 +02:00
2009-03-18 16:42:15 +01:00
?>
< script type = " text/javascript " >
/* <![CDATA[ */
$ ( document ) . ready ( function () {
2010-10-04 17:58:05 +02:00
$ ( " #id_agents " ) . change ( agent_changed_by_multiple_agents );
$ ( " #module_name " ) . change ( module_changed_by_multiple_modules );
clean_lists ();
$ ( " .select_modules_row " ) . css ( 'display' , '<?php echo $modules_row?>' );
$ ( " .select_agents_row " ) . css ( 'display' , '<?php echo $agents_row?>' );
2009-03-23 16:22:19 +01:00
$ ( " #module_type " ) . change ( function () {
2010-10-04 17:58:05 +02:00
if ( this . value < 0 ) {
clean_lists ();
$ ( " .select_modules_row_2 " ) . css ( 'display' , 'none' );
return ;
}
else {
$ ( " #module " ) . html ( '<?php echo __(' None '); ?>' );
$ ( " #module_name " ) . html ( '' );
$ ( 'input[type=checkbox]' ) . attr ( 'disabled' , false );
$ ( " .select_modules_row_2 " ) . css ( 'display' , '' );
}
$ ( " tr#delete_table-edit1, tr#delete_table-edit2, tr#delete_table-edit3, tr#delete_table-edit4, tr#delete_table-edit5, tr#delete_table-edit6, tr#delete_table-edit7 " ) . hide ();
2009-09-08 17:38:43 +02:00
if ( this . value == '0' ) {
filter = '' ;
}
else {
filter = " id_tipo_modulo= " + this . value ;
}
2010-10-04 17:58:05 +02:00
2009-03-23 16:22:19 +01:00
$ ( " #module_loading " ) . show ();
$ ( " tr#delete_table-edit1, tr#delete_table-edit2 " ) . hide ();
$ ( " #module_name " ) . attr ( " disabled " , " disabled " )
$ ( " #module_name option[value!=0] " ) . remove ();
jQuery . post ( " ajax.php " ,
2010-10-04 17:58:05 +02:00
{ " page " : " operation/agentes/ver_agente " ,
2009-03-23 16:22:19 +01:00
" get_agent_modules_json " : 1 ,
2009-09-08 17:38:43 +02:00
" filter " : filter ,
2009-03-23 16:22:19 +01:00
" fields " : " DISTINCT(nombre) " ,
" indexed " : 0
},
function ( data , status ) {
jQuery . each ( data , function ( id , value ) {
option = $ ( " <option></option> " ) . attr ( " value " , value [ " nombre " ]) . html ( value [ " nombre " ]);
$ ( " #module_name " ) . append ( option );
});
$ ( " #module_loading " ) . hide ();
$ ( " #module_name " ) . removeAttr ( " disabled " );
},
" json "
);
});
2010-10-04 17:58:05 +02:00
function show_form () {
2009-03-18 16:42:15 +01:00
$ ( " td#delete_table-0-1, td#delete_table-edit1-1, td#delete_table-edit2-1 " ) . css ( " width " , " 35% " );
$ ( " #form_edit input[type=text] " ) . attr ( " value " , " " );
$ ( " #form_edit input[type=checkbox] " ) . removeAttr ( " checked " );
2009-09-09 13:23:19 +02:00
$ ( " tr#delete_table-edit1, tr#delete_table-edit2, tr#delete_table-edit3, tr#delete_table-edit4, tr#delete_table-edit5, tr#delete_table-edit6, tr#delete_table-edit7 " ) . show ();
2010-10-04 17:58:05 +02:00
}
function clean_lists () {
$ ( " #id_agents " ) . html ( '<?php echo __(' None '); ?>' );
$ ( " #module_name " ) . html ( '<?php echo __(' None '); ?>' );
$ ( " #agents " ) . html ( '<?php echo __(' None '); ?>' );
$ ( " #module " ) . html ( '<?php echo __(' None '); ?>' );
$ ( " tr#delete_table-edit1, tr#delete_table-edit2, tr#delete_table-edit3, tr#delete_table-edit4, tr#delete_table-edit5, tr#delete_table-edit6, tr#delete_table-edit7 " ) . hide ();
$ ( 'input[type=checkbox]' ) . attr ( 'checked' , false );
$ ( 'input[type=checkbox]' ) . attr ( 'disabled' , true );
$ ( '#module_type' ) . val ( - 1 );
$ ( '#groups_select' ) . val ( - 1 );
}
$ ( 'input[type=checkbox]' ) . change (
function () {
if ( this . id == " checkbox-force_type " ){
if ( this . checked ) {
$ ( " .select_modules_row_2 " ) . css ( 'display' , 'none' );
$ ( " tr#delete_table-edit1, tr#delete_table-edit2, tr#delete_table-edit3, tr#delete_table-edit4, tr#delete_table-edit5, tr#delete_table-edit6, tr#delete_table-edit7 " ) . show ();
}
else {
$ ( " .select_modules_row_2 " ) . css ( 'display' , '' );
if ( $ ( '#module_name option:selected' ) . val () == undefined ) {
$ ( " tr#delete_table-edit1, tr#delete_table-edit2, tr#delete_table-edit3, tr#delete_table-edit4, tr#delete_table-edit5, tr#delete_table-edit6, tr#delete_table-edit7 " ) . hide ();
}
}
}
else {
if ( this . checked ) {
$ ( " .select_agents_row_2 " ) . css ( 'display' , 'none' );
$ ( " tr#delete_table-edit1, tr#delete_table-edit2, tr#delete_table-edit3, tr#delete_table-edit4, tr#delete_table-edit5, tr#delete_table-edit6, tr#delete_table-edit7 " ) . show ();
}
else {
$ ( " .select_agents_row_2 " ) . css ( 'display' , '' );
if ( $ ( '#id_agents option:selected' ) . val () == undefined ) {
$ ( " tr#delete_table-edit1, tr#delete_table-edit2, tr#delete_table-edit3, tr#delete_table-edit4, tr#delete_table-edit5, tr#delete_table-edit6, tr#delete_table-edit7 " ) . hide ();
}
}
}
}
);
$ ( " #module_name " ) . change ( show_form );
$ ( " #id_agents " ) . change ( show_form );
$ ( " #form_edit input[name=selection_mode] " ) . change ( function () {
selector = this . value ;
clean_lists ();
if ( selector == 'agents' ) {
$ ( " .select_modules_row " ) . css ( 'display' , 'none' );
$ ( " .select_agents_row " ) . css ( 'display' , '' );
}
else if ( selector == 'modules' ) {
$ ( " .select_agents_row " ) . css ( 'display' , 'none' );
$ ( " .select_modules_row " ) . css ( 'display' , '' );
}
2009-03-18 16:42:15 +01:00
});
2009-09-09 12:39:24 +02:00
$ ( " #groups_select " ) . change (
function () {
2010-10-04 17:58:05 +02:00
if ( this . value < 0 ) {
clean_lists ();
$ ( " .select_agents_row_2 " ) . css ( 'display' , 'none' );
return ;
}
else {
$ ( " #module " ) . html ( '<?php echo __(' None '); ?>' );
$ ( " #id_agents " ) . html ( '' );
$ ( 'input[type=checkbox]' ) . attr ( 'disabled' , false );
$ ( " .select_agents_row_2 " ) . css ( 'display' , '' );
}
$ ( " tr#delete_table-edit1, tr#delete_table-edit2, tr#delete_table-edit3, tr#delete_table-edit4, tr#delete_table-edit5, tr#delete_table-edit6, tr#delete_table-edit7 " ) . hide ();
2009-09-09 12:39:24 +02:00
jQuery . post ( " ajax.php " ,
2010-10-04 17:58:05 +02:00
{ " page " : " operation/agentes/ver_agente " ,
2009-09-09 12:39:24 +02:00
" get_agents_group_json " : 1 ,
2010-10-19 13:04:20 +02:00
" id_group " : this . value
2009-09-09 12:39:24 +02:00
},
function ( data , status ) {
2010-10-04 17:58:05 +02:00
$ ( " #id_agents " ) . html ( '' );
2009-09-09 12:39:24 +02:00
jQuery . each ( data , function ( id , value ) {
option = $ ( " <option></option> " ) . attr ( " value " , value [ " id_agente " ]) . html ( value [ " nombre " ]);
2010-10-04 17:58:05 +02:00
$ ( " #id_agents " ) . append ( option );
2009-09-09 12:39:24 +02:00
});
},
" json "
);
}
);
2009-03-18 16:42:15 +01:00
});
/* ]]> */
</ script >