N°8796 - Add PHP code style validation in iTop and extensions - format whole code base

This commit is contained in:
odain
2025-11-07 15:39:53 +01:00
parent 12f23113f5
commit 890a2568c8
2110 changed files with 53099 additions and 63885 deletions

View File

@@ -6,7 +6,7 @@ class TokenValidation
public function __construct()
{
}
public function isSetupTokenValid($sParamToken) : bool
public function isSetupTokenValid($sParamToken): bool
{
if (!file_exists(APPROOT.'data/.setup')) {
return false;
@@ -16,4 +16,4 @@ class TokenValidation
return $sParamToken === $sSetupToken;
}
}
}

View File

@@ -1,4 +1,5 @@
<?php
// Copyright (C) 2024 Combodo SAS
//
// This file is part of iTop.
@@ -41,10 +42,9 @@ require_once(__DIR__.'/hubruntimeenvironment.class.inc.php');
*/
class DBBackupWithErrorReporting extends DBBackup
{
protected $aInfos = [];
protected $aInfos = array();
protected $aErrors = array();
protected $aErrors = [];
protected function LogInfo($sMsg)
{
@@ -79,19 +79,16 @@ function DoBackup($sTargetFile)
// Make sure the target directory exists
$sBackupDir = dirname($sTargetFile);
SetupUtils::builddir($sBackupDir);
$oBackup = new DBBackupWithErrorReporting();
$oBackup->SetMySQLBinDir(MetaModel::GetConfig()->GetModuleSetting('itop-backup', 'mysql_bindir', ''));
$sSourceConfigFile = APPCONF.utils::GetCurrentEnvironment().'/'.ITOP_CONFIG_FILE;
$oMutex = new iTopMutex('backup.'.utils::GetCurrentEnvironment());
$oMutex->Lock();
try
{
try {
$oBackup->CreateCompressedBackup($sTargetFile, $sSourceConfigFile);
}
catch (Exception $e)
{
} catch (Exception $e) {
$oMutex->Unlock();
throw $e;
}
@@ -101,22 +98,22 @@ function DoBackup($sTargetFile)
/**
* Outputs the status of the current ajax execution (as a JSON structure)
*
*
* @param string $sMessage
* @param bool $bSuccess
* @param number $iErrorCode
* @param array $aMoreFields
* Extra fields to pass to the caller, if needed
*/
function ReportStatus($sMessage, $bSuccess, $iErrorCode = 0, $aMoreFields = array())
function ReportStatus($sMessage, $bSuccess, $iErrorCode = 0, $aMoreFields = [])
{
// Do not use AjaxPage during setup phases, because it uses InterfaceDiscovery in Twig compilation
$oPage = new JsonPage();
$aResult = array(
$aResult = [
'code' => $iErrorCode,
'message' => $sMessage,
'fields' => $aMoreFields
);
'fields' => $aMoreFields,
];
$oPage->SetData($aResult);
$oPage->SetOutputDataOnly(true);
$oPage->output();
@@ -124,154 +121,137 @@ function ReportStatus($sMessage, $bSuccess, $iErrorCode = 0, $aMoreFields = arra
/**
* Helper to output the status of a successful execution
*
*
* @param string $sMessage
* @param array $aMoreFields
* Extra fields to pass to the caller, if needed
*/
function ReportSuccess($sMessage, $aMoreFields = array())
function ReportSuccess($sMessage, $aMoreFields = [])
{
ReportStatus($sMessage, true, 0, $aMoreFields);
}
/**
* Helper to output the status of a failed execution
*
*
* @param string $sMessage
* @param number $iErrorCode
* @param array $aMoreFields
* Extra fields to pass to the caller, if needed
*/
function ReportError($sMessage, $iErrorCode, $aMoreFields = array())
function ReportError($sMessage, $iErrorCode, $aMoreFields = [])
{
if ($iErrorCode==0)
{
if ($iErrorCode == 0) {
// 0 means no error, so change it if no meaningful error code is supplied
$iErrorCode = -1;
}
ReportStatus($sMessage, false, $iErrorCode, $aMoreFields);
}
try
{
try {
SetupUtils::ExitMaintenanceMode(false); // Reset maintenance mode in case of problem
utils::PushArchiveMode(false);
ini_set('max_execution_time', max(3600, ini_get('max_execution_time'))); // Under Windows SQL/backup operations are part of the PHP timeout and require extra time
ini_set('display_errors', 1); // Make sure that fatal errors remain visible from the end-user
// Most of the ajax calls are done without the MetaModel being loaded
// Therefore, the language must be passed as an argument,
// and the dictionnaries be loaded here
// Therefore, the language must be passed as an argument,
// and the dictionnaries be loaded here
$sLanguage = utils::ReadParam('language', '');
if ($sLanguage!='')
{
foreach (glob(APPROOT.'env-production/dictionaries/*.dict.php') as $sFilePath)
{
require_once ($sFilePath);
if ($sLanguage != '') {
foreach (glob(APPROOT.'env-production/dictionaries/*.dict.php') as $sFilePath) {
require_once($sFilePath);
}
$aLanguages = Dict::GetLanguages();
if (array_key_exists($sLanguage, $aLanguages))
{
if (array_key_exists($sLanguage, $aLanguages)) {
Dict::SetUserLanguage($sLanguage);
}
}
$sOperation = utils::ReadParam('operation', '');
switch ($sOperation)
{
switch ($sOperation) {
case 'check_before_backup':
require_once (APPROOT.'/application/startup.inc.php');
require_once (APPROOT.'/application/loginwebpage.class.inc.php');
require_once(APPROOT.'/application/startup.inc.php');
require_once(APPROOT.'/application/loginwebpage.class.inc.php');
LoginWebPage::DoLogin(true); // Check user rights and prompt if needed (must be admin)
$sDBBackupPath = APPROOT.'data/backups/manual';
$aChecks = SetupUtils::CheckBackupPrerequisites($sDBBackupPath);
$bFailed = false;
foreach ($aChecks as $oCheckResult)
{
if ($oCheckResult->iSeverity==CheckResult::ERROR)
{
foreach ($aChecks as $oCheckResult) {
if ($oCheckResult->iSeverity == CheckResult::ERROR) {
$bFailed = true;
ReportError($oCheckResult->sLabel, -2);
}
}
if (!$bFailed)
{
if (!$bFailed) {
// Continue the checks
$fFreeSpace = SetupUtils::CheckDiskSpace($sDBBackupPath);
if ($fFreeSpace!==false)
{
if ($fFreeSpace !== false) {
$sMessage = Dict::Format('iTopHub:BackupFreeDiskSpaceIn', SetupUtils::HumanReadableSize($fFreeSpace), dirname($sDBBackupPath));
ReportSuccess($sMessage);
}
else
{
} else {
ReportError(Dict::S('iTopHub:FailedToCheckFreeDiskSpace'), -1);
}
}
break;
break;
case 'do_backup':
require_once (APPROOT.'/application/startup.inc.php');
require_once (APPROOT.'/application/loginwebpage.class.inc.php');
require_once(APPROOT.'/application/startup.inc.php');
require_once(APPROOT.'/application/loginwebpage.class.inc.php');
LoginWebPage::DoLogin(true); // Check user rights and prompt if needed (must be admin)
try
{
if (MetaModel::GetConfig()->Get('demo_mode')) throw new Exception('Sorry the installation of extensions is not allowed in demo mode');
try {
if (MetaModel::GetConfig()->Get('demo_mode')) {
throw new Exception('Sorry the installation of extensions is not allowed in demo mode');
}
SetupLog::Info('Backup starts...');
set_time_limit(0);
$sBackupPath = APPROOT.'/data/backups/manual/backup-';
$iSuffix = 1;
$sSuffix = '';
// Generate a unique name...
do
{
do {
$sBackupFile = $sBackupPath.date('Y-m-d-His').$sSuffix;
$sSuffix = '-'.$iSuffix;
$iSuffix++ ;
}
while (file_exists($sBackupFile));
} while (file_exists($sBackupFile));
$oBackup = DoBackup($sBackupFile);
$aErrors = $oBackup->GetErrors();
if (count($aErrors)>0)
{
if (count($aErrors) > 0) {
SetupLog::Error('Backup failed.');
SetupLog::Error(implode("\n", $aErrors));
ReportError(Dict::S('iTopHub:BackupFailed'), -1, $aErrors);
}
else
{
ReportError(Dict::S('iTopHub:BackupFailed'), -1, $aErrors);
} else {
SetupLog::Info('Backup successfully completed.');
ReportSuccess(Dict::S('iTopHub:BackupOk'));
}
}
catch (Exception $e)
{
} catch (Exception $e) {
SetupLog::Error($e->getMessage());
ReportError($e->getMessage(), $e->getCode());
}
break;
break;
case 'compile':
SetupLog::Info('Deployment starts...');
$sAuthent = utils::ReadParam('authent', '', false, 'raw_data');
if (!file_exists(APPROOT.'data/hub/compile_authent') || $sAuthent !== file_get_contents(APPROOT.'data/hub/compile_authent'))
{
throw new SecurityException(Dict::S('iTopHub:FailAuthent'));
if (!file_exists(APPROOT.'data/hub/compile_authent') || $sAuthent !== file_get_contents(APPROOT.'data/hub/compile_authent')) {
throw new SecurityException(Dict::S('iTopHub:FailAuthent'));
}
// First step: prepare the datamodel, if it fails, roll-back
$aSelectedExtensionCodes = utils::ReadParam('extension_codes', array());
$aSelectedExtensionDirs = utils::ReadParam('extension_dirs', array());
$aSelectedExtensionCodes = utils::ReadParam('extension_codes', []);
$aSelectedExtensionDirs = utils::ReadParam('extension_dirs', []);
$oRuntimeEnv = new HubRunTimeEnvironment('production', false); // use a temp environment: production-build
$oRuntimeEnv->MoveSelectedExtensions(APPROOT.'/data/downloaded-extensions/', $aSelectedExtensionDirs);
$oConfig = new Config(APPCONF.'production/'.ITOP_CONFIG_FILE);
if ($oConfig->Get('demo_mode')) throw new Exception('Sorry the installation of extensions is not allowed in demo mode');
if ($oConfig->Get('demo_mode')) {
throw new Exception('Sorry the installation of extensions is not allowed in demo mode');
}
$aSelectModules = $oRuntimeEnv->CompileFrom('production', false); // WARNING symlinks does not seem to be compatible with manual Commit
@@ -289,21 +269,19 @@ try
$oRuntimeEnv->Commit();
// Report the success in a way that will be detected by the ajax caller
SetupLog::Info('Compilation completed...');
SetupLog::Info('Compilation completed...');
ReportSuccess('Ok'); // No access to Dict::S here
break;
break;
case 'move_to_production':
// Second step: update the schema and the data
// Everything happening below is based on env-production
$oRuntimeEnv = new RunTimeEnvironment('production', true);
try
{
try {
SetupLog::Info('Move to production starts...');
$sAuthent = utils::ReadParam('authent', '', false, 'raw_data');
if (!file_exists(APPROOT.'data/hub/compile_authent') || $sAuthent !== file_get_contents(APPROOT.'data/hub/compile_authent'))
{
$sAuthent = utils::ReadParam('authent', '', false, 'raw_data');
if (!file_exists(APPROOT.'data/hub/compile_authent') || $sAuthent !== file_get_contents(APPROOT.'data/hub/compile_authent')) {
throw new SecurityException(Dict::S('iTopHub:FailAuthent'));
}
unlink(APPROOT.'data/hub/compile_authent');
@@ -315,15 +293,11 @@ try
$aAvailableModules = $oRuntimeEnv->AnalyzeInstallation($oConfig, $oRuntimeEnv->GetBuildDir(), true);
$aSelectedModules = array();
foreach ($aAvailableModules as $sModuleId => $aModule)
{
if (($sModuleId == ROOT_MODULE) || ($sModuleId == DATAMODEL_MODULE))
{
$aSelectedModules = [];
foreach ($aAvailableModules as $sModuleId => $aModule) {
if (($sModuleId == ROOT_MODULE) || ($sModuleId == DATAMODEL_MODULE)) {
continue;
}
else
{
} else {
$aSelectedModules[] = $sModuleId;
}
}
@@ -349,17 +323,14 @@ try
// Default choices = as before
$oExtensionsMap->LoadChoicesFromDatabase($oConfig);
foreach ($oExtensionsMap->GetAllExtensions() as $oExtension)
{
foreach ($oExtensionsMap->GetAllExtensions() as $oExtension) {
// Plus all "remote" extensions
if ($oExtension->sSource==iTopExtension::SOURCE_REMOTE)
{
if ($oExtension->sSource == iTopExtension::SOURCE_REMOTE) {
$oExtensionsMap->MarkAsChosen($oExtension->sCode);
}
}
$aSelectedExtensionCodes = array();
foreach ($oExtensionsMap->GetChoices() as $oExtension)
{
$aSelectedExtensionCodes = [];
foreach ($oExtensionsMap->GetChoices() as $oExtension) {
$aSelectedExtensionCodes[] = $oExtension->sCode;
}
$aSelectedExtensions = $oExtensionsMap->GetChoices();
@@ -368,34 +339,27 @@ try
// Report the success in a way that will be detected by the ajax caller
SetupLog::Info('Deployment successfully completed.');
ReportSuccess(Dict::S('iTopHub:CompiledOK'));
}
catch (Exception $e)
{
if(file_exists(APPROOT.'data/hub/compile_authent'))
{
} catch (Exception $e) {
if (file_exists(APPROOT.'data/hub/compile_authent')) {
unlink(APPROOT.'data/hub/compile_authent');
}
// Note: at this point, the dictionnary is not necessarily loaded
SetupLog::Error(get_class($e).': '.Dict::S('iTopHub:ConfigurationSafelyReverted')."\n".$e->getMessage());
SetupLog::Error('Debug trace: '.$e->getTraceAsString());
ReportError($e->getMessage(), $e->getCode());
}
finally
{
} finally {
SetupUtils::ExitReadOnlyMode();
}
break;
break;
default:
ReportError("Invalid operation: '$sOperation'", -1);
}
}
catch (Exception $e)
{
} catch (Exception $e) {
SetupLog::Error(get_class($e).': '.Dict::S('iTopHub:ConfigurationSafelyReverted')."\n".$e->getMessage());
SetupLog::Error('Debug trace: '.$e->getTraceAsString());
utils::PopArchiveMode();
ReportError($e->getMessage(), $e->getCode());
}

View File

@@ -1,15 +1,16 @@
<?php
/**
* Localized data
*
* @copyright Copyright (C) 2010-2024 Combodo SAS
* @license https://opensource.org/licenses/AGPL-3.0
*
*
*/
/**
*
*/
Dict::Add('CS CZ', 'Czech', 'Čeština', array(
Dict::Add('CS CZ', 'Czech', 'Čeština', [
'Menu:iTopHub' => 'iTop Hub~~',
'Menu:iTopHub:Register' => 'Připojit k iTop Hubu',
'Menu:iTopHub:Register+' => 'Go to iTop Hub to update your '.ITOP_APPLICATION_SHORT.' instance~~',
@@ -64,6 +65,4 @@ Dict::Add('CS CZ', 'Czech', 'Čeština', array(
'iTopHub:InstallationStatus:Installed_Version' => '%1$s verze: %2$s.',
'iTopHub:InstallationStatus:Installed' => 'Installed~~',
'iTopHub:InstallationStatus:Version_NotInstalled' => 'Verze %1$s <b>Není</b> instalována.',
));
]);

View File

@@ -1,15 +1,16 @@
<?php
/**
* Localized data
*
* @copyright Copyright (C) 2010-2024 Combodo SAS
* @license https://opensource.org/licenses/AGPL-3.0
*
*
*/
/**
*
*/
Dict::Add('DA DA', 'Danish', 'Dansk', array(
Dict::Add('DA DA', 'Danish', 'Dansk', [
'Menu:iTopHub' => 'iTop Hub~~',
'Menu:iTopHub:Register' => 'Connect to iTop Hub~~',
'Menu:iTopHub:Register+' => 'Go to iTop Hub to update your '.ITOP_APPLICATION_SHORT.' instance~~',
@@ -64,6 +65,4 @@ Dict::Add('DA DA', 'Danish', 'Dansk', array(
'iTopHub:InstallationStatus:Installed_Version' => '%1$s version: %2$s.~~',
'iTopHub:InstallationStatus:Installed' => 'Installed~~',
'iTopHub:InstallationStatus:Version_NotInstalled' => 'Version %1$s <b>NOT</b> installed.~~',
));
]);

View File

@@ -1,15 +1,16 @@
<?php
/**
* Localized data
*
* @copyright Copyright (C) 2010-2024 Combodo SAS
* @license https://opensource.org/licenses/AGPL-3.0
*
*
*/
/**
*
*/
Dict::Add('DE DE', 'German', 'Deutsch', array(
Dict::Add('DE DE', 'German', 'Deutsch', [
'Menu:iTopHub' => 'iTop Hub',
'Menu:iTopHub:Register' => 'Mit dem iTop Hub verbinden',
'Menu:iTopHub:Register+' => ITOP_APPLICATION_SHORT.'-Instanzen über den iTop Hub updaten',
@@ -64,6 +65,4 @@ Dict::Add('DE DE', 'German', 'Deutsch', array(
'iTopHub:InstallationStatus:Installed_Version' => '%1$s Version: %2$s.',
'iTopHub:InstallationStatus:Installed' => 'Installiert',
'iTopHub:InstallationStatus:Version_NotInstalled' => 'Version %1$s <b>NICHT</b> installiert.',
));
]);

View File

@@ -1,4 +1,5 @@
<?php
/**
* Localized data
*
@@ -21,7 +22,7 @@
* along with iTop. If not, see <http://www.gnu.org/licenses/>
*/
Dict::Add('EN US', 'English', 'English', array(
Dict::Add('EN US', 'English', 'English', [
// Dictionary entries go here
'Menu:iTopHub' => 'iTop Hub',
'Menu:iTopHub:Register' => 'Connect to iTop Hub',
@@ -82,6 +83,4 @@ Dict::Add('EN US', 'English', 'English', array(
'iTopHub:InstallationStatus:Installed_Version' => '%1$s version: %2$s.',
'iTopHub:InstallationStatus:Installed' => 'Installed',
'iTopHub:InstallationStatus:Version_NotInstalled' => 'Version %1$s <b>NOT</b> installed.',
));
]);

View File

@@ -1,4 +1,5 @@
<?php
/**
* Localized data
*
@@ -21,7 +22,7 @@
* along with iTop. If not, see <http://www.gnu.org/licenses/>
*/
Dict::Add('EN GB', 'British English', 'British English', array(
Dict::Add('EN GB', 'British English', 'British English', [
// Dictionary entries go here
'Menu:iTopHub' => 'iTop Hub',
'Menu:iTopHub:Register' => 'Connect to iTop Hub',
@@ -82,6 +83,4 @@ Dict::Add('EN GB', 'British English', 'British English', array(
'iTopHub:InstallationStatus:Installed_Version' => '%1$s version: %2$s.',
'iTopHub:InstallationStatus:Installed' => 'Installed',
'iTopHub:InstallationStatus:Version_NotInstalled' => 'Version %1$s <b>NOT</b> installed.',
));
]);

View File

@@ -1,13 +1,14 @@
<?php
/**
* Spanish Localized data
*
* @copyright Copyright (C) 2010-2024 Combodo SAS
* @license https://opensource.org/licenses/AGPL-3.0
* @author Miguel Turrubiates <miguel_tf@yahoo.com>
* @notas Utilizar codificación UTF-8 para mostrar acentos y otros caracteres especiales
* @notas Utilizar codificación UTF-8 para mostrar acentos y otros caracteres especiales
*/
Dict::Add('ES CR', 'Spanish', 'Español, Castellano', array(
Dict::Add('ES CR', 'Spanish', 'Español, Castellano', [
'Menu:iTopHub' => 'iTop Hub',
'Menu:iTopHub:Register' => 'Conectar a iTop Hub',
'Menu:iTopHub:Register+' => 'Ir a iTop Hub para actualizar su instancia de '.ITOP_APPLICATION_SHORT,
@@ -62,6 +63,4 @@ Dict::Add('ES CR', 'Spanish', 'Español, Castellano', array(
'iTopHub:InstallationStatus:Installed_Version' => '%1$s versión: %2$s.',
'iTopHub:InstallationStatus:Installed' => 'Instalada',
'iTopHub:InstallationStatus:Version_NotInstalled' => 'Versión %1$s <b>NO</b> está instalada.',
));
]);

View File

@@ -1,15 +1,16 @@
<?php
/**
* Localized data
*
* @copyright Copyright (C) 2010-2024 Combodo SAS
* @license https://opensource.org/licenses/AGPL-3.0
*
*
*/
/**
*
*/
Dict::Add('FR FR', 'French', 'Français', array(
Dict::Add('FR FR', 'French', 'Français', [
'Menu:iTopHub' => 'iTop Hub',
'Menu:iTopHub:Register' => 'Se connecter à iTop Hub',
'Menu:iTopHub:Register+' => 'Connectez-vous à iTop Hub pour enregistrer cette instance d\''.ITOP_APPLICATION_SHORT,
@@ -64,6 +65,4 @@ Dict::Add('FR FR', 'French', 'Français', array(
'iTopHub:InstallationStatus:Installed_Version' => '%1$s version: %2$s.',
'iTopHub:InstallationStatus:Installed' => 'Installée',
'iTopHub:InstallationStatus:Version_NotInstalled' => 'Version %1$s <b>NON</b> installée.',
));
]);

View File

@@ -1,15 +1,16 @@
<?php
/**
* Localized data
*
* @copyright Copyright (C) 2010-2024 Combodo SAS
* @license https://opensource.org/licenses/AGPL-3.0
*
*
*/
/**
*
*/
Dict::Add('HU HU', 'Hungarian', 'Magyar', array(
Dict::Add('HU HU', 'Hungarian', 'Magyar', [
'Menu:iTopHub' => 'iTop Hub',
'Menu:iTopHub:Register' => 'Kapcsolódás az iTop Hub-ra',
'Menu:iTopHub:Register+' => 'Továbblépés az iTop Hub-ra a '.ITOP_APPLICATION_SHORT.' példányának frissítéséhez',
@@ -64,6 +65,4 @@ Dict::Add('HU HU', 'Hungarian', 'Magyar', array(
'iTopHub:InstallationStatus:Installed_Version' => '%1$s verzió: %2$s.',
'iTopHub:InstallationStatus:Installed' => 'Telepítve',
'iTopHub:InstallationStatus:Version_NotInstalled' => 'A %1$s verzió <b>NINCS</b> telepítve.',
));
]);

View File

@@ -1,15 +1,16 @@
<?php
/**
* Localized data
*
* @copyright Copyright (C) 2010-2024 Combodo SAS
* @license https://opensource.org/licenses/AGPL-3.0
*
*
*/
/**
*
*/
Dict::Add('IT IT', 'Italian', 'Italiano', array(
Dict::Add('IT IT', 'Italian', 'Italiano', [
'Menu:iTopHub' => 'iTop Hub',
'Menu:iTopHub:Register' => 'Connetti a iTop Hub',
'Menu:iTopHub:Register+' => 'Vai a iTop Hub per aggiornare la tua istanza di '.ITOP_APPLICATION_SHORT,
@@ -64,6 +65,4 @@ Dict::Add('IT IT', 'Italian', 'Italiano', array(
'iTopHub:InstallationStatus:Installed_Version' => 'Versione %1$s di %2$s installata.',
'iTopHub:InstallationStatus:Installed' => 'Installata',
'iTopHub:InstallationStatus:Version_NotInstalled' => 'Versione %1$s <b>NON</b> installata.',
));
]);

View File

@@ -1,15 +1,16 @@
<?php
/**
* Localized data
*
* @copyright Copyright (C) 2010-2024 Combodo SAS
* @license https://opensource.org/licenses/AGPL-3.0
*
*
*/
/**
*
*/
Dict::Add('JA JP', 'Japanese', '日本語', array(
Dict::Add('JA JP', 'Japanese', '日本語', [
'Menu:iTopHub' => 'iTop Hub~~',
'Menu:iTopHub:Register' => 'Connect to iTop Hub~~',
'Menu:iTopHub:Register+' => 'Go to iTop Hub to update your '.ITOP_APPLICATION_SHORT.' instance~~',
@@ -64,6 +65,4 @@ Dict::Add('JA JP', 'Japanese', '日本語', array(
'iTopHub:InstallationStatus:Installed_Version' => '%1$s version: %2$s.~~',
'iTopHub:InstallationStatus:Installed' => 'Installed~~',
'iTopHub:InstallationStatus:Version_NotInstalled' => 'Version %1$s <b>NOT</b> installed.~~',
));
]);

View File

@@ -1,16 +1,17 @@
<?php
/**
* Localized data
*
* @copyright Copyright (C) 2010-2024 Combodo SAS
* @license https://opensource.org/licenses/AGPL-3.0
*
*
*/
/**
* @author Jeffrey Bostoen <info@jeffreybostoen.be> (2018 - 2022)
*
*/
Dict::Add('NL NL', 'Dutch', 'Nederlands', array(
Dict::Add('NL NL', 'Dutch', 'Nederlands', [
'Menu:iTopHub' => 'iTop Hub',
'Menu:iTopHub:Register' => 'Verbinding maken met iTop Hub',
'Menu:iTopHub:Register+' => 'Ga naar de iTop Hub om je iTop bij te werken.',
@@ -65,6 +66,4 @@ Dict::Add('NL NL', 'Dutch', 'Nederlands', array(
'iTopHub:InstallationStatus:Installed_Version' => '%1$s versie: %2$s.',
'iTopHub:InstallationStatus:Installed' => 'Geïnstalleerd',
'iTopHub:InstallationStatus:Version_NotInstalled' => 'Versie %1$s is <b>NIET</b> geïnstalleerd.',
));
]);

View File

@@ -1,15 +1,16 @@
<?php
/**
* Localized data
*
* @copyright Copyright (C) 2010-2024 Combodo SAS
* @license https://opensource.org/licenses/AGPL-3.0
*
*
*/
/**
*
*/
Dict::Add('PL PL', 'Polish', 'Polski', array(
Dict::Add('PL PL', 'Polish', 'Polski', [
'Menu:iTopHub' => 'iTop Hub',
'Menu:iTopHub:Register' => 'Połącz się z iTop Hub',
'Menu:iTopHub:Register+' => 'Przejdź do iTop Hub, aby zaktualizować swoją instancję '.ITOP_APPLICATION_SHORT,
@@ -64,6 +65,4 @@ Dict::Add('PL PL', 'Polish', 'Polski', array(
'iTopHub:InstallationStatus:Installed_Version' => '%1$s wersja: %2$s.',
'iTopHub:InstallationStatus:Installed' => 'Zainstalowana',
'iTopHub:InstallationStatus:Version_NotInstalled' => 'Wersja %1$s <b>NIE</b> zainstalowana.',
));
]);

View File

@@ -1,15 +1,16 @@
<?php
/**
* Localized data
*
* @copyright Copyright (C) 2010-2024 Combodo SAS
* @license https://opensource.org/licenses/AGPL-3.0
*
*
*/
/**
*
*/
Dict::Add('PT BR', 'Brazilian', 'Brazilian', array(
Dict::Add('PT BR', 'Brazilian', 'Brazilian', [
'Menu:iTopHub' => 'iTop Hub',
'Menu:iTopHub:Register' => 'Conectar ao iTop Hub',
'Menu:iTopHub:Register+' => 'Vá para o iTop Hub para atualizar sua instância '.ITOP_APPLICATION_SHORT,
@@ -64,6 +65,4 @@ Dict::Add('PT BR', 'Brazilian', 'Brazilian', array(
'iTopHub:InstallationStatus:Installed_Version' => '%1$s versão: %2$s',
'iTopHub:InstallationStatus:Installed' => 'Instalado',
'iTopHub:InstallationStatus:Version_NotInstalled' => 'Versão %1$s <b>NÃO</b> instalada',
));
]);

View File

@@ -1,16 +1,17 @@
<?php
/**
* Localized data
*
* @copyright Copyright (C) 2010-2024 Combodo SAS
* @license https://opensource.org/licenses/AGPL-3.0
*
*
*/
/**
* @author Vladimir Kunin <v.b.kunin@gmail.com>
*
*/
Dict::Add('RU RU', 'Russian', 'Русский', array(
Dict::Add('RU RU', 'Russian', 'Русский', [
'Menu:iTopHub' => 'iTop Hub',
'Menu:iTopHub:Register' => 'Подключение к iTop Hub',
'Menu:iTopHub:Register+' => 'Перейдите в iTop Hub, чтобы обновить ваш экземпляр '.ITOP_APPLICATION_SHORT,
@@ -65,6 +66,4 @@ Dict::Add('RU RU', 'Russian', 'Русский', array(
'iTopHub:InstallationStatus:Installed_Version' => '%1$s version: %2$s.~~',
'iTopHub:InstallationStatus:Installed' => 'Installed~~',
'iTopHub:InstallationStatus:Version_NotInstalled' => 'Version %1$s <b>NOT</b> installed.~~',
));
]);

View File

@@ -1,15 +1,16 @@
<?php
/**
* Localized data
*
* @copyright Copyright (C) 2010-2024 Combodo SAS
* @license https://opensource.org/licenses/AGPL-3.0
*
*
*/
/**
*
*/
Dict::Add('SK SK', 'Slovak', 'Slovenčina', array(
Dict::Add('SK SK', 'Slovak', 'Slovenčina', [
'Menu:iTopHub' => 'iTop Hub~~',
'Menu:iTopHub:Register' => 'Connect to iTop Hub~~',
'Menu:iTopHub:Register+' => 'Go to iTop Hub to update your '.ITOP_APPLICATION_SHORT.' instance~~',
@@ -64,6 +65,4 @@ Dict::Add('SK SK', 'Slovak', 'Slovenčina', array(
'iTopHub:InstallationStatus:Installed_Version' => '%1$s version: %2$s.~~',
'iTopHub:InstallationStatus:Installed' => 'Installed~~',
'iTopHub:InstallationStatus:Version_NotInstalled' => 'Version %1$s <b>NOT</b> installed.~~',
));
]);

View File

@@ -1,15 +1,16 @@
<?php
/**
* Localized data
*
* @copyright Copyright (C) 2010-2024 Combodo SAS
* @license https://opensource.org/licenses/AGPL-3.0
*
*
*/
/**
*
*/
Dict::Add('TR TR', 'Turkish', 'Türkçe', array(
Dict::Add('TR TR', 'Turkish', 'Türkçe', [
'Menu:iTopHub' => 'iTop Hub~~',
'Menu:iTopHub:Register' => 'Connect to iTop Hub~~',
'Menu:iTopHub:Register+' => 'Go to iTop Hub to update your '.ITOP_APPLICATION_SHORT.' instance~~',
@@ -64,6 +65,4 @@ Dict::Add('TR TR', 'Turkish', 'Türkçe', array(
'iTopHub:InstallationStatus:Installed_Version' => '%1$s version: %2$s.~~',
'iTopHub:InstallationStatus:Installed' => 'Installed~~',
'iTopHub:InstallationStatus:Version_NotInstalled' => 'Version %1$s <b>NOT</b> installed.~~',
));
]);

View File

@@ -1,4 +1,5 @@
<?php
/**
* Localized data
*
@@ -20,7 +21,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with iTop. If not, see <http://www.gnu.org/licenses/>
*/
Dict::Add('ZH CN', 'Chinese', '简体中文', array(
Dict::Add('ZH CN', 'Chinese', '简体中文', [
// Dictionary entries go here
'Menu:iTopHub' => 'iTop Hub',
'Menu:iTopHub:Register' => '进入iTop Hub',
@@ -76,6 +77,4 @@ Dict::Add('ZH CN', 'Chinese', '简体中文', array(
'iTopHub:InstallationStatus:Installed_Version' => '%1$s 版本: %2$s.',
'iTopHub:InstallationStatus:Installed' => '已安装',
'iTopHub:InstallationStatus:Version_NotInstalled' => '版本 %1$s <b>未被</b> 安装.',
));
]);

View File

@@ -18,11 +18,13 @@ class HubConnectorPage extends NiceWebPage
$sUserPrefs = appUserPreferences::GetAsJSON();
$this->LinkScriptFromAppRoot('js/utils.js');
$this->add_script(<<<JS
$this->add_script(
<<<JS
var oUserPreferences = $sUserPrefs;
JS
);
$this->add_style(<<<CSS
$this->add_style(
<<<CSS
body {
background-color: #FFFFFF;
color: rgba(0, 0, 0, 0.87);

View File

@@ -1,4 +1,5 @@
<?php
require_once(APPROOT.'application/newsroomprovider.class.inc.php');
class HubNewsroomProvider extends NewsroomProviderBase
@@ -10,24 +11,21 @@ class HubNewsroomProvider extends NewsroomProviderBase
public function GetTTL()
{
// TODO Auto-generated method stub
return 15*60; // Update every 15 minutes
return 15 * 60; // Update every 15 minutes
}
/**
* {@inheritDoc}
* @see NewsroomProviderBase::IsApplicable()
*/
public function IsApplicable(User $oUser = null)
{
if ($oUser !== null)
{
if ($oUser !== null) {
return UserRights::IsAdministrator($oUser);
}
else
{
} else {
return false;
}
}
/**
* {@inheritDoc}
@@ -37,33 +35,33 @@ class HubNewsroomProvider extends NewsroomProviderBase
{
return 'iTop Hub'; // No need to translate...
}
public function GetMarkAllAsReadURL()
{
return $this->MakeURL('route_mark_all_messages_as_read');
}
public function GetFetchURL()
{
return $this->MakeURL('route_fetch_unread_messages');
}
public function GetViewAllURL()
{
return $sBaseUrl = $this->oConfig->GetModuleSetting('itop-hub-connector', 'url').MetaModel::GetModuleSetting('itop-hub-connector', 'route_view_all_messages');
}
/**
* {@inheritDoc}
* @see iNewsroomProvider::GetPlaceholders()
*/
public function GetPlaceholders()
{
return array(
'%connect_to_itop_hub%' => utils::GetAbsoluteUrlModulePage('itop-hub-connector', 'launch.php', array('target' => 'view_dashboard')),
);
return [
'%connect_to_itop_hub%' => utils::GetAbsoluteUrlModulePage('itop-hub-connector', 'launch.php', ['target' => 'view_dashboard']),
];
}
/**
* {@inheritDoc}
* @see NewsroomProviderBase::GetPreferencesUrl()
@@ -72,15 +70,15 @@ class HubNewsroomProvider extends NewsroomProviderBase
{
return null;
}
private function MakeURL($sRouteCode)
{
$sBaseUrl = $this->oConfig->GetModuleSetting('itop-hub-connector', 'url').MetaModel::GetModuleSetting('itop-hub-connector', $sRouteCode);
$sParameters = 'uuid[bdd]='.urlencode((string) trim(DBProperty::GetProperty('database_uuid', ''), '{}'));
$sParameters .= '&uuid[file]='.urlencode((string) trim(@file_get_contents(APPROOT."data/instance.txt"), "{} \n"));
$sParameters .= '&uuid[user]='.urlencode(UserRights::GetUserId());
return $sBaseUrl.'?'.$sParameters;
}
}

View File

@@ -16,7 +16,7 @@ function DisplayStatus(WebPage $oPage)
$oPage->add('<div class="module-selection-body">');
// Now scan the extensions and display a report of the extensions brought by the hub
$sPath = APPROOT.'data/downloaded-extensions/';
$aExtraDirs = array();
$aExtraDirs = [];
if (is_dir($sPath)) {
$aExtraDirs[] = $sPath; // Also read the extra downloaded-modules directory
}
@@ -25,7 +25,7 @@ function DisplayStatus(WebPage $oPage)
foreach ($oExtensionsMap->GetAllExtensions() as $oExtension) {
if ($oExtension->sSource == iTopExtension::SOURCE_REMOTE) {
$aCSSClasses = array('landing-extension');
$aCSSClasses = ['landing-extension'];
if ($oExtension->sInstalledVersion === '') {
$aCSSClasses[] = 'landing-installation';
$sInstallation = Dict::Format('iTopHub:InstallationStatus:Version_NotInstalled', $oExtension->sVersion);
@@ -68,12 +68,11 @@ function DoLanding(WebPage $oPage)
$oPage->add('<div class="module-selection-body" style="text-align: center; line-height: 14em;"><h2>'.Dict::S('iTopHub:Uncompressing').'</h2></div>');
$sProduct = utils::ReadParam('applicationName', '', false, 'raw_data');
$sVersion = utils::ReadParam('applicationVersion', '', false, 'raw_data');
$sInstanceUUID = utils::ReadParam('uuidFile', '', false, 'raw_data');
$sDatabaseUUID = utils::ReadParam('uuidBdd', '', false, 'raw_data');
$aExtensions = utils::ReadParam('extensions', array(), false, 'raw_data');
$aExtensions = utils::ReadParam('extensions', [], false, 'raw_data');
// Basic consistency validation
if ($sProduct != ITOP_APPLICATION) {
@@ -128,7 +127,7 @@ function DoLanding(WebPage $oPage)
}
// Now scan the extensions and display a report of the extensions brought by the hub
$sNextPage = utils::GetAbsoluteUrlModulePage('itop-hub-connector', 'land.php', array('operation' => 'install'));
$sNextPage = utils::GetAbsoluteUrlModulePage('itop-hub-connector', 'land.php', ['operation' => 'install']);
$oPage->add_ready_script("window.location.href='$sNextPage'");
}
@@ -148,11 +147,10 @@ function DoInstall(WebPage $oPage)
$oPage->set_title(Dict::S('iTopHub:Landing:Install'));
$oPage->add('<div id="installation-summary" class="module-selection-body" style="position: relative">');
// Now scan the extensions and display a report of the extensions brought by the hub
// Now scan the extensions and display a report of the extensions brought by the hub
$sPath = APPROOT.'data/downloaded-extensions/';
$aExtraDirs = array();
$aExtraDirs = [];
if (is_dir($sPath)) {
$aExtraDirs[] = $sPath; // Also read the extra downloaded-modules directory
}
@@ -175,14 +173,14 @@ function DoInstall(WebPage $oPage)
$oPage->add('</div>');
$oPage->add('</div>');
} else {
$aCSSClasses = array('landing-extension');
$aCSSClasses = ['landing-extension'];
if ($oExtension->sInstalledVersion === '') {
$aCSSClasses[] = 'landing-installation';
$sInstallation = Dict::Format('iTopHub:InstallationEffect:Install', $oExtension->sVersion);
} else if ($oExtension->sInstalledVersion == $oExtension->sVersion) {
} elseif ($oExtension->sInstalledVersion == $oExtension->sVersion) {
$aCSSClasses[] = 'landing-no-change';
$sInstallation = Dict::Format('iTopHub:InstallationEffect:NoChange', $oExtension->sVersion);
} else if (version_compare($oExtension->sInstalledVersion, $oExtension->sVersion, '<')) {
} elseif (version_compare($oExtension->sInstalledVersion, $oExtension->sVersion, '<')) {
$aCSSClasses[] = 'landing-upgrade';
$sInstallation = Dict::Format('iTopHub:InstallationEffect:Upgrade', $oExtension->sInstalledVersion, $oExtension->sVersion);
} else {
@@ -213,10 +211,8 @@ function DoInstall(WebPage $oPage)
$oPage->add('</div>'); // module-selection-body
$oPage->LinkStylesheetFromAppRoot('css/font-awesome/css/all.min.css');
$oPage->add('<div id="hub_installation_widget"></div>');
$oPage->add('<fieldset id="database-backup-fieldset"><legend>'.Dict::S('iTopHub:DBBackupLabel').'</legend>');
$oPage->add('<div id="backup_form"><input id="backup_checkbox" type="checkbox" checked><label for="backup_checkbox"> '.Dict::S('iTopHub:DBBackupSentence').'</label></div>');
@@ -224,22 +220,22 @@ function DoInstall(WebPage $oPage)
$oPage->add('</fieldset>');
$oPage->add('<p style="text-align: center"><input type="button" id="hub_start_installation" type="button" disabled value="'.Dict::S('iTopHub:DeployBtn').'"/></p>');
$sIframeUrl = utils::GetAbsoluteUrlModulePage('itop-hub-connector', 'launch.php', array('target' => 'inform_after_setup'));
$sStatusPageUrl = utils::GetAbsoluteUrlModulePage('itop-hub-connector', 'land.php', array('operation' => 'done'));
$sIframeUrl = utils::GetAbsoluteUrlModulePage('itop-hub-connector', 'launch.php', ['target' => 'inform_after_setup']);
$sStatusPageUrl = utils::GetAbsoluteUrlModulePage('itop-hub-connector', 'land.php', ['operation' => 'done']);
$aWidgetParams = array(
'self_url' => utils::GetAbsoluteUrlModulePage('itop-hub-connector', 'ajax.php', array('maintenance' => true)),
$aWidgetParams = [
'self_url' => utils::GetAbsoluteUrlModulePage('itop-hub-connector', 'ajax.php', ['maintenance' => true]),
'iframe_url' => $sIframeUrl,
'redirect_after_completion_url' => $sStatusPageUrl,
'mysql_bindir' => MetaModel::GetConfig()->GetModuleSetting('itop-backup', 'mysql_bindir', ''),
'labels' => array(
'labels' => [
'database_backup' => Dict::S('iTopHub:InstallationProgress:DatabaseBackup'),
'extensions_installation' => Dict::S('iTopHub:InstallationProgress:ExtensionsInstallation'),
'installation_successful' => Dict::S('iTopHub:InstallationProgress:InstallationSuccessful'),
'rollback' => Dict::S('iTopHub:ConfigurationSafelyReverted'),
),
],
'authent' => $sUID,
);
];
$sWidgetParams = json_encode($aWidgetParams);
@@ -249,7 +245,6 @@ function DoInstall(WebPage $oPage)
$oPage->add('<div id="debug"></div>');
}
try {
require_once(APPROOT.'/application/application.inc.php');
require_once(APPROOT.'/setup/setuppage.class.inc.php');
@@ -266,7 +261,8 @@ try {
$oPage->LinkScriptFromModule('itop-hub-connector/js/hub.js');
$oPage->LinkStylesheetFromAppRoot('css/font-combodo/font-combodo.css');
$oPage->add_style(<<<CSS
$oPage->add_style(
<<<CSS
div.choice { margin: 0.5em;}
div.choice a { text-decoration:none; font-weight: bold; color: #1C94C4 }
div.description { margin-left: 2em; }
@@ -295,8 +291,7 @@ CSS
}
$oPage->output();
}
catch (Exception $e) {
} catch (Exception $e) {
require_once(APPROOT.'/setup/setuppage.class.inc.php');
$oP = new ErrorPage(Dict::S('UI:PageTitle:FatalError'));
$oP->add("<h1>".Dict::S('UI:FatalErrorMessage')."</h1>\n");
@@ -312,7 +307,7 @@ catch (Exception $e) {
$oLog->Set('issue', 'PHP Exception');
$oLog->Set('impact', 'Page could not be displayed');
$oLog->Set('callstack', $e->getTrace());
$oLog->Set('data', array());
$oLog->Set('data', []);
$oLog->DBInsertNoReload();
}

View File

@@ -114,7 +114,7 @@ use Combodo\iTop\Application\WebPage\NiceWebPage;
*/
function CleanVersionNumber($sString)
{
$aMatches = array();
$aMatches = [];
if (preg_match("|^([0-9\\.]+)-|", $sString, $aMatches)) {
return $aMatches[1];
}
@@ -124,11 +124,11 @@ function CleanVersionNumber($sString)
function collect_configuration()
{
$aConfiguration = array(
'php' => array(),
'mysql' => array(),
'apache' => array(),
);
$aConfiguration = [
'php' => [],
'mysql' => [],
'apache' => [],
];
// Database information
$m_oMysqli = CMDBSource::GetMysqli();
@@ -170,7 +170,7 @@ function collect_configuration()
// PHP extensions
if (!MetaModel::GetConfig()->GetModuleSetting('itop-hub-connector', 'php_extensions_enable', true)) {
$aConfiguration['php_extensions'] = array();
$aConfiguration['php_extensions'] = [];
} else {
foreach (get_loaded_extensions() as $extension) {
$aConfiguration['php_extensions'][$extension] = $extension;
@@ -178,8 +178,8 @@ function collect_configuration()
}
// Collect some PHP settings having a known impact on iTop
$aIniGet = MetaModel::GetConfig()->GetModuleSetting('itop-hub-connector', 'php_settings_array', array()); // by default, on the time of the writting, it values are : array('post_max_size', 'upload_max_filesize', 'apc.enabled', 'timezone', 'memory_limit', 'max_execution_time');
$aConfiguration['php_settings'] = array();
$aIniGet = MetaModel::GetConfig()->GetModuleSetting('itop-hub-connector', 'php_settings_array', []); // by default, on the time of the writting, it values are : array('post_max_size', 'upload_max_filesize', 'apc.enabled', 'timezone', 'memory_limit', 'max_execution_time');
$aConfiguration['php_settings'] = [];
foreach ($aIniGet as $iniGet) {
$aConfiguration['php_settings'][$iniGet] = (string)ini_get($iniGet);
}
@@ -197,22 +197,22 @@ function collect_configuration()
// iTop Installation Options, i.e. "Extensions"
$oExtensionMap = new iTopExtensionsMap();
$oExtensionMap->LoadChoicesFromDatabase($oConfig);
$aConfiguration['itop_extensions'] = array();
$aConfiguration['itop_extensions'] = [];
foreach ($oExtensionMap->GetChoices() as $oExtension) {
switch ($oExtension->sSource) {
case iTopExtension::SOURCE_MANUAL:
case iTopExtension::SOURCE_REMOTE:
$aConfiguration['itop_extensions'][$oExtension->sCode] = array(
$aConfiguration['itop_extensions'][$oExtension->sCode] = [
'label' => $oExtension->sLabel,
'value' => $oExtension->sInstalledVersion,
);
];
break;
default:
$aConfiguration['itop_installation_options'][$oExtension->sCode] = array(
$aConfiguration['itop_installation_options'][$oExtension->sCode] = [
'label' => $oExtension->sLabel,
'value' => true,
);
];
}
}
@@ -223,13 +223,13 @@ function MakeDataToPost($sTargetRoute)
{
if (MetaModel::GetConfig()->Get('demo_mode')) {
// Don't expose such information in demo mode
$aDataToPost = array('disabled' => true, 'reason' => 'demo_mode');
$aDataToPost = ['disabled' => true, 'reason' => 'demo_mode'];
} else {
$aConfiguration = collect_configuration();
$aDataToPost = array(
$aDataToPost = [
'itop_hub_target_route' => $sTargetRoute,
'itop_stack' => array(
'itop_stack' => [
"uuidBdd" => (string)trim(DBProperty::GetProperty('database_uuid', ''), '{}'), // TODO check if empty and... regenerate a new UUID ??
"uuidFile" => (string)trim(@file_get_contents(APPROOT."data/instance.txt"), "{} \n"), // TODO check if empty and... regenerate a new UUID ??
'instance_friendly_name' => (string)$_SERVER['SERVER_NAME'],
@@ -242,8 +242,8 @@ function MakeDataToPost($sTargetRoute)
'itop_modules' => (object)$aConfiguration['itop_modules'],
'itop_extensions' => (object)$aConfiguration['itop_extensions'],
'itop_installation_options' => (object)$aConfiguration['itop_installation_options'],
),
'server_stack' => array(
],
'server_stack' => [
'os_name' => (string)PHP_OS,
'web_server_name' => (string)$aConfiguration['web_server_name'],
'web_server_version' => (string)$aConfiguration['web_server_version'],
@@ -253,8 +253,8 @@ function MakeDataToPost($sTargetRoute)
'php_version' => (string)CleanVersionNumber(phpversion()),
'php_settings' => (object)$aConfiguration['php_settings'],
'php_extensions' => (object)$aConfiguration['php_extensions'],
),
);
],
];
}
return $aDataToPost;
@@ -282,23 +282,23 @@ try {
switch ($sTargetRoute) {
case 'inform_after_setup':
// Hidden IFRAME at the end of the setup
require_once (APPROOT.'/application/ajaxwebpage.class.inc.php');
// Hidden IFRAME at the end of the setup
require_once(APPROOT.'/application/ajaxwebpage.class.inc.php');
$sParamToken = utils::ReadParam('setup_token');
$oTokenValidation = new TokenValidation();
$bIsTokenValid = $oTokenValidation->isSetupTokenValid($sParamToken);
if (UserRights::IsAdministrator() || $bIsTokenValid) {
$oPage = new NiceWebPage('');
$aDataToPost = MakeDataToPost($sTargetRoute);
$oPage->add('<form id="hub_launch_form" action="'.$sHubUrlStateless.'" method="post">');
$oPage->add('<input type="hidden" name="json" value="'.utils::EscapeHtml(json_encode($aDataToPost)).'">');
$oPage->add_ready_script('$("#hub_launch_form").submit();');
} else {
IssueLog::Error('TokenValidation failed on inform_after_setup page');
throw new Exception("Not allowed");
}
break;
$sParamToken = utils::ReadParam('setup_token');
$oTokenValidation = new TokenValidation();
$bIsTokenValid = $oTokenValidation->isSetupTokenValid($sParamToken);
if (UserRights::IsAdministrator() || $bIsTokenValid) {
$oPage = new NiceWebPage('');
$aDataToPost = MakeDataToPost($sTargetRoute);
$oPage->add('<form id="hub_launch_form" action="'.$sHubUrlStateless.'" method="post">');
$oPage->add('<input type="hidden" name="json" value="'.utils::EscapeHtml(json_encode($aDataToPost)).'">');
$oPage->add_ready_script('$("#hub_launch_form").submit();');
} else {
IssueLog::Error('TokenValidation failed on inform_after_setup page');
throw new Exception("Not allowed");
}
break;
default:
// All other cases, special "Hub like" web page
@@ -337,7 +337,8 @@ try {
$sButtonLabelClose = Dict::S('iTopHub:CloseBtn');
$sButtonLabelGo = Dict::S('iTopHub:GoBtn');
$sButtonLabelTooltip = Dict::S('iTopHub:GoBtn:Tooltip');
$oPage->add(<<<HTML
$oPage->add(
<<<HTML
<p>
<button type="button" class="ibo-button" id="CancelBtn" title="Go back to iTop"><img src="$sCloseUrl"><span class="ibo-button--label">$sButtonLabelClose</span></button>
<span class="horiz-spacer"></span>
@@ -405,8 +406,7 @@ JS
}
$oPage->output();
}
catch (CoreException $e) {
} catch (CoreException $e) {
require_once(APPROOT.'/setup/setuppage.class.inc.php');
$oP = new ErrorPage(Dict::S('UI:PageTitle:FatalError'));
$oP->add("<h1>".Dict::S('UI:FatalErrorMessage')."</h1>\n");
@@ -431,8 +431,7 @@ catch (CoreException $e) {
// For debugging only
// throw $e;
}
catch (Exception $e) {
} catch (Exception $e) {
require_once(APPROOT.'/setup/setuppage.class.inc.php');
$oP = new ErrorPage(Dict::S('UI:PageTitle:FatalError'));
$oP->add("<h1>".Dict::S('UI:FatalErrorMessage')."</h1>\n");
@@ -448,11 +447,10 @@ catch (Exception $e) {
$oLog->Set('issue', 'PHP Exception');
$oLog->Set('impact', 'Page could not be displayed');
$oLog->Set('callstack', $e->getTrace());
$oLog->Set('data', array());
$oLog->Set('data', []);
$oLog->DBInsertNoReload();
}
IssueLog::Error($e->getMessage());
}
}

View File

@@ -17,16 +17,15 @@ class ItopHubMenusHandler extends ModuleHandlerAPI
public static function OnMenuCreation()
{
// Add the admin menus
if (UserRights::IsAdministrator())
{
if (UserRights::IsAdministrator()) {
$sRootUrl = utils::GetAbsoluteUrlAppRoot().'pages/exec.php?exec_module=itop-hub-connector&exec_page=launch.php';
$sMyExtensionsUrl = utils::GetAbsoluteUrlAppRoot().'pages/exec.php?exec_module=itop-hub-connector&exec_page=myextensions.php';
$oHubMenu = new MenuGroup('iTopHub', 999 /* fRank */, 'fc fc-itophub-icon fc-1-5x');
$fRank = 1;
new WebPageMenuNode('iTopHub:Register', $sRootUrl.'&target=view_dashboard', $oHubMenu->GetIndex(), $fRank++);
new WebPageMenuNode('iTopHub:MyExtensions', $sMyExtensionsUrl, $oHubMenu->GetIndex(), $fRank++);
new WebPageMenuNode('iTopHub:BrowseExtensions', $sRootUrl.'&target=browse_extensions', $oHubMenu->GetIndex(), $fRank++);
}
}
}
}
}

View File

@@ -1,4 +1,5 @@
<?php
//
// iTop module definition file
//
@@ -6,7 +7,7 @@
SetupWebPage::AddModule(
__FILE__, // Path to the current file, all other file names are relative to the directory containing this file
'itop-hub-connector/3.2.1',
array(
[
// Identification
//
'label' => 'iTop Hub Connector',
@@ -14,31 +15,31 @@ SetupWebPage::AddModule(
// Setup
//
'dependencies' => array(
'dependencies' => [
'itop-config-mgmt/2.4.0', // Actually this module requires iTop 2.4.1 minimum
),
],
'mandatory' => false,
'visible' => true,
// Components
//
'datamodel' => array(
'datamodel' => [
'menus.php',
'hubnewsroomprovider.class.inc.php',
),
'webservice' => array(
),
'data.struct' => array(
'hubnewsroomprovider.class.inc.php',
],
'webservice' => [
],
'data.struct' => [
// add your 'structure' definition XML files here,
),
'data.sample' => array(
],
'data.sample' => [
// add your sample data XML files here,
),
],
// Documentation
//
'doc.manual_setup' => '', // hyperlink to manual setup documentation, if any
'doc.more_information' => '', // hyperlink to more information, if any
)
'doc.more_information' => '', // hyperlink to more information, if any
]
);

View File

@@ -1,4 +1,5 @@
<?php
/*
* @copyright Copyright (C) 2010-2024 Combodo SAS
* @license http://opensource.org/licenses/AGPL-3.0
@@ -26,7 +27,6 @@ $oAppContext = new ApplicationContext();
$oPage = new iTopWebPage(Dict::S('iTopHub:InstalledExtensions'));
$oPage->SetBreadCrumbEntry('ui-hub-myextensions', Dict::S('Menu:iTopHub:MyExtensions'), Dict::S('Menu:iTopHub:MyExtensions+'), '', 'fas fa-puzzle-piece', iTopWebPage::ENUM_BREADCRUMB_ENTRY_ICON_TYPE_CSS_CLASSES);
function GetExtensionInfoComponent(iTopExtension $oExtension): UIBlock
{
$sExtensionDescription = Dict::Format('UI:About:Extension_Version', $oExtension->sVersion);
@@ -40,16 +40,12 @@ function GetExtensionInfoComponent(iTopExtension $oExtension): UIBlock
->SetOpenedByDefault(false);
}
try {
$oExtensionsMap = new iTopExtensionsMap();
$oExtensionsMap->LoadChoicesFromDatabase(MetaModel::GetConfig());
$oPage->AddUiBlock(TitleUIBlockFactory::MakeForPage(Dict::S('iTopHub:InstalledExtensions')));
/**------------------------------------------------------------------------------------------------------
* Remotely deployed ext
*/
@@ -80,13 +76,12 @@ try {
$oHubButtonContainer = UIContentBlockUIBlockFactory::MakeStandard()
->AddCSSClass('hub-button');
$oPage->AddSubBlock($oHubButtonContainer);
$sUrl = utils::GetAbsoluteUrlModulePage('itop-hub-connector', 'launch.php', array('target' => 'browse_extensions'));
$sUrl = utils::GetAbsoluteUrlModulePage('itop-hub-connector', 'launch.php', ['target' => 'browse_extensions']);
$oHubButton = ButtonUIBlockFactory::MakeForPrimaryAction(Dict::S('iTopHub:GetMoreExtensions'), 'install-extensions-button')
->SetOnClickJsCode("window.location.href='$sUrl'")
->SetIconClass('fa-fw fc fc-itophub-icon fc-1-5x');
$oHubButtonContainer->AddSubBlock($oHubButton);
/**------------------------------------------------------------------------------------------------------
* Manually deployed ext
* Only if there are some !
@@ -121,8 +116,7 @@ try {
}
CSS
);
}
catch (Exception $e) {
} catch (Exception $e) {
$oPage->p('<b>'.Dict::Format('UI:Error_Details', $e->getMessage()).'</b>');
}