Rewrite of all mail templates with user data to new 'tag-like' functionality
[mailer.git] / inc / libs / surfbar_functions.php
index 278ad21d4a7d35a72adffef5da2cf17fc420df99..95705bc254012b231b3772f5a595541696b29da0 100644 (file)
@@ -494,18 +494,18 @@ function SURFBAR_HANDLE_DEPLETED_VIEWS () {
 // Alert users which have URLs booked and are low on points amount
 function SURFBAR_HANDLE_LOW_POINTS () {
        // Get all userids
-       $UIDs = SURFBAR_DETERMINE_DEPLETED_USERIDS(getConfig('surfbar_warn_low_points'));
+       $userids = SURFBAR_DETERMINE_DEPLETED_USERIDS(getConfig('surfbar_warn_low_points'));
 
        // "Walk" through all URLs
-       foreach ($UIDs['userid'] as $userid => $dummy) {
+       foreach ($userids['userid'] as $userid => $dummy) {
                // Is the last notification far enougth away to notify again?
-               if ((time() - $UIDs['notified'][$userid]) >= getConfig('surfbar_low_interval')) {
+               if ((time() - $userids['notified'][$userid]) >= getConfig('surfbar_low_interval')) {
                        // Prepare content
                        $content = array(
                                'userid'      => $userid,
                                'low'      => translateComma(getConfig('surfbar_warn_low_points')),
-                               'points'   => translateComma($UIDs['points'][$userid]),
-                               'notified' => generateDateTime($UIDs['notified'][$userid]),
+                               'points'   => translateComma($userids['points'][$userid]),
+                               'notified' => generateDateTime($userids['notified'][$userid]),
                                'interval' => createFancyTime(getConfig('surfbar_low_interval'))
                        );
 
@@ -866,10 +866,10 @@ LIMIT 1",
 // Get total amount of URLs of given status for current user or of ACTIVE URLs by default
 function SURFBAR_GET_TOTAL_URLS ($status = 'ACTIVE', $excludeUserId = '0') {
        // Determine depleted user account
-       $UIDs = SURFBAR_DETERMINE_DEPLETED_USERIDS();
+       $userids = SURFBAR_DETERMINE_DEPLETED_USERIDS();
 
        // If we dont get any user ids back, there are no URLs
-       if (count($UIDs['userid']) == '0') {
+       if (count($userids['userid']) == '0') {
                // No user ids found, no URLs!
                return 0;
        } // END - if
@@ -877,13 +877,13 @@ function SURFBAR_GET_TOTAL_URLS ($status = 'ACTIVE', $excludeUserId = '0') {
        // Is the exlude userid set?
        if ($excludeUserId > 0) {
                // Then add it
-               $UIDs['userid'][$excludeUserId] = $excludeUserId;
+               $userids['userid'][$excludeUserId] = $excludeUserId;
        } // END - if
 
        // Get amount from database
        $result = SQL_QUERY_ESC("SELECT COUNT(`id`) AS cnt
 FROM `{?_MYSQL_PREFIX?}_surfbar_urls`
-WHERE `userid` NOT IN (".implode(', ', $UIDs['userid']).") AND `status`='%s'",
+WHERE `userid` NOT IN (".implode(', ', $userids['userid']).") AND `status`='%s'",
                array($status), __FUNCTION__, __LINE__
        );
 
@@ -1114,7 +1114,7 @@ LIMIT 1",
 // Determine which user hash no more points left
 function SURFBAR_DETERMINE_DEPLETED_USERIDS ($limit=0) {
        // Init array
-       $UIDs = array(
+       $userids = array(
                'userid'      => array(),
                'points'   => array(),
                'notified' => array(),
@@ -1123,9 +1123,9 @@ function SURFBAR_DETERMINE_DEPLETED_USERIDS ($limit=0) {
        // Do we have a current user id?
        if ((isMember()) && ($limit == '0')) {
                // Then add this as well
-               $UIDs['userid'][getMemberId()]      = getMemberId();
-               $UIDs['points'][getMemberId()]   = countSumTotalData(getMemberId(), 'user_points', 'points') - countSumTotalData(getMemberId(), 'user_data', 'used_points');
-               $UIDs['notified'][getMemberId()] = '0';
+               $userids['userid'][getMemberId()]      = getMemberId();
+               $userids['points'][getMemberId()]   = countSumTotalData(getMemberId(), 'user_points', 'points') - countSumTotalData(getMemberId(), 'user_data', 'used_points');
+               $userids['notified'][getMemberId()] = '0';
 
                // Get all userid except logged in one
                $result = SQL_QUERY_ESC("SELECT
@@ -1171,9 +1171,9 @@ ORDER BY
                if ($points <= $limit) {
                        // Ignore this one!
                        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "userid={$content['userid']} has depleted points amount!", false);
-                       $UIDs['userid'][$content['userid']]      = $content['userid'];
-                       $UIDs['points'][$content['userid']]   = $points;
-                       $UIDs['notified'][$content['userid']] = $content['notified'];
+                       $userids['userid'][$content['userid']]      = $content['userid'];
+                       $userids['points'][$content['userid']]   = $points;
+                       $userids['notified'][$content['userid']] = $content['notified'];
                } // END - if
        } // END - while
 
@@ -1181,10 +1181,10 @@ ORDER BY
        SQL_FREERESULT($result);
 
        // Debug message
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "UIDs::count=".count($UIDs)." (with own userid=".getMemberId().')', false);
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "UIDs::count=".count($userids)." (with own userid=".getMemberId().')', false);
 
        // Return result
-       return $UIDs;
+       return $userids;
 }
 
 // Determine how many users are Online in surfbar
@@ -1424,7 +1424,7 @@ ORDER BY
 }
 
 // "Getter" for maximum random number
-function SURFBAR_GET_MAX_RANDOM ($UIDs, $add) {
+function SURFBAR_GET_MAX_RANDOM ($userids, $add) {
        // Count max availabe entries
        $result = SQL_QUERY("SELECT sbu.id AS cnt
 FROM `{?_MYSQL_PREFIX?}_surfbar_urls` AS sbu
@@ -1432,7 +1432,7 @@ LEFT JOIN `{?_MYSQL_PREFIX?}_surfbar_salts` AS sbs
 ON sbu.id=sbs.url_id
 LEFT JOIN `{?_MYSQL_PREFIX?}_surfbar_locks` AS l
 ON sbu.id=l.url_id
-WHERE sbu.userid NOT IN (".implode(',', $UIDs).") AND (sbu.views_allowed=0 OR (sbu.views_allowed > 0 AND sbu.views_max > 0)) AND sbu.`status`='ACTIVE'".$add."
+WHERE sbu.userid NOT IN (".implode(',', $userids).") AND (sbu.views_allowed=0 OR (sbu.views_allowed > 0 AND sbu.views_max > 0)) AND sbu.`status`='ACTIVE'".$add."
 GROUP BY sbu.id", __FUNCTION__, __LINE__);
 
        // Log last query
@@ -1540,10 +1540,10 @@ function SURFBAR_DETERMINE_NEXT_ID ($urlId = '0') {
                } // END - if
 
                // Determine depleted user account
-               $UIDs = SURFBAR_DETERMINE_DEPLETED_USERIDS();
+               $userids = SURFBAR_DETERMINE_DEPLETED_USERIDS();
 
                // Get maximum randomness factor
-               $maxRand = SURFBAR_GET_MAX_RANDOM($UIDs['userid'], $add);
+               $maxRand = SURFBAR_GET_MAX_RANDOM($userids['userid'], $add);
 
                // If more than one URL can be called generate the random number!
                if ($maxRand > 1) {
@@ -1559,7 +1559,7 @@ LEFT JOIN `{?_MYSQL_PREFIX?}_surfbar_salts` AS sbs
 ON sbu.id=sbs.url_id
 LEFT JOIN `{?_MYSQL_PREFIX?}_surfbar_locks` AS l
 ON sbu.id=l.url_id
-WHERE sbu.userid NOT IN (".implode(',', $UIDs['userid']).") AND sbu.`status`='ACTIVE' AND (sbu.views_allowed=0 OR (sbu.views_allowed > 0 AND sbu.views_max > 0))".$add."
+WHERE sbu.userid NOT IN (".implode(',', $userids['userid']).") AND sbu.`status`='ACTIVE' AND (sbu.views_allowed=0 OR (sbu.views_allowed > 0 AND sbu.views_max > 0))".$add."
 GROUP BY sbu.id
 ORDER BY l.last_surfed ASC, sbu.id ASC
 LIMIT %s,1",