+// Checks whether 'mailer_theme' was found in session
+function isMailerThemeSet () {
+ // Is cache set?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Determine it
+ $GLOBALS[__FUNCTION__] = isSessionVariableSet('mailer_theme');
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
+}
+
+/**
+ * Setter for theme in session (This setter does return the success of
+ * setSession() which is required e.g. for destroySponsorSession().
+ */
+function setMailerTheme ($newTheme) {
+ // Set it in session
+ return setSession('mailer_theme', $newTheme);
+}
+
+/**
+ * Getter for theme from session (This getter does return 'mailer_theme' from
+ * session data or throws an error if not possible
+ */
+function getMailerTheme () {
+ // Is cache set?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Is 'mailer_theme' set?
+ if (!isMailerThemeSet()) {
+ // No, then abort here
+ reportBug(__FUNCTION__, __LINE__, 'mailer_theme not set in session. Please fix your code.');
+ } // END - if
+
+ // Get it and store it in cache
+ $GLOBALS[__FUNCTION__] = getSession('mailer_theme');
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for last_module/last_what depending on ext-user version
+function getUserLastWhatName () {
+ // Default is old one: last_module
+ $columnName = 'last_module';
+
+ // Is ext-user up-to-date?
+ if (isExtensionInstalledAndNewer('user', '0.4.9')) {
+ // Yes, then use new one
+ $columnName = 'last_what';
+ } // END - if
+
+ // Return it
+ return $columnName;
+}
+
+// "Getter" for all columns for given alias and separator
+function getAllPointColumns ($alias = NULL, $separator = ',') {
+ // Prepare the filter array
+ $filterData = array(
+ 'columns' => '',
+ 'alias' => $alias,
+ 'separator' => $separator
+ );
+
+ // Run the filter
+ $filterData = runFilterChain('get_all_point_columns', $filterData);
+
+ // Return the columns
+ return $filterData['columns'];
+}
+
+// Checks whether the copyright footer (which breaks framesets) is enabled
+function ifCopyrightFooterEnabled () {
+ // Is not unset and not 'N'?
+ return ((!isset($GLOBALS['__copyright_enabled'])) || ($GLOBALS['__copyright_enabled'] == 'Y'));
+}
+
+/**
+ * Wrapper to check whether we have a "full page". This means that the actual
+ * content is not delivered in any frame of a frameset.
+ */
+function isFullPage () {
+ /*
+ * The parameter 'frame' is generic and always indicates that this content
+ * will be output into a frame. Furthermore, if a frameset is reported or
+ * the copyright line is explicitly deactivated, this cannot be a "full
+ * page" again.
+ */
+ // @TODO Find a way to not use direct module comparison
+ $isFullPage = ((!isGetRequestElementSet('frame')) && (getModule() != 'frametester') && (!isFramesetModeEnabled()) && (ifCopyrightFooterEnabled()));
+
+ // Return it
+ return $isFullPage;
+}
+
+// Checks whether frameset_mode is set to true
+function isFramesetModeEnabled () {
+ // Check it
+ return ((isset($GLOBALS['frameset_mode'])) && ($GLOBALS['frameset_mode'] === true));
+}
+
+// Function to determine correct 'what' value
+function determineWhat ($module = NULL) {
+ // Init default 'what'
+ $what = 'welcome';
+
+ // Is module NULL?
+ if (is_null($module)) {
+ // Then use default
+ $module = getModule();
+ } // END - if
+
+ // Is what set?
+ if (isWhatSet()) {
+ // Then use it
+ $what = getWhat();
+ } else {
+ // Else try to get it from current module
+ $what = getWhatFromModule($module);
+ }
+ //* DEBUG: */ debugOutput(__LINE__.'*'.$what.'/'.$module.'/'.getAction().'/'.getWhat().'*');
+
+ // Remove any spaces from variable
+ $what = trim($what);
+
+ // Is it empty?
+ if (empty($what)) {
+ // Default action for non-admin menus
+ $what = 'welcome';
+ } else {
+ // Secure it
+ $what = secureString($what);
+ }
+
+ // Return what
+ return $what;
+}
+
+// Fills (prepend) a string with zeros. This function has been taken from user comments at de.php.net/str_pad
+function prependZeros ($mStretch, $length = 2) {
+ // Return prepended string
+ return sprintf('%0' . (int) $length . 's', $mStretch);
+}
+
+// Wraps convertSelectionsToEpocheTime()
+function convertSelectionsToEpocheTimeInPostData ($id) {
+ // Init variables
+ $content = array();
+ $skip = false;
+
+ // Get all POST data
+ $postData = postRequestArray();
+
+ // Convert given selection id
+ convertSelectionsToEpocheTime($postData, $content, $id, $skip);
+
+ // Set the POST array back
+ setPostRequestArray($postData);
+}
+
+// Wraps checking if given points account type matches with given in POST data
+function ifPointsAccountTypeMatchesPost ($type) {
+ // Check condition
+ exit(__FUNCTION__.':type='.$type.',post=<pre>'.print_r(postRequestArray(), true).'</pre>');
+}
+
+// Gets given user's total referral
+function getUsersTotalReferrals ($userid, $level = NULL) {
+ // Do we have cache?
+ if (!isset($GLOBALS[__FUNCTION__][$userid][$level])) {
+ // Is the level NULL?
+ if (is_null($level)) {
+ // Get total amount (all levels)
+ $GLOBALS[__FUNCTION__][$userid][$level] = countSumTotalData($userid, 'user_refs', 'refid', 'userid', true);
+ } else {
+ // Get it from user refs
+ $GLOBALS[__FUNCTION__][$userid][$level] = countSumTotalData($userid, 'user_refs', 'refid', 'userid', true, ' AND `level`=' . bigintval($level));
+ }
+ } // END - if
+
+ // Return it
+ return $GLOBALS[__FUNCTION__][$userid][$level];
+}
+
+// Gets given user's total referral
+function getUsersTotalLockedReferrals ($userid, $level = NULL) {
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level[' . gettype($level) . ']=' . $level . ' - ENTERED!');
+ // Do we have cache?
+ if (!isset($GLOBALS[__FUNCTION__][$userid][$level])) {
+ // Default is all refs
+ $add = '';
+
+ // Is the not level NULL?
+ if (!is_null($level)) {
+ // Then add referral level
+ $add = ' AND r.`level`=' . bigintval($level);
+ } // END - if
+
+ // Check for all referrals
+ $result = SQL_QUERY_ESC("SELECT
+ COUNT(d.`userid`) AS `cnt`
+FROM
+ `{?_MYSQL_PREFIX?}_user_data` AS d
+INNER JOIN
+ `{?_MYSQL_PREFIX?}_user_refs` AS r
+ON
+ d.`userid`=r.`refid`
+WHERE
+ d.`status` != 'CONFIRMED' AND
+ r.`userid`=%s
+ " . $add . "
+ORDER BY
+ d.`userid` ASC
+LIMIT 1",
+ array(
+ $userid
+ ), __FUNCTION__, __LINE__);
+
+ // Load count
+ list($GLOBALS[__FUNCTION__][$userid][$level]) = SQL_FETCHROW($result);
+
+ // Free result
+ SQL_FREERESULT($result);
+ } // END - if
+
+ // Return it
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level[' . gettype($level) . ']=' . $level . ':' . $GLOBALS[__FUNCTION__][$userid][$level] . ' - EXIT!');
+ return $GLOBALS[__FUNCTION__][$userid][$level];
+}
+
+// Converts, if found, dollar data to get element
+function convertDollarDataToGetElement ($data) {
+ // Is first char a dollar?
+ if (substr($data, 0, 1) == chr(36)) {
+ // Use last part for getRequestElement()
+ $data = getRequestElement(substr($data, 1));
+ } // END - if
+
+ // Return it
+ return $data;
+}
+
+// Wrapper function for SQL layer to speed-up things
+function SQL_DEBUG_ENABLED () {
+ // Is there cache?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Determine it
+ $GLOBALS[__FUNCTION__] = ((!isCssOutputMode()) && (isDebugModeEnabled()) && (isSqlDebuggingEnabled()));
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
+}
+