From 15d03825972c38fbd95abad41f304c7494c5a70e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Mon, 5 Jul 2010 14:48:01 +0000 Subject: [PATCH] More wrapper functions added --- inc/libs/register_functions.php | 6 +++--- inc/libs/task_functions.php | 4 ++-- inc/modules/guest/what-mediadata.php | 6 +++--- inc/mysql-manager.php | 4 +--- inc/wrapper-functions.php | 24 ++++++++++++++++++++++++ 5 files changed, 33 insertions(+), 11 deletions(-) diff --git a/inc/libs/register_functions.php b/inc/libs/register_functions.php index 13be207a73..cfbca85c3f 100644 --- a/inc/libs/register_functions.php +++ b/inc/libs/register_functions.php @@ -266,11 +266,11 @@ function doRegistration () { // Get total ... // ... confirmed, ... - $confirmedUsers = countSumTotalData('CONFIRMED' , 'user_data', 'userid', 'status', true); + $confirmedUsers = getTotalConfirmedUser(); // ... unconfirmed ... - $unconfirmedUsers = countSumTotalData('UNCONFIRMED', 'user_data', 'userid', 'status', true); + $unconfirmedUsers = getTotalUnconfirmedUser(); // ... and locked users! - $lockedUsers = countSumTotalData('LOCKED' , 'user_data', 'userid', 'status', true); + $lockedUsers = getTotalLockedUser(); // Generate hash which will be inserted into confirmation mail $hash = generateHash(sha1( diff --git a/inc/libs/task_functions.php b/inc/libs/task_functions.php index 09c7788bae..1ac3596bd7 100644 --- a/inc/libs/task_functions.php +++ b/inc/libs/task_functions.php @@ -101,7 +101,7 @@ function outputAdvancedOverview (&$result_main) { } // END - if // Unconfirmed accounts - $value = countSumTotalData('UNCONFIRMED', 'user_data', 'userid', 'status', true); + $value = getTotalUnconfirmedUser(); if ($value > 0) { $content['unconfirmed_members'] = '' . $value . ''; @@ -109,7 +109,7 @@ function outputAdvancedOverview (&$result_main) { // And locked accounts - $value = countSumTotalData('LOCKED', 'user_data', 'userid', 'status', true); + $value = getTotalLockedUser(); if ($value > 0) { $content['locked_members'] = '' . $value . ''; } // END - if diff --git a/inc/modules/guest/what-mediadata.php b/inc/modules/guest/what-mediadata.php index 36b4b8a9ad..6fd3e085d1 100644 --- a/inc/modules/guest/what-mediadata.php +++ b/inc/modules/guest/what-mediadata.php @@ -56,9 +56,9 @@ if ((!isExtensionActive('mediadata')) && (!isAdmin())) { } // END - if // Get total confirmed user ids... -$content['user_confirmed'] = round(countSumTotalData('CONFIRMED' , 'user_data', 'userid', 'status', true)); -$content['user_unconfirmed'] = round(countSumTotalData('UNCONFIRMED', 'user_data', 'userid', 'status', true)); -$content['user_locked'] = round(countSumTotalData('LOCKED' , 'user_data', 'userid', 'status', true)); +$content['user_confirmed'] = getTotalConfirmedUser(); +$content['user_unconfirmed'] = getTotalUnconfirmedUser(); +$content['user_locked'] = getTotalLockedUser(); $content['user_count'] = ($content['user_confirmed'] + $content['user_unconfirmed'] + $content['user_locked']); // Start of this exchange diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index 571697aabd..910f6a5513 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -1443,9 +1443,7 @@ function FILTER_ACTIVATE_EXCHANGE () { } // END - if // Check total amount of users - $totalUsers = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', true, ' AND max_mails > 0'); - - if ($totalUsers >= getConfig('activate_xchange')) { + if (getTotalConfirmedUser() >= getConfig('activate_xchange')) { // Activate System setSqlsArray(array( "UPDATE `{?_MYSQL_PREFIX?}_mod_reg` SET `locked`='N', `hidden`='N', `mem_only`='Y' WHERE `module`='order' LIMIT 1", diff --git a/inc/wrapper-functions.php b/inc/wrapper-functions.php index e47587883e..58674e0649 100644 --- a/inc/wrapper-functions.php +++ b/inc/wrapper-functions.php @@ -1010,6 +1010,30 @@ function getTotalConfirmedUser () { return $GLOBALS['total_confirmed_users']; } +// "Getter" for total unconfirmed user accounts +function getTotalUnconfirmedUser () { + // Is it cached? + if (!isset($GLOBALS['total_unconfirmed_users'])) { + // Then do it + $GLOBALS['total_unconfirmed_users'] = countSumTotalData('UNCONFIRMED', 'user_data', 'userid', 'status', true); + } // END - if + + // Return cached value + return $GLOBALS['total_unconfirmed_users']; +} + +// "Getter" for total locked user accounts +function getTotalLockedUser () { + // Is it cached? + if (!isset($GLOBALS['total_locked_users'])) { + // Then do it + $GLOBALS['total_locked_users'] = countSumTotalData('LOCKED', 'user_data', 'userid', 'status', true); + } // END - if + + // Return cached value + return $GLOBALS['total_locked_users']; +} + // Is given userid valid? function isValidUserId ($userid) { // Do we have cache? -- 2.39.5