From 899f87f163a474c0a027ddb74c2047d4ee048cf5 Mon Sep 17 00:00:00 2001 From: Timmy38 Date: Thu, 30 Jul 2026 10:55:01 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B08908=20Warn=20user=20that=20an=20extensi?= =?UTF-8?q?on=20is=20part=20of=20package?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- setup/wizardsteps/WizStepModulesChoice.php | 70 ++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/setup/wizardsteps/WizStepModulesChoice.php b/setup/wizardsteps/WizStepModulesChoice.php index 9afb266cb..bcf35fbe2 100644 --- a/setup/wizardsteps/WizStepModulesChoice.php +++ b/setup/wizardsteps/WizStepModulesChoice.php @@ -49,6 +49,7 @@ class WizStepModulesChoice extends AbstractWizStepInstall protected bool $bChoicesFromDatabase; private array $aAnalyzeInstallationModules = []; + private ?array $aBasePackageModules = null; private ?MissingDependencyException $oMissingDependencyException = null; public function __construct(WizardController $oWizard, $sCurrentState, bool $bOverWriteConfig = true) @@ -752,6 +753,7 @@ EOF $bMandatory = (isset($aChoice['mandatory']) && $aChoice['mandatory']); $bInstalled = $bMissingFromDisk || $oITopExtension?->bInstalled ?? false; $bDependencyIssue = $oITopExtension?->HasDependencyIssue() ?? false; + file_put_contents('C:/tmp/compute_choice_flags.log', "mandatory for ".$aChoice['extension_code']."=".(int)$bMandatory."\n", FILE_APPEND); $bChecked = $bSelected; $bDisabled = false; @@ -898,6 +900,9 @@ EOF if (isset($aChoice['version']) && isset($aChoice['source_label'])) { $sMetadata = 'v'.$aChoice['version'].''.$aChoice['source_label'].''; } + if ($this->IsIncludedInBasePackage($aChoice)) { + $sMetadata .= 'Included in package'; + } $sChoiceDisabled = $aFlags['disabled'] && !$aFlags['checked'] ? 'choice-disabled' : ''; $oPage->add(' @@ -937,6 +942,71 @@ EOF return $sSourceDir.'/installation.xml'; } + private function GetBasePackageModules(): array + { + if ($this->aBasePackageModules !== null) { + return $this->aBasePackageModules; + } + + $this->aBasePackageModules = []; + $sSourceDir = $this->NormalizePath($this->oWizard->GetParameter('source_dir', '')); + echo "
";
+
+		foreach ($this->aAnalyzeInstallationModules as $sModuleId => $aModuleInfo) {
+			var_dump($sModuleId);
+			if ($sModuleId === ROOT_MODULE) {
+				continue;
+			}
+
+			$sRootDir = $aModuleInfo['root_dir'] ?? '';
+			var_dump($sRootDir);
+			if ($sRootDir === '') {
+				continue;
+			}
+
+			$sModuleRootDir = $this->NormalizePath($sRootDir);
+			if (($sSourceDir !== '') && utils::StartsWith($sModuleRootDir, $sSourceDir)) {
+				$this->aBasePackageModules[$sModuleId] = true;
+			}
+		}
+		echo "
"; + + return $this->aBasePackageModules; + } + + + private function IsIncludedInBasePackage(array $aChoice): bool + { + $sExtensionCode = $aChoice['extension_code'] ?? ''; + if ($sExtensionCode === '') { + return false; + } + + $oExtension = $this->oExtensionsMap->GetFromExtensionCode($sExtensionCode); + if (($oExtension === null) || ($oExtension->sSource === iTopExtension::SOURCE_WIZARD)) { + return false; + } + + $aModules = $aChoice['modules'] ?? []; + if (!is_array($aModules) || empty($aModules)) { + return false; + } + + $aBasePackageModules = $this->GetBasePackageModules(); + foreach ($aModules as $sModuleId) { + if (!array_key_exists($sModuleId, $aBasePackageModules)) { + return false; + } + } + + return true; + } + + private function NormalizePath(string $sPath): string + { + return rtrim(str_replace('\\', '/', $sPath), '/'); + } + public function CanMoveForward() { return true;