From: Roland Häder Date: Wed, 29 Jul 2009 16:46:55 +0000 (+0000) Subject: New wrapper functions enableBlockMode() and isBlockModeEnabled() introduced X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=102d8ff4dc03d13ba12cc5181da83f48feb7a4d6;p=mailer.git New wrapper functions enableBlockMode() and isBlockModeEnabled() introduced --- diff --git a/inc/modules/guest/action-admin.php b/inc/modules/guest/action-admin.php index 844be918d2..d0ea45f3d3 100644 --- a/inc/modules/guest/action-admin.php +++ b/inc/modules/guest/action-admin.php @@ -40,7 +40,7 @@ if (!defined('__SECURITY')) { $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php'; require($INC); -} elseif ($GLOBALS['block_mode']) { +} elseif (isBlockModeEnabled()) { // Block mode detected return; } diff --git a/inc/modules/guest/action-main.php b/inc/modules/guest/action-main.php index 2515ae59d8..9b7e984c4a 100644 --- a/inc/modules/guest/action-main.php +++ b/inc/modules/guest/action-main.php @@ -40,7 +40,7 @@ if (!defined('__SECURITY')) { $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php'; require($INC); -} elseif ($GLOBALS['block_mode']) { +} elseif (isBlockModeEnabled()) { // Block mode detected return; } diff --git a/inc/modules/guest/action-members.php b/inc/modules/guest/action-members.php index c98d8569e5..df2c434248 100644 --- a/inc/modules/guest/action-members.php +++ b/inc/modules/guest/action-members.php @@ -40,7 +40,7 @@ if (!defined('__SECURITY')) { $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php'; require($INC); -} elseif ($GLOBALS['block_mode']) { +} elseif (isBlockModeEnabled()) { // Block mode detected return; } diff --git a/inc/modules/guest/action-sponsor.php b/inc/modules/guest/action-sponsor.php index 948fbf7cdf..08efab2a61 100644 --- a/inc/modules/guest/action-sponsor.php +++ b/inc/modules/guest/action-sponsor.php @@ -42,7 +42,7 @@ if (!defined('__SECURITY')) { } elseif ((!EXT_IS_ACTIVE('sponsor')) && (!IS_ADMIN())) { addFatalMessage(__FILE__, __LINE__, generateExtensionInactiveNotInstalledMessage('sponsor')); return; -} elseif ($GLOBALS['block_mode']) { +} elseif (isBlockModeEnabled()) { // Block mode detected return; } diff --git a/inc/modules/index.php b/inc/modules/index.php index 10525b30e9..7c13b54fa4 100644 --- a/inc/modules/index.php +++ b/inc/modules/index.php @@ -76,7 +76,7 @@ if ((getConfig('guest_menu') == 'Y') || (!EXT_IS_ACTIVE('sql_patches', true))) { LOAD_TEMPLATE('guest_menu_content'); // Disable block-mode by default -$GLOBALS['block_mode'] = false; +enableBlockMode(false); // Construct FQFN $INC = sprintf("inc/modules/guest/action-%s.php", getAction()); diff --git a/inc/modules/login.php b/inc/modules/login.php index 67b049ad2e..3ce8c164ac 100644 --- a/inc/modules/login.php +++ b/inc/modules/login.php @@ -58,7 +58,7 @@ if ($GLOBALS['status'] != 'CONFIRMED') { define('__MEMBER_ADVERT', LOAD_TEMPLATE('member_banner', true)); // Disable block mode by default -$GLOBALS['block_mode'] = false; +enableBlockMode(false); // Generate a tableset for the menu title and content LOAD_TEMPLATE('member_header'); diff --git a/inc/modules/member/action-account.php b/inc/modules/member/action-account.php index 2fb0d256ca..d044aa5db5 100644 --- a/inc/modules/member/action-account.php +++ b/inc/modules/member/action-account.php @@ -42,7 +42,7 @@ if (!defined('__SECURITY')) { require($INC); } elseif (!IS_MEMBER()) { redirectToUrl('modules.php?module=index'); -} elseif ($GLOBALS['block_mode']) { +} elseif (isBlockModeEnabled()) { // Block mode detected return; } diff --git a/inc/modules/member/action-bank.php b/inc/modules/member/action-bank.php index 6fb577f5fd..5d89820fc1 100644 --- a/inc/modules/member/action-bank.php +++ b/inc/modules/member/action-bank.php @@ -45,7 +45,7 @@ if (!defined('__SECURITY')) { } elseif ((!EXT_IS_ACTIVE('bank')) && (!IS_ADMIN())) { addFatalMessage(__FILE__, __LINE__, generateExtensionInactiveNotInstalledMessage('bank')); return; -} elseif ($GLOBALS['block_mode']) { +} elseif (isBlockModeEnabled()) { // Block mode detected return; } diff --git a/inc/modules/member/action-extras.php b/inc/modules/member/action-extras.php index 80760aee9b..fa0601962e 100644 --- a/inc/modules/member/action-extras.php +++ b/inc/modules/member/action-extras.php @@ -42,7 +42,7 @@ if (!defined('__SECURITY')) { require($INC); } elseif (!IS_MEMBER()) { redirectToUrl('modules.php?module=index'); -} elseif ($GLOBALS['block_mode']) { +} elseif (isBlockModeEnabled()) { // Block mode detected return; } diff --git a/inc/modules/member/action-logout.php b/inc/modules/member/action-logout.php index 4c3ee15933..85a5775f14 100644 --- a/inc/modules/member/action-logout.php +++ b/inc/modules/member/action-logout.php @@ -42,7 +42,7 @@ if (!defined('__SECURITY')) { require($INC); } elseif (!IS_MEMBER()) { redirectToUrl('modules.php?module=index'); -} elseif ($GLOBALS['block_mode']) { +} elseif (isBlockModeEnabled()) { // Block mode detected return; } diff --git a/inc/modules/member/action-main.php b/inc/modules/member/action-main.php index ad1179d414..8f5950640f 100644 --- a/inc/modules/member/action-main.php +++ b/inc/modules/member/action-main.php @@ -42,7 +42,7 @@ if (!defined('__SECURITY')) { require($INC); } elseif (!IS_MEMBER()) { redirectToUrl('modules.php?module=index'); -} elseif ($GLOBALS['block_mode']) { +} elseif (isBlockModeEnabled()) { // Block mode detected return; } diff --git a/inc/modules/member/action-order.php b/inc/modules/member/action-order.php index 71fb41b0b8..37d2377e9e 100644 --- a/inc/modules/member/action-order.php +++ b/inc/modules/member/action-order.php @@ -45,7 +45,7 @@ if (!defined('__SECURITY')) { } elseif ((!EXT_IS_ACTIVE('order')) && (!IS_ADMIN())) { addFatalMessage(__FILE__, __LINE__, generateExtensionInactiveNotInstalledMessage('order')); return; -} elseif ($GLOBALS['block_mode']) { +} elseif (isBlockModeEnabled()) { // Block mode detected return; } diff --git a/inc/modules/member/action-rals.php b/inc/modules/member/action-rals.php index 3a3c1681ec..779013e7c9 100644 --- a/inc/modules/member/action-rals.php +++ b/inc/modules/member/action-rals.php @@ -42,7 +42,7 @@ if (!defined('__SECURITY')) { require($INC); } elseif (!IS_MEMBER()) { redirectToUrl('modules.php?module=index'); -} elseif ($GLOBALS['block_mode']) { +} elseif (isBlockModeEnabled()) { // Block mode detected return; } diff --git a/inc/modules/member/action-stats.php b/inc/modules/member/action-stats.php index 3e47e7fe83..edc8248f8c 100644 --- a/inc/modules/member/action-stats.php +++ b/inc/modules/member/action-stats.php @@ -42,7 +42,7 @@ if (!defined('__SECURITY')) { require($INC); } elseif (!IS_MEMBER()) { redirectToUrl('modules.php?module=index'); -} elseif ($GLOBALS['block_mode']) { +} elseif (isBlockModeEnabled()) { // Block mode detected return; } diff --git a/inc/modules/member/action-surfbar.php b/inc/modules/member/action-surfbar.php index a1e5c7719b..4470b082fc 100644 --- a/inc/modules/member/action-surfbar.php +++ b/inc/modules/member/action-surfbar.php @@ -45,7 +45,7 @@ if (!defined('__SECURITY')) { } elseif ((!EXT_IS_ACTIVE('surfbar')) && (!IS_ADMIN())) { addFatalMessage(__FILE__, __LINE__, generateExtensionInactiveNotInstalledMessage('surfbar')); return; -} elseif ($GLOBALS['block_mode']) { +} elseif (isBlockModeEnabled()) { // Block mode detected return; } diff --git a/inc/mysql-connect.php b/inc/mysql-connect.php index 91dc03e9e2..57ee9fc67c 100644 --- a/inc/mysql-connect.php +++ b/inc/mysql-connect.php @@ -57,6 +57,9 @@ foreach (array('request-functions', 'session-functions', 'config-functions', 'co // Set error handler set_error_handler('__errorHandler'); +// Disable block-mode by default +enableBlockMode(false); + // Init error handler initErrorHandler(); diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index d0edc7d94f..726ddbd205 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -410,8 +410,8 @@ function ADD_MENU ($mode, $act, $wht) { } // END - if // Load SQL data and add the menu to the output stream... - $result_main = SQL_QUERY_ESC("SELECT title, action FROM `{!_MYSQL_PREFIX!}_%s_menu` WHERE (`what`='' OR `what` IS NULL)".$AND." ORDER BY `sort`", - array($mode), __FUNCTION__, __LINE__); + $result_main = SQL_QUERY_ESC("SELECT `title`, `action` FROM `{!_MYSQL_PREFIX!}_%s_menu` WHERE (`what`='' OR `what` IS NULL)".$AND." ORDER BY `sort`", + array($mode), __FUNCTION__, __LINE__); //* DEBUG: */ echo __LINE__.'/'.$main_cnt.'/'.$main_action.'/'.$sub_what.':'.getWhat()."*
\n"; if (SQL_NUMROWS($result_main) > 0) { OUTPUT_HTML(""); @@ -419,11 +419,11 @@ function ADD_MENU ($mode, $act, $wht) { while ($content = SQL_FETCHARRAY($result_main)) { //* DEBUG: */ echo __LINE__.'/'.$main_cnt.'/'.$content['action'].'/'.$sub_what.':'.getWhat()."*
\n"; // Init variables - $GLOBALS['block_mode'] = false; + enableBlockMode(false); $act = $content['action']; // Load menu header template - LOAD_TEMPLATE($mode."_menu_title", false, $content); + LOAD_TEMPLATE($mode . '_menu_title', false, $content); // Sub menu $result_sub = SQL_QUERY_ESC("SELECT title AS sub_title, what AS sub_what FROM `{!_MYSQL_PREFIX!}_%s_menu` WHERE `action`='%s' AND `what` != '' AND `what` IS NOT NULL ".$AND." ORDER BY `sort`", @@ -490,7 +490,7 @@ function ADD_MENU ($mode, $act, $wht) { } } else { // This is a menu block... ;-) - $GLOBALS['block_mode'] = true; + enableBlockMode(); $INC_BLOCK = sprintf("inc/modules/%s/action-%s.php", $mode, $content['action']); if (isFileReadable($INC_BLOCK)) { // Load include file diff --git a/inc/wrapper-functions.php b/inc/wrapper-functions.php index 1df653fb9b..7c721976e4 100644 --- a/inc/wrapper-functions.php +++ b/inc/wrapper-functions.php @@ -593,5 +593,22 @@ function isOutputModeSet ($abortOnMiss = false) { return $isset; } +// Enables block-mode +function enableBlockMode ($enabled = true) { + $GLOBALS['block_mode'] = $enabled; +} + +// Checks wether block-mode is enabled +function isBlockModeEnabled () { + // Abort if not set + if (!isset($GLOBALS['block_mode'])) { + // Needs to be fixed + debug_report_bug(__FUNCTION__ . ': block_mode is not set.'); + } // END - if + + // Return it + return $GLOBALS['block_mode']; +} + // [EOF] ?>