* $Author:: $ *
* -------------------------------------------------------------------- *
* Copyright (c) 2003 - 2009 by Roland Haeder *
- * Copyright (c) 2009 - 2011 by Mailer Developer Team *
+ * Copyright (c) 2009 - 2012 by Mailer Developer Team *
* For more information visit: http://mxchange.org *
* *
* This program is free software; you can redistribute it and/or modify *
// "Getter" for module title
function getModuleTitle ($module) {
- // Init variables
- $data['title'] = '';
- $result = false;
-
- // Is the script installed?
- if ((isInstalled()) && ($module != 'error')) {
- // Check if cache is valid
- if ((isExtensionInstalledAndNewer('cache', '0.1.2')) && (isset($GLOBALS['cache_array']['modules']['module'])) && (in_array($module, $GLOBALS['cache_array']['modules']['module']))) {
- // Load from cache
- $data['title'] = $GLOBALS['cache_array']['modules']['title'][$module];
-
- // Update cache hits
- incrementStatsEntry('cache_hits');
- } elseif (!isExtensionActive('cache')) {
- // Load from database
- $result = SQL_QUERY_ESC("SELECT `title` FROM `{?_MYSQL_PREFIX?}_mod_reg` WHERE `module`='%s' LIMIT 1",
- array($module), __FUNCTION__, __LINE__);
-
- // Is the entry there?
- if (SQL_NUMROWS($result) == 1) {
- // Get the title from database
- $data = SQL_FETCHARRAY($result);
- } // END - if
+ // Do we have cache?
+ if (!isset($GLOBALS[__FUNCTION__][$module])) {
+ // Init variables
+ $data['title'] = '';
+ $result = false;
+
+ // Is the script installed?
+ if ((isInstalled()) && ($module != 'error')) {
+ // Check if cache is valid
+ if ((isExtensionInstalledAndNewer('cache', '0.1.2')) && (isset($GLOBALS['cache_array']['modules']['module'])) && (in_array($module, $GLOBALS['cache_array']['modules']['module']))) {
+ // Load from cache
+ $data['title'] = $GLOBALS['cache_array']['modules']['title'][$module];
+
+ // Update cache hits
+ incrementStatsEntry('cache_hits');
+ } elseif (!isExtensionActive('cache')) {
+ // Load from database
+ $result = SQL_QUERY_ESC("SELECT `title` FROM `{?_MYSQL_PREFIX?}_mod_reg` WHERE `module`='%s' LIMIT 1",
+ array($module), __FUNCTION__, __LINE__);
+
+ // Is the entry there?
+ if (SQL_NUMROWS($result) == 1) {
+ // Get the title from database
+ $data = SQL_FETCHARRAY($result);
+ } // END - if
+
+ // Free the result
+ SQL_FREERESULT($result);
+ }
+ } // END - if
- // Free the result
- SQL_FREERESULT($result);
- }
- } // END - if
+ // Trim name
+ $data['title'] = trim($data['title']);
+
+ // Still no luck or empty title?
+ if (empty($data['title'])) {
+ // Is it 'error'?
+ if ($module == 'error') {
+ // Error (real module was not found)
+ $data['title'] = '{--MODULE_ERROR_404--}';
+ } else {
+ // No name found
+ $data['title'] = '{%message,UNKNOWN_MODULE_DETECTED_TITLE=' . $module . '%}';
+ if ((is_resource($result)) && (SQL_HASZERONUMS($result))) {
+ // Add module to database and ignore return value
+ checkModulePermissions($module);
+ } // END - if
+ }
+ } // END - if
- // Trim name
- $data['title'] = trim($data['title']);
-
- // Still no luck or empty title?
- if (empty($data['title'])) {
- // Is it 'error'?
- if ($module == 'error') {
- // Error (real module was not found)
- $data['title'] = '{--MODULE_ERROR_404--}';
- } else {
- // No name found
- $data['title'] = '{%message,UNKNOWN_MODULE_DETECTED_TITLE=' . $module . '%}';
- if ((is_resource($result)) && (SQL_HASZERONUMS($result))) {
- // Add module to database and ignore return value
- checkModulePermissions($module);
- } // END - if
- }
+ // Store in cache
+ $GLOBALS[__FUNCTION__][$module] = $data['title'];
} // END - if
- // Return name
- return $data['title'];
+ // Return it
+ return $GLOBALS[__FUNCTION__][$module];
}
// Checks if module_status entry is there
// Is the module_status entry there?
if (!isModuleStatusSet($module)) {
// Abort
- debug_report_bug('Module status not set. module=' . $module);
+ reportBug('Module status not set. module=' . $module);
} // END - if
// Return it
return $GLOBALS['module_status'][$module];
}
-// Checks wether the given module is registered
+// Checks whether the given module is registered
function isModuleRegistered ($module) {
// By default nothing is found
$found = false;
$data = SQL_FETCHARRAY($result);
// Set all entries
- foreach ($data as $key=>$value) {
+ foreach ($data as $key => $value) {
$GLOBALS['cache_array']['modules'][$key][$module] = $value;
} // END - foreach
return $found;
}
-// Checks wether the given module is locked by just checking the cache
+// Checks whether the given module is locked by just checking the cache
function isModuleLocked ($module) {
// Determine if there a cache entry and is it set
$return = ((isset($GLOBALS['cache_array']['modules']['locked'][$module])) && ($GLOBALS['cache_array']['modules']['locked'][$module] == 'Y'));
return $return;
}
-// Checks wether the given module is hidden by just checking the cache
+// Checks whether the given module is hidden by just checking the cache
function isModuleHidden ($module) {
// Determine if there a cache entry and is it set
$return = ((isset($GLOBALS['cache_array']['modules']['hidden'][$module])) && ($GLOBALS['cache_array']['modules']['hidden'][$module] == 'Y'));
return $return;
}
-// Checks wether the given module is mem_only by just checking the cache
+// Checks whether the given module is mem_only by just checking the cache
function isModuleMemberOnly ($module) {
// Determine if there a cache entry and is it set
$return = ((isset($GLOBALS['cache_array']['modules']['mem_only'][$module])) && ($GLOBALS['cache_array']['modules']['mem_only'][$module] == 'Y'));
return $return;
}
-// Checks wether the given module is admin_only by just checking the cache
+// Checks whether the given module is admin_only by just checking the cache
function isModuleAdminOnly ($module) {
// Determine if there a cache entry and is it set
$return = ((isset($GLOBALS['cache_array']['modules']['admin_only'][$module])) && ($GLOBALS['cache_array']['modules']['admin_only'][$module] == 'Y'));
}
// Adds a SQL for given module
-function addModuleSql ($module, $locked, $hidden, $adminOnly, $memOnly) {
+function addModuleSql ($module, $title, $locked, $hidden, $adminOnly, $memOnly) {
// Is the module already registered?
if (!isModuleRegistered($module)) {
// Add it
- addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_mod_reg` (`module`,`locked`,`hidden`,`admin_only`,`mem_only`) VALUES ('" . $module . "','" . $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",
case 'locked':
// Set HTTP status
- setHttpStatus('403 FORBIDDEN');
+ setHttpStatus('403 Forbidden');
if (!isIncludeReadable($GLOBALS['module_inc'])) {
// Set HTTP status again
- setHttpStatus('404 NOT FOUND');
+ setHttpStatus('404 Not Found');
// Module does addionally not exists
- addFatalMessage(__FUNCTION__, __LINE__, '{--MODULE_REGISTRY_404--}');
+ addFatalMessage(__FUNCTION__, __LINE__, '{--MODULE_REGISTRY_LOCKED_404--}');
} // END - if
// Add fatal message
addFatalMessage(__FUNCTION__, __LINE__, '{--MYSQL_ERRORS--}');
}
+ // Is the module valid?
if (($isModuleValid === true) && (!is_null($GLOBALS['module_inc']))) {
+ // Run pre-filter
+ runFilterChain('pre_module_load');
+
// Everything is okay so we can load the module
loadIncludeOnce($GLOBALS['module_inc']);
+
+ // Run post-filter
+ runFilterChain('post_module_load');
} // END - if
- // Add the footer (this will call shutdown())
+ // Add the footer (this will call doShutdown())
loadIncludeOnce('inc/footer.php');
}