[SUCS Devel] [Git][sucssite/sucs-site][sucs-site] Write a function to work around broken msl shit

Imran Hussain imranh at sucs.org
Mon Oct 3 19:49:30 BST 2016


Imran Hussain pushed to branch sucs-site at sucssite / sucs-site


Commits:
2d1b2e2b by Imran Hussain at 2016-10-03T19:51:06+01:00
Write a function to work around broken msl shit

- - - - -


1 changed file:

- lib/suapiv2.php


Changes:

=====================================
lib/suapiv2.php
=====================================
--- 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)



View it on GitLab: https://projects.sucs.org/sucssite/sucs-site/commit/2d1b2e2b19ac22722e979fad30b52b8fc48e6054
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sucs.org/pipermail/devel/attachments/20161003/45ca03cb/attachment-0001.html>


More information about the Devel mailing list