示例#1
0
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_project_slice_member_info($sa_url, $ma_url, $user, $allow_expired = False, $project_id = null)
{
    $member_ids = array();
    $slice_ids = array();
    $slice_objects = array();
    $project_objects = array();
    $member_objects = array();
    $project_slice_map = array();
    $project_activeslice_map = array();
    if (!is_null($project_id)) {
        $projects = array($project_id);
    } else {
        // This is all project IDs the member belongs to, even expired
        $projects = get_projects_for_member($sa_url, $user, $user->account_id, true);
    }
    if (count($projects) > 0) {
        // These are the details of these projects
        $project_objects = lookup_project_details($sa_url, $user, $projects);
        // We get back all the projects. But optionally filter out expired projects.
        if (!$allow_expired) {
            $unexpired_projects = array();
            $unexpired_project_objects = array();
            $now = new DateTime();
            foreach ($project_objects as $project) {
                $project_id = $project[PA_PROJECT_TABLE_FIELDNAME::PROJECT_ID];
                $project_expired = $project[PA_PROJECT_TABLE_FIELDNAME::EXPIRED];
                $project_name = $project[PA_PROJECT_TABLE_FIELDNAME::PROJECT_NAME];
                //	error_log("PEXP = " . $project_id . " " . $project_name .
                //      " " . $project_expired);
                if (convert_boolean($project_expired)) {
                    continue;
                }
                $unexpired_project_objects[] = $project;
                $unexpired_projects[] = $project_id;
            }
            $projects = $unexpired_projects;
            $project_objects = $unexpired_project_objects;
        }
        // At this point, $projects and $project_objects have all
        // the projects we're interested in: expired or not
        // Get all slices of which user is a member (expired or not)
        $slice_member_role_ids = get_slices_for_member($sa_url, $user, $user->account_id, True);
        $slice_member_ids = array();
        foreach ($slice_member_role_ids as $slice_member_role_id) {
            //NOTE: FOR NOW ONLY ALLOW UNEXPIRED SLICES
            if (!$slice_member_role_id[SA_SLICE_TABLE_FIELDNAME::EXPIRED]) {
                $slice_member_id = $slice_member_role_id[SA_SLICE_MEMBER_TABLE_FIELDNAME::SLICE_ID];
                $slice_member_ids[] = $slice_member_id;
            }
        }
        // $slice_member_ids is the ID's of slices to which the member belongs
        // This is indexed by project_id, containing an array of slice data
        // CHAPI: this doesn't generally work any more, since non-members aren't allowed
        // to get details for slices they aren't members of
        //$slice_data = get_slices_for_projects($sa_url, $user, $projects, $allow_expired);
        $slice_data = get_slices_in_projects($sa_url, $user, $slice_member_ids, $projects, $allow_expired);
        //    error_log("SLICE_MEMBER_IDS = " . print_r($slice_member_ids, true));
        //    error_log("SLICE_DATA =  = " . print_r($slice_data, true));
        //    error_log("PROJECTS = " . print_r($projects, true));
        foreach ($project_objects as $project) {
            $project_id = $project[PA_PROJECT_TABLE_FIELDNAME::PROJECT_ID];
            $proj_lead_id = $project[PA_PROJECT_TABLE_FIELDNAME::LEAD_ID];
            $proj_slices = $slice_data[$project_id];
            $member_ids[] = $proj_lead_id;
            $proj_slice_ids = array();
            $proj_activeslice_ids = array();
            foreach ($proj_slices as $proj_slice) {
                $proj_slice_id = $proj_slice[SA_SLICE_TABLE_FIELDNAME::SLICE_ID];
                $proj_slice_id_expired = $proj_slice[SA_SLICE_TABLE_FIELDNAME::EXPIRED];
                if (!in_array($proj_slice_id, $slice_member_ids)) {
                    continue;
                }
                $proj_slice_ids[] = $proj_slice_id;
                //error_log("slice id = ". $proj_slice_id . " expired = " . $proj_slice_id_expired);
                if (!$proj_slice_id_expired) {
                    //error_log("Adding active slice to list ....");
                    $proj_activeslice_ids[] = $proj_slice_id;
                }
                $owner_id = $proj_slice[SA_SLICE_TABLE_FIELDNAME::OWNER_ID];
                if (!in_array($owner_id, $member_ids)) {
                    $member_ids[] = $owner_id;
                }
                // Optionally filter out expired slices
                if (!convert_boolean($proj_slice_id_expired) || $allow_expired) {
                    $slice_objects[$proj_slice_id] = $proj_slice;
                }
            }
            //	$proj_slice_ids = lookup_slice_ids($sa_url, $user, $project_id);
            $project_slice_map[$project_id] = $proj_slice_ids;
            $project_activeslice_map[$project_id] = $proj_activeslice_ids;
            //error_log("GPSMI: project ".$project_id." ids = ".print_r($proj_activeslice_ids,true));
            $slice_ids = array_merge($slice_ids, $proj_slice_ids);
            // is this ok
        }
    }
    if (count($member_ids) > 0) {
        $member_objects = lookup_member_details($ma_url, $user, $member_ids);
    }
    //  error_log("SIDS = " . print_r($slice_ids, true));
    //  error_log("MIDS = " . print_r($member_ids, true));
    //  error_log("SMIDS = " . print_r($slice_member_ids, true));
    //  foreach($project_objects as $po) { error_log("PO = " . print_r($po, true)); }
    //  foreach($slice_objects as $so) { error_log("SO = " . print_r($so, true)); }
    //  foreach($member_objects as $mo) { error_log("MO = " . print_r($mo, true)); }
    //  error_log("PSM = " . print_r($project_slice_map, true));
    //  error_log("PASM = " . print_r($project_activeslice_map, true));
    // At this point, we should have
    // project_objects has all the projects to which the member belongs
    //    expired or not by request
    // slice_objects has all the slices to which the member belongs
    //    expired or not by request
    // member_objects
    //    all the members who are leads of slices or projects in previous lists
    return array($project_objects, $slice_objects, $member_objects, $project_slice_map, $project_activeslice_map);
}
示例#3
0
}
if ($member == "None") {
    show_header('GENI Portal: Slices');
    include "tool-breadcrumbs.php";
    print "<h2>Error: Couldn't find member</h2>";
    include "footer.php";
    exit;
}
// FIXME: Currently, get_slices_for_member requires that this user _BE_ the member
if ($user->account_id != $member_id) {
    error_log("attempt to do slice-member for different member");
    $_SESSION['lasterror'] = "You can't see someone else's slices.";
    relative_redirect('home.php');
}
//$slice_attribs = get_attributes($cs_url, $user, $member_id, CS_CONTEXT_TYPE::SLICE, $slice_id);
$slices_for_member = get_slices_for_member($sa_url, $user, $member_id, true, null);
//error_log("SLICE ATTRIBS = " . print_r($attributes, true));
show_header('GENI Portal: Slices');
include "tool-breadcrumbs.php";
print "<h1>GENI Slice: " . "<i>" . $slice_name . "</i>" . ", Member: " . "<i>" . $member_name . "</i>" . "</h1>\n";
print "<b>Slice Roles</b>";
print "\n<table>\n";
print "<tr><th>Slice</th><th>Role</th></tr>";
/*
foreach($slice_attribs as $attrib) {
  $slice_id = $attrib[CS_ASSERTION_TABLE_FIELDNAME::CONTEXT];
  $slice_link = "<a href=\"slice.php?slice_id=$slice_id\">" . $slice_name . "</a>";
  $role = $attrib[CS_ATTRIBUTE_TABLE_FIELDNAME::NAME];
  print("<tr><td>$slice_link</td><td>$role</td></tr>\n");
}
*/
示例#4
0
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;
}