if (!isset($GLOBALS[__FUNCTION__][$module])) {
// Init variables
$data['title'] = '';
- $result = false;
+ $result = FALSE;
// Is the script installed?
if ((isInstalled()) && ($module != 'error')) {
// Is it 'error'?
if ($module == 'error') {
// Error (real module was not found)
- $data['title'] = '{--MODULE_ERROR_404--}';
+ $data['title'] = '{--MODULE_ERROR_404_TITLE--}';
} else {
// No name found
$data['title'] = '{%message,UNKNOWN_MODULE_DETECTED_TITLE=' . $module . '%}';
// Is the module_status entry there?
if (!isModuleStatusSet($module)) {
// Abort
- reportBug('Module status not set. module=' . $module);
+ reportBug(__FUNCTION__, __LINE__, 'Module status not set. module=' . $module);
} // END - if
// Return it
// Checks whether the given module is registered
function isModuleRegistered ($module) {
// By default nothing is found
- $found = false;
+ $found = FALSE;
// Check if cache is latest version
if (isExtensionInstalledAndNewer('cache', '0.1.2')) {
incrementStatsEntry('cache_hits');
// Is found
- $found = true;
+ $found = TRUE;
} else {
// No, then we have to update it!
setModuleStatus($module, 'cache_miss');
} // END - foreach
// Mark as found
- $found = true;
+ $found = TRUE;
} elseif (isDebugModeEnabled()) {
// Debug message only in debug-mode...
logDebugMessage(__FUNCTION__, __LINE__, 'Module ' . $module . ' not found.');
$found = isModuleRegistered($module_chk);
// Is the module found?
- if ($found === true) {
+ if ($found === TRUE) {
// Check returned values against current access permissions
//
// Admin access ----- Guest access ----- --- Guest or member? ---
} // END - if
// Still no luck or not found?
- if (($found === false) && (!isExtensionActive('cache')) && (getModuleStatus($module_chk) != 'done')) {
+ if (($found === FALSE) && (!isExtensionActive('cache')) && (getModuleStatus($module_chk) != 'done')) {
// ----- Default module ----- ---- Module in base folder ---- --- Module with extension's name ---
if ((isIncludeReadable(sprintf("inc/modules/%s.php", $module))) || (isIncludeReadable(sprintf("%s.php", $module))) || (isIncludeReadable(sprintf("%s/%s.php", $extension, $module)))) {
// Data is missing so we add it
if (isExtensionInstalledAndNewer('sql_patches', '0.3.6')) {
/*
- * Since 0.3.6 we have a has_menu column, this took me a half
+ * Since 0.3.6 there is a has_menu column, this took me a half
* hour to find a loop here... *sigh*
*/
SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_mod_reg`
} elseif ((getModuleStatus($module_chk) == 'cache_miss') && (isHtmlOutputMode())) {
// Rebuild the cache files
rebuildCache('modules', 'modules');
- } elseif ($found === false) {
+ } elseif ($found === FALSE) {
// Problem with module detected
logDebugMessage(__FUNCTION__, __LINE__, sprintf("Problem in module %s detected. getModuleStatus()=%s,locked=%d,hidden=%d,mem=%d,admin=%d,output_mode=%s",
$module_chk,
}
// Checks if the module has a menu
-function ifModuleHasMenu ($module, $forceDb = false) {
+function ifModuleHasMenu ($module, $forceDb = FALSE) {
// All is false by default
- $ret = false;
+ $ret = FALSE;
// Extension installed and newer than or has version 0.1.2?
if (isExtensionInstalledAndNewer('cache', '0.1.2')) {
// Admin/guest/member/sponsor modules have always a menu!
$ret = in_array($module, array('admin', 'index', 'login', 'sponsor'));
}
- } elseif ((isExtensionInstalledAndNewer('sql_patches', '0.3.6')) && ((!isExtensionActive('cache')) || ($forceDb === true))) {
+ } elseif ((isExtensionInstalledAndNewer('sql_patches', '0.3.6')) && ((!isExtensionActive('cache')) || ($forceDb === TRUE))) {
// Check database for entry
$result = SQL_QUERY_ESC("SELECT `has_menu` FROM `{?_MYSQL_PREFIX?}_mod_reg` WHERE `module`='%s' LIMIT 1",
array($module), __FUNCTION__, __LINE__);
// Free memory
SQL_FREERESULT($result);
} elseif (!isExtensionInstalled('sql_patches')) {
- // No sql_patches installed, so maybe in admin/guest/member/sponsor area or no admin registered?
+ // No ext-sql_patches installed, so maybe in admin/guest/member/sponsor area or no admin registered?
$ret = in_array($module, array('admin', 'index', 'login', 'sponsor')); // Then there is a menu!
- } else {
- // Unsupported state!
- logDebugMessage(__FUNCTION__, __LINE__, 'This should never be reached.');
+ } elseif (!isInstallationPhase()) {
+ // Unsupported state, but ignored in installation phase
+ logDebugMessage(__FUNCTION__, __LINE__, 'This should never be reached, module[' . gettype($module) . ']=' . $module . ',forceDb=' . intval($forceDb));
}
// Return status
// Is the module already registered?
if (!isModuleRegistered($module)) {
// Add it
- addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_mod_reg` (`module`, `title`, `locked`, `hidden`, `admin_only`, `mem_only`) VALUES ('" . $module . "','" . $title . "','" . $locked . "','" . $hidden . "','" . $adminOnly . "','" . $memOnly . "')");
+ addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_mod_reg` (`module`, `title`, `locked`, `hidden`, `admin_only`, `mem_only`) VALUES ('" . $module . "', '" . $title . "', '" . $locked . "', '" . $hidden . "', '" . $adminOnly . "', '" . $memOnly . "')");
} else {
// Already registered
logDebugMessage(__FUNCTION__, __LINE__, sprintf("Already registered: module=%s,locked=%s,hidden=%s,admin=%s,mem=%s",
// Load the currently set module
function loadModule () {
// By default all modules are invalid
- $isModuleValid = false;
-
- // Init module state as 'failed' (always failed first)
- $moduleState = 'failed';
+ $isModuleValid = FALSE;
// Construct module name
- $GLOBALS['module_inc'] = sprintf("inc/modules/%s.php", getModule());
+ $GLOBALS['module_inc'] = sprintf("inc/modules/%s.php", getModule());
// Check module permission (again)
$moduleState = checkModulePermissions();
// Does the module exists on local file system?
if ((isIncludeReadable($GLOBALS['module_inc'])) && (!ifFatalErrorsDetected())) {
// Module is valid, active and located on the local disk...
- $isModuleValid = true;
+ $isModuleValid = TRUE;
} elseif (!ifFatalErrorsDetected()) {
// Set HTTP status
setHttpStatus('404');
loadIncludeOnce('inc/header.php');
// Modules are by default not valid!
- $isModuleValid = false;
+ $isModuleValid = FALSE;
// By default NULL is used
$GLOBALS['module_inc'] = NULL;
}
// Is the module valid?
- if (($isModuleValid === true) && (!is_null($GLOBALS['module_inc']))) {
+ if (($isModuleValid === TRUE) && (!is_null($GLOBALS['module_inc']))) {
// Run pre-filter
runFilterChain('pre_module_load');
loadIncludeOnce('inc/footer.php');
}
+// "Getter" for menu mode from given module
+function getMenuModeFromModule () {
+ // Is cache set?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Default is 'noindex' which is invalid for SQL tables but okay for meta data template
+ $GLOBALS[__FUNCTION__] = 'noindex';
+
+ // Determine it hard-coded
+ if (getModule() == 'login') {
+ // Is member area
+ $GLOBALS[__FUNCTION__] = 'member';
+ } elseif (getModule() == 'index') {
+ // Is guest area
+ $GLOBALS[__FUNCTION__] = 'guest';
+ } elseif (getModule() == 'admin') {
+ // Is admin area
+ $GLOBALS[__FUNCTION__] = 'admin';
+ } elseif (isInstallationPhase()) {
+ // Is installation phase
+ $GLOBALS[__FUNCTION__] = 'install';
+ } else {
+ // Get it from filter
+ $GLOBALS[__FUNCTION__] = runFilterChain('determine_menu_mode');
+ }
+ } // END - if
+
+ // Return it
+ return $GLOBALS[__FUNCTION__];
+}
+
// [EOF]
?>