Index: branches/RC/core/units/general/helpers/modules.php =================================================================== diff -u -N -r11623 -r11702 --- branches/RC/core/units/general/helpers/modules.php (.../modules.php) (revision 11623) +++ branches/RC/core/units/general/helpers/modules.php (.../modules.php) (revision 11702) @@ -2,11 +2,6 @@ class kModulesHelper extends kHelper { - function checkLogin() - { - return $this->_GetModules(); - } - function getWhereClause() { $where_clause = Array('Loaded = 1'); @@ -172,12 +167,40 @@ } } - // TODO: find a ways to make all modules auto-licensed except in-commerce & in-auction without scanning directory structure - array_push($modules, 'Core', 'In-Portal', 'In-Link', 'In-News', 'In-Bulletin', 'Custom'); + // all modules starting from "in-" doesn't require license + $base_modules = Array ('Core', 'In-Portal', 'Custom'); + $modules = array_merge($modules, $base_modules, $this->_getFreeModules()); + $modules = array_unique( array_map('strtolower', $modules) ); + return $modules; } /** + * Get all modules, that don't require licensing + * + * @return Array + */ + function _getFreeModules() + { + $skip_modules = Array ('.', '..', 'in-commerce', 'in-auction'); + $folder = dir(MODULES_PATH); + + $ret = Array (); + while (($entry = $folder->read()) !== false) { + $entry_lowercased = strtolower($entry); + if (!is_dir($folder->path . '/' . $entry) || in_array($entry_lowercased, $skip_modules) || (substr($entry_lowercased, 0, 3) != 'in-')) { + continue; + } + + $ret[] = $entry_lowercased; + } + + $folder->close(); + + return $ret; + } + + /** * Allows to determine if module is licensed * * @param string $name Index: branches/RC/core/units/users/users_event_handler.php =================================================================== diff -u -N -r11676 -r11702 --- branches/RC/core/units/users/users_event_handler.php (.../users_event_handler.php) (revision 11676) +++ branches/RC/core/units/users/users_event_handler.php (.../users_event_handler.php) (revision 11702) @@ -352,7 +352,6 @@ // root is virtual user, so allow him to login to admin in any case $ret = $this->Application->CheckPermission('ADMIN', 1); } - $ret = $ret && $modules_helper->checkLogin(); } else { $ret = $this->Application->CheckPermission('LOGIN', 1); Index: branches/RC/core/kernel/application.php =================================================================== diff -u -N -r11685 -r11702 --- branches/RC/core/kernel/application.php (.../application.php) (revision 11685) +++ branches/RC/core/kernel/application.php (.../application.php) (revision 11702) @@ -425,14 +425,22 @@ $this->registerModuleConstants(); return false; } + $modules_helper =& $this->recallObject('ModulesHelper'); - $this->ModuleInfo = $this->Conn->Query('SELECT * FROM '.TABLE_PREFIX.'Modules WHERE Loaded = 1 ORDER BY LoadOrder', 'Name'); + /* @var $modules_helper kModulesHelper */ + $sql = 'SELECT * + FROM ' . TABLE_PREFIX . 'Modules + WHERE Loaded = 1 + ORDER BY LoadOrder'; + $this->ModuleInfo = $this->Conn->Query($sql, 'Name'); + + $sql = 'SELECT * FROM '.TABLE_PREFIX.'Modules WHERE '.$modules_helper->getWhereClause().' ORDER BY LoadOrder'; - $this->ModuleInfo = $this->Conn->Query($sql, 'Name'); + $this->registerModuleConstants(); }