nagiosql/admin/menuaccess.php

109 lines
4.4 KiB
PHP
Raw Permalink Normal View History

2017-05-22 11:24:21 +02:00
<?php
///////////////////////////////////////////////////////////////////////////////
//
// NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
2019-04-17 11:40:50 +02:00
// (c) 2005-2018 by Martin Willisegger
2017-05-22 11:24:21 +02:00
//
// Project : NagiosQL
// Component : Menu access administration
2019-04-17 11:40:50 +02:00
// Website : https://sourceforge.net/projects/nagiosql/
// Version : 3.4.0
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
2017-05-22 11:24:21 +02:00
//
///////////////////////////////////////////////////////////////////////////////
//
2019-04-17 11:40:50 +02:00
// Path settings
// ===================
$strPattern = '(admin/[^/]*.php)';
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME', FILTER_SANITIZE_STRING));
//
2017-05-22 11:24:21 +02:00
// Define common variables
// =======================
2019-04-17 11:40:50 +02:00
$prePageId = 34;
$preContent = 'admin/menuaccess.htm.tpl';
$preAccess = 1;
$preFieldvars = 1;
$preNoAccessGrp = 1;
$intFieldId = 0;
2017-05-22 11:24:21 +02:00
//
// Include preprocessing files
// ===========================
2019-04-17 11:40:50 +02:00
require $preBasePath.'functions/prepend_adm.php';
require $preBasePath.'functions/prepend_content.php';
2017-05-22 11:24:21 +02:00
//
// Process data
// ============
2019-04-17 11:40:50 +02:00
if (filter_input(INPUT_POST, 'subSave') && ($chkSelValue1 != 0)) {
$strSQL = "UPDATE `tbl_menu` SET `mnuGrpId`='$chkSelValue2' WHERE `mnuId`=$chkSelValue1";
$booReturn = $myDBClass->insertData($strSQL);
if ($booReturn == false) {
$myVisClass->processMessage(translate('Error while inserting the data into the database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
} else {
$myVisClass->processMessage(translate('Data were successfully inserted to the data base!'), $strInfoMessage);
$myDataClass->writeLog(translate('Access group set for menu item:'). ' ' .
$myDBClass->getFieldData("SELECT `mnuName` FROM `tbl_menu` WHERE `mnuId`=$chkSelValue1"));
}
2017-05-22 11:24:21 +02:00
}
//
// Include content
// ===============
2019-04-17 11:40:50 +02:00
$conttp->setVariable('TITLE', translate('Define Menu Access Rights'));
foreach ($arrDescription as $elem) {
$conttp->setVariable($elem['name'], $elem['string']);
2017-05-22 11:24:21 +02:00
}
2019-04-17 11:40:50 +02:00
$conttp->setVariable('LANG_ACCESSDESCRIPTION', translate('In order for a user to get access, he needs to be member '
. 'of the group selected here.'));
2017-05-22 11:24:21 +02:00
//
// Auswahlfeld einlesen
// ====================
2019-04-17 11:40:50 +02:00
$strSQL = 'SELECT A.`mnuId` , B.`mnuName` AS `mainitem`, A.`mnuName` AS `subitem`, A.`mnuGrpId` '
. 'FROM `tbl_menu` AS A LEFT JOIN `tbl_menu` AS B ON A.`mnuTopId` = B.`mnuId` '
. 'ORDER BY A.`mnuTopId`, A.`mnuOrderId`';
$booReturn = $myDBClass->hasDataArray($strSQL, $arrDataLines, $intDataCount);
2017-05-22 11:24:21 +02:00
if ($booReturn == false) {
2019-04-17 11:40:50 +02:00
$myVisClass->processMessage(translate('Error while selecting data from database:'), $strErrorMessage);
$myVisClass->processMessage($myDBClass->strErrorMessage, $strErrorMessage);
2017-05-22 11:24:21 +02:00
} else {
2019-04-17 11:40:50 +02:00
$conttp->setVariable('SUBMENU_VALUE', '0');
$conttp->setVariable('SUBMENU_NAME', '&nbsp;');
$conttp->parse('submenu');
foreach ($arrDataLines as $elem) {
$conttp->setVariable('SUBMENU_VALUE', $elem['mnuId']);
if ($elem['mainitem'] != '') {
$conttp->setVariable('SUBMENU_NAME', translate($elem['mainitem']). ' - ' .translate($elem['subitem']));
} else {
$conttp->setVariable('SUBMENU_NAME', translate($elem['subitem']));
}
if ($chkSelValue1 == $elem['mnuId']) {
$conttp->setVariable('SUBMENU_SELECTED', 'selected');
$intFieldId = $elem['mnuGrpId'];
}
// Bypass main site
if ($elem['mnuId'] != 1) {
$conttp->parse('submenu');
}
}
// Process access group selection field
$intReturn = $myVisClass->parseSelectSimple('tbl_group', 'groupname', 'acc_group', 0, $intFieldId);
2017-05-22 11:24:21 +02:00
}
2019-04-17 11:40:50 +02:00
$conttp->setVariable('ERRORMESSAGE', $strErrorMessage);
$conttp->setVariable('INFOMESSAGE', $strInfoMessage);
2017-05-22 11:24:21 +02:00
// Check access rights for adding new objects
2019-04-17 11:40:50 +02:00
if ($intGlobalWriteAccess == 1) {
$conttp->setVariable('DISABLE_SAVE', 'disabled="disabled"');
}
$conttp->parse('menuaccesssite');
$conttp->show('menuaccesssite');
2017-05-22 11:24:21 +02:00
//
// Process footer
// ==============
2019-04-17 11:40:50 +02:00
$maintp->setVariable('VERSION_INFO', "<a href='https://sourceforge.net/projects/nagiosql/' "
. "target='_blank'>NagiosQL</a> $setFileVersion");
$maintp->parse('footer');
$maintp->show('footer');