mirror of
https://github.com/Combodo/iTop.git
synced 2026-08-12 16:58:18 +02:00
Compare commits
3 Commits
feature/99
...
develop
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1bba486ee8 | ||
|
|
801090fddb | ||
|
|
1d77b9faa2 |
@@ -130,8 +130,8 @@ class HubController
|
||||
$oRuntimeEnv->MoveSelectedExtensions(APPROOT.'/data/downloaded-extensions/', $aSelectedExtensionDirs);
|
||||
|
||||
$oExtensionMap = iTopExtensionsMap::GetExtensionsMap($oRuntimeEnv->GetBuildEnv());
|
||||
$aPreviousRemoteExtensions = $oExtensionMap->GetExtensionsFromDir(APPROOT.'data/'.$oRuntimeEnv->GetFinalEnv().'-modules/') ?: [];
|
||||
$aCurrentRemoteExtensions = $oExtensionMap->GetExtensionsFromDir(APPROOT.'data/'.$oRuntimeEnv->GetBuildEnv().'-modules/') ?: [];
|
||||
$aPreviousRemoteExtensions = $oExtensionMap->GetExtensionsFromDir(APPROOT.'data/'.$oRuntimeEnv->GetFinalEnv().'-modules/');
|
||||
$aCurrentRemoteExtensions = $oExtensionMap->GetExtensionsFromDir(APPROOT.'data/'.$oRuntimeEnv->GetBuildEnv().'-modules/');
|
||||
$aAddedExtensions = array_diff($aCurrentRemoteExtensions, $aPreviousRemoteExtensions);
|
||||
|
||||
$sBuildConfigFile = APPCONF.ITOP_DEFAULT_ENV.'/'.ITOP_CONFIG_FILE;
|
||||
|
||||
@@ -394,12 +394,13 @@ class iTopExtensionsMap
|
||||
*
|
||||
* @param string $sSearchDir The directory to scan
|
||||
*
|
||||
* @return string[]|bool
|
||||
* @return string[]
|
||||
*/
|
||||
public function GetExtensionsFromDir(string $sSearchDir): array|bool
|
||||
public function GetExtensionsFromDir(string $sSearchDir): array
|
||||
{
|
||||
if (!is_readable($sSearchDir)) {
|
||||
return false;
|
||||
SetupLog::Error("No extension found: Directory $sSearchDir is not readable");
|
||||
return [];
|
||||
}
|
||||
|
||||
$aExtensions = [];
|
||||
|
||||
@@ -2177,11 +2177,13 @@ JS
|
||||
*/
|
||||
public static function EraseSetupToken()
|
||||
{
|
||||
$sTokenFile = utils::GetDataPath().'setup/authent';
|
||||
if (is_file($sTokenFile)) {
|
||||
unlink($sTokenFile);
|
||||
if (self::IsSessionSetupTokenValid()) {
|
||||
$sTokenFile = utils::GetDataPath().'setup/authent';
|
||||
if (is_file($sTokenFile)) {
|
||||
unlink($sTokenFile);
|
||||
}
|
||||
Session::Unset('setup_token');
|
||||
}
|
||||
Session::Unset('setup_token');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -51,8 +51,6 @@ class WizStepModulesChoice extends AbstractWizStepInstall
|
||||
private array $aAnalyzeInstallationModules = [];
|
||||
private ?MissingDependencyException $oMissingDependencyException = null;
|
||||
|
||||
private array $aFlagsByChoiceId = [];
|
||||
|
||||
public function __construct(WizardController $oWizard, $sCurrentState, bool $bOverWriteConfig = true)
|
||||
{
|
||||
parent::__construct($oWizard, $sCurrentState);
|
||||
@@ -292,34 +290,6 @@ class WizStepModulesChoice extends AbstractWizStepInstall
|
||||
$oPage->warning($sManualInstallError);
|
||||
}
|
||||
|
||||
// Build the default choices
|
||||
$aDefaults = $this->GetDefaults($aStepInfo, $this->aAnalyzeInstallationModules);
|
||||
$index = $this->GetStepIndex();
|
||||
|
||||
// retrieve the saved selection
|
||||
// use json_encode:decode to store a hash array: step_id => array(input_name => selected_input_id)
|
||||
$aParameters = json_decode($this->oWizard->GetParameter('selected_components', '{}'), true);
|
||||
if (!isset($aParameters[$index])) {
|
||||
$aParameters[$index] = $aDefaults;
|
||||
}
|
||||
$aSelectedComponents = $aParameters[$index];
|
||||
|
||||
$bDisableUninstallCheck = (bool)$this->oWizard->GetParameter('force-uninstall', false);
|
||||
|
||||
$aOptions = $aStepInfo['options'] ?? [];
|
||||
foreach ($aOptions as $index => $aChoice) {
|
||||
$sChoiceId = self::$SEP.$index;
|
||||
$this->ComputeChoiceFlags($aChoice, $sChoiceId, $aSelectedComponents, false, $bDisableUninstallCheck);
|
||||
}
|
||||
|
||||
if (!$this->bCanMoveForward) {
|
||||
if (SetupUtils::IsConnectableToITopHub($this->aAnalyzeInstallationModules)) {
|
||||
$oPage->error('Due to some inconsistencies the upgrade can\'t continue. You must deactivate "consistency protections" in the previous steps and restore a consistent environment.');
|
||||
} else {
|
||||
$oPage->error('Due to some inconsistencies the upgrade can\'t continue, please contact Combodo support.');
|
||||
}
|
||||
}
|
||||
|
||||
$oPage->add('<div class="module-selection-banner">');
|
||||
$sBannerPath = isset($aStepInfo['banner']) ? $aStepInfo['banner'] : '';
|
||||
if (!empty($sBannerPath)) {
|
||||
@@ -338,6 +308,18 @@ class WizStepModulesChoice extends AbstractWizStepInstall
|
||||
$oPage->add('<span>'.$sDescription.'</span>');
|
||||
$oPage->add('</div>');
|
||||
|
||||
// Build the default choices
|
||||
$aDefaults = $this->GetDefaults($aStepInfo, $this->aAnalyzeInstallationModules);
|
||||
$index = $this->GetStepIndex();
|
||||
|
||||
// retrieve the saved selection
|
||||
// use json_encode:decode to store a hash array: step_id => array(input_name => selected_input_id)
|
||||
$aParameters = json_decode($this->oWizard->GetParameter('selected_components', '{}'), true);
|
||||
if (!isset($aParameters[$index])) {
|
||||
$aParameters[$index] = $aDefaults;
|
||||
}
|
||||
$aSelectedComponents = $aParameters[$index];
|
||||
|
||||
$oPage->add('<div class="module-selection-body">');
|
||||
$this->DisplayOptions($oPage, $aStepInfo, $aSelectedComponents, $aDefaults);
|
||||
$oPage->add('</div>');
|
||||
@@ -760,12 +742,8 @@ EOF
|
||||
return $this->aSteps[$index] ?? null;
|
||||
}
|
||||
|
||||
public function ComputeChoiceFlags(array $aChoice, string $sChoiceId, array $aSelectedComponents, bool $bAllDisabled, bool $bDisableUninstallCheck)
|
||||
public function ComputeChoiceFlags(array $aChoice, string $sChoiceId, array $aSelectedComponents, bool $bAllDisabled, bool $bDisableUninstallCheck, bool $bUpgradeMode)
|
||||
{
|
||||
if (array_key_exists($sChoiceId, $this->aFlagsByChoiceId)) {
|
||||
return $this->aFlagsByChoiceId[$sChoiceId];
|
||||
}
|
||||
|
||||
$oITopExtension = $this->oExtensionsMap->GetFromExtensionCode($aChoice['extension_code']);
|
||||
//If the extension is missing from disk, it won't exist in the ExtensionsMap, thus returning null
|
||||
$bCanBeUninstalled = isset($aChoice['uninstallable']) ? $aChoice['uninstallable'] === true || $aChoice['uninstallable'] === 'yes' : $oITopExtension->CanBeUninstalled();
|
||||
@@ -806,7 +784,7 @@ EOF
|
||||
$aOptions = $aChoice['sub_options']['options'] ?? [];
|
||||
foreach ($aOptions as $index => $aSubChoice) {
|
||||
$sSubChoiceId = $sChoiceId.self::$SEP.$index;
|
||||
$aSubFlags = $this->ComputeChoiceFlags($aSubChoice, $sSubChoiceId, $aSelectedComponents, $bAllDisabled, $bDisableUninstallCheck);
|
||||
$aSubFlags = $this->ComputeChoiceFlags($aSubChoice, $sSubChoiceId, $aSelectedComponents, $bAllDisabled, $bDisableUninstallCheck, $bUpgradeMode);
|
||||
if ($aSubFlags['checked']) {
|
||||
$bChecked = true;
|
||||
if ($aSubFlags['disabled']) {
|
||||
@@ -818,7 +796,7 @@ EOF
|
||||
}
|
||||
}
|
||||
|
||||
$aFlags = [
|
||||
return [
|
||||
'uninstallable' => $bCanBeUninstalled,
|
||||
'dependency_issue' => $bDependencyIssue,
|
||||
'mandatory' => $bMandatory,
|
||||
@@ -827,11 +805,6 @@ EOF
|
||||
'disabled' => $bDisabled,
|
||||
'checked' => $bChecked,
|
||||
];
|
||||
|
||||
$this->bCanMoveForward = $this->bCanMoveForward && $this->CanMoveForwardFromChoiceFlags($aFlags, $bDisableUninstallCheck);
|
||||
$this->aFlagsByChoiceId[$sChoiceId] = $aFlags;
|
||||
|
||||
return $aFlags;
|
||||
}
|
||||
|
||||
public function DisplayOptions($oPage, $aStepInfo, $aSelectedComponents, $aDefaults, $sParentId = '', $bAllDisabled = false)
|
||||
@@ -843,7 +816,16 @@ EOF
|
||||
|
||||
foreach ($aOptions as $index => $aChoice) {
|
||||
$sChoiceId = $sParentId.self::$SEP.$index;
|
||||
$aFlags = $this->ComputeChoiceFlags($aChoice, $sChoiceId, $aSelectedComponents, $bAllDisabled, $bDisableUninstallCheck);
|
||||
$aFlags = $this->ComputeChoiceFlags($aChoice, $sChoiceId, $aSelectedComponents, $bAllDisabled, $bDisableUninstallCheck, $this->bUpgrade);
|
||||
|
||||
if (!$aFlags['checked'] && $aFlags['installed'] && !$bDisableUninstallCheck && (!$aFlags['uninstallable'] || $aFlags['mandatory'])) {
|
||||
// If the user cannot uninstall a mandatory extension, he cannot move forward unless he uses the "force-uninstall" option
|
||||
// The same applies if the extension is not uninstallable (i.e. a product extension)
|
||||
$this->bCanMoveForward = false;
|
||||
} elseif ($aFlags['checked'] && $aFlags['disabled'] && $aFlags['dependency_issue'] && !$bDisableUninstallCheck) {
|
||||
// If there is a dependency issue on a selected and disabled extension, the user cannot move forward unless he uses the "force-uninstall" option
|
||||
$this->bCanMoveForward = false;
|
||||
}
|
||||
|
||||
$this->DisplayChoice($oPage, $aChoice, $aSelectedComponents, $aDefaults, $sChoiceId, $sChoiceId, $aFlags);
|
||||
}
|
||||
@@ -882,7 +864,7 @@ EOF
|
||||
$bSelected = ($sChoiceId === $sChoiceIdNone);
|
||||
}
|
||||
|
||||
$aFlags = $this->ComputeChoiceFlags($aChoice, $sChoiceId, $aSelectedComponents, $bAllDisabled, $bDisableUninstallCheck);
|
||||
$aFlags = $this->ComputeChoiceFlags($aChoice, $sChoiceId, $aSelectedComponents, $bAllDisabled, $bDisableUninstallCheck, $this->bUpgrade);
|
||||
//ComputeChoiceFlags does not completely compute alternative flags
|
||||
$aFlags['disabled'] = $bDisabled;
|
||||
$aFlags['checked'] = $bSelected;
|
||||
@@ -890,32 +872,6 @@ EOF
|
||||
}
|
||||
}
|
||||
|
||||
protected function CanMoveForwardFromChoiceFlags(array $aFlags, bool $bDisableUninstallCheck): bool
|
||||
{
|
||||
// The user can force to move forward with the "force-uninstall" option
|
||||
if ($bDisableUninstallCheck) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($aFlags['checked']) {
|
||||
// An extension cannot be installed if it has a dependency issue
|
||||
if ($aFlags['disabled'] && $aFlags['dependency_issue']) {
|
||||
return false;
|
||||
}
|
||||
} elseif ($aFlags['installed']) {
|
||||
// An extension cannot be uninstalled if it is not uninstallable
|
||||
if (!$aFlags['uninstallable']) {
|
||||
return false;
|
||||
}
|
||||
// An extension cannot be uninstalled if it is mandatory
|
||||
if ($aFlags['mandatory']) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function DisplayChoice($oPage, $aChoice, $aSelectedComponents, $aDefaults, $sChoiceName, $sChoiceId, $aFlags, $sInputType = 'checkbox')
|
||||
{
|
||||
$sMoreInfo = (isset($aChoice['more_info']) && ($aChoice['more_info'] != '')) ? '
|
||||
|
||||
@@ -15,12 +15,12 @@
|
||||
$('#{{ oUIBlock.GetId() }}').on('edit_object', function(){
|
||||
let oFavoriteButton = $(this).find('#UIMenuModify');
|
||||
if(oFavoriteButton[0]){
|
||||
oFavoriteButton[0].trigger('click');
|
||||
oFavoriteButton[0].click();
|
||||
}
|
||||
else{
|
||||
let oPopupItemButton = $('[data-role="ibo-popover-menu"]').find('[data-resource-id="UI:Menu:Modify"]');
|
||||
if(oPopupItemButton[0]){
|
||||
oPopupItemButton[0].trigger('click');
|
||||
oPopupItemButton[0].click();
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -28,12 +28,12 @@
|
||||
$('#{{ oUIBlock.GetId() }}').on('delete_object', function(){
|
||||
let oFavoriteButton = $(this).find('#UIMenuDelete');
|
||||
if(oFavoriteButton[0]){
|
||||
oFavoriteButton[0].trigger('click');
|
||||
oFavoriteButton[0].click();
|
||||
}
|
||||
else{
|
||||
let oPopupItemButton = $('[data-role="ibo-popover-menu"]').find('[data-resource-id="UI:Menu:Delete"]');
|
||||
if(oPopupItemButton[0]){
|
||||
oPopupItemButton[0].trigger('click');
|
||||
oPopupItemButton[0].click();
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -41,12 +41,12 @@
|
||||
$('#{{ oUIBlock.GetId() }}').on('new_object', function(){
|
||||
let oFavoriteButton = $(this).find('#UIMenuNew');
|
||||
if(oFavoriteButton[0]){
|
||||
oFavoriteButton[0].trigger('click');
|
||||
oFavoriteButton[0].click();
|
||||
}
|
||||
else{
|
||||
let oPopupItemButton = $('[data-role="ibo-popover-menu"]').find('[data-resource-id="UI:Menu:New"]');
|
||||
if(oPopupItemButton[0]){
|
||||
oPopupItemButton[0].trigger('click');
|
||||
oPopupItemButton[0].click();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -592,7 +592,7 @@ class WizStepModulesChoiceTest extends ItopTestCase
|
||||
public function testComputeChoiceFlags($aExtensionsOnDiskOrDb, $aWizardStepDefinition, $bIsCurrentSelected, $bDisableUninstallChecks, $aExpectedFlags)
|
||||
{
|
||||
$this->oWizStepModulesChoiceFake->setExtensionMap(iTopExtensionsMapFake::createFromArray($aExtensionsOnDiskOrDb));
|
||||
$aFlags = $this->oWizStepModulesChoiceFake->ComputeChoiceFlags($aWizardStepDefinition, '_0', $bIsCurrentSelected ? ['_0' => '_0'] : [], false, $bDisableUninstallChecks);
|
||||
$aFlags = $this->oWizStepModulesChoiceFake->ComputeChoiceFlags($aWizardStepDefinition, '_0', $bIsCurrentSelected ? ['_0' => '_0'] : [], false, $bDisableUninstallChecks, true);
|
||||
$this->assertEquals($aExpectedFlags, $aFlags);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user