Minor fixes applied

This commit is contained in:
Jose Gonzalez 2020-04-01 16:36:06 +02:00
parent 6be6e19ad3
commit 1b8fa26193
2 changed files with 7 additions and 116 deletions

View File

@ -65,112 +65,3 @@ if (is_ajax()) {
// Run.
$obj->run();
}
/*
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2020 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Load global vars
// TESTING
/*
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL); *
// END
global $config;
/* hd($_POST);
hd($_REQUEST); *
check_login();
if (! check_acl($config['id_user'], 0, 'PM')) {
db_pandora_audit(
'ACL Violation',
'Trying to access Network Profile Management'
);
include 'general/noaccess.php';
return;
}
require_once $config['homedir'].'/include/class/ModuleTemplates.class.php';
$ajaxPage = ENTERPRISE_DIR.'/godmode/agentes/ModuleTemplates';
// Control call flow.
try {
// User access and validation is being processed on class constructor.
$moduleTemplates = new ModuleTemplates('');
// Run.
$moduleTemplates->run();
// Get the id_np.
$id_np = $moduleTemplates->getIdNp();
$moduleTemplates->processData();
if ($id_np === -1) {
// List all Module Blocks.
$moduleTemplates->moduleBlockList();
} else {
// Create new o update Template.
$moduleTemplates->moduleTemplateForm();
}
} catch (Exception $e) {
echo '[ModuleTemplates]'.$e->getMessage();
// Stop this execution, but continue 'globally'.
return;
}
?>
<script>
function switchBlockControl(e){
var switchId = e.target.id.split('_');
var blockNumber = switchId[2];
var switchNumber = switchId[3];
var totalCount = 0;
var markedCount = 0;
$('[id*=checkbox-module_check_'+blockNumber+']').each(function(){
if ($(this).prop('checked')) {
markedCount++;
}
totalCount++;
});
if (totalCount == markedCount) {
$('#checkbox-block_id_'+blockNumber).prop('checked', true);
$('#checkbox-block_id_'+blockNumber).parent().removeClass('alpha50');
} else if (markedCount == 0) {
$('#checkbox-block_id_'+blockNumber).prop('checked', false);
$('#checkbox-block_id_'+blockNumber).parent().removeClass('alpha50');
} else {
$('#checkbox-block_id_'+blockNumber).prop('checked', true);
$('#checkbox-block_id_'+blockNumber).parent().addClass('alpha50');
}
}
$(document).ready (function () {
var listValidPens = $('#hidden-valid-pen').val();
listValidPens = listValidPens.split(',');
//Adding tagEditor for PEN management.
$('#text-pen').tagEditor({
beforeTagSave: function(field, editor, tags, tag, val) {
if (listValidPens.indexOf(val) == -1) {
return false;
}
}
});
//Values for add.
$('#add-modules-components').change(function(){
var valores = ($('#add-modules-components').val()).join(',');
$('#hidden-add-modules-components-values').val(valores);
});
});
</script>

View File

@ -150,16 +150,12 @@ class ModuleTemplates extends HTML
$this->baseUrl = ui_get_full_url('index.php?sec=gmodules&sec2=godmode/modules/manage_module_templates');
// Capture all parameters before start.
$this->id_np = get_parameter('id_np', -1);
if ($this->id_np > 0) {
$this->action = get_parameter('action_button', '');
if ($this->id_np > 0 || empty($this->action)) {
// Profile exists. Set the attributes with the info.
$this->setNetworkProfile();
} else {
$this->name = get_parameter('name', '');
$this->description = get_parameter('description', '');
$this->pen = get_parameter('pen', '');
}
$this->action = get_parameter('action_button', '');
$this->offset = get_parameter('offset', 0);
$this->ajaxController = $ajax_controller;
$this->ncGroup = get_parameter('add-modules-group', '0');
@ -257,7 +253,7 @@ class ModuleTemplates extends HTML
$this->printHeader(true)
);
// Process the data if action is required
// Process the data if action is required.
if (!empty($this->action)) {
$this->processData();
}
@ -331,6 +327,10 @@ class ModuleTemplates extends HTML
}
}
$this->name = get_parameter('name', '');
$this->description = get_parameter('description', '');
$this->pen = get_parameter('pen', '');
switch ($this->action) {
case 'Update':
$dbResult_tnp = db_process_sql_update(