From 44dc89b9547e3716d5df6dda3b0442f4efb59414 Mon Sep 17 00:00:00 2001
From: Imran Hussain <imranh@sucs.org>
Date: Mon, 3 Oct 2016 19:50:27 +0100
Subject: [PATCH] Write a function to work around broken msl shit

---
 lib/suapiv2.php | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/lib/suapiv2.php b/lib/suapiv2.php
index b11c5fb..ea04bfb 100644
--- a/lib/suapiv2.php
+++ b/lib/suapiv2.php
@@ -31,12 +31,29 @@ $membership_data = $formated_raw_data["table1"]["table1_Product_Collection"]["ta
 
 // make a new array that just contains *every* member no matter what they bought
 $just_members = array();
-foreach ($membership_data as $typeOfMember) {
-	foreach ($typeOfMember["Detail_Collection"]["Detail"] as $member) {
-		array_push($just_members, $member["@attributes"]);
+
+function filter_array($data){
+	global $just_members;
+	// we have more than one type of member if this is true
+	if (count($data[0]["Detail_Collection"]["Detail"][0]["@attributes"]) == 7){
+		//split them up then feed them back
+		foreach ($data as $membershipType){
+		 	filter_array($membershipType);
+ 		}
+ 	// we have more then 1 of the same type of member if this is true
+ 	} else if (count($data["Detail_Collection"]["Detail"][0]["@attributes"]) == 7) {
+ 		//wack them onto the used array
+ 		foreach ($data["Detail_Collection"]["Detail"] as $member) {
+	 	 	array_push($just_members, $member["@attributes"]);
+ 	 	}
+  	// we have 1 member :(
+ 	} else if (count($data["Detail_Collection"]["Detail"]["@attributes"]) == 7) {
+		array_push($just_members, $data["Detail_Collection"]["Detail"]["@attributes"]);
 	}
 }
 
+filter_array($membership_data);
+
 /* You can now use $just_members to probe member detials. It's an array of arrays which each contain:
 * transaction_id (recepit id)
 * purchaser (full name)
-- 
GitLab