X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fwrapper-functions.php;h=97fe0ab20a436f2dcc43b012ff1d17dda9428671;hp=46d999cddcc5fdc6919afcdc486cc6efc5ddc6c5;hb=9ad55a40b49ea7dc484b1553039715fbce8086f0;hpb=69069fc1db04dca089547d6614dea50b88d49f27 diff --git a/inc/wrapper-functions.php b/inc/wrapper-functions.php index 46d999cddc..97fe0ab20a 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. @@ -734,10 +741,19 @@ function isBlockModeEnabled () { return $GLOBALS['block_mode']; } -// Wrapper function for addPointsThroughReferalSystem() +/** + * Wrapper function for addPointsThroughReferalSystem(), you should generally + * avoid this function and use addPointsThroughReferalSystem() directly and add + * your special payment method entry to points_data instead. + * + * @param $subject A string-encoded subject for this add + * @param $userid The recipient (member) for given points + * @param $points Points to be added to member's account + * @return $added Wether the points has been added to the user's account + */ function addPointsDirectly ($subject, $userid, $points) { // Reset level here - unset($GLOBALS['ref_level']); + initReferalSystem(); // Call more complicated method (due to more parameters) return addPointsThroughReferalSystem($subject, $userid, $points, false, 0, 'DIRECT'); @@ -944,8 +960,16 @@ 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' @@ -1037,6 +1061,7 @@ function isDebuggingTemplateCache () { // Wrapper for fetchUserData() and getUserData() calls function getFetchedUserData ($keyColumn, $userid, $valueColumn) { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'keyColumn=' . $keyColumn . ',userid=' . $userid . ',valueColumn=' . $valueColumn . ' - ENTERED!'); // Is it cached? if (!isset($GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn])) { // Default is 'guest' @@ -1053,6 +1078,7 @@ function getFetchedUserData ($keyColumn, $userid, $valueColumn) { } // END - if // Return it + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'keyColumn=' . $keyColumn . ',userid=' . $userid . ',valueColumn=' . $valueColumn . ',value=' . $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn] . ' - EXIT!'); return $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn]; } @@ -1203,6 +1229,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? @@ -2438,6 +2480,7 @@ function generateWrappedUserEmailLink ($email) { // Wrapper to check if user points are locked function ifUserPointsLocked ($userid) { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ' - ENTERED!'); // Do we have cache? if (!isset($GLOBALS[__FUNCTION__][$userid])) { // Determine it @@ -2445,6 +2488,7 @@ function ifUserPointsLocked ($userid) { } // END - if // Return cache + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',locked=' . intval($GLOBALS[__FUNCTION__][$userid]) . ' - EXIT!'); return $GLOBALS[__FUNCTION__][$userid]; } @@ -2495,7 +2539,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? @@ -2506,6 +2550,32 @@ 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); +} + +// Generates a YES/NO option list from given default +function generateYesNoOptionList ($default = '') { + // Generate it + return generateOptionList('/ARRAY/', array('Y', 'N'), array('{--YES--}', '{--NO--}'), $default); +} + +//----------------------------------------------------------------------------- +// Configuration wrapper +//----------------------------------------------------------------------------- + // Getter for 'check_double_email' function getCheckDoubleEmail () { // Is the cache entry set? @@ -2518,7 +2588,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__])) {