From 1b2087e52ea8d30873ff6a544f6aa3fd0190bf1c Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Fri, 22 Jan 2021 12:08:14 +0100 Subject: [PATCH] =?UTF-8?q?N=C2=B03568=20Backup=20various=20improvements?= =?UTF-8?q?=20-=20fix=20path=20not=20displayed=20if=20not=20existing=20-?= =?UTF-8?q?=20fix=20HTML=20code=20in=20warnings=20&=20errors?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- datamodels/2.x/itop-backup/status.php | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/datamodels/2.x/itop-backup/status.php b/datamodels/2.x/itop-backup/status.php index 0e5ca48ab..64ee3ec20 100644 --- a/datamodels/2.x/itop-backup/status.php +++ b/datamodels/2.x/itop-backup/status.php @@ -38,6 +38,11 @@ require_once(APPROOT.'application/startup.inc.php'); require_once(APPROOT.'application/loginwebpage.class.inc.php'); +function DecorateErrorMessages(string $sMessage) +{ + return ''.$sMessage.''; +} + function GenerateBackupsList(string $sListTitleDictKey, string $sNoRecordDictKey, $aListConfig, $aListData): UIBlock { $oFieldsetForList = new FieldSet(Dict::S($sListTitleDictKey)); @@ -115,7 +120,7 @@ try { $sMySqlDump = Dict::Format("bkp-mysqldump-issue", $iRetCode); } $oFieldsetChecks->AddSubBlock( - AlertUIBlockFactory::MakeForWarning($sMySqlDump, '') + AlertUIBlockFactory::MakeForWarning('', DecorateErrorMessages($sMySqlDump)) ->SetIsClosable(false) ->SetIsCollapsible(false) ); @@ -131,11 +136,12 @@ try { SetupUtils::builddir($sBackupDir); if (!is_dir($sBackupDir)) { $oFieldsetChecks->AddSubBlock( - AlertUIBlockFactory::MakeForWarning(Dict::Format('bkp-missing-dir', $sBackupDir), '') + AlertUIBlockFactory::MakeForWarning('', DecorateErrorMessages(Dict::Format('bkp-missing-dir', $sBackupDir))) ->SetIsClosable(false) ->SetIsCollapsible(false) ); } else { + $sBackupDir = realpath($sBackupDir); // just for cosmetic purpose (dir separator, as APPROOT contains a hardcoded '/') $sDiskSpaceReadable = SetupUtils::HumanReadableSize(SetupUtils::CheckDiskSpace($sBackupDir)); $oFieldsetChecks->AddSubBlock( AlertUIBlockFactory::MakeForInformation('', Dict::Format('bkp-free-disk-space', $sDiskSpaceReadable, $sBackupDir)) @@ -144,7 +150,7 @@ try { ); if (!is_writable($sBackupDir)) { $oFieldsetChecks->AddSubBlock( - AlertUIBlockFactory::MakeForWarning(Dict::Format('bkp-dir-not-writeable', $sBackupDir), '') + AlertUIBlockFactory::MakeForWarning('', DecorateErrorMessages(Dict::Format('bkp-dir-not-writeable', $sBackupDir))) ->SetIsClosable(false) ->SetIsCollapsible(false) ); @@ -163,7 +169,10 @@ try { $sZipNameInfo = ''; if ($sZipName == '') { $oFieldsetChecks->AddSubBlock( - AlertUIBlockFactory::MakeForWarning(Dict::Format('bkp-wrong-format-spec', $sBackupFile, BACKUP_DEFAULT_FORMAT), '') + AlertUIBlockFactory::MakeForWarning( + '', + DecorateErrorMessages(Dict::Format('bkp-wrong-format-spec', $sBackupFile, BACKUP_DEFAULT_FORMAT)) + ) ->SetIsClosable(false) ->SetIsCollapsible(false) ); @@ -314,7 +323,7 @@ try { $oBackupMutex = new iTopMutex('backup.'.utils::GetCurrentEnvironment()); if ($oBackupMutex->IsLocked()) { $oFieldsetBackupNow->AddSubBlock( - AlertUIBlockFactory::MakeForFailure(Dict::S('bkp-backup-running'), '') + AlertUIBlockFactory::MakeForFailure('', DecorateErrorMessages(Dict::S('bkp-backup-running'))) ->SetIsClosable(false) ->SetIsCollapsible(false) ); @@ -322,7 +331,7 @@ try { $oRestoreMutex = new iTopMutex('restore.'.utils::GetCurrentEnvironment()); if ($oRestoreMutex->IsLocked()) { $oFieldsetBackupNow->AddSubBlock( - AlertUIBlockFactory::MakeForFailure(Dict::S('bkp-restore-running'), '') + AlertUIBlockFactory::MakeForFailure('', DecorateErrorMessages(Dict::S('bkp-restore-running'))) ->SetIsClosable(false) ->SetIsCollapsible(false) );