diff --git a/pandora_console/extensions/insert_data.php b/pandora_console/extensions/insert_data.php index 592d0d2b2a..494bbdd0d2 100644 --- a/pandora_console/extensions/insert_data.php +++ b/pandora_console/extensions/insert_data.php @@ -209,7 +209,7 @@ function mainInsertData() { var inputs = []; inputs.push ("agent_name=" + agent_name); - inputs.push ('filter=delete_pending = 0'); + inputs.push ("delete_pending=0"); inputs.push ("get_agent_modules_json=1"); inputs.push ("page=operation/agentes/ver_agente"); jQuery.ajax ({ diff --git a/pandora_console/godmode/massive/massive_copy_modules.php b/pandora_console/godmode/massive/massive_copy_modules.php index a9d5178b4e..d386f34406 100755 --- a/pandora_console/godmode/massive/massive_copy_modules.php +++ b/pandora_console/godmode/massive/massive_copy_modules.php @@ -316,8 +316,8 @@ $(document).ready (function () { {"page" : "operation/agentes/ver_agente", "get_agent_modules_json" : 1, "id_agent" : this.value, - "filter" : "disabled = 0", - "fields" : "id_agente_modulo,nombre" + "disabled" : 0, + "get_id_and_name" : 1 }, function (data, status) { if (data.length == 0) { diff --git a/pandora_console/godmode/massive/massive_delete_modules.php b/pandora_console/godmode/massive/massive_delete_modules.php index f9e5279138..f74baa1ba1 100755 --- a/pandora_console/godmode/massive/massive_delete_modules.php +++ b/pandora_console/godmode/massive/massive_delete_modules.php @@ -412,25 +412,23 @@ $(document).ready (function () { $("tr#delete_table-edit1, tr#delete_table-edit2, tr#delete_table-edit3, tr#delete_table-edit35, tr#delete_table-edit4, tr#delete_table-edit5, tr#delete_table-edit6, tr#delete_table-edit7, tr#delete_table-edit8") .hide (); - if (this.value == '0') { - filter = ''; - } - else { - filter = "id_tipo_modulo="+this.value; - } + var params = { + "page" : "operation/agentes/ver_agente", + "get_agent_modules_json" : 1, + "get_distinct_name" : 1, + "indexed" : 0, + "privilege" : "AW" + }; + + if (this.value != '0') + params['id_tipo_modulo'] = this.value; $("#module_loading").show (); $("tr#delete_table-edit1, tr#delete_table-edit2").hide (); $("#module_name").attr ("disabled", "disabled") $("#module_name option[value!=0]").remove (); jQuery.post ("ajax.php", - {"page" : "operation/agentes/ver_agente", - "get_agent_modules_json" : 1, - "filter" : filter, - "fields" : "DISTINCT(nombre)", - "indexed" : 0, - "privilege" : "AW" - }, + params, function (data, status) { jQuery.each (data, function (id, value) { option = $("") diff --git a/pandora_console/godmode/massive/massive_edit_modules.php b/pandora_console/godmode/massive/massive_edit_modules.php index 2727436eb3..e1ca492ecb 100755 --- a/pandora_console/godmode/massive/massive_edit_modules.php +++ b/pandora_console/godmode/massive/massive_edit_modules.php @@ -675,24 +675,22 @@ $(document).ready (function () { "tr#delete_table-edit13, " + "tr#delete_table-edit14").hide (); - if (this.value == '0') { - filter = ''; - } - else { - filter = "id_tipo_modulo="+this.value; - } + var params = { + "page" : "operation/agentes/ver_agente", + "get_agent_modules_json" : 1, + "get_distinct_name" : 1, + "indexed" : 0 + }; + + if (this.value != '0') + params['id_tipo_modulo'] = this.value; $("#module_loading").show (); $("tr#delete_table-edit1, tr#delete_table-edit2").hide (); $("#module_name").attr ("disabled", "disabled") $("#module_name option[value!=0]").remove (); jQuery.post ("ajax.php", - {"page" : "operation/agentes/ver_agente", - "get_agent_modules_json" : 1, - "filter" : filter, - "fields" : "DISTINCT(nombre)", - "indexed" : 0 - }, + params, function (data, status) { jQuery.each (data, function (id, value) { option = $("").attr ("value", value["nombre"]).html (value["nombre"]); diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 9bb6d6fae3..e5e6f4387a 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -2951,7 +2951,7 @@ function ui_print_agent_autocomplete_input($parameters) { var inputs = []; inputs.push ("agent_name=" + agent_name); - inputs.push ("filter=delete_pending = 0"); + inputs.push ("delete_pending=0"); inputs.push ("get_agent_modules_json=1"); inputs.push ("page=operation/agentes/ver_agente"); diff --git a/pandora_console/include/javascript/jquery.pandora.controls.js b/pandora_console/include/javascript/jquery.pandora.controls.js index ccc0274fb1..9ef224e4e7 100644 --- a/pandora_console/include/javascript/jquery.pandora.controls.js +++ b/pandora_console/include/javascript/jquery.pandora.controls.js @@ -89,7 +89,10 @@ callbackPre: dummyFunc, callbackPost: dummyFunc, callbackAfter: dummyFunc, - moduleFilter: 'disabled=0 AND delete_pending=0', + moduleFilter: { + disabled: 0, + deletePending: 0 + }, debug: false }; @@ -107,12 +110,14 @@ $("option[value!=0]", $select).remove (); if (! config.callbackBefore (this)) return; + jQuery.post ('ajax.php', - {"page": "operation/agentes/ver_agente", - "get_agent_modules_json": 1, - "id_agent": this.value, - "filter" : config.moduleFilter, - "fields" : "id_agente_modulo,nombre" + { + "page": "operation/agentes/ver_agente", + "get_agent_modules_json": 1, + "id_agent": this.value, + "disabled": config.moduleFilter.disabled, + "delete_pending": config.moduleFilter.deletePending }, function (data) { jQuery.each (data, function (i, value) { diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php index f22ef0fee4..560118cf9d 100644 --- a/pandora_console/operation/agentes/ver_agente.php +++ b/pandora_console/operation/agentes/ver_agente.php @@ -415,8 +415,34 @@ if (is_ajax ()) { if ($get_agent_modules_json) { $id_agent = (int) get_parameter ('id_agent'); - $filter = io_safe_output((string) get_parameter ('filter')); - $fields = io_safe_output((string) get_parameter ('fields')); + + // Use -1 as not received + $disabled = (int) get_parameter ('disabled', -1); + $delete_pending = (int) get_parameter ('delete_pending', -1); + // Use 0 as not received + $id_tipo_modulo = (int) get_parameter ('id_tipo_modulo', 0); + + // Filter + $filter = array(); + if ($disabled !== -1) + $filter['disabled'] = $disabled; + if ($delete_pending !== -1) + $filter['delete_pending'] = $delete_pending; + if (!empty($id_tipo_modulo)) + $filter['id_tipo_modulo'] = $id_tipo_modulo; + if (empty($filter)) + $filter = false; + + $get_id_and_name = (bool) get_parameter ('get_id_and_name'); + $get_distinct_name = (bool) get_parameter ('get_distinct_name'); + + // Fields + $fields = '*'; + if ($get_id_and_name) + $fields = array('id_agente_modulo', 'nombre'); + if ($get_distinct_name) + $fields = array('DISTINCT(nombre)'); + $indexed = (bool) get_parameter ('indexed', true); $agentName = (string) get_parameter ('agent_name', null); $server_name = (string) get_parameter ('server_name', null); @@ -431,7 +457,7 @@ if (is_ajax ()) { else $search = false; - if ($config ['metaconsole'] == 1 and !$force_local_modules and defined('METACONSOLE')) { + if (is_metaconsole() && !$force_local_modules) { if (enterprise_include_once ('include/functions_metaconsole.php') !== ENTERPRISE_NOT_HOOK) { $connection = metaconsole_get_connection($server_name); @@ -448,9 +474,7 @@ if (is_ajax ()) { agents_get_group_agents( array_keys (users_get_groups ()), $search, "none")); - $agent_modules = agents_get_modules ($id_agent, - ($fields != '' ? explode (',', $fields) : "*"), - ($filter != '' ? $filter : false), $indexed); + $agent_modules = agents_get_modules ($id_agent, $fields, $filter, $indexed); } // Restore db connection metaconsole_restore_db(); @@ -463,9 +487,7 @@ if (is_ajax ()) { agents_get_group_agents( array_keys(users_get_groups ()), $search, "none")); - $agent_modules = agents_get_modules ($id_agent, - ($fields != '' ? explode (',', $fields) : "*"), - ($filter != '' ? $filter : false), $indexed); + $agent_modules = agents_get_modules ($id_agent, $fields, $filter, $indexed); } if (empty($agent_modules))