X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fwrapper-functions.php;h=6fc935bd28a050adf6a4116e55d3ee69c8b4e1c1;hb=8d4176053d397a86baca20b4d7ab7ed526355be8;hp=fdd6be73f4f2ecf713c5ced74d8de4feb2178334;hpb=4dfa7b2274172717e7e5da373f8bb6bdc7b3d51b;p=mailer.git diff --git a/inc/wrapper-functions.php b/inc/wrapper-functions.php index fdd6be73f4..6fc935bd28 100644 --- a/inc/wrapper-functions.php +++ b/inc/wrapper-functions.php @@ -694,6 +694,12 @@ function addPointsDirectly ($subject, $userid, $points) { return addPointsThroughReferalSystem($subject, $userid, $points, false, 0, false, 'direct'); } +// Wrapper for redirectToUrl but URL comes from a configuration entry +function redirectToConfiguredUrl ($configEntry) { + // Load the URL + redirectToUrl(getConfig($configEntry)); +} + // Wrapper function to redirect from member-only modules to index function redirectToIndexMemberOnlyModule () { // Do the redirect here @@ -775,7 +781,7 @@ function isDemoModeActive () { // Is cache set? if (!isset($GLOBALS['demo_mode_active'])) { // Simply check it - $GLOBALS['demo_mode_active'] = ((isExtensionActive('demo')) && (getSession('admin_login') == 'demo')); + $GLOBALS['demo_mode_active'] = ((isExtensionActive('demo')) && (getAdminLogin(getSession('admin_id')) == 'demo')); } // END - if // Return it @@ -788,35 +794,20 @@ function getPhpCaching () { } // Checks wether the admin hash is set -function isAdminHashSet ($admin) { - /** - * @TODO Do we really need this check? If yes, try to fix this: - * 1.:functions.php:2504, debug_get_mailable_backtrace(0) - * 2.:wrapper-functions.php:744, debug_report_bug(1) - * 3.:mysql-manager.php:728, isAdminHashSet(1) - * 4.:filters.php:384, isAdmin(0) - * 5.:debug_get_mailable_backtrace:2457, FILTER_DETERMINE_USERNAME(1) - * 6.:filter-functions.php:280, call_user_func_array(2) - * 7.:load_cache.php:74, runFilterChain(1) - * 8.:inc-functions.php:131, include(1) - * 9.:inc-functions.php:145, loadInclude(1) - * 10.:mysql-connect.php:104, loadIncludeOnce(1) - * 11.:inc-functions.php:131, include(1) - * 12.:inc-functions.php:145, loadInclude(1) - * 13.:config-global.php:106, loadIncludeOnce(1) - * 14.:js.php:57, require(1) - */ +function isAdminHashSet ($adminId) { + // Is the array there? if (!isset($GLOBALS['cache_array']['admin'])) { + // Missing array should be reported debug_report_bug(__FUNCTION__, __LINE__, 'Cache not set.'); } // END - if // Check for admin hash - return isset($GLOBALS['cache_array']['admin']['password'][$admin]); + return isset($GLOBALS['cache_array']['admin']['password'][$adminId]); } // Setter for admin hash -function setAdminHash ($admin, $hash) { - $GLOBALS['cache_array']['admin']['password'][$admin] = $hash; +function setAdminHash ($adminId, $hash) { + $GLOBALS['cache_array']['admin']['password'][$adminId] = $hash; } // Init user data array @@ -941,11 +932,6 @@ function ifFatalErrorsDetected () { return (getTotalFatalErrors() > 0); } -// Wrapper until we merged to the EL branch -function preCompileCode ($code, $template = '', $compiled = false, $full = true, $overwrite = false) { - return compileCode($code, false, true, $full); -} - // Setter for HTTP status function setHttpStatus ($status) { $GLOBALS['http_status'] = (string) $status; @@ -956,24 +942,6 @@ function getHttpStatus () { return $GLOBALS['http_status']; } -// Setter for 'is_template_html' -function enableTemplateHtml ($enable = true) { - $GLOBALS['is_template_html'] = (bool) $enable; -} - -// Checks wether the template is HTML or not by previously set flag -// Default: true -function isTemplateHtml () { - // Is the output_mode other than 0 (HTML), then no comments are enabled - if (getOutputMode() != 0) { - // No HTML - return false; - } else { - // Maybe HTML? - return $GLOBALS['is_template_html']; - } -} - /** * Send a HTTP redirect to the browser. This function was taken from DokuWiki * (GNU GPL 2; http://www.dokuwiki.org) and modified to fit into mailer project. @@ -1044,11 +1012,6 @@ function getTotalConfirmedUser () { return $GLOBALS['total_confirmed_users']; } -// Wrapper for writing debug informations to the browser -function debugOutput ($message) { - outputHtml('
' . $message . '
'); -} - // Is given userid valid? function isValidUserId ($userid) { // Do we have cache? @@ -1073,5 +1036,137 @@ function encodeEntities ($str) { return $str; } +// "Getter" for date from patch_ctime +function getDateFromPatchTime () { + // Is it cached? + if (!isset($GLOBALS[__FUNCTION__])) { + // Then set it + $GLOBALS[__FUNCTION__] = generateDateTime(getConfig('patch_ctime'), '5'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + +// Getter for current year (default) +function getYear ($timestamp = null) { + // Is it cached? + if (!isset($GLOBALS['year'][$timestamp])) { + // null is time() + if (is_null($timestamp)) $timestamp = time(); + + // Then create it + $GLOBALS['year'][$timestamp] = date('Y', $timestamp); + } // END - if + + // Return cache + return $GLOBALS['year'][$timestamp]; +} + +// Getter for current month (default) +function getMonth ($timestamp = null) { + // Is it cached? + if (!isset($GLOBALS['month'][$timestamp])) { + // null is time() + if (is_null($timestamp)) $timestamp = time(); + + // Then create it + $GLOBALS['month'][$timestamp] = date('m', $timestamp); + } // END - if + + // Return cache + return $GLOBALS['month'][$timestamp]; +} + +// Getter for current day (default) +function getDay ($timestamp = null) { + // Is it cached? + if (!isset($GLOBALS['day'][$timestamp])) { + // null is time() + if (is_null($timestamp)) $timestamp = time(); + + // Then create it + $GLOBALS['day'][$timestamp] = date('d', $timestamp); + } // END - if + + // Return cache + return $GLOBALS['day'][$timestamp]; +} + +// Getter for current week (default) +function getWeek ($timestamp = null) { + // Is it cached? + if (!isset($GLOBALS['week'][$timestamp])) { + // null is time() + if (is_null($timestamp)) $timestamp = time(); + + // Then create it + $GLOBALS['week'][$timestamp] = date('W', $timestamp); + } // END - if + + // Return cache + return $GLOBALS['week'][$timestamp]; +} + +// Getter for current short_hour (default) +function getShortHour ($timestamp = null) { + // Is it cached? + if (!isset($GLOBALS['short_hour'][$timestamp])) { + // null is time() + if (is_null($timestamp)) $timestamp = time(); + + // Then create it + $GLOBALS['short_hour'][$timestamp] = date('G', $timestamp); + } // END - if + + // Return cache + return $GLOBALS['short_hour'][$timestamp]; +} + +// Getter for current long_hour (default) +function getLongHour ($timestamp = null) { + // Is it cached? + if (!isset($GLOBALS['long_hour'][$timestamp])) { + // null is time() + if (is_null($timestamp)) $timestamp = time(); + + // Then create it + $GLOBALS['long_hour'][$timestamp] = date('H', $timestamp); + } // END - if + + // Return cache + return $GLOBALS['long_hour'][$timestamp]; +} + +// Getter for current second (default) +function getSecond ($timestamp = null) { + // Is it cached? + if (!isset($GLOBALS['second'][$timestamp])) { + // null is time() + if (is_null($timestamp)) $timestamp = time(); + + // Then create it + $GLOBALS['second'][$timestamp] = date('s', $timestamp); + } // END - if + + // Return cache + return $GLOBALS['second'][$timestamp]; +} + +// Getter for current minute (default) +function getMinute ($timestamp = null) { + // Is it cached? + if (!isset($GLOBALS['minute'][$timestamp])) { + // null is time() + if (is_null($timestamp)) $timestamp = time(); + + // Then create it + $GLOBALS['minute'][$timestamp] = date('i', $timestamp); + } // END - if + + // Return cache + return $GLOBALS['minute'][$timestamp]; +} + // [EOF] ?>