2008-08-22 20:07:32 +02:00
< ? php
2009-06-08 20:21:21 +02:00
// Pandora FMS - http://pandorafms.com
// ==================================================
2020-11-27 13:52:35 +01:00
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
2009-06-08 20:21:21 +02:00
// Please see http://pandorafms.org for full contribution list
2007-03-12 18:58:52 +01:00
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
2008-08-22 20:07:32 +02:00
// as published by the Free Software Foundation for version 2.
2007-03-12 18:58:52 +01:00
// 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.
// Load global vars
2010-03-02 Sancho Lerena <slerena@artica.es>
* include/functions_reporting.php: Solved issue with several undefined
vars.
* include/functions_servers.php: Solved issue with several undefined
vars.
* include/functions_config.php: Added metaconsola witch to readconfig.
* include/config_process.php: Update build.. is YYMMDD !
* include/functions_ui.php: Removed deprecated call to split and replaced
by preg_split.
* index.php: Activated developer mode.
* operation/agentes/estado_monitores.php: Solved small problem with modules
without history, filling missing column in table. Added headers
* godmode/alerts/configure_alert_compound.php,
operation/agentes/status_monitor.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_commands.php,
godmode/modules/manage_network_templates.php,
godmode/modules/module_list.php,
godmode/modules/manage_network_components.php,
godmode/modules/manage_nc_groups.php: Removed deprecated call to include
config.php and in some cases, added new header style.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2444 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2010-03-02 15:13:00 +01:00
global $config ;
2007-03-12 18:58:52 +01:00
2019-01-30 16:18:44 +01:00
check_login ();
2007-03-12 18:58:52 +01:00
2015-03-06 12:28:05 +01:00
enterprise_hook ( 'open_meta_frame' );
2020-03-11 16:21:25 +01:00
if ( ! check_acl ( $config [ 'id_user' ], 0 , 'PM' ) && ! check_acl ( $config [ 'id_user' ], 0 , 'AW' )) {
2019-01-30 16:18:44 +01:00
db_pandora_audit (
'ACL Violation' ,
'Trying to access SNMP Group Management'
);
include 'general/noaccess.php' ;
return ;
2007-03-12 18:58:52 +01:00
}
2009-03-13 12:22:07 +01:00
2019-01-30 16:18:44 +01:00
enterprise_include_once ( 'meta/include/functions_components_meta.php' );
require_once $config [ 'homedir' ] . '/include/functions_network_components.php' ;
require_once $config [ 'homedir' ] . '/include/functions_component_groups.php' ;
2010-03-02 Sancho Lerena <slerena@artica.es>
* include/functions_reporting.php: Solved issue with several undefined
vars.
* include/functions_servers.php: Solved issue with several undefined
vars.
* include/functions_config.php: Added metaconsola witch to readconfig.
* include/config_process.php: Update build.. is YYMMDD !
* include/functions_ui.php: Removed deprecated call to split and replaced
by preg_split.
* index.php: Activated developer mode.
* operation/agentes/estado_monitores.php: Solved small problem with modules
without history, filling missing column in table. Added headers
* godmode/alerts/configure_alert_compound.php,
operation/agentes/status_monitor.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_commands.php,
godmode/modules/manage_network_templates.php,
godmode/modules/module_list.php,
godmode/modules/manage_network_components.php,
godmode/modules/manage_nc_groups.php: Removed deprecated call to include
config.php and in some cases, added new header style.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2444 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2010-03-02 15:13:00 +01:00
2012-12-12 20:37:35 +01:00
// Header
if ( defined ( 'METACONSOLE' )) {
2019-01-30 16:18:44 +01:00
components_meta_print_header ();
$sec = 'advanced' ;
} else {
2019-04-29 14:36:02 +02:00
ui_print_page_header (
__ ( 'Module management' ) . ' » ' . __ ( 'Component group management' ),
'' ,
false ,
2020-05-29 11:37:06 +02:00
'' ,
2019-04-29 14:36:02 +02:00
true
);
2019-01-30 16:18:44 +01:00
$sec = 'gmodules' ;
2012-12-12 20:37:35 +01:00
}
2009-05-25 15:29:48 +02:00
2020-06-04 21:07:53 +02:00
if ( is_management_allowed () === true ) {
$create = ( bool ) get_parameter ( 'create' );
$update = ( bool ) get_parameter ( 'update' );
$delete = ( bool ) get_parameter ( 'delete' );
$new = ( bool ) get_parameter ( 'new' );
$id = ( int ) get_parameter ( 'id' );
$multiple_delete = ( bool ) get_parameter ( 'multiple_delete' , 0 );
$pure = get_parameter ( 'pure' , 0 );
}
2019-01-30 16:18:44 +01:00
2009-03-13 12:22:07 +01:00
if ( $create ) {
2019-01-30 16:18:44 +01:00
$name = ( string ) get_parameter ( 'name' );
$parent = ( int ) get_parameter ( 'parent' );
if ( $name == '' ) {
ui_print_error_message ( __ ( 'Could not be created. Blank name' ));
include_once 'manage_nc_groups_form.php' ;
return ;
} else {
$result = db_process_sql_insert (
'tnetwork_component_group' ,
[
'name' => $name ,
'parent' => $parent ,
]
);
if ( $result ) {
db_pandora_audit ( 'Module management' , " Create component group # $result " );
} else {
db_pandora_audit ( 'Module management' , 'Fail try to create component group' );
}
ui_print_result_message (
$result ,
__ ( 'Successfully created' ),
__ ( 'Could not be created' )
);
}
2007-03-12 18:58:52 +01:00
}
2009-03-13 12:22:07 +01:00
if ( $update ) {
2019-01-30 16:18:44 +01:00
$name = ( string ) get_parameter ( 'name' );
$parent = ( int ) get_parameter ( 'parent' );
if ( $name == '' ) {
ui_print_error_message ( __ ( 'Not updated. Blank name' ));
} else {
$result = db_process_sql_update (
'tnetwork_component_group' ,
[
'name' => $name ,
'parent' => $parent ,
],
[ 'id_sg' => $id ]
);
if ( $result ) {
db_pandora_audit ( 'Module management' , " Update component group # $id " );
} else {
db_pandora_audit ( 'Module management' , " Fail try to update component group # $id " );
}
ui_print_result_message (
$result ,
__ ( 'Successfully updated' ),
__ ( 'Not updated. Error updating data' )
);
}
2007-03-12 18:58:52 +01:00
}
2009-05-25 15:29:48 +02:00
if ( $delete ) {
2019-01-30 16:18:44 +01:00
$parent_id = db_get_value_filter ( 'parent' , 'tnetwork_component_group' , [ 'id_sg' => $id ]);
$result1 = db_process_sql_update ( 'tnetwork_component_group' , [ 'parent' => $parent_id ], [ 'parent' => $id ]);
$result = db_process_sql_delete (
'tnetwork_component_group' ,
[ 'id_sg' => $id ]
);
if (( $result !== false ) and ( $result1 !== false )) {
$result = true ;
} else {
$result = false ;
}
if ( $result ) {
db_pandora_audit ( 'Module management' , " Delete component group # $id " );
} else {
db_pandora_audit ( 'Module management' , " Fail try to delete component group # $id " );
}
ui_print_result_message (
$result ,
__ ( 'Successfully deleted' ),
__ ( 'Not deleted. Error deleting data' )
);
2007-03-12 18:58:52 +01:00
}
2011-08-25 20:27:47 +02:00
if ( $multiple_delete ) {
2019-01-30 16:18:44 +01:00
$ids = ( array ) get_parameter ( 'delete_multiple' , []);
foreach ( $ids as $id ) {
$result = db_process_sql_delete (
'tnetwork_component_group' ,
[ 'id_sg' => $id ]
);
$result1 = db_process_sql_update ( 'tnetwork_component_group' , [ 'parent' => 0 ], [ 'parent' => $id ]);
if (( $result === false ) or ( $result1 === false )) {
break ;
}
}
if ( $result !== false ) {
$result = true ;
} else {
$result = false ;
}
$str_ids = implode ( ',' , $ids );
if ( $result ) {
db_pandora_audit (
'Module management' ,
" Multiple delete component group: $str_ids "
);
} else {
db_pandora_audit (
'Module management' ,
" Fail try to delete component group: $str_ids "
);
}
ui_print_result_message (
$result ,
__ ( 'Successfully multiple deleted' ),
__ ( 'Not deleted. Error deleting multiple data' )
);
2011-08-25 20:27:47 +02:00
}
2020-06-04 21:07:53 +02:00
if (( $id || $new ) && ! $delete && ! $multiple_delete && is_management_allowed () === true ) {
2019-01-30 16:18:44 +01:00
include_once 'manage_nc_groups_form.php' ;
return ;
2009-05-25 15:29:48 +02:00
}
2019-01-30 16:18:44 +01:00
$url = ui_get_url_refresh (
[
'offset' => false ,
'create' => false ,
'update' => false ,
'delete' => false ,
'new' => false ,
'crt' => false ,
'upd' => false ,
'id' => false ,
]
);
$filter = [];
// $filter['offset'] = (int) get_parameter ('offset');
// $filter['limit'] = (int) $config['block_size'];
2013-01-11 15:32:28 +01:00
$filter [ 'order' ] = 'parent' ;
2011-08-11 11:19:31 +02:00
2019-01-30 16:18:44 +01:00
$groups = db_get_all_rows_filter ( 'tnetwork_component_group' , $filter );
if ( $groups === false ) {
$groups = [];
}
2012-07-10 Miguel de Dios <miguel.dedios@artica.es>
* install.php, operation/reporting/reporting_xml.php,
operation/netflow/nf_live_view.php, operation/netflow/nf_view.php,
operation/tree.php, operation/agentes/gis_view.php,
operation/agentes/estado_monitores.php,
operation/agentes/networkmap.php,
operation/agentes/datos_agente.php,
operation/agentes/alerts_status.php, operation/menu.php,
operation/snmpconsole/snmp_view.php, operation/users/user_edit.php,
godmode/groups/configure_group.php,
godmode/groups/configure_modu_group.php,
godmode/agentes/module_manager_editor_prediction.php,
godmode/servers/manage_recontask.php,
godmode/alerts/alert_compounds.php,
godmode/alerts/configure_alert_template.php,
godmode/alerts/alert_special_days.php, godmode/setup/links.php,
godmode/setup/os.php, godmode/users/configure_profile.php,
godmode/events/events.php,
godmode/massive/massive_delete_modules.php,
godmode/massive/massive_edit_modules.php,
godmode/massive/massive_standby_alerts.php,
godmode/massive/massive_add_action_alerts.php,
godmode/massive/massive_enable_disable_alerts.php,
godmode/massive/massive_operations.php,
godmode/massive/massive_delete_profiles.php,
godmode/modules/manage_network_components.php,
godmode/modules/manage_nc_groups.php,
godmode/reporting/graph_builder.php,
godmode/reporting/reporting_builder.item_editor.php,
include/functions_menu.php, include/functions_visual_map.php,
include/functions_db.php: cleaned source code style.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6759 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-07-10 12:38:02 +02:00
2019-01-30 16:18:44 +01:00
$groups_clean = [];
2013-01-11 15:32:28 +01:00
foreach ( $groups as $group_key => $group_val ) {
2019-01-30 16:18:44 +01:00
$groups_clean [ $group_val [ 'id_sg' ]] = $group_val ;
2013-01-11 15:32:28 +01:00
}
// Format component groups in tree form
2019-01-30 16:18:44 +01:00
$groups = component_groups_get_groups_tree_recursive ( $groups_clean , 0 , 0 );
2013-01-11 15:32:28 +01:00
2017-02-14 15:47:12 +01:00
$table = new stdClass ();
2015-06-12 15:50:46 +02:00
$table -> width = '100%' ;
2019-04-02 13:42:30 +02:00
$table -> class = 'info_table' ;
2019-01-30 16:18:44 +01:00
$table -> head = [];
2019-04-02 13:42:30 +02:00
$table -> head [ 'checkbox' ] = html_print_checkbox ( 'all_delete' , 0 , false , true , false );
2009-03-13 12:22:07 +01:00
$table -> head [ 0 ] = __ ( 'Name' );
2020-06-04 21:07:53 +02:00
if ( is_management_allowed () === true ) {
$table -> head [ 1 ] = __ ( 'Action' );
}
2019-01-30 16:18:44 +01:00
$table -> style = [];
2009-03-13 12:22:07 +01:00
$table -> style [ 0 ] = 'font-weight: bold' ;
2019-01-30 16:18:44 +01:00
$table -> align = [];
2015-06-12 15:50:46 +02:00
$table -> align [ 1 ] = 'left' ;
2019-01-30 16:18:44 +01:00
$table -> size = [];
2019-04-02 13:42:30 +02:00
$table -> size [ 'checkbox' ] = '20px' ;
// $table->size[0] = '80%';
$table -> size [ 1 ] = '60px' ;
2019-01-30 16:18:44 +01:00
$table -> data = [];
2007-03-12 18:58:52 +01:00
2019-01-30 16:18:44 +01:00
$total_groups = db_get_all_rows_filter ( 'tnetwork_component_group' , false , 'COUNT(*) AS total' );
2009-05-25 15:29:48 +02:00
$total_groups = $total_groups [ 0 ][ 'total' ];
2019-01-30 16:18:44 +01:00
// ui_pagination ($total_groups, $url);
2009-03-13 12:22:07 +01:00
foreach ( $groups as $group ) {
2019-01-30 16:18:44 +01:00
$data = [];
2019-04-02 13:42:30 +02:00
$data [ 'checkbox' ] = html_print_checkbox_extended ( 'delete_multiple[]' , $group [ 'id_sg' ], false , false , '' , 'class="check_delete"' , true );
2019-01-30 16:18:44 +01:00
$tabulation = str_repeat ( ' ' , $group [ 'deep' ]);
if ( defined ( 'METACONSOLE' )) {
$data [ 0 ] = $tabulation . '<a href="index.php?sec=advanced&sec2=godmode/modules/manage_nc_groups&id=' . $group [ 'id_sg' ] . '">' . $group [ 'name' ] . '</a>' ;
} else {
$data [ 0 ] = $tabulation . '<a href="index.php?sec=gmodules&sec2=godmode/modules/manage_nc_groups&id=' . $group [ 'id_sg' ] . '">' . $group [ 'name' ] . '</a>' ;
}
2019-04-02 13:42:30 +02:00
$table -> cellclass [][ 1 ] = 'action_buttons' ;
2020-06-04 21:07:53 +02:00
if ( is_management_allowed () === true ) {
$data [ 1 ] = " <a onclick='if(confirm( \" " . __ ( 'Are you sure?' ) . " \" )) return true; else return false;'
2019-04-02 13:42:30 +02:00
href = 'index.php?sec=".$sec.' & sec2 = godmode / modules / manage_nc_groups & delete = 1 & id = '.$group[' id_sg ']."&offset=0' > " .html_print_image('images/cross.png', true, ['title' => __('Delete')]).'</a>';
2020-06-04 21:07:53 +02:00
}
2019-01-30 16:18:44 +01:00
array_push ( $table -> data , $data );
2007-03-12 18:58:52 +01:00
}
2020-06-04 21:07:53 +02:00
if ( is_management_allowed () === false ) {
ui_print_warning_message ( __ ( 'This node is configured with centralized mode. This page is for read only. Go to metaconsole to manage the component groups.' ));
}
2013-02-07 16:53:04 +01:00
if ( isset ( $data )) {
2019-01-30 16:18:44 +01:00
echo " <form method='post' action='index.php?sec= " . $sec . " &sec2=godmode/modules/manage_nc_groups'> " ;
html_print_input_hidden ( 'multiple_delete' , 1 );
html_print_table ( $table );
2020-06-04 21:07:53 +02:00
if ( is_management_allowed () === true ) {
echo " <div style='padding-left: 10px; float: right;'> " ;
html_print_submit_button ( __ ( 'Delete' ), 'delete_btn' , false , 'class="sub delete"' );
echo '</div>' ;
}
2019-01-30 16:18:44 +01:00
echo '</form>' ;
} else {
ui_print_info_message ([ 'no_close' => true , 'message' => __ ( 'There are no defined component groups' ) ]);
2011-07-21 14:37:24 +02:00
}
2020-06-04 21:07:53 +02:00
if ( is_management_allowed () === true ) {
echo '<form method="post" action=' . $url . '>' ;
echo '<div class="" style="float:right;">' ;
html_print_input_hidden ( 'new' , 1 );
html_print_submit_button ( __ ( 'Create' ), 'crt' , false , 'class="sub next"' );
echo '</div>' ;
echo '</form>' ;
}
2009-03-13 12:22:07 +01:00
2013-05-20 10:42:02 +02:00
enterprise_hook ( 'close_meta_frame' );
2008-08-11 Esteban Sanchez <estebans@artica.es>
* include/functions_db.php: Added __ as an alias of lang_string().
* include/functions_reporting_pdf.php,
include/functions_reporting.php, include/functions.php,
include/functions_visual_map.php, index.php,
operation/incidents/incident.php,
operation/incidents/incident_detail.php,
operation/incidents/incident_note.php,
operation/incidents/incident_search.php,
operation/incidents/incident_statistics.php,
operation/snmpconsole/snmp_alert.php,
operation/snmpconsole/snmp_view.php, operation/users/user.php,
operation/users/user_edit.php, operation/users/user_statistics.php,
operation/events/event_statistics.php, operation/events/events.php,
operation/visual_console/render_view.php,
operation/visual_console/index.php, operation/extensions.php,
operation/agentes/estado_alertas.php,
operation/agentes/status_monitor.php,
operation/agentes/estado_grupo.php, operation/agentes/export_csv.php,
operation/agentes/datos_agente.php,
operation/agentes/estado_ultimopaquete.php,
operation/agentes/estado_generalagente.php,
operation/agentes/estado_agente.php, operation/agentes/bulbs.php,
operation/agentes/status_events.php, operation/agentes/sla_view.php,
operation/agentes/exportdata.php,
operation/agentes/estado_monitores.php,
operation/agentes/ver_agente.php, operation/agentes/estadisticas.php,
operation/agentes/tactical.php, operation/agentes/networkmap.php,
operation/messages/message.php,
operation/reporting/reporting_viewer.php,
operation/reporting/graph_viewer.php,
operation/reporting/custom_reporting.php,
operation/servers/view_server.php,
operation/servers/view_server_detail.php, operation/menu.php,
reporting/fgraph.php, reporting/stat_win.php, ajax.php,
general/logoff.php, general/pandora_help.php, general/footer.php,
general/noaccess.php, general/logon_failed.php,
general/links_menu.php, general/login_page.php, general/logon_ok.php,
general/header.php, general/main_menu.php,
godmode/groups/configure_group.php, godmode/groups/group_list.php,
godmode/setup/news.php, godmode/setup/links.php,
godmode/setup/setup.php, godmode/users/user_list.php,
godmode/users/configure_user.php, godmode/profiles/profile_list.php,
godmode/admin_access_logs.php, godmode/db/db_info_data.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_network.php,
godmode/agentes/module_manager_editor_wmi.php,
godmode/agentes/alert_manager.php,
godmode/agentes/module_manager_editor_plugin.php,
godmode/agentes/module_manager_editor_prediction.php,
godmode/agentes/alert_manager_editor.php,
godmode/agentes/manage_config.php,
godmode/agentes/module_manager_editor_data.php,
godmode/agentes/module_manager.php,
godmode/agentes/modificar_agente.php,
godmode/agentes/configurar_agente.php,
godmode/agentes/agent_disk_conf_editor.php,
godmode/agentes/planned_downtime.php,
godmode/agentes/manage_config_remote.php,
godmode/agentes/agent_manager.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_templates_form.php,
godmode/modules/manage_network_components_form_network.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.php,
godmode/reporting/map_builder.php,
godmode/reporting/graph_builder.php, godmode/servers/plugin.php,
godmode/servers/manage_recontask.php,
godmode/servers/modificar_server.php,
godmode/servers/manage_recontask_form.php,
godmode/alerts/modify_alert.php, godmode/alerts/configure_alert.php,
godmode/menu.php: Replaced $id_user with $config['id_user']. Use __a
instead of $lang_label to future use of gettext. Style
corrections.
* godmode/agentes/planned_downtime.php: Rewritten to use Pandora
functions and adopt the UI style. Replaced lang_string with __().
* pandoradb.sql: Fields in tplanned_downtime renamed to fit
guidelines.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1005 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-08-11 12:59:07 +02:00
?>
2011-08-25 20:27:47 +02:00
< script type = " text/javascript " >
2019-01-30 16:18:44 +01:00
$ ( document ) . ready ( function () {
$ ( '[id^=checkbox-delete_multiple]' ) . change ( function (){
if ( $ ( this ) . parent () . parent () . hasClass ( 'checkselected' )){
$ ( this ) . parent () . parent () . removeClass ( 'checkselected' );
}
else {
$ ( this ) . parent () . parent () . addClass ( 'checkselected' );
}
});
$ ( '[id^=checkbox-all_delete]' ) . change ( function (){
if ( $ ( " #checkbox-all_delete " ) . prop ( " checked " )) {
$ ( '[id^=checkbox-delete_multiple]' ) . parent () . parent () . addClass ( 'checkselected' );
$ ( " .check_delete " ) . prop ( " checked " , true );
}
else {
$ ( '[id^=checkbox-delete_multiple]' ) . parent () . parent () . removeClass ( 'checkselected' );
$ ( " .check_delete " ) . prop ( " checked " , false );
}
});
});
2013-05-20 10:42:02 +02:00
</ script >