// Check cache and count hit
$ret = ($GLOBALS['cache_array']['extension']['ext_menu'][$mod] == 'Y');
incrementStatsEntry('cache_hits');
- } elseif ($mod == 'admin') {
- // Admin module has always a menu!
- $ret = true;
+ } else {
+ // Admin/guest/member/sponsor modules have always a menu!
+ $ret = in_array($mod, array('admin', 'index', 'login', 'sponsor'));
}
} elseif ((isExtensionInstalled('sql_patches')) && (getExtensionVersion('sql_patches') >= '0.3.6') && ((!isExtensionActive('cache')) || ($forceDb === true))) {
// Check database for entry
// Free memory
SQL_FREERESULT($result);
} elseif (!isExtensionInstalled('sql_patches')) {
- // No sql_patches installed, so maybe in admin area or no admin registered?
- $ret = (((isAdmin()) || (!isAdminRegistered())) && ($mod == 'admin')); // Then there is a menu!
+ // No sql_patches installed, so maybe in admin/guest/member/sponsor area or no admin registered?
+ $ret = in_array($mod, array('admin', 'index', 'login', 'sponsor')); // Then there is a menu!
+ } else {
+ // Unsupported state!
+ debug_report_bug('This should never be reached.');
}
// Return status
if (!isWhatSet()) setWhat(getWhatFromModule(getModule()));
// Fix 'action' if not yet set
- if (!isActionSet()) setAction(getModeAction(getModule(), getWhat()));
+ if (!isActionSet()) setAction(getActionFromModuleWhat(getModule(), getWhat()));
} else {
// Set action/what to empty
setAction('');
if ((!isWhatSet()) && (!isActionSet()) && (getOutputMode() != 1) && (getOutputMode() != -1)) {
if (getModule() == 'admin') {
// Set 'action' value to 'login' in admin menu
- setAction(getModeAction(getModule(), getWhat()));
+ setAction(getActionFromModuleWhat(getModule(), getWhat()));
} elseif ((getModule() == 'index') || (getModule() == 'login')) {
// Set 'what' value to 'welcome' in guest and member menu
setWhatFromConfig('index_home');
$action = getAction();
if (isWhatSet()) {
// Get action value by what-value
- $action = getModeAction('admin', getWhat());
+ $action = getActionFromModuleWhat('admin', getWhat());
} // END - if
// Check for access control line of current menu entry
} // END - if
// Three different ways to debug...
- //* DEBUG: */ debug_report_bug(sprintf("%s[%s:] URL=%s", __FUNCTION__, __LINE__, $URL));
+ /* DEBUG: */ debug_report_bug(sprintf("%s[%s:] URL=%s", __FUNCTION__, __LINE__, $URL));
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'URL=' . $URL);
//* DEBUG: */ die($URL);
if (!empty($what)) {
// Check for parent menu:
// First get it's action value
- $parent_action = getModeAction('admin', $what);
+ $parent_action = getActionFromModuleWhat('admin', $what);
// Check with this function...
$parent = adminsCheckAdminAcl($parent_action, '');
// Rewrite overview module
if (getWhat() == 'overview') {
- setAction(getModeAction(getModule(), getWhat()));
+ setAction(getActionFromModuleWhat(getModule(), getWhat()));
} // END - if
// Add data to URL
}
// Get action value
- $action = getModeAction(getModule(), $what);
+ $action = getActionFromModuleWhat(getModule(), $what);
// Define admin login name and id number
$content['login'] = getSession('admin_login');
$ACL = false;
if (isPostRequestParameterSet('what_menu')) {
// Check parent ACL
- $ACL = adminsCheckAdminAcl(getModeAction('admin', postRequestParameter('what_menu')), '');
+ $ACL = adminsCheckAdminAcl(getActionFromModuleWhat('admin', postRequestParameter('what_menu')), '');
} // END - if
if (($mode != postRequestParameter('mode')) || ($ACL)) {
// Some of you needs this to be extracted into a template... ???
loadTemplate('guest_menu_td');
-// When no what value is provided take the "home" value
-if (!isWhatSet()) setWhatFromConfig('index_home');
-
-// Adding the main content module here
-if (!isActionSet()) {
- // Get action value from what value
- setAction(getModeAction('guest', getWhat()));
-} // END - if
-
// Add the guest's menu here...
if ((getConfig('guest_menu') == 'Y') || (!isExtensionActive('sql_patches', true))) {
// Show only when guest menu is active
// Add the member's menu here...
if ((getConfig('member_menu') == 'Y') || (!isExtensionActive('sql_patches', true))) {
- addMenu('member', getModeAction('member', getWhat()), getWhat());
+ addMenu('member', getActionFromModuleWhat('member', getWhat()), getWhat());
} // END - if
// Disable block-mode again
if (isAdmin()) $ADD = '';
$dummy = substr($search, 0, -4);
- $ADD .= " AND `action`='".getModeAction($accessLevel, $dummy)."'";
+ $ADD .= " AND `action`='".getActionFromModuleWhat($accessLevel, $dummy)."'";
} elseif (($accessLevel == 'sponsor') || ($accessLevel == 'engine')) {
// Sponsor / engine menu
$type = 'what';
}
// Get action value from mode (admin/guest/member) and what-value
-function getModeAction ($mode, $what) {
+function getActionFromModuleWhat ($module, $what) {
// Init status
$data['action'] = '';
- //* DEBUG: */ print(__LINE__.'='.$mode.'/'.$what.'/'.getAction()."=<br />");
+ //* DEBUG: */ print(__LINE__.'='.$module.'/'.$what.'/'.getAction()."=<br />");
if (!isExtensionInstalledAndNewer('sql_patches', '0.0.5')) {
// sql_patches is missing so choose depending on mode
if (isWhatSet()) {
// Use setted what
$what = getWhat();
- } elseif ($mode == 'admin') {
+ } elseif ($module == 'admin') {
// Admin area
$what = 'overview';
} else {
// Everywhere else
$what = 'welcome';
}
- } elseif ((empty($what)) && ($mode != 'admin')) {
+ } elseif ((empty($what)) && ($module != 'admin')) {
// Use configured 'home'
$what = getConfig('index_home');
} // END - if
- if ($mode == 'admin') {
+ if ($module == 'admin') {
// Action value for admin area
if (isGetRequestParameterSet('action')) {
// Use from request!
// Get it directly from URL
return getAction();
}
- //* DEBUG: */ print(__FUNCTION__ . '(<font color="#0000aa">' . __LINE__."</font>): ret=".$data['action'].'<br />');
+ //* DEBUG: */ print(__FUNCTION__ . '(<font color="#0000aa">' . __LINE__ . '</font>): ret=' . $data['action'] . '<br />');
// Does the module have a menu?
- if (ifModuleHasMenu($mode)) {
+ if (ifModuleHasMenu($module)) {
// Rewriting modules to menu
- $mode = mapModuleToTable($mode);
+ $module = mapModuleToTable($module);
// Guest and member menu is 'main' as the default
if (empty($data['action'])) $data['action'] = 'main';
// Load from database
$result = SQL_QUERY_ESC("SELECT `action` FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE `what`='%s' LIMIT 1",
- array($mode, $what), __FUNCTION__, __LINE__);
+ array($module, $what), __FUNCTION__, __LINE__);
if (SQL_NUMROWS($result) == 1) {
// Load action value and pray that this one is the right you want... ;-)
$data = SQL_FETCHARRAY($result);
// Free memory
SQL_FREERESULT($result);
- } elseif ((!isExtensionInstalled('sql_patches')) && (($mode != 'admin') && ($mode != 'unknown'))) {
+ } elseif ((!isExtensionInstalled('sql_patches')) && ($module != 'admin') && ($module != 'unknown')) {
// No sql_patches installed, but maybe we need to register an admin?
if (isAdminRegistered()) {
// Redirect to admin area
// Checks wether what is set and optionally aborts on miss
function isWhatSet ($strict = false) {
// Check for it
- $isset = (isset($GLOBALS['what']));
+ $isset = ((isset($GLOBALS['what'])) && (!empty($GLOBALS['what'])));
// Should we abort here?
if (($strict === true) && ($isset === false)) {
// Checks wether action is set and optionally aborts on miss
function isActionSet ($strict = false) {
// Check for it
- $isset = (isset($GLOBALS['action']));
+ $isset = ((isset($GLOBALS['action'])) && (!empty($GLOBALS['action'])));
// Should we abort here?
if (($strict === true) && ($isset === false)) {