@@ -37,18 +37,32 @@ class modules {
3737 /*
3838 This function is called to load the modules from the mods-enabled or the mods-core folder
3939 */
40- function loadModules ($ type ) {
40+ function loadModules ($ type = ' all ' ) {
4141 global $ app , $ conf ;
4242
4343 $ subPath = 'mods-enabled ' ;
44- if ($ type == 'core ' ) $ subPath = 'mods-core ' ;
44+ if ($ type == 'core ' ) {
45+ $ subPath = 'mods-core ' ;
46+ } elseif ($ type == 'all ' ) {
47+ $ type = '' ;
48+ } elseif (!preg_match ('/^\w+$/ ' , $ type )) {
49+ $ app ->log ('Invalid loadModules type ' . $ type , LOGLEVEL_ERROR );
50+ return false ;
51+ } else {
52+ $ subPath = 'mods-available ' ;
53+ }
4554
55+ $ loaded = false ;
4656 $ modules_dir = $ conf ['rootpath ' ].$ conf ['fs_div ' ].$ subPath .$ conf ['fs_div ' ];
4757 if (is_dir ($ modules_dir )) {
4858 if ($ dh = opendir ($ modules_dir )) {
4959 while (($ file = readdir ($ dh )) !== false ) {
5060 if ($ file != '. ' && $ file != '.. ' && substr ($ file , -8 , 8 ) == '.inc.php ' ) {
5161 $ module_name = substr ($ file , 0 , -8 );
62+ if ($ type && $ type !== 'core ' && $ type != $ module_name ) {
63+ continue ;
64+ }
65+ $ loaded = true ;
5266 include_once $ modules_dir .$ file ;
5367 if ($ this ->debug ) $ app ->log ('Loading Module: ' .$ module_name , LOGLEVEL_DEBUG );
5468 $ app ->loaded_modules [$ module_name ] = new $ module_name ;
@@ -60,6 +74,9 @@ function loadModules($type) {
6074 $ app ->log ('Modules directory missing: ' .$ modules_dir , LOGLEVEL_ERROR );
6175 }
6276
77+ if ($ type && $ type !== 'core ' && $ loaded === false ) {
78+ $ app ->log ('Module ' . $ type . ' not found. ' , LOGLEVEL_ERROR );
79+ }
6380 }
6481
6582 /*
0 commit comments