X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fwrapper-functions.php;h=c81d9d09d30ff956b334d6c60580579376e254d3;hb=f4c3a7ea1b3a8695e403a665ed2a0ad74246ae67;hp=9a40f9ea8356992695109e2d38284e44dead5aae;hpb=ca9005c019278284580b5f824d209afab5f6844b;p=mailer.git diff --git a/inc/wrapper-functions.php b/inc/wrapper-functions.php index 9a40f9ea83..c81d9d09d3 100644 --- a/inc/wrapper-functions.php +++ b/inc/wrapper-functions.php @@ -1,7 +1,7 @@ '; - debug_print_backtrace(); - die(' 1)); + // Is it cached? + if (!isset($GLOBALS['is_userdata_valid'][getCurrentUserId()])) { + // Determine it + $GLOBALS['is_userdata_valid'][getCurrentUserId()] = ((isset($GLOBALS['user_data'][getCurrentUserId()])) && (count($GLOBALS['user_data'][getCurrentUserId()]) > 1)); + } // END - if + + // Return the result + return $GLOBALS['is_userdata_valid'][getCurrentUserId()]; } // Setter for current userid @@ -764,5 +862,44 @@ function isDebuggingTemplateCache () { return (getConfig('DEBUG_TEMPLATE_CACHE') == 'Y'); } +// Wrapper for fetchUserData() and getUserData() calls +function getFetchedUserData ($keyColumn, $userId, $valueColumn) { + // Is it cached? + if (!isset($GLOBALS['user_data_cache'][$userid][$keyColumn][$valueColumn])) { + // Default is 'guest' + $data = getMessage('USERNAME_GUEST'); + + // Can we fetch the user data? + if (($userId > 0) && (fetchUserData($userId, $keyColumn))) { + // Now get the data back + $data = getUserData($valueColumn); + } // END - if + + // Cache it + $GLOBALS['user_data_cache'][$userid][$keyColumn][$valueColumn] = $data; + } // END - if + + // Return it + return $GLOBALS['user_data_cache'][$userid][$keyColumn][$valueColumn]; +} + +// Wrapper for strpos() to ease porting from deprecated ereg() function +function isInString ($needle, $haystack) { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'needle=' . $needle . ', haystack=' . $haystack . ', returned=' . intval(strpos($haystack, $needle) !== false)); + return (strpos($haystack, $needle) !== false); +} + +// Wrapper for strpos() to ease porting from deprecated eregi() function +// This function is case-insensitive +function isInStringIgnoreCase ($needle, $haystack) { + return (isInString(strtolower($needle), strtolower($haystack))); +} + +// Wrapper to check for if fatal errors where detected +function ifFatalErrorsDetected () { + // Just call the inner function + return (getTotalFatalErrors() > 0); +} + // [EOF] ?>