diff --git a/pandora_console/godmode/massive/massive_add_policies_alerts.php b/pandora_console/godmode/massive/massive_add_policies_alerts.php
new file mode 100644
index 0000000000..b1f289a3e3
--- /dev/null
+++ b/pandora_console/godmode/massive/massive_add_policies_alerts.php
@@ -0,0 +1,284 @@
+ '<>0']) as $row) {
+ $alerts[$row['id']] = io_safe_output(alerts_get_alert_template_name($row['id_alert_template']).' - '.policies_get_module_name($row['id_policy_module']));
+ }
+ }
+
+ echo json_encode($alerts, true);
+ return;
+ }
+}
+
+$add = (bool) get_parameter_post('add');
+
+if ($add) {
+ $array_alerts = (array) get_parameter('id_alerts');
+ $array_actions = (array) get_parameter('action');
+ $fires_min = (int) get_parameter('fires_min', 0);
+ $fires_max = (int) get_parameter('fires_max', 0);
+
+ if (empty($array_alerts) === false) {
+ foreach ($array_alerts as $id_alert) {
+ foreach ($array_actions as $action) {
+ $id_policy_alert = db_get_value('id_policy_alert', 'tpolicy_alerts_actions', 'id', $action);
+ $result = policies_add_action_alert($id_alert, $action, $fires_min, $fires_max);
+ }
+ }
+
+ ui_print_result_message($result, __('Add action successfully'), __('Could not be added'), '');
+ }
+}
+
+
+$table = new stdClass();
+$table->id = 'add_table';
+$table->class = 'databox filters filter-table-adv';
+$table->width = '100%';
+$table->data = [];
+$table->style = [];
+$table->style[0] = 'font-weight: bold; vertical-align:top';
+$table->style[2] = 'font-weight: bold; vertical-align:top';
+$table->size = [];
+$table->size[0] = '50%';
+$table->size[1] = '50%';
+
+$table->data = [];
+
+$table->data[0][0] = html_print_label_input_block(
+ __('Group'),
+ html_print_select_groups(
+ false,
+ 'AW',
+ true,
+ 'id_group',
+ 0,
+ '',
+ 'All',
+ 0,
+ true,
+ false,
+ true,
+ '',
+ false,
+ 'width:100%;'
+ )
+);
+
+$table->data[0][1] = html_print_label_input_block(
+ __('Group recursion'),
+ html_print_checkbox('recursion', 1, $recursion, true, false, '', true)
+);
+
+$arr_policies = policies_get_policies();
+$policies = [];
+foreach ($arr_policies as $row) {
+ $policies[$row['id']] = $row['name'];
+}
+
+$table->data[1][0] = html_print_label_input_block(
+ __('Policies'),
+ html_print_select(
+ $policies,
+ 'id_policies[]',
+ '',
+ '',
+ '',
+ '',
+ true,
+ true,
+ true,
+ '',
+ false,
+ 'width:100%;'
+ )
+);
+
+$table->data[1][1] = html_print_label_input_block(
+ __('Alerts'),
+ html_print_select(
+ [],
+ 'id_alerts[]',
+ '',
+ '',
+ '',
+ '',
+ true,
+ true,
+ true,
+ '',
+ false,
+ 'width:100%;'
+ )
+);
+$actions = alerts_get_alert_actions();
+$table->data[2][0] = html_print_label_input_block(
+ __('Action'),
+ html_print_select(
+ $actions,
+ 'action[]',
+ '',
+ '',
+ '',
+ '',
+ true,
+ true,
+ true,
+ 'w100p',
+ false,
+ 'width:100%'
+ )
+);
+
+$table->data[2][1] = html_print_label_input_block(
+ __('Number of matching alerts'),
+ '
'.html_print_input_text('fires_min', 0, '', false, 10, true, false, false, '', 'w30p').''.__('to').''.html_print_input_text('fires_max', 0, '', false, 10, true, false, false, '', 'w30p').'
'
+);
+
+echo '';
+
+?>
+
+
diff --git a/pandora_console/godmode/massive/massive_add_policies_alerts_action_external.php b/pandora_console/godmode/massive/massive_add_policies_alerts_action_external.php
new file mode 100644
index 0000000000..177af408f1
--- /dev/null
+++ b/pandora_console/godmode/massive/massive_add_policies_alerts_action_external.php
@@ -0,0 +1,288 @@
+ '0']
+ );
+ foreach ($array_alerts as $row) {
+ $alerts[$row['id']] = io_safe_output(alerts_get_alert_template_name($row['id_alert_template']).' - '.$row['name_extern_module']);
+ }
+ }
+
+ echo json_encode($alerts, true);
+ return;
+ }
+}
+
+$add = (bool) get_parameter_post('add');
+
+if ($add) {
+ $array_alerts = (array) get_parameter('id_alerts');
+ $array_actions = (array) get_parameter('action');
+ $fires_min = (int) get_parameter('fires_min', 0);
+ $fires_max = (int) get_parameter('fires_max', 0);
+
+ if (empty($array_alerts) === false) {
+ foreach ($array_alerts as $id_alert) {
+ foreach ($array_actions as $action) {
+ $id_policy_alert = db_get_value('id_policy_alert', 'tpolicy_alerts_actions', 'id', $action);
+ $result = policies_add_action_alert($id_alert, $action, $fires_min, $fires_max);
+ }
+ }
+
+ ui_print_result_message($result, __('Add action successfully'), __('Could not be added'), '');
+ }
+}
+
+
+$table = new stdClass();
+$table->id = 'add_table';
+$table->class = 'databox filters filter-table-adv';
+$table->width = '100%';
+$table->data = [];
+$table->style = [];
+$table->style[0] = 'font-weight: bold; vertical-align:top';
+$table->style[2] = 'font-weight: bold; vertical-align:top';
+$table->size = [];
+$table->size[0] = '50%';
+$table->size[1] = '50%';
+
+$table->data = [];
+
+$table->data[0][0] = html_print_label_input_block(
+ __('Group'),
+ html_print_select_groups(
+ false,
+ 'AW',
+ true,
+ 'id_group',
+ 0,
+ '',
+ 'All',
+ 0,
+ true,
+ false,
+ true,
+ '',
+ false,
+ 'width:180px;'
+ )
+);
+
+$table->data[0][1] = html_print_label_input_block(
+ __('Group recursion'),
+ html_print_checkbox('recursion', 1, $recursion, true, false, '', true)
+);
+
+$arr_policies = policies_get_policies();
+$policies = [];
+foreach ($arr_policies as $row) {
+ $policies[$row['id']] = $row['name'];
+}
+
+$table->data[1][0] = html_print_label_input_block(
+ __('Policies'),
+ html_print_select(
+ $policies,
+ 'id_policies[]',
+ '',
+ '',
+ '',
+ '',
+ true,
+ true,
+ true,
+ '',
+ false,
+ 'width:100%;'
+ )
+);
+
+$table->data[1][1] = html_print_label_input_block(
+ __('Alerts'),
+ html_print_select(
+ [],
+ 'id_alerts[]',
+ '',
+ '',
+ '',
+ '',
+ true,
+ true,
+ true,
+ '',
+ false,
+ 'width:100%;'
+ )
+);
+$actions = alerts_get_alert_actions();
+$table->data[2][0] = html_print_label_input_block(
+ __('Action'),
+ html_print_select(
+ $actions,
+ 'action[]',
+ '',
+ '',
+ '',
+ '',
+ true,
+ true,
+ true,
+ 'w100p',
+ false,
+ 'width:100%'
+ )
+);
+
+$table->data[2][1] = html_print_label_input_block(
+ __('Number of matching alerts'),
+ ''.html_print_input_text('fires_min', 0, '', false, 10, true, false, false, '', 'w30p').''.__('to').''.html_print_input_text('fires_max', 0, '', false, 10, true, false, false, '', 'w30p').'
'
+);
+
+echo '';
+
+?>
+
+
diff --git a/pandora_console/godmode/massive/massive_delete_policies_alerts.php b/pandora_console/godmode/massive/massive_delete_policies_alerts.php
new file mode 100644
index 0000000000..564e2afba6
--- /dev/null
+++ b/pandora_console/godmode/massive/massive_delete_policies_alerts.php
@@ -0,0 +1,325 @@
+ '<>0']) as $row) {
+ $name = io_safe_output(alerts_get_alert_template_name($row['id_alert_template']).' - '.policies_get_module_name($row['id_policy_module']));
+ $alerts[$row['id'].'__'.policies_get_name($policie).' - '.$name] = $name;
+ }
+ }
+
+ echo json_encode($alerts, true);
+ return;
+ }
+
+ if ($load_actions_alerts) {
+ $array_alerts = get_parameter('id_alerts', []);
+
+ $actions = [];
+ foreach ($array_alerts as $alert) {
+ $alert_policie = explode('__', $alert);
+ $alert_id = $alert_policie[0];
+ $alert_name = $alert_policie[1];
+ $array_actions = db_get_all_rows_filter(
+ 'tpolicy_alerts_actions',
+ ['id_policy_alert' => $alert]
+ );
+ foreach ($array_actions as $row) {
+ $action = db_get_row_filter(
+ 'talert_actions',
+ ['id' => $row['id_alert_action']]
+ );
+ $actions[$row['id']] = $alert_name.' - '.$action['name'];
+ }
+ }
+
+ echo json_encode($actions, true);
+ return;
+ }
+}
+
+$delete = (bool) get_parameter_post('delete');
+
+if ($delete) {
+ $array_actions = get_parameter('id_actions');
+ foreach ($array_actions as $id_action) {
+ $result = policies_delete_action_alert($id_action);
+ }
+
+ ui_print_result_message($result, __('Deleted action successfully'), __('Could not be deleted'), '');
+}
+
+
+$table = new stdClass();
+$table->id = 'add_table';
+$table->class = 'databox filters filter-table-adv';
+$table->width = '100%';
+$table->data = [];
+$table->style = [];
+$table->style[0] = 'font-weight: bold; vertical-align:top';
+$table->style[2] = 'font-weight: bold; vertical-align:top';
+$table->size = [];
+$table->size[0] = '50%';
+$table->size[1] = '50%';
+
+$table->data = [];
+
+$table->data[0][0] = html_print_label_input_block(
+ __('Group'),
+ html_print_select_groups(
+ false,
+ 'AW',
+ true,
+ 'id_group',
+ 0,
+ '',
+ 'All',
+ 0,
+ true,
+ false,
+ true,
+ '',
+ false,
+ 'width:180px;'
+ )
+);
+
+$table->data[0][1] = html_print_label_input_block(
+ __('Group recursion'),
+ html_print_checkbox('recursion', 1, $recursion, true, false, '', true)
+);
+
+$arr_policies = policies_get_policies();
+$policies = [];
+foreach ($arr_policies as $row) {
+ $policies[$row['id']] = $row['name'];
+}
+
+$table->data[1][0] = html_print_label_input_block(
+ __('Policies'),
+ html_print_select(
+ $policies,
+ 'id_policies[]',
+ '',
+ '',
+ '',
+ '',
+ true,
+ true,
+ true,
+ '',
+ false,
+ 'width:100%;'
+ )
+);
+
+$table->data[1][1] = html_print_label_input_block(
+ __('Alerts'),
+ html_print_select(
+ [],
+ 'id_alerts[]',
+ '',
+ '',
+ '',
+ '',
+ true,
+ true,
+ true,
+ '',
+ false,
+ 'width:100%;'
+ )
+);
+
+$table->colspan[2][0] = 2;
+$table->data[2][0] = html_print_label_input_block(
+ __('Actions'),
+ html_print_select(
+ [],
+ 'id_actions[]',
+ '',
+ '',
+ '',
+ '',
+ true,
+ true,
+ true,
+ '',
+ false,
+ 'width:100%;'
+ )
+);
+
+echo '';
+
+?>
+
+
diff --git a/pandora_console/godmode/massive/massive_delete_policies_alerts_action_external.php b/pandora_console/godmode/massive/massive_delete_policies_alerts_action_external.php
new file mode 100644
index 0000000000..a3d251ae09
--- /dev/null
+++ b/pandora_console/godmode/massive/massive_delete_policies_alerts_action_external.php
@@ -0,0 +1,325 @@
+ '0']) as $row) {
+ $name = io_safe_output(alerts_get_alert_template_name($row['id_alert_template']).' - '.$row['name_extern_module']);
+ $alerts[$row['id'].'__'.policies_get_name($policie).' - '.$name] = $name;
+ }
+ }
+
+ echo json_encode($alerts, true);
+ return;
+ }
+
+ if ($load_actions_alerts) {
+ $array_alerts = get_parameter('id_alerts', []);
+
+ $actions = [];
+ foreach ($array_alerts as $alert) {
+ $alert_policie = explode('__', $alert);
+ $alert_id = $alert_policie[0];
+ $alert_name = $alert_policie[1];
+ $array_actions = db_get_all_rows_filter(
+ 'tpolicy_alerts_actions',
+ ['id_policy_alert' => $alert]
+ );
+ foreach ($array_actions as $row) {
+ $action = db_get_row_filter(
+ 'talert_actions',
+ ['id' => $row['id_alert_action']]
+ );
+ $actions[$row['id']] = $alert_name.' - '.$action['name'];
+ }
+ }
+
+ echo json_encode($actions, true);
+ return;
+ }
+}
+
+$delete = (bool) get_parameter_post('delete');
+
+if ($delete) {
+ $array_actions = get_parameter('id_actions');
+ foreach ($array_actions as $id_action) {
+ $result = policies_delete_action_alert($id_action);
+ }
+
+ ui_print_result_message($result, __('Deleted action successfully'), __('Could not be deleted'), '');
+}
+
+
+$table = new stdClass();
+$table->id = 'add_table';
+$table->class = 'databox filters filter-table-adv';
+$table->width = '100%';
+$table->data = [];
+$table->style = [];
+$table->style[0] = 'font-weight: bold; vertical-align:top';
+$table->style[2] = 'font-weight: bold; vertical-align:top';
+$table->size = [];
+$table->size[0] = '50%';
+$table->size[1] = '50%';
+
+$table->data = [];
+
+$table->data[0][0] = html_print_label_input_block(
+ __('Group'),
+ html_print_select_groups(
+ false,
+ 'AW',
+ true,
+ 'id_group',
+ 0,
+ '',
+ 'All',
+ 0,
+ true,
+ false,
+ true,
+ '',
+ false,
+ 'width:180px;'
+ )
+);
+
+$table->data[0][1] = html_print_label_input_block(
+ __('Group recursion'),
+ html_print_checkbox('recursion', 1, $recursion, true, false, '', true)
+);
+
+$arr_policies = policies_get_policies();
+$policies = [];
+foreach ($arr_policies as $row) {
+ $policies[$row['id']] = $row['name'];
+}
+
+$table->data[1][0] = html_print_label_input_block(
+ __('Policies'),
+ html_print_select(
+ $policies,
+ 'id_policies[]',
+ '',
+ '',
+ '',
+ '',
+ true,
+ true,
+ true,
+ '',
+ false,
+ 'width:100%;'
+ )
+);
+
+$table->data[1][1] = html_print_label_input_block(
+ __('Alerts'),
+ html_print_select(
+ [],
+ 'id_alerts[]',
+ '',
+ '',
+ '',
+ '',
+ true,
+ true,
+ true,
+ '',
+ false,
+ 'width:100%;'
+ )
+);
+
+$table->colspan[2][0] = 2;
+$table->data[2][0] = html_print_label_input_block(
+ __('Actions'),
+ html_print_select(
+ [],
+ 'id_actions[]',
+ '',
+ '',
+ '',
+ '',
+ true,
+ true,
+ true,
+ '',
+ false,
+ 'width:100%;'
+ )
+);
+
+echo '';
+
+?>
+
+
diff --git a/pandora_console/godmode/massive/massive_operations.php b/pandora_console/godmode/massive/massive_operations.php
index 534a881d91..b91f1dfa94 100755
--- a/pandora_console/godmode/massive/massive_operations.php
+++ b/pandora_console/godmode/massive/massive_operations.php
@@ -64,6 +64,16 @@ $options_alerts = [
'standby_alerts' => __('Bulk alert setting standby'),
];
+$options_alerts_policies = [
+ 'add_policies_alerts' => __('Bulk policies alert action add'),
+ 'delete_policies_alerts' => __('Bulk policies alert action delete'),
+];
+
+$options_policies_alerts_externals = [
+ 'add_policies_alerts_action_external' => __('Bulk policies external alert action add'),
+ 'delete_policies_alerts_action_external' => __('Bulk policies external alert action delete'),
+];
+
$options_agents = [
'edit_agents' => __('Bulk agent edit'),
'delete_agents' => __('Bulk agent delete'),
@@ -119,6 +129,10 @@ if ($satellite_options != ENTERPRISE_NOT_HOOK) {
if (in_array($option, array_keys($options_alerts)) === true) {
$tab = 'massive_alerts';
+} else if (in_array($option, array_keys($options_alerts_policies)) === true) {
+ $tab = 'massive_policies_alerts';
+} else if (in_array($option, array_keys($options_policies_alerts_externals)) === true) {
+ $tab = 'massive_policies_alerts_external';
} else if (in_array($option, array_keys($options_agents)) === true) {
$tab = 'massive_agents';
} else if (in_array($option, array_keys($options_users)) === true) {
@@ -173,6 +187,14 @@ switch ($tab) {
$options = $options_alerts;
break;
+ case 'massive_policies_alerts':
+ $options = $options_alerts_policies;
+ break;
+
+ case 'massive_policies_alerts_external':
+ $options = $options_policies_alerts_externals;
+ break;
+
case 'massive_agents':
$options = $options_agents;
break;
@@ -223,6 +245,30 @@ $alertstab = [
'active' => $tab == 'massive_alerts',
];
+$policiesalertstab = [
+ 'text' => ''.html_print_image(
+ 'images/policies_mc.png',
+ true,
+ [
+ 'title' => __('Policies alerts'),
+ 'class' => 'invert_filter main_menu_icon',
+ ]
+ ).'',
+ 'active' => $tab == 'massive_policies_alerts',
+];
+
+$policiesalertsexternaltab = [
+ 'text' => ''.html_print_image(
+ 'images/alerts_extern.png',
+ true,
+ [
+ 'title' => __('Policies external alerts'),
+ 'class' => 'invert_filter main_menu_icon',
+ ]
+ ).'',
+ 'active' => $tab == 'massive_policies_alerts_external',
+];
+
$userstab = [
'text' => ''.html_print_image(
'images/user.svg',
@@ -298,6 +344,8 @@ if (check_acl($config['id_user'], 0, 'UM')) {
}
$onheader['massive_alerts'] = $alertstab;
+$onheader['massive_policies_alerts'] = $policiesalertstab;
+$onheader['massive_policies_alerts_external'] = $policiesalertsexternaltab;
$onheader['policies'] = $policiestab;
$onheader['snmp'] = $snmptab;
$onheader['satellite'] = $satellitetab;
@@ -318,6 +366,8 @@ if (is_metaconsole() === false) {
$pluginstab,
$userstab,
$alertstab,
+ $policiesalertstab,
+ $policiesalertsexternaltab,
$policiestab,
$snmptab,
$satellitetab,
@@ -490,6 +540,22 @@ switch ($option) {
include_once $config['homedir'].'/godmode/massive/massive_standby_alerts.php';
break;
+ case 'add_policies_alerts':
+ include_once $config['homedir'].'/godmode/massive/massive_add_policies_alerts.php';
+ break;
+
+ case 'delete_policies_alerts':
+ include_once $config['homedir'].'/godmode/massive/massive_delete_policies_alerts.php';
+ break;
+
+ case 'add_policies_alerts_action_external':
+ include_once $config['homedir'].'/godmode/massive/massive_add_policies_alerts_action_external.php';
+ break;
+
+ case 'delete_policies_alerts_action_external':
+ include_once $config['homedir'].'/godmode/massive/massive_delete_policies_alerts_action_external.php';
+ break;
+
case 'add_profiles':
include_once $config['homedir'].'/godmode/massive/massive_add_profiles.php';
break;
diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php
index 5090a8baa1..7cd504c8ac 100644
--- a/pandora_console/godmode/menu.php
+++ b/pandora_console/godmode/menu.php
@@ -309,6 +309,8 @@ if ($access_console_node === true) {
}
$sub2['godmode/massive/massive_operations&tab=massive_alerts']['text'] = __('Alerts operations');
+ $sub2['godmode/massive/massive_operations&tab=massive_policies_alerts']['text'] = __('Policies alerts');
+ $sub2['godmode/massive/massive_operations&tab=massive_policies_alerts_external']['text'] = __('Policies External alerts');
enterprise_hook('massivepolicies_submenu');
enterprise_hook('massivesnmp_submenu');
enterprise_hook('massivesatellite_submenu');