mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-19 00:28:47 +02:00
N°6759 - Small fixes
This commit is contained in:
@@ -17,7 +17,7 @@ LoginWebPage::DoLogin(); // Check user rights and prompt if needed
|
||||
ApplicationMenu::CheckMenuIdEnabled('ConfigEditor');
|
||||
|
||||
|
||||
$oLogCenterController = new ConfigEditorController();
|
||||
$oLogCenterController->SetDefaultOperation('Edit');
|
||||
$oLogCenterController->HandleOperation();
|
||||
$oConfigEditorController = new ConfigEditorController();
|
||||
$oConfigEditorController->SetDefaultOperation('Edit');
|
||||
$oConfigEditorController->HandleOperation();
|
||||
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
namespace Combodo\iTop\Config\Controller;
|
||||
|
||||
@@ -15,27 +19,23 @@ class ConfigEditorController extends Controller
|
||||
{
|
||||
public const ROUTE_NAMESPACE = 'config_editor';
|
||||
public const MODULE_NAME = "itop-config";
|
||||
private $aWarnings = [];
|
||||
private $aInfo = [];
|
||||
private $aErrors = [];
|
||||
private $aSuccesses = [];
|
||||
private array $aWarnings = [];
|
||||
private array $aInfo = [];
|
||||
private array $aErrors = [];
|
||||
private array $aSuccesses = [];
|
||||
|
||||
public function __construct() {
|
||||
$sModuleName = 'itop-config';
|
||||
parent::__construct(MODULESROOT.$sModuleName.'/templates', $sModuleName);
|
||||
parent::__construct(MODULESROOT.self::MODULE_NAME.'/templates', self::MODULE_NAME);
|
||||
}
|
||||
|
||||
// /pages/UI.php?route=config_editor.edit
|
||||
|
||||
|
||||
public function OperationEdit()
|
||||
public function OperationEdit() : void
|
||||
{
|
||||
$bShowEditor = true;
|
||||
$sConfigChecksum = '';
|
||||
$sCurrentConfig = '';
|
||||
|
||||
try {
|
||||
$sOperation = utils::ReadParam('edit_operation', '');
|
||||
$sOperation = utils::ReadParam('edit_operation');
|
||||
if (MetaModel::GetConfig()->Get('demo_mode')) {
|
||||
throw new Exception(Dict::S('config-not-allowed-in-demo'), iTopConfigValidator::CONFIG_INFO);
|
||||
}
|
||||
@@ -55,7 +55,7 @@ class ConfigEditorController extends Controller
|
||||
}
|
||||
else if ($sOperation == 'save') {
|
||||
$sTransactionId = utils::ReadParam('transaction_id', '', false, 'transaction_id');
|
||||
if (!utils::IsTransactionValid($sTransactionId, true)) {
|
||||
if (!utils::IsTransactionValid($sTransactionId)) {
|
||||
throw new Exception(Dict::S('config-error-transaction'), iTopConfigValidator::CONFIG_ERROR);
|
||||
}
|
||||
$sChecksum = utils::ReadParam('checksum');
|
||||
@@ -134,20 +134,23 @@ class ConfigEditorController extends Controller
|
||||
* @return void
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function AddAceScripts(): void {
|
||||
public function AddAceScripts(): void
|
||||
{
|
||||
$sAceDir = 'node_modules/ace-builds/src-min/';
|
||||
$this->AddLinkedScript(\utils::GetAbsoluteUrlAppRoot().$sAceDir.'ace.js');
|
||||
$this->AddLinkedScript(\utils::GetAbsoluteUrlAppRoot().$sAceDir.'mode-php.js');
|
||||
$this->AddLinkedScript(\utils::GetAbsoluteUrlAppRoot().$sAceDir.'theme-eclipse.js');
|
||||
$this->AddLinkedScript(\utils::GetAbsoluteUrlAppRoot().$sAceDir.'ext-searchbox.js');
|
||||
$this->AddLinkedScript(utils::GetAbsoluteUrlAppRoot().$sAceDir.'ace.js');
|
||||
$this->AddLinkedScript(utils::GetAbsoluteUrlAppRoot().$sAceDir.'mode-php.js');
|
||||
$this->AddLinkedScript(utils::GetAbsoluteUrlAppRoot().$sAceDir.'theme-eclipse.js');
|
||||
$this->AddLinkedScript(utils::GetAbsoluteUrlAppRoot().$sAceDir.'ext-searchbox.js');
|
||||
}
|
||||
|
||||
|
||||
public function AddAlertFromException(Exception $e): void {
|
||||
public function AddAlertFromException(Exception $e): void
|
||||
{
|
||||
$this->AddAlert($e->getMessage(), $e->getCode());
|
||||
}
|
||||
|
||||
public function AddAlert(array|string $sMessage, $iLevel): void {
|
||||
public function AddAlert(array|string $sMessage, $iLevel): void
|
||||
{
|
||||
if (is_array($sMessage)) {
|
||||
foreach ($sMessage as $sSingleMessage) {
|
||||
$this->AddAlert($sSingleMessage, $iLevel);
|
||||
@@ -166,7 +169,7 @@ class ConfigEditorController extends Controller
|
||||
break;
|
||||
default :
|
||||
$this->aErrors[] = $sMessage;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,7 +16,7 @@ class iTopConfigValidator {
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function Validate($sRawConfig)
|
||||
public function Validate($sRawConfig):void
|
||||
{
|
||||
$oiTopConfigValidator = new iTopConfigAstValidator();
|
||||
$oiTopConfigValidator->Validate($sRawConfig);
|
||||
@@ -26,7 +26,7 @@ class iTopConfigValidator {
|
||||
$oiTopConfigValidator->Validate($sRawConfig);
|
||||
}
|
||||
|
||||
function DBPasswordIsOk($sPassword)
|
||||
function DBPasswordIsOk($sPassword):bool
|
||||
{
|
||||
$bIsWindows = (array_key_exists('WINDIR', $_SERVER) || array_key_exists('windir', $_SERVER));
|
||||
|
||||
|
||||
@@ -12,10 +12,7 @@
|
||||
{% endfor %}
|
||||
|
||||
{% UITitle ForPage {'sTitle':'config-edit-title'|dict_s} %}{% EndUITitle %}
|
||||
{#
|
||||
{% UIButton ForPrimaryAction {'sLabel':'SysInfo:UI:DownloadReport'|dict_s, 'bIsSubmit':true} %}
|
||||
{% UIInput ForHidden {sName:'operation', sValue:'SysInfoReport'} %}
|
||||
#}
|
||||
|
||||
{% if bShowEditor %}
|
||||
<p>{{ 'config-edit-intro'|dict_s }}</p>
|
||||
{% UIForm Standard {} %}
|
||||
|
||||
@@ -110,11 +110,6 @@ editorForm.on('submit', function() {
|
||||
EditorUtils.restoreEditorDisplay(editor);
|
||||
editor.focus();
|
||||
|
||||
//$sConfirmCancel = addslashes(Dict::S('config-confirm-cancel'));
|
||||
function ResetConfig()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
const repositionEditor = () => {
|
||||
let oSubmitButton = document.getElementById('submit_button');
|
||||
@@ -126,9 +121,8 @@ repositionEditor();
|
||||
document.getElementById('ibo-main-content').addEventListener('click',repositionEditor);
|
||||
|
||||
document.getElementById('cancel_button').onclick = ()=>{
|
||||
$("#operation").attr('value', 'revert');
|
||||
if (confirm({{ 'config-confirm-cancel'|dict_s|json_encode|raw }})) {
|
||||
$('input[name="new_config"]').val($('input[name="prev_config"]').val());
|
||||
document.querySelector('input[name="new_config"]').value = document.querySelector('input[name="prev_config"]').value;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user