+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',count()=' . count($GLOBALS['refback_refid'][$userid]));
+
+ // Now walk through the array, first levels
+ foreach ($GLOBALS['refback_refid'][$userid] as $level=>$levelArray) {
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . $level . ',count()=' . count($levelArray));
+ // Next are the users
+ foreach ($levelArray as $refid) {
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . $level . ',refid=' . $refid);
+ // Does the refid have an array?
+ if (isset($GLOBALS['refback_refid'][$refid])) {
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . $level . ',refid=' . $refid . ',count()=' . count($GLOBALS['refback_refid'][$refid]));
+ // Okay, then walk through here, too
+ foreach ($GLOBALS['refback_refid'][$refid] as $refLevel=>$refArray) {
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . $level . ',refid=' . $refid . ',refLevel=' . $refLevel . ',count()=' . count($refArray));
+ // Also walk through this one
+ foreach ($refArray as $refRefid) {
+ // Calculate new level
+ $newLevel = $level + $refLevel;
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . $level . ',refid=' . $refid . ',refLevel=' . $refLevel . ',refRefid=' . $refRefid . ',newLevel=' . $newLevel);
+ // Is the refRefid not in?
+ if ((!isset($GLOBALS['refback_refid'][$userid][$newLevel])) || (!in_array($refRefid, $GLOBALS['refback_refid'][$userid][$newLevel]))) {
+ // Then we must add this ref's refid to the userid's next level
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',newLevel=' . $newLevel . ',refRefid=' . $refRefid . ' - ADDED!');
+ $GLOBALS['refback_refid'][$userid][$newLevel][] = $refRefid;
+ } // END - if
+ } // END - foreach
+ } // END - foreach
+ } // END - foreach
+ } // END - foreach
+ } // END - foreach
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ' - EXIT!');
+}