diff --git a/interface/modules/zend_modules/module/Installer/src/Installer/Controller/InstallerController.php b/interface/modules/zend_modules/module/Installer/src/Installer/Controller/InstallerController.php index 88b94900be5..4b5dccd19ae 100644 --- a/interface/modules/zend_modules/module/Installer/src/Installer/Controller/InstallerController.php +++ b/interface/modules/zend_modules/module/Installer/src/Installer/Controller/InstallerController.php @@ -96,9 +96,10 @@ private function scanAndRegisterCustomModules(): void $baseModuleDir = $GLOBALS['baseModDir']; $customDir = $GLOBALS['customModDir']; $zendModDir = $GLOBALS['zendModDir']; + $coreModules = ['Application', 'Acl', 'Installer', 'FHIR', 'PatientFlowBoard']; + $allModules = array(); $result = $this->getInstallerTable()->allModules(); - $allModules = array(); foreach ($result as $dataArray) { $mod = new InstModule(); $mod->exchangeArray($dataArray); @@ -107,34 +108,44 @@ private function scanAndRegisterCustomModules(): void $allModules[] = $mod; } - $dpath = $GLOBALS['srcdir'] . "/../$baseModuleDir$customDir/"; - $dp = opendir($dpath); - $inDir = array(); - for ($i = 0; false != ($fname = readdir($dp)); $i++) { - if ($fname != "." && $fname != ".." && $fname != "Application" && is_dir($dpath . $fname)) { - $inDir[$i] = $fname; + $dir_path = $GLOBALS['srcdir'] . "/../$baseModuleDir$customDir/"; + $dp = opendir($dir_path); + $inDirCustom = array(); + for ($i = 0; false != ($file_name = readdir($dp)); $i++) { + if ($file_name != "." && $file_name != ".." && $file_name != "Application" && is_dir($dir_path . $file_name)) { + $inDirCustom[$i] = $file_name; + } + } + /* Laminas directory Unregistered scan */ + $dir_path = $GLOBALS['srcdir'] . "/../$baseModuleDir$zendModDir/module"; + $dp = opendir($dir_path); + $inDirLaminas = array(); + for ($i = 0; false != ($file_name = readdir($dp)); $i++) { + if ($file_name != "." && $file_name != ".." && (!in_array($file_name, $coreModules)) && is_dir($dir_path . "/" . $file_name)) { + $inDirLaminas[$i] = $file_name; } } // do not show registered modules in the unregistered list if (sizeof($allModules) > 0) { foreach ($allModules as $modules) { - $key = array_search($modules->modDirectory, $inDir); + $key = array_search($modules->modDirectory, $inDirLaminas); if ($key !== false) { - unset($inDir[$key]); + unset($inDirLaminas[$key]); + continue; + } + $key = array_search($modules->modDirectory, $inDirCustom); + if ($key !== false) { + unset($inDirCustom[$key]); } } } - foreach ($inDir as $fname) { - $form_title_file = @file($GLOBALS['srcdir'] . "/../$baseModuleDir$customDir/$fname/info.txt"); - if ($form_title_file) { - $form_title = trim($form_title_file[0]); - } else { - $form_title = $fname; - } - $rel_path = $fname . "/index.php"; - if ($this->getInstallerTable()->register($fname, $rel_path)) { - $status = true; - } + foreach ($inDirLaminas as $file_name) { + $rel_path = $file_name . "/index.php"; + $status = $this->getInstallerTable()->register($file_name, $rel_path, 0, $zendModDir); + } + foreach ($inDirCustom as $file_name) { + $rel_path = $file_name . "/index.php"; + $status = $this->getInstallerTable()->register($file_name, $rel_path); } } diff --git a/interface/modules/zend_modules/module/Installer/view/installer/installer/configure.phtml b/interface/modules/zend_modules/module/Installer/view/installer/installer/configure.phtml index 2038d2a9505..4b0d390da2d 100644 --- a/interface/modules/zend_modules/module/Installer/view/installer/installer/configure.phtml +++ b/interface/modules/zend_modules/module/Installer/view/installer/installer/configure.phtml @@ -15,7 +15,7 @@ // Warning : PoC code // TBD - Must handle modules in external namespaces -Use OpenEMR\Modules; +use OpenEMR\Modules; $listener = $this->listenerObject; $hangers = $this->hangers; @@ -199,11 +199,9 @@ if (count($TabSettings ?? []) > 0) { ?> // TBD : clsOeModule $rs_mod = sqlQuery('select * from modules where `mod_id` = ?', [$mod_id]); $fConfig = dirname(realpath('.')) . '/custom_modules/' . $rs_mod['mod_directory'] . '/moduleConfig.php'; - if (($rs_mod['type'] == 0) && file_exists($fConfig)) { - ?> + if (($rs_mod['type'] == 0) && file_exists($fConfig)) { ?>