+ // 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) {
+ // Is there 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));
+ }