diff --git a/pandora_console/godmode/massive/massive_add_tags.php b/pandora_console/godmode/massive/massive_add_tags.php
new file mode 100755
index 0000000000..c6ccc45848
--- /dev/null
+++ b/pandora_console/godmode/massive/massive_add_tags.php
@@ -0,0 +1,249 @@
+ $name_module) {
+ $modules_id[] = $id_module;
+ }
+ }
+ }
+
+
+ $conttotal = 0;
+ $contsuccess = 0;
+ foreach($modules_id as $id_module) {
+ $err_count = tags_insert_module_tag($id_module, $id_tags);
+
+ if ($err_count == 0) {
+ $contsuccess ++;
+ }
+
+ $conttotal ++;
+ }
+
+ if ($contsuccess > 0) {
+ db_pandora_audit("Massive management", "Add tags", false, false,
+ "");
+ }
+ else {
+ db_pandora_audit("Massive management", "Fail try to add tags",
+ false, false, "");
+ }
+
+ ui_print_result_message ($contsuccess > 0,
+ __('Successfully added') . "(" . $contsuccess . "/" . $conttotal . ")",
+ __('Could not be added'));
+
+}
+
+$id_agents = get_parameter ('id_agents');
+$id_tags = get_parameter ('id_tags');
+$modules = get_parameter ('module');
+
+$add = (bool) get_parameter_post ('add');
+
+if ($add) {
+ process_manage_add ($id_agents, $modules, $id_tags);
+}
+
+$groups = users_get_groups ();
+$own_info = get_user_info($config['id_user']);
+if (!$own_info['is_admin'] && !check_acl ($config['id_user'], 0, "AW"))
+ $return_all_group = false;
+else
+ $return_all_group = true;
+
+$table->id = 'add_table';
+$table->width = '98%';
+$table->data = array ();
+$table->style = array ();
+$table->style[0] = 'font-weight: bold; vertical-align:top';
+$table->style[2] = 'font-weight: bold; vertical-align:top';
+$table->size = array ();
+$table->size[0] = '15%';
+$table->size[1] = '40%';
+$table->size[2] = '15%';
+$table->size[3] = '40%';
+
+$table->data = array ();
+
+$table->data[0][0] = __('Group');
+$table->data[0][1] = html_print_select_groups(false, "AW",
+ $return_all_group, 'id_group', 0, '', 'Select', -1, true, false,
+ true, '', false, 'width:180px;');
+
+$table->data[1][0] = __('Agents');
+$table->data[1][0] .= '';
+$table->data[1][0] .= html_print_image('images/spinner.png', true);
+$table->data[1][0] .= '';
+
+$agents = agents_get_group_agents(
+ array_keys(users_get_groups ($config["id_user"], "AW", false)));
+$table->data[1][1] = html_print_select ($agents,
+ 'id_agents[]', '', '', '', '', true, true, true, '', false, 'width:180px;');
+
+$table->data[1][2] = __('Modules');
+$table->data[1][2] .= '';
+$table->data[1][2] .= html_print_image('images/spinner.png', true);
+$table->data[1][2] .= '';
+$table->data[1][3] = '' .
+ html_print_select (array(), 'module[]', '', false, '', '', true, true, false, '', false, 'width:180px;');
+
+
+$table->data[2][0] = __('Tags');
+$tags = tags_get_all_tags();
+$table->data[2][1] = html_print_select ($tags,
+ 'id_tags[]', '', '', '', '', true, true, true, '', false, 'width:180px;');
+
+
+echo '
';
+
+// TODO: Change to iu_print_error system
+echo '
';
+
+//Hack to translate text "none" in PHP to javascript
+echo '' . __('None') . '';
+
+ui_require_jquery_file ('form');
+ui_require_jquery_file ('pandora.controls');
+?>
+
+
diff --git a/pandora_console/godmode/massive/massive_operations.php b/pandora_console/godmode/massive/massive_operations.php
index 5659a59abd..8ffd93e04c 100644
--- a/pandora_console/godmode/massive/massive_operations.php
+++ b/pandora_console/godmode/massive/massive_operations.php
@@ -40,6 +40,11 @@ $options_alerts = array(
'enable_disable_alerts' => __('Massive alert enable/disable'),
'standby_alerts' => __('Massive alert setting standby'));
+$options_tags = array(
+ 'add_tags' => __('Massive tags addition'),
+ 'delete_tags' => __('Massive tags deletion')
+ );
+
$options_agents = array(
'edit_agents' => __('Massive agents edition'),
'delete_agents' => __('Massive agents deletion'));
@@ -89,6 +94,9 @@ if ($satellite_options != ENTERPRISE_NOT_HOOK) {
if (in_array($option, array_keys($options_alerts))) {
$tab = 'massive_alerts';
}
+elseif (in_array($option, array_keys($options_tags))) {
+ $tab = 'massive_tags';
+}
elseif (in_array($option, array_keys($options_agents))) {
$tab = 'massive_agents';
}
@@ -112,6 +120,9 @@ else {
}
switch ($tab) {
+ case 'massive_tags':
+ $options = $options_tags;
+ break;
case 'massive_alerts':
$options = $options_alerts;
break;
@@ -140,9 +151,18 @@ if ($option == '') {
$option = array_shift(array_keys($options));
}
-$alertstab = array('text' => ''
- . html_print_image ('images/op_alerts.png', true, array ('title' => __('Alerts operations')))
- . '', 'active' => $tab == 'massive_alerts');
+$tagstab = array('text' =>
+ '' .
+ html_print_image ('images/tag.png', true,
+ array('title' => __('Tags operations'))) . '',
+ 'active' => $tab == 'massive_tags');
+
+
+$alertstab = array('text' =>
+ '' .
+ html_print_image ('images/op_alerts.png', true,
+ array('title' => __('Alerts operations'))) . '',
+ 'active' => $tab == 'massive_alerts');
$userstab = array('text' => ''
. html_print_image ('images/op_workspace.png', true, array ('title' => __('Users operations')))
@@ -180,6 +200,7 @@ $onheader['massive_modules'] = $modulestab;
if (check_acl ($config['id_user'], 0, "PM")) {
$onheader['user_agents'] = $userstab;
}
+$onheader['massive_tags'] = $tagstab;
$onheader['massive_alerts'] = $alertstab;
$onheader['policies'] = $policiestab;
$onheader['snmp'] = $snmptab;
@@ -292,6 +313,12 @@ switch ($option) {
case 'copy_modules':
require_once ('godmode/massive/massive_copy_modules.php');
break;
+ case 'add_tags':
+ require_once ('godmode/massive/massive_add_tags.php');
+ break;
+ case 'delete_tags':
+ require_once ('godmode/massive/massive_delete_tags.php');
+ break;
default:
if (!enterprise_hook('massive_operations', array($option))) {
require_once ('godmode/massive/massive_config.php');
diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php
index b93a0e42e2..5ba3ac5a42 100644
--- a/pandora_console/godmode/menu.php
+++ b/pandora_console/godmode/menu.php
@@ -64,6 +64,7 @@ if (check_acl ($config['id_user'], 0, "AW")) {
$sub["godmode/massive/massive_operations&tab=massive_users"]["text"] = __('Users operations');
}
$sub["godmode/massive/massive_operations&tab=massive_alerts"]["text"] = __('Alerts operations');
+ $sub["godmode/massive/massive_operations&tab=massive_tags"]["text"] = __('Tags operations');
enterprise_hook('massivepolicies_submenu');
enterprise_hook('massivesnmp_submenu');
enterprise_hook('massivesatellite_submenu');
diff --git a/pandora_console/include/functions_tags.php b/pandora_console/include/functions_tags.php
index 809f366a1f..4605cd5cb4 100644
--- a/pandora_console/include/functions_tags.php
+++ b/pandora_console/include/functions_tags.php
@@ -425,7 +425,7 @@ function tags_insert_module_tag ($id_agent_module, $tags) {
$values = array();
- if($tags == false) {
+ if ($tags == false) {
$tags = array();
}
@@ -440,6 +440,8 @@ function tags_insert_module_tag ($id_agent_module, $tags) {
if ($result_tag === false)
$errn++;
}
+
+ return $errn;
}
/**
diff --git a/pandora_console/include/javascript/pandora.js b/pandora_console/include/javascript/pandora.js
index 298d2ecf51..c3924f5d89 100644
--- a/pandora_console/include/javascript/pandora.js
+++ b/pandora_console/include/javascript/pandora.js
@@ -177,7 +177,8 @@ function agent_changed_by_multiple_agents (event, id_agent, selected) {
$('#module').attr ('disabled', 1);
$('#module').empty ();
- $('#module').append ($('').html ("Loading...").attr ("value", 0));
+ $('#module').append ($('')
+ .html ("Loading...").attr ("value", 0));
// Check if homedir was received like a JSON