]> git.mxchange.org Git - mailer.git/blobdiff - inc/wrapper-functions.php
Wrapper introduced, renaming to the naming convention:
[mailer.git] / inc / wrapper-functions.php
index 00844537956bacb634ef375ee5479089473325bd..a826c3d69b85716689946314fb9f18eb01ac04d9 100644 (file)
@@ -741,10 +741,19 @@ function isBlockModeEnabled () {
        return $GLOBALS['block_mode'];
 }
 
-// Wrapper function for addPointsThroughReferalSystem()
+/**
+ * Wrapper function for addPointsThroughReferalSystem(), you should generally
+ * avoid this function and use addPointsThroughReferalSystem() directly and add
+ * your special payment method entry to points_data instead.
+ *
+ * @param      $subject        A string-encoded subject for this add
+ * @param      $userid         The recipient (member) for given points
+ * @param      $points         Points to be added to member's account
+ * @return     $added          Wether the points has been added to the user's account
+ */
 function addPointsDirectly ($subject, $userid, $points) {
        // Reset level here
-       unset($GLOBALS['ref_level']);
+       initReferalSystem();
 
        // Call more complicated method (due to more parameters)
        return addPointsThroughReferalSystem($subject, $userid, $points, false, 0, 'DIRECT');
@@ -1052,6 +1061,7 @@ function isDebuggingTemplateCache () {
 
 // Wrapper for fetchUserData() and getUserData() calls
 function getFetchedUserData ($keyColumn, $userid, $valueColumn) {
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'keyColumn=' . $keyColumn . ',userid=' . $userid . ',valueColumn=' . $valueColumn . ' - ENTERED!');
        // Is it cached?
        if (!isset($GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn])) {
                // Default is 'guest'
@@ -1068,6 +1078,7 @@ function getFetchedUserData ($keyColumn, $userid, $valueColumn) {
        } // END - if
 
        // Return it
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'keyColumn=' . $keyColumn . ',userid=' . $userid . ',valueColumn=' . $valueColumn . ',value=' . $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn] . ' - EXIT!');
        return $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn];
 }
 
@@ -1218,6 +1229,22 @@ function getTotalLockedUser () {
        return $GLOBALS[__FUNCTION__];
 }
 
+// "Getter" for total locked user accounts
+function getTotalRandomRefidUser () {
+       // Is it cached?
+       if (!isset($GLOBALS[__FUNCTION__])) {
+               // Then do it
+               if (isExtensionInstalledAndNewer('user', '0.3.4')) {
+                       $GLOBALS[__FUNCTION__] = countSumTotalData('{?user_min_confirmed?}', 'user_data', 'userid', 'rand_confirmed', true, '', '>=');
+               } else {
+                       $GLOBALS[__FUNCTION__] = 0;
+               }
+       } // END - if
+
+       // Return cached value
+       return $GLOBALS[__FUNCTION__];
+}
+
 // Is given userid valid?
 function isValidUserId ($userid) {
        // Do we have cache?
@@ -2453,6 +2480,7 @@ function generateWrappedUserEmailLink ($email) {
 
 // Wrapper to check if user points are locked
 function ifUserPointsLocked ($userid) {
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ' - ENTERED!');
        // Do we have cache?
        if (!isset($GLOBALS[__FUNCTION__][$userid])) {
                // Determine it
@@ -2460,6 +2488,7 @@ function ifUserPointsLocked ($userid) {
        } // END - if
 
        // Return cache
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',locked=' . intval($GLOBALS[__FUNCTION__][$userid]) . ' - EXIT!');
        return $GLOBALS[__FUNCTION__][$userid];
 }
 
@@ -2510,7 +2539,7 @@ function convertCommaToDotInPostData ($postEntry) {
 }
 
 // Converts German commas to Computer's version in all entries
-function convertCommaToDotInPostDataArray (array $postEntries) {
+function convertCommaToDotInPostDataArray ($postEntries) {
        // Replace german decimal comma with computer decimal dot
        foreach ($postEntries as $entry) {
                // Is the entry there?
@@ -2521,6 +2550,53 @@ function convertCommaToDotInPostDataArray (array $postEntries) {
        } // END - foreach
 }
 
+/**
+ * Parses a string into a US formated float variable, taken from user comments
+ * from PHP documentation website.
+ *
+ * @param      $floatString    A string holding a float expression
+ * @return     $float                  Corresponding float variable
+ * @author     chris<at>georgakopoulos<dot>com
+ * @link       http://de.php.net/manual/en/function.floatval.php#92563
+ */
+function parseFloat ($floatString){
+    $LocaleInfo = localeconv();
+    $floatString = str_replace($LocaleInfo['mon_thousands_sep'] , '', $floatString);
+    $floatString = str_replace($LocaleInfo['mon_decimal_point'] , '.', $floatString);
+    return floatval($floatString);
+}
+
+// Generates a YES/NO option list from given default
+function generateYesNoOptionList ($default = '') {
+       // Generate it
+       return generateOptionList('/ARRAY/', array('Y', 'N'), array('{--YES--}', '{--NO--}'), $default);
+}
+
+// "Getter" for total available receivers
+function getTotalReceivers ($mode = 'normal') {
+       // Get num rows
+       $numRows = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', true, ' AND `receive_mails` > 0' . runFilterChain('exclude_users', $mode));
+
+       // Return value
+       return $numRows;
+}
+
+// Wrapper "getter" to get total unconfirmed mails for given userid
+function getTotalUnconfirmedMails ($userid) {
+       // Do we have cache?
+       if (!isset($GLOBALS[__FUNCTION__][$userid])) {
+               // Determine it
+               $GLOBALS[__FUNCTION__][$userid] = countSumTotalData($userid, 'user_links', 'id', 'userid', true);
+       } // END - if
+
+       // Return cache
+       return $GLOBALS[__FUNCTION__][$userid];
+}
+
+//-----------------------------------------------------------------------------
+//                        Configuration wrapper
+//-----------------------------------------------------------------------------
+
 // Getter for 'check_double_email'
 function getCheckDoubleEmail () {
        // Is the cache entry set?
@@ -2533,7 +2609,7 @@ function getCheckDoubleEmail () {
        return $GLOBALS[__FUNCTION__];
 }
 
-// Checks wether 'check_double_email' is "YES"
+// Checks wether 'check_double_email' is 'Y'
 function isCheckDoubleEmailEnabled () {
        // Is the cache entry set?
        if (!isset($GLOBALS[__FUNCTION__])) {