function search_for_slices($term, $search_type, $signer, $ma_url, $sa_url) { if ($search_type == "urn") { if (is_valid_urn($term)) { // don't redirect to the error page if you can't find a slice global $put_message_result_handler; $put_message_result_handler = 'no_redirect_result_handler'; $results = lookup_slice_by_urn($sa_url, $signer, $term); } else { print "<p>Error: invalid URN</p>"; return array(); } if (count($results) > 0) { return lookup_slice_details($sa_url, $signer, array($results[0])); } else { return array(); } } else { if ($search_type == "owner_email") { $email_results = lookup_members_by_email($ma_url, $signer, array($term)); if (count($email_results) > 0) { $member_ids_arr = $email_results[$term]; $member_id = $member_ids_arr[0]; $slices = get_slices_for_member($sa_url, $signer, $member_id, true); $slice_ids = array(); foreach ($slices as $slice) { if ($slice[SA_SLICE_MEMBER_TABLE_FIELDNAME::ROLE] == CS_ATTRIBUTE_TYPE::LEAD && $slice[SA_SLICE_TABLE_FIELDNAME::EXPIRED] != 1) { $slice_ids[] = $slice[SA_SLICE_TABLE_FIELDNAME::SLICE_ID]; } } return lookup_slice_details($sa_url, $signer, $slice_ids); } else { return array(); } } else { print "<p>Error: searching by {$search_type} not yet implemented</p>"; return array(); } } }
function get_user_slice_info($user_id, $name, $signer) { $sa_url = get_first_service_of_type(SR_SERVICE_TYPE::SLICE_AUTHORITY); $slices = get_slices_for_member($sa_url, $signer, $user_id, true); $slice_data = "<b style='text-decoration: underline;'>{$name}'s slices</b><br>"; $slice_ids = array(); foreach ($slices as $slice) { $slice_ids[] = $slice[SA_SLICE_TABLE_FIELDNAME::SLICE_ID]; } $slice_info = lookup_slice_details($sa_url, $signer, $slice_ids); $active_slice_count = 0; foreach ($slice_info as $slice_urn => $slice_details) { if ($slice_details['expired'] != 1) { $slice_data .= "<b>Slice name: </b>" . $slice_details[SA_SLICE_TABLE_FIELDNAME::SLICE_NAME] . "<br>"; $slice_data .= "<b>Slice URN: </b>{$slice_urn}<br>"; $owner = $slice_details[SA_SLICE_TABLE_FIELDNAME::OWNER_ID] == $user_id ? "yes" : "no"; $slice_data .= "<b>Owner? </b>{$owner}<hr style='height: 1px; background-color: #5F584E; margin: 3px'>"; $active_slice_count++; } } if ($active_slice_count == 0) { $slice_data .= "<i>user has no slices</i>"; } return $slice_data; }