Merge branch 'develop' of https://github.com/pandorafms/pandorafms into develop

This commit is contained in:
m-lopez-f 2015-08-04 12:51:44 +02:00
commit 1a20a5b025
7 changed files with 67 additions and 44 deletions

View File

@ -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 ({

View File

@ -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) {

View File

@ -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 = $("<option></option>")

View File

@ -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 = $("<option></option>").attr ("value", value["nombre"]).html (value["nombre"]);

View File

@ -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");

View File

@ -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",
{
"page": "operation/agentes/ver_agente",
"get_agent_modules_json": 1,
"id_agent": this.value,
"filter" : config.moduleFilter,
"fields" : "id_agente_modulo,nombre"
"disabled": config.moduleFilter.disabled,
"delete_pending": config.moduleFilter.deletePending
},
function (data) {
jQuery.each (data, function (i, value) {

View File

@ -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))