function get_slices_for_member($sa_url, $signer, $member_id, $is_member, $role = null) { $member_urn = get_member_urn(sa_to_ma_url($sa_url), $signer, $member_id); $client = XMLRPCClient::get_client($sa_url, $signer); if ($is_member) { $options = array(); if (!is_null($role)) { $options = array('match' => array('SLICE_ROLE' => $role)); } $options = array_merge($options, $client->options()); $results = $client->lookup_slices_for_member($member_urn, $client->creds(), $options); } else { // CHAPI: TODO: implement is_member = FALSE error_log("get_slices_for_member using is_member=false is unimplemented."); return array(); } // Convert columns from 'external' to 'internal' format $converted_results = array(); foreach ($results as $row) { $converted_row = array(SA_SLICE_MEMBER_TABLE_FIELDNAME::SLICE_ID => $row['SLICE_UID'], SA_SLICE_MEMBER_TABLE_FIELDNAME::ROLE => $row['SLICE_ROLE'], SA_SLICE_TABLE_FIELDNAME::EXPIRED => $row['EXPIRED']); $converted_row = convert_role($converted_row); $converted_results[] = $converted_row; } $results = $converted_results; // error_log("GSFM.RESULTS = " . print_r($results, true)); return $results; }
function get_projects_for_member($sa_url, $signer, $member_id, $is_member) { if (!is_object($signer)) { throw new InvalidArgumentException('Null signer'); } if (!$signer instanceof GeniUser) { /* Signer must be a GeniUser because we need its URN. */ throw new InvalidArgumentException('Signer is not a GeniUser'); } $client = XMLRPCClient::get_client($sa_url, $signer); $member_urn = get_member_urn(sa_to_ma_url($sa_url), $signer, $member_id); $rows = $client->lookup_projects_for_member($member_urn, $client->creds(), $client->options()); if ($is_member) { $project_uuids = array_map(function ($row) { return $row['PROJECT_UID']; }, array_values($rows)); return $project_uuids; } // if not a member $current = array(); foreach ($rows as $row) { if ($row['EXPIRED'] == false) { $current[] = $row; } } $project_uuids = array_map(function ($row) { return $row['PROJECT_UID']; }, array_values($current)); //print "<p> privatekey ".print_r($signer->privateKey(), true)."<\p>\n"; //print "<p> cert ".print_r($signer->certificate(), true)."<\p>\n"; $options = array('match' => array('PROJECT_EXPIRED' => "false"), 'filter' => array('PROJECT_UID')); $options = array_merge($options, $client->options()); $rows = $client->lookup_projects($client->creds(), $options); $all_uuids = array_map(function ($row) { return $row['PROJECT_UID']; }, array_values($rows)); return array_values(array_diff($all_uuids, $project_uuids)); }