A lot while() conditions rewritten to SQL_FETCHARRAY(), see bug #107, @TODO tags...
[mailer.git] / inc / libs / surfbar_functions.php
index 7c467d9..c122b79 100644 (file)
@@ -1106,18 +1106,18 @@ ORDER BY u.userid ASC", __FUNCTION__, __LINE__);
        }
 
        // Load all userid
-       while (list($uid, $notified) = SQL_FETCHROW($result)) {
+       while ($content = SQL_FETCHARRAY($result)) {
                // Get total points
-               $points = GET_TOTAL_DATA($uid, "user_points", "points") - GET_TOTAL_DATA($uid, "user_data", "used_points");
-               //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "uid={$uid},points={$points}", false);
+               $points = GET_TOTAL_DATA($content['userid'], "user_points", "points") - GET_TOTAL_DATA($content['userid'], "user_data", "used_points");
+               //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "uid={$content['userid']},points={$points}", false);
 
                // Shall we add this to ignore?
                if ($points <= $limit) {
                        // Ignore this one!
-                       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "uid={$uid} has depleted points amount!", false);
-                       $UIDs['uid'][$uid] = $uid;
-                       $UIDs['points'][$uid] = $points;
-                       $UIDs['notified'][$uid] = $notified;
+                       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "uid={$content['userid']} has depleted points amount!", false);
+                       $UIDs['uid'][$content['userid']]      = $content['userid'];
+                       $UIDs['points'][$content['userid']]   = $points;
+                       $UIDs['notified'][$content['userid']] = $content['notified'];
                } // END - if
        } // END - while
 
@@ -1319,32 +1319,32 @@ ORDER BY
                __FUNCTION__, __LINE__);
 
        // Load all entries
-       while (list($lid, $url, $last) = SQL_FETCHROW($result)) {
+       while ($content = SQL_FETCHARRAY($result)) {
                // Debug message
-               //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "next - lid={$lid},url={$url},rest=".(time() - $last)."/".SURFBAR_GET_SURF_LOCK()."", false);
+               //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "next - lid={$content['id']},url={$content['url_id']},rest=".(time() - $last)."/".SURFBAR_GET_SURF_LOCK()."", false);
 
                // Skip entries that are too old
-               if (($last > (time() - SURFBAR_GET_SURF_LOCK())) && (!in_array($url, $ignored))) {
+               if (($last > (time() - SURFBAR_GET_SURF_LOCK())) && (!in_array($content['url_id'], $ignored))) {
                        // Debug message
-                       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "okay - lid={$lid},url={$url},last={$last}", false);
+                       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "okay - lid={$content['id']},url={$content['url_id']},last={$last}", false);
 
                        // Add only if missing or bigger
-                       if ((!isset($IDs[$url])) || ($IDs[$url] > $last)) {
+                       if ((!isset($IDs[$content['url_id']])) || ($IDs[$content['url_id']] > $last)) {
                                // Debug message
-                               //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "ADD - lid={$lid},url={$url},last={$last}", false);
+                               //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "ADD - lid={$content['id']},url={$content['url_id']},last={$last}", false);
 
                                // Add this ID
-                               $IDs[$url] = $last;
-                               $USE[$url] = $lid;
+                               $IDs[$content['url_id']] = $last;
+                               $USE[$content['url_id']] = $content['id'];
                        } // END - if
                } else {
                        // Debug message
-                       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "ignore - lid={$lid},url={$url},last={$last}", false);
+                       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "ignore - lid={$content['id']},url={$content['url_id']},last={$last}", false);
 
                        // Ignore these old entries!
-                       $ignored[] = $url;
-                       unset($IDs[$url]);
-                       unset($USE[$url]);
+                       $ignored[] = $content['url_id'];
+                       unset($IDs[$content['url_id']]);
+                       unset($USE[$content['url_id']]);
                }
        } // END - while
 
@@ -1417,8 +1417,9 @@ function SURFBAR_GET_ACTION_ARRAY ($status) {
        // Some entries there?
        if (SQL_NUMROWS($result) > 0) {
                // Load all actions
-               while (list($action) = SQL_FETCHROW($result)) {
-                       $returnArray[] = $action;
+               // @TODO This can be somehow rewritten
+               while ($content = SQL_FETCHARRAY($result)) {
+                       $returnArray[] = $content['action'];
                } // END - if
        } // END - if