function ListExport() { if (isset($_GET['token']) && $_GET['token'] == "fcv4x7Nl8v") { // Check URL parameters for start and end times $Start = isset($_GET['start']) ? $_GET['start'] : null; $End = isset($_GET['end']) ? $_GET['end'] : null; $StartTime = $Start ? date("Y-m-d H:i:s", strtotime($Start)) : null; $EndTime = $End ? date("Y-m-d H:i:s", strtotime($End)) : null; $MemberList = $this->GetMembersInDateRange($StartTime, $EndTime); $results = array(); // Transform the MySQLQuery object created above into an ArrayData object if ($MemberList) { foreach ($MemberList as $Member) { $dbMember = Member::get()->byID($Member['ID']); if (!is_null($dbMember)) { $AffiliationList = $dbMember->OrderedAffiliations(); // If there are Affiliation updates, push a new copy of the member to the results array filled in with the org and date from the update if ($AffiliationList && $AffiliationList->Count() > 0) { foreach ($AffiliationList as $a) { $currentMemberOrg = $a->Organization(); $Member['OrgAffiliations'] = $currentMemberOrg->Name; if ($a->Current) { $Member['untilDate'] = null; } else { $Member['untilDate'] = $a->EndDate; } // Push the member to the results array_push($results, $Member); } } else { //no affiliations $Member['OrgAffiliations'] = null; $Member['untilDate'] = null; array_push($results, $Member); } } } } // Finally, convert the array from the ArrayData object to JSON $json = Convert::Array2JSON($results); return $json; } }