Created new files with Module Blocks and changed Menu entries

This commit is contained in:
Jose Gonzalez 2020-03-16 20:48:38 +01:00
parent ce11d89953
commit 106f8bd1cf
3 changed files with 178 additions and 2 deletions

View File

@ -137,10 +137,12 @@ if (!empty($sub)) {
$sub = []; $sub = [];
if (check_acl($config['id_user'], 0, 'PM')) { if (check_acl($config['id_user'], 0, 'PM')) {
$sub['godmode/modules/manage_network_components']['text'] = __('Network components'); $sub['godmode/modules/manage_network_components']['text'] = __('Remote components');
$sub['godmode/modules/manage_network_components']['id'] = 'Network components'; $sub['godmode/modules/manage_network_components']['id'] = 'Network components';
enterprise_hook('components_submenu'); enterprise_hook('components_submenu');
$sub['godmode/modules/manage_network_templates']['text'] = __('Module templates'); $sub['godmode/modules/manage_block_templates']['text'] = __('Module blocks');
$sub['godmode/modules/manage_block_templates']['id'] = 'Module blocks';
$sub['godmode/modules/manage_network_templates']['text'] = __('Module templates (legacy)');
$sub['godmode/modules/manage_network_templates']['id'] = 'Module templates'; $sub['godmode/modules/manage_network_templates']['id'] = 'Module templates';
enterprise_hook('inventory_submenu'); enterprise_hook('inventory_submenu');
enterprise_hook('autoconfiguration_menu'); enterprise_hook('autoconfiguration_menu');

View File

@ -0,0 +1,71 @@
<?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
global $config;
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;
}
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require_once $config['homedir'].'/include/class/ManageBlock.class.php';
// $ajaxPage = ENTERPRISE_DIR.'/godmode/agentes/ManageBlock';
// Control call flow.
try {
// User access and validation is being processed on class constructor.
$manageBlock = new ManageBlock('');
} catch (Exception $e) {
echo '[ManageBlock]'.$e->getMessage();
/*
if (is_ajax()) {
echo json_encode(['error' => '[MiFuncionalidad]'.$e->getMessage() ]);
exit;
} else {
echo '[MiFuncionalidad]'.$e->getMessage();
}
*/
// Stop this execution, but continue 'globally'.
return;
}
// AJAX controller.
if (is_ajax()) {
$method = get_parameter('method');
/*
if (method_exists($miFuncionalidad, $method) === true) {
if ($miFuncionalidad>ajaxMethod($method) === true) {
$miFuncionalidad>{$method}();
} else {
$miFuncionalidad>error('Unavailable method.');
}
} else {
$miFuncionalidad->error('Method not found. ['.$method.']');
}
*/
// Stop any execution.
exit;
} else {
// Run.
$manageBlock->run();
}

View File

@ -0,0 +1,103 @@
<?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.
global $config;
require_once $config['homedir'].'/include/class/HTML.class.php';
class ManageBlock extends HTML
{
private $ajax_controller;
public function __construct($ajax_controller)
{
global $config;
// Check access.
check_login();
if (! check_acl($config['id_user'], 0, 'AR')) {
db_pandora_audit(
'ACL Violation',
'Trying to access event viewer'
);
if (is_ajax()) {
echo json_encode(['error' => 'noaccess']);
}
include 'general/noaccess.php';
exit;
}
$this->ajaxController = $ajax_controller;
$this->setBreadcrum([]);
return $this;
}
/**
* Run MiFuncionalidad (main page).
*
* @return void
*/
public function run()
{
$this->prepareBreadcrum(
[
[
'link' => 'mishuevos',
// $this->url,
'label' => __('Configuration'),
'selected' => 0,
],
[
'link' => 'url',
// $this->url,
'label' => __('Module Blocks'),
'selected' => 1,
],
],
true
);
ui_print_page_header(
__('Manage module blocks'),
'',
false,
'',
true,
'',
false,
'',
GENERIC_SIZE_TEXT,
'',
$this->printHeader(true)
);
// $this->printForm(
// [
// 'form' => $form,
// 'inputs' => $inputs,
// ],
// true
// );
}
}