diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 881b2faecd..018d13259b 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,14 @@ +2010-05-31 Sergio Martin + + * images/cog_del.png + godmode/agentes/massive_add_alerts.php + godmode/agentes/massive_delete_action_alerts.php + godmode/agentes/massive_operations.php + godmode/agentes/massive_add_action_alerts.php: Added the alert massive + operations 'add alerts', 'add actions' and 'delete actions'. + An icon to delete actions added too. + All for pending task: 3004606 + 2010-05-28 Miguel de Dios * godmode/reporting/reporting_builder.item_editor.php: added more intervals diff --git a/pandora_console/godmode/agentes/massive_add_action_alerts.php b/pandora_console/godmode/agentes/massive_add_action_alerts.php new file mode 100644 index 0000000000..1755fdec5b --- /dev/null +++ b/pandora_console/godmode/agentes/massive_add_action_alerts.php @@ -0,0 +1,149 @@ + 0){ + $agent_alerts = get_agent_alerts($id_agents); + $cont = 0; + $agent_alerts_id = array(); + foreach($agent_alerts['simple'] as $agent_alert){ + $agent_alerts_id[$cont] = $agent_alert['id']; + $cont = $cont + 1; + } + + foreach($agent_alerts['compounds'] as $agent_alert){ + $agent_alerts_id[$cont] = $agent_alert['id']; + $cont = $cont + 1; + } + + $options = array(); + + if($fires_min > 0) + $options['fires_min'] = $fires_min; + if($fires_max > 0) + $options['fires_max'] = $fires_max; + + $results = true; + foreach($agent_alerts_id as $agent_alert_id){ + $result = add_alert_agent_module_action($agent_alert_id, $action, $options); + if($result === false) + $results = false; + } + + print_result_message ($results, __('Successfully added'), __('Could not be added')); + } + else { + print_result_message (false, '', __('Could not be added').". ".__('No action selected')); + } + } + +} + +echo '

'.__('Massive alert actions addition').'

'; + +$groups = get_user_groups (); + +$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->size = array (); +$table->size[0] = '15%'; +$table->size[1] = '85%'; + +$table->data = array (); +$table->data[0][0] = __('Group'); +$table->data[0][1] = print_select ($groups, 'id_group', $id_group, + false, '', '', true); + +$table->data[1][0] = __('Agents'); +$table->data[1][0] .= ''; +$table->data[1][1] = print_select (get_group_agents ($id_group, false, "none"), + 'id_agents[]', 0, false, '', '', true, true); + +$actions = get_alert_actions (); +$table->data[2][0] = __('Action'); +$table->data[2][1] = print_select ($actions, 'action', '', '', __('None'), 0, true); +$table->data[2][1] .= ''.__('Advanced options').' » '; +$table->data[2][1] .= ''; + +echo '
'; +print_table ($table); + +echo '
'; +print_input_hidden ('add', 1); +print_submit_button (__('Add'), 'go', false, 'class="sub add"'); +echo '
'; +echo '
'; + +echo ''; + +require_jquery_file ('form'); +require_jquery_file ('pandora.controls'); +?> + + diff --git a/pandora_console/godmode/agentes/massive_add_alerts.php b/pandora_console/godmode/agentes/massive_add_alerts.php new file mode 100644 index 0000000000..c13fa3aa07 --- /dev/null +++ b/pandora_console/godmode/agentes/massive_add_alerts.php @@ -0,0 +1,165 @@ +'.__('Massive alerts addition').''; +function process_manage_add ($id_alert_template, $id_agents) { + if (empty ($id_agents)) { + echo '

'.__('No agents selected').'

'; + return false; + } + + if (empty ($id_alert_template)) { + echo '

'.__('No alert selected').'

'; + return false; + } + + process_sql_begin (); + $modules = get_agent_modules ($id_agents, 'id_agente_modulo', false, true); + $contfail = 0; + $contsuccess = 0; + foreach($modules as $module){ + $success = create_alert_agent_module ($module, $id_alert_template); + if(!$success) + $contfail = $contfail + 1; + else + $contsuccess = $contsuccess + 1; + } + + if ($contfail > 0) { + echo '

'.__('There was an error adding the alerts, the operation has been cancelled').'

'; + echo '

'.__('Could not add alerts').'

'; + process_sql_rollback (); + } + else { + echo '

'.__('Successfully added').' '.$contsuccess.' '.__('Alerts').'

'; + process_sql_commit (); + } +} + +$id_group = (int) get_parameter ('id_group', -1); +$id_agents = get_parameter ('id_agents'); +$id_alert_template = (int) get_parameter ('id_alert_template'); + +$add = (bool) get_parameter_post ('add'); + +if ($add) { + process_manage_add ($id_alert_template, $id_agents); +} + +$groups = get_user_groups (); + +$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->size = array (); +$table->size[0] = '15%'; +$table->size[1] = '85%'; + +$table->data = array (); + +$table->data[0][0] = __('Group'); +$table->data[0][1] = print_select ($groups, 'id_group', $id_group, + '', 'Select', -1, true, false, true, '', false); + +$table->data[1][0] = __('Agent'); +$table->data[1][0] .= ''; +$agents_alerts = get_agents_with_alert_template ($id_alert_template, $id_group, + false, array ('tagente.nombre', 'tagente.id_agente')); +$table->data[1][1] = print_select (index_array ($agents_alerts, 'id_agente', 'nombre'), + 'id_agents[]', '', '', '', '', true, true, true, '', false); + +$templates = get_alert_templates (false, array ('id', 'name')); +$table->data[2][0] = __('Alert template'); +$table->data[2][1] = print_select (index_array ($templates, 'id', 'name'), + 'id_alert_template', $id_alert_template, false, __('Select'), 0, true); + +echo '
'; +print_table ($table); + +echo '
'; +print_input_hidden ('add', 1); +print_submit_button (__('Add'), 'go', false, 'class="sub add"'); +echo '
'; +echo '
'; + +echo ''; + +require_jquery_file ('form'); +require_jquery_file ('pandora.controls'); +?> + + diff --git a/pandora_console/godmode/agentes/massive_delete_action_alerts.php b/pandora_console/godmode/agentes/massive_delete_action_alerts.php new file mode 100644 index 0000000000..06580c52de --- /dev/null +++ b/pandora_console/godmode/agentes/massive_delete_action_alerts.php @@ -0,0 +1,131 @@ + 0){ + $agent_alerts = get_agent_alerts($id_agents); + + $alerts_agent_modules = array(); + foreach($agent_alerts['simple'] as $agent_alert){ + $alerts_agent_modules = array_merge($alerts_agent_modules, get_alerts_agent_module ($agent_alert['id_agent_module'], true, false, 'id')); + } + + foreach($agent_alerts['compounds'] as $agent_alert){ + $alerts_agent_modules = array_merge($alerts_agent_modules, get_alerts_agent_module ($agent_alert['id'], false, false, 'id')); + } + + + $results = true; + $agent_module_actions = array(); + + foreach($alerts_agent_modules as $alert_agent_module){ + $agent_module_actions = get_alert_agent_module_actions ($alert_agent_module['id'], array('id','id_alert_action')); + + foreach ($agent_module_actions as $agent_module_action){ + if($agent_module_action['id_alert_action'] == $action) { + echo $agent_module_action['id']." . ". $alert_agent_module['id'] ." ; "; + $result = delete_alert_agent_module_action ($agent_module_action['id']); + + if($result === false) + $results = false; + } + } + } + + print_result_message ($results, __('Successfully deleted'), __('Could not be deleted')/*.": ". $agent_alerts['simple'][0]['id']*/); + } + else { + print_result_message (false, '', __('Could not be deleted').". ".__('No action selected')); + } + } + +} + +echo '

'.__('Massive alert actions deletion').'

'; + +$groups = get_user_groups (); + +$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->size = array (); +$table->size[0] = '15%'; +$table->size[1] = '85%'; + +$table->data = array (); +$table->data[0][0] = __('Group'); +$table->data[0][1] = print_select ($groups, 'id_group', $id_group, + false, '', '', true); + +$table->data[1][0] = __('Agents'); +$table->data[1][0] .= ''; +$table->data[1][1] = print_select (get_group_agents ($id_group, false, "none"), + 'id_agents[]', 0, false, '', '', true, true); + +$actions = get_alert_actions (); +$table->data[2][0] = __('Action'); +$table->data[2][1] = print_select ($actions, 'action', '', '', __('None'), 0, true); + +echo '
'; +print_table ($table); + +echo '
'; +print_input_hidden ('delete', 1); +print_submit_button (__('Delete'), 'go', false, 'class="sub delete"'); +echo '
'; +echo '
'; + +echo ''; + +require_jquery_file ('form'); +require_jquery_file ('pandora.controls'); +?> + + diff --git a/pandora_console/godmode/agentes/massive_operations.php b/pandora_console/godmode/agentes/massive_operations.php index 7d37584241..e5f4180d30 100644 --- a/pandora_console/godmode/agentes/massive_operations.php +++ b/pandora_console/godmode/agentes/massive_operations.php @@ -65,6 +65,33 @@ if($tab == 'delete_agents') else $deleteagenttab['active'] = false; +/* Add alerts actions */ +$addactionalerttab['text'] = '' + . print_image ("images/cog.png", true, array ("title" => __('Add Actions'))) + . ""; +if($tab == 'add_action_alerts') + $addactionalerttab['active'] = true; +else + $addactionalerttab['active'] = false; + +/* Delete alerts actions */ +$deleteactionalerttab['text'] = '' + . print_image ("images/cog_del.png", true, array ("title" => __('Delete Actions'))) + . ""; +if($tab == 'delete_action_alerts') + $deleteactionalerttab['active'] = true; +else + $deleteactionalerttab['active'] = false; + +/* Add Alerts */ +$addalerttab['text'] = '' + . print_image ("images/god2.png", true, array ("title" => __('Add alerts'))) + . ""; +if($tab == 'add_alerts') + $addalerttab['active'] = true; +else + $addalerttab['active'] = false; + /* Delete Alerts */ $deletealerttab['text'] = '' . print_image ("images/delete_alerts.png", true, array ("title" => __('Delete alerts'))) @@ -75,7 +102,7 @@ else $deletealerttab['active'] = false; -$onheader = array('copy_modules' => $copymoduletab, 'edit_modules' => $editmoduletab, 'delete_modules' => $deletemoduletab, 'delete_agents' => $deleteagenttab, 'delete_alerts' => $deletealerttab); +$onheader = array('copy_modules' => $copymoduletab, 'edit_modules' => $editmoduletab, 'delete_modules' => $deletemoduletab, 'delete_agents' => $deleteagenttab, 'add_action_alerts' => $addactionalerttab, 'delete_action_alerts' => $deleteactionalerttab, 'add_alerts' => $addalerttab, 'delete_alerts' => $deletealerttab); print_page_header (__('Agent configuration'). ' » '. __('Massive operations'), "images/god1.png", false, "", true, $onheader); @@ -84,6 +111,15 @@ switch ($tab) { case 'delete_alerts': require_once ('godmode/agentes/massive_delete_alerts.php'); break; +case 'add_alerts': + require_once ('godmode/agentes/massive_add_alerts.php'); + break; +case 'delete_action_alerts': + require_once ('godmode/agentes/massive_delete_action_alerts.php'); + break; +case 'add_action_alerts': + require_once ('godmode/agentes/massive_add_action_alerts.php'); + break; case 'delete_agents': require_once ('godmode/agentes/massive_delete_agents.php'); break; diff --git a/pandora_console/images/cog_del.png b/pandora_console/images/cog_del.png new file mode 100644 index 0000000000..621ef0b011 Binary files /dev/null and b/pandora_console/images/cog_del.png differ