X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fwrapper-functions.php;h=bb570f585aeee4b92253ce8aef94166df8c36d45;hb=50c257ecdf297672ffb6c6f1f9430bc35bca2c51;hp=aa7b6a0218667ddee3c6af8257d6c3e5232d826f;hpb=dc48c8d18b395c1bf2147baadbecd056f843b818;p=mailer.git diff --git a/inc/wrapper-functions.php b/inc/wrapper-functions.php index aa7b6a0218..bb570f585a 100644 --- a/inc/wrapper-functions.php +++ b/inc/wrapper-functions.php @@ -1,7 +1,7 @@ '; - debug_print_backtrace(); - die(' 1)); @@ -749,8 +826,52 @@ function setCurrentUserId ($userid) { // Getter for current userid function getCurrentUserId () { + // Userid must be set before it can be used + if (!isCurrentUserIdSet()) { + // Not set + debug_report_bug('User id is not set.'); + } // END - if + + // Return the userid return $GLOBALS['current_userid']; } +// Checks if current userid is set +function isCurrentUserIdSet () { + return isset($GLOBALS['current_userid']); +} + +// Checks wether we are debugging template cache +function isDebuggingTemplateCache () { + return (getConfig('DEBUG_TEMPLATE_CACHE') == 'Y'); +} + +// Wrapper for fetchUserData() and getUserData() calls +function getFetchedUserData ($keyColumn, $userId, $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 + + // Return it + return $data; +} + +// 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))); +} + // [EOF] ?>