X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fwrapper-functions.php;h=a89c49a676972c42d106c7e4548a8e29a71e84f3;hb=387a99be2a05128c307013cb7ed27628a46c27f4;hp=eb9419c94e5f07279ce1377e9ab169636f293b3f;hpb=adb05fb6876bdca84e73f4ea04998c1400e2cfb7;p=mailer.git diff --git a/inc/wrapper-functions.php b/inc/wrapper-functions.php index eb9419c94e..a89c49a676 100644 --- a/inc/wrapper-functions.php +++ b/inc/wrapper-functions.php @@ -432,7 +432,14 @@ function isDebugRegularExpressionEnabled () { // Checks wether the cache instance is valid function isCacheInstanceValid () { - return ((isset($GLOBALS['cache_instance'])) && (is_object($GLOBALS['cache_instance']))); + // Do we have cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = ((isset($GLOBALS['cache_instance'])) && (is_object($GLOBALS['cache_instance']))); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; } // Copies a file from source to destination and verifies if that goes fine. @@ -554,7 +561,7 @@ function isNicknameUsed ($userid) { // Is the cache there if (!isset($GLOBALS[__FUNCTION__][$userid])) { // Determine it - $GLOBALS[__FUNCTION__][$userid] = (('' . round($userid) . '') != $userid); + $GLOBALS[__FUNCTION__][$userid] = ((!empty($userid)) && (('' . round($userid) . '') != $userid)); } // END - if // Return the result @@ -944,8 +951,28 @@ function getUserData ($column) { debug_report_bug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . getCurrentUserId()); } // END - if - // Return the value - return $GLOBALS['user_data'][getCurrentUserId()][$column]; + // Default is empty + $data = null; + + if (isset($GLOBALS['user_data'][getCurrentUserId()][$column])) { + // Return the value + $data = $GLOBALS['user_data'][getCurrentUserId()][$column]; + } // END - if + + // Return it + return $data; +} + +// Checks wether given user data is set to 'Y' +function isUserDataEnabled ($column) { + // Do we have cache? + if (!isset($GLOBALS[__FUNCTION__][getCurrentUserId()][$column])) { + // Determine it + $GLOBALS[__FUNCTION__][getCurrentUserId()][$column] = (getUserData($column) == 'Y'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__][getCurrentUserId()][$column]; } // Geter for whole user data array @@ -1191,6 +1218,22 @@ function getTotalLockedUser () { return $GLOBALS[__FUNCTION__]; } +// "Getter" for total locked user accounts +function getTotalRandomRefidUser () { + // Is it cached? + if (!isset($GLOBALS[__FUNCTION__])) { + // Then do it + if (isExtensionInstalledAndNewer('user', '0.3.4')) { + $GLOBALS[__FUNCTION__] = countSumTotalData('{?user_min_confirmed?}', 'user_data', 'userid', 'rand_confirmed', true, '', '>='); + } else { + $GLOBALS[__FUNCTION__] = 0; + } + } // END - if + + // Return cached value + return $GLOBALS[__FUNCTION__]; +} + // Is given userid valid? function isValidUserId ($userid) { // Do we have cache? @@ -2354,7 +2397,7 @@ function getTotalPoints ($userid) { ); // Run filter chain for getting more point values - $data = runFilter('get_total_points', $data); + $data = runFilterChain('get_total_points', $data); // Determine it $GLOBALS[__FUNCTION__][$userid] = $data['points'] - countSumTotalData($userid, 'user_data', 'used_points'); @@ -2483,7 +2526,7 @@ function convertCommaToDotInPostData ($postEntry) { } // Converts German commas to Computer's version in all entries -function convertCommaToDotInPostDataArray (array $postEntries) { +function convertCommaToDotInPostDataArray ($postEntries) { // Replace german decimal comma with computer decimal dot foreach ($postEntries as $entry) { // Is the entry there? @@ -2494,6 +2537,26 @@ function convertCommaToDotInPostDataArray (array $postEntries) { } // END - foreach } +/** + * Parses a string into a US formated float variable, taken from user comments + * from PHP documentation website. + * + * @param $floatString A string holding a float expression + * @return $float Corresponding float variable + * @author chrisgeorgakopouloscom + * @link http://de.php.net/manual/en/function.floatval.php#92563 + */ +function parseFloat ($floatString){ + $LocaleInfo = localeconv(); + $floatString = str_replace($LocaleInfo['mon_thousands_sep'] , '', $floatString); + $floatString = str_replace($LocaleInfo['mon_decimal_point'] , '.', $floatString); + return floatval($floatString); +} + +//----------------------------------------------------------------------------- +// Configuration wrapper +//----------------------------------------------------------------------------- + // Getter for 'check_double_email' function getCheckDoubleEmail () { // Is the cache entry set? @@ -2506,7 +2569,7 @@ function getCheckDoubleEmail () { return $GLOBALS[__FUNCTION__]; } -// Checks wether 'check_double_email' is "YES" +// Checks wether 'check_double_email' is 'Y' function isCheckDoubleEmailEnabled () { // Is the cache entry set? if (!isset($GLOBALS[__FUNCTION__])) {