From c97627dea31660890d0d140ab3d564c1ac2c64b5 Mon Sep 17 00:00:00 2001 From: Llewellyn van der Merwe Date: Thu, 16 Dec 2021 15:15:47 +0200 Subject: [PATCH] update - v1.0.0 --- componentbuilderpowersautoloadercompiler.xml | 2 +- script.php | 25 +++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/componentbuilderpowersautoloadercompiler.xml b/componentbuilderpowersautoloadercompiler.xml index 94e5520..92ecc52 100644 --- a/componentbuilderpowersautoloadercompiler.xml +++ b/componentbuilderpowersautoloadercompiler.xml @@ -1,7 +1,7 @@ PLG_EXTENSION_COMPONENTBUILDERPOWERSAUTOLOADERCOMPILER - 3rd December, 2021 + 16th December, 2021 Llewellyn van der Merwe joomla@vdm.io https://dev.vdm.io diff --git a/script.php b/script.php index f42a53e..1463017 100644 --- a/script.php +++ b/script.php @@ -43,11 +43,34 @@ class plgExtensionComponentbuilderPowersAutoloaderCompilerInstallerScript if ('install' === $route) { + // check that componentbuilder is installed $pathToCore = JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/componentbuilder.php'; if (!JFile::exists($pathToCore)) { - $app->enqueueMessage('Joomla Component Builder must first be installed from Joomla Component Builder.', 'error'); + $app->enqueueMessage('JCB must first be installed from Joomla Component Builder.', 'error'); + return false; + } + // load the helper class + JLoader::register('ComponentbuilderHelper', JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/componentbuilder.php'); + // block install + $blockInstall = true; + // check the version of JCB + $manifest = ComponentbuilderHelper::manifest(); + if (isset($manifest->version) && strpos($manifest->version, '.') !== false) + { + // get the version + $jcbVersion = explode('.', $manifest->version); + // check that we have JCB 3 or higher installed + if (count($jcbVersion) == 3 && $jcbVersion[0] >= 3) + { + $blockInstall = false; + } + } + // allow install if all conditions are met + if ($blockInstall) + { + $app->enqueueMessage('Please upgrade to JCB-Pro v3.0.0 or higher before installing this plugin.', 'error'); return false; } }