]> git.mxchange.org Git - mailer.git/blobdiff - inc/libs/user_functions.php
Member area section 'referal links' refactured:
[mailer.git] / inc / libs / user_functions.php
index 8e1eea9389e1432b67110480085ae5bb04883d66..e9a14776500636d76220c3c81fab3a8fa7242a64 100644 (file)
@@ -42,9 +42,15 @@ if (!defined('__SECURITY')) {
 
 // Add links for selecting some users
 function alpha ($sortby, $colspan, $return=false) {
-       if (!isGetRequestParameterSet('offset')) setGetRequestParameter('offset', 0);
-       $add = '&page='.getRequestParameter('page').'&offset='.getRequestParameter('offset');
-       if (isGetRequestParameterSet('mode')) $add .= '&mode='.getRequestParameter('mode');
+       if (!isGetRequestParameterSet('offset')) {
+               setGetRequestParameter('offset', 0);
+       } // END - if
+       $add = '&page=' . getRequestParameter('page').'&offset=' . getRequestParameter('offset');
+       foreach (array('mode','status') as $param) {
+               if (isGetRequestParameterSet($param)) {
+                       $add .= '&' . $param . '=' . getRequestParameter($param);
+               } // END - if
+       } // END - foreach
 
        /* Creates the list of letters and makes them a link. */
        $alphabet = explode(',', 'A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,');
@@ -57,7 +63,11 @@ function alpha ($sortby, $colspan, $return=false) {
                } else {
                        // Output link to letter
                        $OUT .= '<a href="{%url=modules.php?module=admin&amp;what=' . getWhat();
-                       if (isGetRequestParameterSet('mode')) $OUT .= '&amp;mode=' . getRequestParameter('mode');
+                       foreach (array('mode','status') as $param) {
+                               if (isGetRequestParameterSet($param)) {
+                                       $OUT .= '&amp;' . $param . '=' . getRequestParameter($param);
+                               } // END - if
+                       } // END - foreach
                        $OUT .= '&amp;letter=' . $ltr . '&amp;sortby=' . $sortby . $add . '%}">' . $ltr . '</a>';
                }
 
@@ -94,12 +104,17 @@ function addSortLinks ($letter, $sortby, $colspan, $return=false) {
        // Add page and offset
        $add = '&amp;page=' . getRequestParameter('page') . '&amp;offset=' . getRequestParameter('offset');
 
-       // Add status or mode
-       if (isGetRequestParameterSet('status'))   $add .= '&amp;mode=' . getRequestParameter('status');
-       elseif (isGetRequestParameterSet('mode')) $add .= '&amp;mode=' . getRequestParameter('mode');
+       // Add status/ mode
+       foreach (array('mode','status') as $param) {
+               if (isGetRequestParameterSet($param)) {
+                       $add .= '&amp;' . $param . '=' . getRequestParameter($param);
+               } // END - if
+       } // END - foreach
 
        // Makes order by links..
-       if ($letter == 'front') $letter = '';
+       if ($letter == 'front') {
+               $letter = '';
+       } // END - if
 
        // Prepare array with all possible sorters
        $list = array(
@@ -163,9 +178,12 @@ function addPageNavigation ($numPages, $offset, $showForm, $colspan, $return=fal
                        // Base link
                        $OUT .= '<a href="{%url=modules.php?module=admin&amp;what=' . getWhat();
 
-                       // Add status or mode
-                       if (isGetRequestParameterSet('status'))    $OUT .= '&amp;mode=' . getRequestParameter('status');
-                        elseif (isGetRequestParameterSet('mode')) $OUT .= '&amp;mode=' . getRequestParameter('mode');
+                       // Add status/mode
+                       foreach (array('mode','status') as $param) {
+                               if (isGetRequestParameterSet($param)) {
+                                       $OUT .= '&amp;' . $param . '=' . getRequestParameter($param);
+                               } // END - if
+                       } // END - foreach
 
                        // Letter and so on
                        $OUT .= '&amp;letter=' . getRequestParameter('letter') . '&amp;sortby=' . getRequestParameter('sortby') . '&amp;page=' . $page . '&amp;offset=' . $offset . '%}">';
@@ -232,7 +250,7 @@ LIMIT 1",
 // @TODO Double-check configuration entry here
 function determineRandomReferalId () {
        // Default is zero refid
-       $refid = null;
+       $refid = NULL;
 
        // Is the extension version fine?
        if (isExtensionInstalledAndNewer('user', '0.3.4')) {
@@ -254,8 +272,7 @@ function determineRandomReferalId () {
                                list($refid) = SQL_FETCHROW($result);
 
                                // Reset all users, this makes this random referal id more challenging
-                               SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `rand_confirmed`=0",
-                                       array($refid), __FUNCTION__, __LINE__);
+                               SQL_QUERY('UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `rand_confirmed`=0', __FUNCTION__, __LINE__);
                        } // END - if
 
                        // Free result
@@ -542,7 +559,7 @@ function insertUserStatsRecord ($userid, $statsType, $statsData) {
        // Does it exist?
        if ((!getEpocheTimeFromUserStats($statsType, $statsData, $userid)) && (!is_array($statsData))) {
                // Then insert it!
-               SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_stats_data` (`userid`,`stats_type`,`stats_data`) VALUES (%s,'%s','%s')",
+               SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_stats_data` (`userid`, `stats_type`, `stats_data`) VALUES (%s,'%s','%s')",
                        array(
                                bigintval($userid),
                                $statsType,
@@ -586,7 +603,6 @@ function doConfirmUserAccount ($hash) {
        `{?_MYSQL_PREFIX?}_user_data`
 SET
        `status`='CONFIRMED',
-       `ref_payout`={?ref_payout?},
        `user_hash`=NULL
 WHERE
        `user_hash`='%s' AND
@@ -620,9 +636,8 @@ LIMIT 1",
                                        } // END - if
 
                                        // Add one-time referal bonus over referal system or directly
-                                       // @TODO Try to rewrite the following unset()
-                                       unset($GLOBALS['ref_level']);
-                                       addPointsThroughReferalSystem('referal_bonus', $refid, getPointsRef(), true, bigintval($userid), getConfig('reg_points_mode'));
+                                       initReferalSystem();
+                                       addPointsThroughReferalSystem('referal_bonus', $refid, getPointsRef(), bigintval($userid));
                                } // END - if
                        } // END - if
 
@@ -730,7 +745,13 @@ function doExpressionUser ($data) {
                        // Use dynamic call
                        $functionName = "getFetchedUserData('userid', \$userid, '" . $data['callback'] . "')";
                } elseif (!empty($data['matches'][4][$data['key']])) {
-                       // User data found
+                       // Do we have a number or a dollar sign in front of it?
+                       if (preg_replace('/[^0123456789]/', '', $data['matches'][4][$data['key']]) != $data['matches'][4][$data['key']]) {
+                               // Possible database column, so get it again
+                               $data['matches'][4][$data['key']] = "getFetchedUserData('userid', getMemberId(), '" . $data['matches'][4][$data['key']] . "')";
+                       } // END - if
+
+                       // Fix all together
                        $functionName = "getFetchedUserData('userid', " . $data['matches'][4][$data['key']] . ", '" . $data['callback'] . "')";
                }
        } elseif ((!empty($data['callback'])) && (isUserDataValid())) {
@@ -743,6 +764,7 @@ function doExpressionUser ($data) {
                // Surround the original function call with it
                $functionName = $data['extra_func'] . '(' . $functionName . ')';
        } // END - if
+       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'functionName=' . $functionName);
 
        // Generate replacer
        $replacer = '{DQUOTE} . ' . $functionName . ' . {DQUOTE}';