Endless redirect fixed and needless action/what sets removed
authorRoland Häder <roland@mxchange.org>
Thu, 3 Dec 2009 22:36:06 +0000 (22:36 +0000)
committerRoland Häder <roland@mxchange.org>
Thu, 3 Dec 2009 22:36:06 +0000 (22:36 +0000)
inc/extensions-functions.php
inc/filters.php
inc/functions.php
inc/libs/admins_functions.php
inc/modules/admin.php
inc/modules/admin/admin-inc.php
inc/modules/admin/what-config_admins.php
inc/modules/index.php
inc/modules/login.php
inc/mysql-manager.php
inc/wrapper-functions.php

index 001aee7e1dc14b8fc9cbb7c2ba23d99f7938679a..a9c6fd92391bdc6227654e03015edf95292af0a8 100644 (file)
@@ -960,9 +960,9 @@ function ifModuleHasMenu ($mod, $forceDb = false) {
                        // 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
@@ -984,8 +984,11 @@ function ifModuleHasMenu ($mod, $forceDb = false) {
                // 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
index b4970d71b897934a902db27fb937bc76b260219e..35ff120eb7067af5178da838051dafbb9822e897 100644 (file)
@@ -705,7 +705,7 @@ function FILTER_DETERMINE_WHAT_ACTION () {
                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('');
@@ -717,7 +717,7 @@ function FILTER_DETERMINE_WHAT_ACTION () {
        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');
@@ -803,7 +803,7 @@ function FILTER_CHECK_ADMIN_ACL () {
                $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
index f9bdf90e029da5655300645f60fee2986f20b986..a8870527a70758d83d4acfe1b65fe3fc94581359 100644 (file)
@@ -936,7 +936,7 @@ function redirectToUrl ($URL) {
        } // 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);
 
index 4b3aa1bedfdd41bb87a2f8c4ffe84311d360758d..b3336935e27449487b33c5bb36461f32893aa28c 100644 (file)
@@ -59,7 +59,7 @@ function adminsCheckAdminAcl ($action, $what) {
        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, '');
index 3455022bc731152e5df9c077c623e9e1a8008a8b..51fa7f9e1e90bc1c13b5d16889fe0905794d11af 100644 (file)
@@ -215,7 +215,7 @@ if (!isAdminRegistered()) {
 
                                // Rewrite overview module
                                if (getWhat() == 'overview') {
-                                       setAction(getModeAction(getModule(), getWhat()));
+                                       setAction(getActionFromModuleWhat(getModule(), getWhat()));
                                } // END - if
 
                                // Add data to URL
index 28dc8a33f192bbf8fcb2f2eb511ad111df8600e3..cd753943fbede721c8c014dd8d3fd72b2364ae01 100644 (file)
@@ -255,7 +255,7 @@ function doAdminAction () {
        }
 
        // Get action value
-       $action = getModeAction(getModule(), $what);
+       $action = getActionFromModuleWhat(getModule(), $what);
 
        // Define admin login name and id number
        $content['login'] = getSession('admin_login');
index 0391c25e6a24bac4bcc11923a3ae187e1a29e0b0..6040a1f3addf9ae893b2ee5b8a27db7933bd82ff 100644 (file)
@@ -163,7 +163,7 @@ if ((isPostRequestParameterSet('edit')) && (countPostSelection() > 0)) {
        $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)) {
index 79141ef94459d156bf7a9cbc0b3ed803595a05aa..3f4fb3da07950f484de682b15187de9ce6716e34 100644 (file)
@@ -50,15 +50,6 @@ handleCodeMessage();
 // 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
index 0e04a299d8ee2e96ecc602892a778ee505204045..f06beeb852a5b6d76ce1b8c40c312ecbbe752ec7 100644 (file)
@@ -66,7 +66,7 @@ if (!isActionSet()) {
 
 // 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
index 95fc006a8423946b4e46c308a29315570220126a..bd453fac30a4aa7c3b1f44fd84a53c971608df86 100644 (file)
@@ -326,7 +326,7 @@ function addMenuDescription ($accessLevel, $FQFN, $return = false) {
                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';
@@ -870,29 +870,29 @@ function isMenuActionValid ($mode, $action, $what, $updateEntry=false) {
 }
 
 // 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!
@@ -908,19 +908,19 @@ function getModeAction ($mode, $what) {
                // 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);
@@ -928,7 +928,7 @@ function getModeAction ($mode, $what) {
 
                // 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
index ca8ef7430bea5c8278e7db68de63e6ad31a72ff2..cd0b929be717077e111e5233e8f3448cf5c80761 100644 (file)
@@ -504,7 +504,7 @@ function setWhatFromConfig ($configEntry) {
 // 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)) {
@@ -539,7 +539,7 @@ function setAction ($newAction) {
 // 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)) {