diff --git a/pandora_console/extensions/insert_data.php b/pandora_console/extensions/insert_data.php index 698938aa63..5cfcc331d0 100644 --- a/pandora_console/extensions/insert_data.php +++ b/pandora_console/extensions/insert_data.php @@ -174,7 +174,6 @@ function mainInsertData() { $table->data[1][0] = __('Module'); $modules = array (); if ($agent_id){ - // TODO TAGS agents_get_modules $modules = agents_get_modules ($agent_id, false, array("delete_pending" => 0)); } $table->data[1][1] = html_print_select ($modules, 'id_agent_module', $id_agent_module, true, diff --git a/pandora_console/extras/pandora_diag.php b/pandora_console/extras/pandora_diag.php index 0b4be02ae1..4c851238ad 100644 --- a/pandora_console/extras/pandora_diag.php +++ b/pandora_console/extras/pandora_diag.php @@ -612,7 +612,7 @@ echo "data[0][0] = __('Module'); $modules = array (); -// TODO TAGS agents_get_modules + if ($id_agente) $modules = agents_get_modules ($id_agente, false, array("delete_pending" => 0)); diff --git a/pandora_console/godmode/massive/massive_delete_modules.php b/pandora_console/godmode/massive/massive_delete_modules.php index 26bcb7ec19..8e6684c6fc 100755 --- a/pandora_console/godmode/massive/massive_delete_modules.php +++ b/pandora_console/godmode/massive/massive_delete_modules.php @@ -76,147 +76,14 @@ function process_manage_delete ($module_name, $id_agents, $module_status = 'all' if (($module_name[0] == "0") and (is_array($module_name)) and (count($module_name) == 1)) $filter_for_module_deletion = false; else - $filter_for_module_deletion = sprintf('nombre IN ("%s")', implode('","', $module_name)); + $filter_for_module_deletion = sprintf('tagente_modulo.nombre IN ("%s")', implode('","', $module_name)); - if ($config['dbtype'] == "oracle") { - $all_agent_modules = false; - if (($module_name[0] == "0") and (is_array($module_name)) and (count($module_name) == 1)) { - $all_agent_modules = true; - } - $names_to_long = array(); - $i = 0; - foreach ($module_name as $name) { - if (strlen($name) > 30) { - $original_names[] = $module_name[$i]; - unset($module_name[$i]); - $names_to_long[] = substr($name, 0, 28) . "%"; - } - $i++; - } - $modules = "SELECT id_agente_modulo, nombre FROM tagente_modulo WHERE"; - $modules .= sprintf(" id_agente IN (%s)", implode(",", $id_agents)); - if (!empty($module_name) && (!$all_agent_modules)) { - $modules .= sprintf(" AND nombre IN ('%s')", implode("','", $module_name)); - } - $modules = db_get_all_rows_sql($modules); - $modules2 = ""; - if (!empty($names_to_long) && (!$all_agent_modules)) { - $modules2 = "SELECT id_agente_modulo, nombre FROM tagente_modulo WHERE"; - $modules2 .= sprintf(" id_agente IN (%s) AND (", implode(",", $id_agents)); - $j = 0; - foreach ($names_to_long as $name) { - if ($j == 0) { - $modules2 .= "nombre LIKE ('" . $name . "')"; - } - else { - $modules2 .= " OR nombre LIKE ('" . $name . "')"; - } - $j++; - } - $modules2 .= ")"; - $modules2 = db_get_all_rows_sql($modules2); - $modules = array_merge($modules, $modules2); - } - $all_names = array(); - foreach ($modules as $module) { - $all_modules[] = $module['id_agente_modulo']; - $all_names[] = $module['nombre']; - } - $modules = $all_modules; - $modules = array_unique($modules); - if (!empty($names_to_long) && (!$all_agent_modules)) { - $j = 0; - foreach ($all_names as $name) { - if (strlen($name) > 30) { - if (!in_array($name, $original_names)) { - unset($modules[$j]); - } - } - $j++; - } - } - } - else { - // TODO TAGS agents_get_modules - $modules = agents_get_modules ($id_agents, 'id_agente_modulo', - $filter_for_module_deletion, true); - } + $modules = agents_get_modules ($id_agents, 'id_agente_modulo', + $filter_for_module_deletion, true); } else { - if ($config['dbtype'] == "oracle") { - $all_agent_modules = false; - $names_to_long = array(); - if (($module_name[0] == "0") and (is_array($module_name)) and (count($module_name) == 1)) { - $all_agent_modules = true; - } - $i = 0; - foreach ($module_name as $name) { - if (strlen($name) > 30) { - $original_names[] = $module_name[$i]; - unset($module_name[$i]); - $names_to_long[] = substr($name, 0, 28) . "%"; - } - $i++; - } - $modules = "SELECT id_agente_modulo, nombre FROM tagente_modulo WHERE"; - $any_agent = false; - if ($id_agents == null) { - $any_agent = true; - } - if (!empty($id_agents)) { - $modules .= sprintf(" id_agente IN (%s)", implode(",", $id_agents)); - $agents_selected = true; - } - if (!empty($module_name) && (!$all_agent_modules)) { - if ($any_agent) { - $modules .= sprintf(" nombre IN ('%s')", implode("','", $module_name)); - } - else { - $modules .= sprintf(" AND nombre IN ('%s')", implode("','", $module_name)); - } - } - $modules = db_get_all_rows_sql($modules); - if (!empty($names_to_long) && (!$all_agent_modules)) { - $modules2 = "SELECT id_agente_modulo, nombre FROM tagente_modulo WHERE"; - $modules2 .= sprintf(" id_agente IN (%s) AND (", implode(",", $id_agents)); - $j = 0; - foreach ($names_to_long as $name) { - if ($j == 0) { - $modules2 .= "nombre LIKE ('" . $name . "')"; - } - else { - $modules2 .= " OR nombre LIKE ('" . $name . "')"; - } - $j++; - } - $modules2 .= ")"; - $modules2 = db_get_all_rows_sql($modules2); - $modules = array_merge($modules, $modules2); - } - $all_names = array(); - foreach ($modules as $module) { - $all_modules[] = $module['id_agente_modulo']; - $all_names[] = $module['nombre']; - } - $modules = $all_modules; - $modules = array_unique($modules); - if (!empty($names_to_long) && (!$all_agent_modules)) { - $j = 0; - foreach ($all_names as $name) { - if (strlen($name) > 30) { - if (!in_array($name, $original_names)) { - unset($modules[$j]); - } - } - $j++; - } - } - } - else { - // TODO TAGS agents_get_modules - $modules = agents_get_modules ($id_agents, 'id_agente_modulo', - sprintf('nombre IN ("%s")', implode('","',$module_name)), true); - } + $modules = agents_get_modules ($id_agents, 'id_agente_modulo', + 'tagente_modulo.nombre IN ("' . implode('","',$module_name) . '")', true); } if (($module_status == 'unknown') && ($module_name[0] == "0") && (is_array($module_name)) && (count($module_name) == 1)) { @@ -432,8 +299,6 @@ $table->data['form_modules_1'][3] = __('Select all modules of this type') . ' ' html_print_checkbox_extended("force_type", 'type', '', '', false, '', 'style="margin-right: 40px;"', true); - - $modules = array (); if ($module_type != '') { $filter = array ('id_tipo_modulo' => $module_type); @@ -441,9 +306,8 @@ if ($module_type != '') { else { $filter = false; } -// TODO TAGS agents_get_modules $names = agents_get_modules (array_keys ($agents), - 'DISTINCT(nombre)', $filter, false); + 'DISTINCT(tagente_modulo.nombre)', $filter, false); foreach ($names as $name) { $modules[$name['nombre']] = $name['nombre']; } diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index ef146bd7b8..4199f2c9a5 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -1177,7 +1177,10 @@ function agents_get_modules ($id_agent = null, $details = false, else { $details = (array)$details; $details = io_safe_input ($details); - $details = array_map(function ($a) { return 'tagente_modulo.' . $a;}, $details); + $details = array_map(function ($a) { + return preg_match('/tagente_modulo./i', $a) ? $a : 'tagente_modulo.' . $a; + },$details + ); } $sql_tags_join = ""; diff --git a/pandora_console/include/functions_tags.php b/pandora_console/include/functions_tags.php index 75eef28bdd..d7349c745f 100644 --- a/pandora_console/include/functions_tags.php +++ b/pandora_console/include/functions_tags.php @@ -2640,7 +2640,7 @@ function tags_get_module_policy_tags($id_tag, $id_module) { * true if there is not any tag restriction * array with all tags if there are tags configured */ -function tags_get_user_applied_agent_tags ($id_agent, $access) { +function tags_get_user_applied_agent_tags ($id_agent, $access = "AR") { global $config; $agent_groups = agents_get_all_groups_agent($id_agent); diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php index 7f67e01c43..6c1d3b9718 100644 --- a/pandora_console/operation/agentes/ver_agente.php +++ b/pandora_console/operation/agentes/ver_agente.php @@ -673,7 +673,7 @@ if (is_ajax ()) { } if ($status_modulo != -1) { - $filter['id_agente_modulo IN'] = ' (SELECT id_agente_modulo FROM tagente_estado where ' . $sql_conditions; + $filter['tagente_modulo.id_agente_modulo IN'] = ' (SELECT id_agente_modulo FROM tagente_estado where ' . $sql_conditions; } @@ -685,7 +685,7 @@ if (is_ajax ()) { if ($get_id_and_name) $fields = array('id_agente_modulo', 'nombre'); if ($get_distinct_name) - $fields = array('DISTINCT(nombre)'); + $fields = array('DISTINCT(tagente_modulo.nombre)'); $indexed = (bool) get_parameter ('indexed', true); $agentName = (string) get_parameter ('agent_name', null); @@ -730,7 +730,6 @@ if (is_ajax ()) { $id_agent = array_keys( agents_get_group_agents( array_keys(users_get_groups ()), $search, "none")); - // TODO TAGS agents_get_modules $agent_modules = agents_get_modules ($id_agent, $fields, $filter, $indexed, true, false, $tags); }