function get_project_info($slice, $signer, $ma_url, $sa_url) { $project_id = $slice[SA_SLICE_TABLE_FIELDNAME::PROJECT_ID]; $project_details = lookup_project($sa_url, $signer, $project_id); $project_name = $project_details[PA_PROJECT_TABLE_FIELDNAME::PROJECT_NAME]; $project_expiration = dateUIFormat($project_details[PA_PROJECT_TABLE_FIELDNAME::EXPIRATION]); $project_description = $project_details[PA_PROJECT_TABLE_FIELDNAME::PROJECT_PURPOSE]; $project_lead_id = $project_details[PA_PROJECT_TABLE_FIELDNAME::LEAD_ID]; $project_lead_detail_list = lookup_member_details($ma_url, $signer, array($project_lead_id)); $project_lead_details = $project_lead_detail_list[$project_lead_id]; $member = new Member($project_lead_id); $member->init_from_record($project_lead_details); $project_lead_name = $member->prettyName(); $project_lead_email = $project_lead_details[MA_ATTRIBUTE_NAME::EMAIL_ADDRESS]; $mailto_link = "<a href='mailto:{$project_lead_email}'>{$project_lead_email}</a>"; $project_lead_number = $project_lead_details[MA_ATTRIBUTE_NAME::TELEPHONE_NUMBER]; $project_info = "<b style='text-decoration: underline;'>Parent project</b><br>"; $project_info .= "<b>Name: </b>{$project_name}<br>" . "<b>Expiration: </b>{$project_expiration}<br>" . "<b>Description: </b>{$project_description}<br>" . "<b>Lead Name: </b>{$project_lead_name}<br>" . "<b>Lead Email: </b>{$mailto_link}<br>" . "<b>Lead Phone: </b>{$project_lead_number}"; return $project_info; }
function list_slice($slice, $user) { global $project_objects, $slice_owner_names; global $base_url, $slice_base_url, $listres_base_url, $resource_base_url; global $delete_sliver_base_url; global $gemini_base_url, $labwiki_base_url; global $disabled, $jfed_button_start, $jfed_button_part2; global $sa_url, $user; global $portal_max_slice_renewal_days; $slice_id = $slice[SA_SLICE_TABLE_FIELDNAME::SLICE_ID]; $slice_urn = $slice[SA_ARGUMENT::SLICE_URN]; $slice_expired = false; if (array_key_exists(SA_SLICE_TABLE_FIELDNAME::EXPIRED, $slice)) { $slice_expired = $slice[SA_SLICE_TABLE_FIELDNAME::EXPIRED]; } $disable_buttons_str = ""; if (isset($slice_expired) && convert_boolean($slice_expired)) { $disable_buttons_str = "disabled"; } $slice_name = $slice[SA_ARGUMENT::SLICE_NAME]; $args['slice_id'] = $slice_id; $query = http_build_query($args); $slice_url = $slice_base_url . $query; print "<tr class='slicetablerow'><td><a href='{$slice_url}'>{$slice_name}</a></td>"; $slice_project_id = $slice[SA_ARGUMENT::PROJECT_ID]; // There's an odd edge case in which a project has expired // but some slice of the project has not. In this case, $project_objects may not // contain the project of the slice. If so, list the project using something else. if (!array_key_exists($slice_project_id, $project_objects)) { $slice_project_name = "-Expired Project-"; $project_expiration = ""; } else { $project = $project_objects[$slice_project_id]; $project_expiration = $project[PA_PROJECT_TABLE_FIELDNAME::EXPIRATION]; $slice_project_name = $project[PA_PROJECT_TABLE_FIELDNAME::PROJECT_NAME]; } print "<td><a href='project.php?project_id={$slice_project_id}'>{$slice_project_name}</a></td>"; // Slice owner name $slice_owner_id = $slice[SA_ARGUMENT::OWNER_ID]; $slice_owner_name = $slice_owner_names[$slice_owner_id]; print "<td>{$slice_owner_name}</td>"; // Slice expiration $slice_exp_date = $slice[SA_ARGUMENT::EXPIRATION]; $slice_exp_hours = get_time_diff($slice_exp_date); $slice_exp_str = dateUIFormat($slice_exp_date); $slice_exp_pretty_str = "In <b>" . get_time_diff_string($slice_exp_hours) . "</b>"; $slice_exp_color = get_urgency_color($slice_exp_hours); $slice_exp_icon = get_urgency_icon($slice_exp_hours); print "<td><span title='{$slice_exp_str}'>{$slice_exp_pretty_str} "; print "<i class='material-icons' style='color:{$slice_exp_color}; font-size: 18px;'>{$slice_exp_icon}</i></span></td>"; // Next resource expiration $slivers = lookup_sliver_info_by_slice($sa_url, $user, $slice_urn); $resource_count = count($slivers); if ($resource_count == 0) { $resource_exp_str = ""; $resource_exp_pretty_str = "<i>No resources</i>"; $resource_exp_color = "#5F584E"; $resource_exp_icon = ""; $resource_exp_hours = 1000000; } else { $first_sliver = reset($slivers); $next_exp = new DateTime($first_sliver[SA_SLIVER_INFO_TABLE_FIELDNAME::SLIVER_INFO_EXPIRATION]); foreach ($slivers as $sliver) { $this_date = new DateTime($sliver[SA_SLIVER_INFO_TABLE_FIELDNAME::SLIVER_INFO_EXPIRATION]); if ($next_exp > $this_date) { $next_exp = $this_date; } } $resource_exp_str = dateUIFormat($next_exp); $resource_exp_hours = get_time_diff($resource_exp_str); $resource_exp_pretty_str = "In <b>" . get_time_diff_string($resource_exp_hours) . "</b>"; $resource_exp_color = get_urgency_color($resource_exp_hours); $resource_exp_icon = get_urgency_icon($resource_exp_hours); } print "<td><span title='{$resource_exp_str}'>{$resource_exp_pretty_str} "; print "<i class='material-icons' style='color:{$resource_exp_color}; font-size: 18px;'>{$resource_exp_icon}</i></span></td>"; // Slice actions $add_url = $resource_base_url . $query; $remove_url = $delete_sliver_base_url . $query; $listres_url = $listres_base_url . $query; $gemini_url = $gemini_base_url . $query; $labwiki_url = $labwiki_base_url . $query; print "<td style='text-align: center;'>"; print "<ul class='selectorcontainer slicetableactions' style='margin: 0px;'><li class='has-sub selector' style='float:none;'>"; print "<span class='selectorshown'>Actions</span><ul class='submenu'>"; print "<li><a href='{$slice_url}'>Manage slice</a></li>"; if ($user->isAllowed(SA_ACTION::ADD_SLIVERS, CS_CONTEXT_TYPE::SLICE, $slice_id)) { print "<li><a href='{$add_url}'>Add resources</a></li>"; } $dashboard_max_renewal_days = 7; $renewal_days = min($dashboard_max_renewal_days, $portal_max_slice_renewal_days); if ($project_expiration) { $project_expiration_dt = new DateTime($project_expiration); $now_dt = new DateTime(); $difference = $project_expiration_dt->diff($now_dt); $renewal_days = $difference->days; $renewal_days = min($renewal_days, $portal_max_slice_renewal_days, $dashboard_max_renewal_days); } $slivers = lookup_sliver_info_by_slice($sa_url, $user, $slice_urn); $renewal_hours = 24 * $renewal_days; $disable_renewal = ""; if ($slice_exp_hours > $renewal_hours && $resource_exp_hours > $renewal_hours) { $disable_renewal = "class='disabledaction'"; } if ($resource_count > 0) { print "<li><a {$disable_renewal} onclick='renew_slice(\"{$slice_id}\", {$renewal_days}, {$resource_count}, {$slice_exp_hours}, {$resource_exp_hours});'>Renew resources ({$renewal_days} days)</a></li>"; if ($user->isAllowed(SA_ACTION::GET_SLICE_CREDENTIAL, CS_CONTEXT_TYPE::SLICE, $slice_id)) { print "<li><a onclick='info_set_location(\"{$slice_id}\", \"{$listres_url}\")'>Resource details</a></li>"; } if ($user->isAllowed(SA_ACTION::DELETE_SLIVERS, CS_CONTEXT_TYPE::SLICE, $slice_id)) { print "<li><a onclick='info_set_location(\"{$slice_id}\", \"{$remove_url}\")'>Delete resources</a></li>"; } } print "</ul></li></ul>"; print "</td></tr>\n"; }
function get_next_resource_expiration($slivers) { if (count($slivers) == 0) { $next_exp = ""; } else { $first_sliver = reset($slivers); $next_exp = new DateTime($first_sliver[SA_SLIVER_INFO_TABLE_FIELDNAME::SLIVER_INFO_EXPIRATION]); foreach ($slivers as $sliver) { $this_date = new DateTime($sliver[SA_SLIVER_INFO_TABLE_FIELDNAME::SLIVER_INFO_EXPIRATION]); if ($next_exp > $this_date) { $next_exp = $this_date; } } } return $next_exp == "" ? "" : dateUIFormat($next_exp); }
function get_homepage_log_table() { global $user; global $num_hours; global $log_url; $entries = get_log_entries_for_context($log_url, $user, CS_CONTEXT_TYPE::MEMBER, $user->account_id, $num_hours); $new_entries = get_log_entries_by_author($log_url, $user, $user->account_id, $num_hours); $entries = array_merge($entries, $new_entries); $messages = array(); $logs = array(); if (is_array($entries) && count($entries) > 0) { foreach ($entries as $entry) { $msg = $entry[LOGGING_TABLE_FIELDNAME::EVENT_TIME] . $entry[LOGGING_TABLE_FIELDNAME::MESSAGE]; if (!in_array($msg, $messages)) { $messages[] = $msg; $logs[$msg] = $entry; } } krsort($logs); foreach ($logs as $msg => $entry) { $rawtime = $entry[LOGGING_TABLE_FIELDNAME::EVENT_TIME]; $message = $entry[LOGGING_TABLE_FIELDNAME::MESSAGE]; $time = dateUIFormat($rawtime); print "<tr><td>{$time}</td><td>{$message}</td></tr>\n"; } } else { print "<tr><td></td><td><i>No messages.</i></td><td></td></tr>\n"; } }
print "<br/>\n"; print "<h3>Projects you Asked to Join</h3>\n"; print "Found " . count($reqs) . " outstanding project join request(s) by you:<br/>\n"; print "<div class='tablecontainer'>"; print "<table>\n"; // Could add a cancel button? print "<tr><th>Project Name</th><th>Project Lead</th><th>Project Purpose</th><th>Request Created</th><th>Request Reason</th><th>Cancel Request</th></tr>\n"; foreach ($reqs as $request) { // Print it out $project_id = $request['context_id']; $project = $projects[$project_id]; $project_name = $project[PA_PROJECT_TABLE_FIELDNAME::PROJECT_NAME]; $purpose = $project[PA_PROJECT_TABLE_FIELDNAME::PROJECT_PURPOSE]; $reason = $request['request_text']; if (strlen($reason) > 45) { $reason = substr($reason, 0, 40) . '...'; } $req_date_db = $request['creation_timestamp']; $req_date = dateUIFormat($req_date_db); $lead_id = $project[PA_PROJECT_TABLE_FIELDNAME::LEAD_ID]; $lead_name = $project_lead_names[$lead_id]; $cancel_url = "cancel-join-project.php?request_id=" . $request[RQ_REQUEST_TABLE_FIELDNAME::ID]; $cancel_button = "<button style=\"\" onClick=\"window.location='" . $cancel_url . "'\"><b>Cancel Request</b></button>"; print "<tr><td>{$project_name}</td><td>{$lead_name}</td><td>{$purpose}</td><td>{$req_date}</td><td>{$reason}</td><td>{$cancel_button}</td></tr>\n"; } print "</table>\n"; print "</div>"; print "<br/><br/>\n"; } else { print "<div class='announce'><p>No outstanding project join requests by you.</p></div>\n"; }
unset($slice); include "tool-lookupids.php"; if (!$user->isAllowed(SA_ACTION::LOOKUP_SLICE, CS_CONTEXT_TYPE::SLICE, $slice_id)) { relative_redirect('home.php'); } if (isset($slice)) { /* $pretty_result = print_r($slice, true); */ /* error_log("fetch_slice result: $pretty_result\n"); */ // $slice_name = $slice[SA_ARGUMENT::SLICE_NAME]; // error_log("slice_name result: $slice_name\n"); $slice_expiration_db = $slice[SA_ARGUMENT::EXPIRATION]; $slice_expiration = dateUIFormat($slice_expiration_db); $slice_urn = $slice[SA_ARGUMENT::SLICE_URN]; // error_log("slice_urn result: $slice_urn\n"); $slice_creation_db = $slice[SA_ARGUMENT::CREATION]; $slice_creation = dateUIFormat($slice_creation_db); $slice_description = $slice[SA_ARGUMENT::SLICE_DESCRIPTION]; $slice_owner_id = $slice[SA_ARGUMENT::OWNER_ID]; $owner = $user->fetchMember($slice_owner_id); $slice_owner_name = $owner->prettyName(); $owner_email = $owner->email(); // error_log("slice_project_id result: $slice_project_id\n"); /* error_log("project result: $project\n"); */ // $slice_project_name = $project[PA_PROJECT_TABLE_FIELDNAME::PROJECT_NAME]; // error_log("slice project_name result: $project_name\n"); $proj_url = 'project.php?project_id=' . $slice_project_id; $slice_own_url = 'slice-member.php?member_id=' . $slice_owner_id . "&slice_id=" . $slice_id; } else { error_log("No slice to edit"); relative_redirect("home.php"); }
if (array_key_exists("slice_expiration", $_REQUEST)) { $req_exp = dateUIFormat($_REQUEST["slice_expiration"]); } else { relative_redirect('slice.php?slice_id=' . $slice_id); } if (isset($slice)) { $old_slice_expiration = dateUIFormat($slice[SA_ARGUMENT::EXPIRATION]); } $res = renew_slice($sa_url, $user, $slice_id, $req_exp); //error_log("Renew Slice output = " . $res); if ($res) { // get the new slice expiration $res = "Renewed slice (requested {$req_exp}, was {$old_slice_expiration})"; unset($slice); $slice = lookup_slice($sa_url, $user, $slice_id); $slice_expiration = dateUIFormat($slice[SA_ARGUMENT::EXPIRATION]); } else { $res = "FAILed to renew slice (requested {$req_exp}, was {$old_slice_expiration})"; $slice_expiration = $old_slice_expiration; } $res = $res . " - slice expiration is now: <b>{$slice_expiration}</b>\n"; $header = "Renewed Slice {$slice_name}"; show_header('GENI Portal: Slices'); include "tool-breadcrumbs.php"; print "<h2>{$header}</h2>\n"; print "<div>"; print_r($res); print "</div>"; print "<hr/>"; print "<p><a href='dashboard.php#slices'>Back to All slices</a>"; print "<br/>";
if (array_key_exists("result", $_GET)) { $result = $_GET['result']; if (!is_null($result) && $result != '') { $result = " (" . $result . ")"; } } include "tool-lookupids.php"; if (!is_null($project) && $project != "None") { $purpose = $project[PA_PROJECT_TABLE_FIELDNAME::PROJECT_PURPOSE]; $creation_db = $project[PA_PROJECT_TABLE_FIELDNAME::CREATION]; $creation = dateUIFormat($creation_db); $expiration_db = $project[PA_PROJECT_TABLE_FIELDNAME::EXPIRATION]; $project_urn = $project['project_urn']; $expired = $project[PA_PROJECT_TABLE_FIELDNAME::EXPIRED]; if ($expiration_db) { $expiration = dateUIFormat($expiration_db); } else { $expiration = "<i>None</i>"; } $leadid = $project[PA_PROJECT_TABLE_FIELDNAME::LEAD_ID]; if (uuid_is_valid($leadid)) { $lead = $user->fetchMember($leadid); $leademail = $lead->email(); $leadname = $lead->prettyName(); } else { error_log("project.php: Invalid project lead id from DB for project {$project_name}"); } } else { $_SESSION['lasterror'] = "No project specified for project page"; relative_redirect('dashboard.php#projects'); }
// If you didn't specify a time, use min of end of day, slice expiration $desired_array = date_parse($desired_expiration); if ($desired_array["hour"] == 0 and $desired_array["minute"] == 0 and $desired_array["second"] == 0 and $desired_array["fraction"] == 0) { $sliceexp_array = date_parse($slice[SA_ARGUMENT::EXPIRATION]); if ($desired_array["year"] == $sliceexp_array["year"] and $desired_array["month"] == $sliceexp_array["month"] and $desired_array["day"] == $sliceexp_array["day"]) { $desired_expiration = $slice[SA_ARGUMENT::EXPIRATION]; } else { // renew for the end of the day $desired_expiration = $desired_expiration . " 23:59:59"; } } } // what to send to the AM(s) $rfc3339_expiration = rfc3339Format($desired_expiration); // what to display to the user $ui_expiration = dateUIFormat($desired_expiration); } else { no_time_error(); } // Takes an arg am_id which may have multiple values. Each is treated // as the ID from the DB of an AM which should be queried // If no such arg is given, then query the DB and query all registered AMs if (!isset($ams) || is_null($ams)) { // Didnt get an array of AMs if (!isset($am) || is_null($am)) { // Nor a single am $ams = get_services_of_type(SR_SERVICE_TYPE::AGGREGATE_MANAGER); } else { $ams = array(); $ams[] = $am; }
// --- ?> <h2 id="recent_actions">Recent Slice Actions</h2> <table> <tr> <th>Time</th> <th>Message</th> <th>Member</th> <?php $log_url = get_first_service_of_type(SR_SERVICE_TYPE::LOGGING_SERVICE); $entries = get_log_entries_for_context($log_url, $user, CS_CONTEXT_TYPE::SLICE, $slice_id); $entry_member_names = lookup_member_names_for_rows($ma_url, $user, $entries, LOGGING_TABLE_FIELDNAME::USER_ID); usort($entries, 'compare_log_entries'); foreach ($entries as $entry) { $message = $entry[LOGGING_TABLE_FIELDNAME::MESSAGE]; $time = dateUIFormat($entry[LOGGING_TABLE_FIELDNAME::EVENT_TIME]); $member_id = $entry[LOGGING_TABLE_FIELDNAME::USER_ID]; $member_name = $entry_member_names[$member_id]; // error_log("ENTRY = " . print_r($entry, true)); // print "<tr><td>$time</td><td>$message</td><td><a href=\"slice-member.php?slice_id=" . $slice_id . "&member_id=$member_id\">$member_name</a></td></tr>\n"; // FIXME: Want a mailto link print "<tr><td>{$time}</td><td>{$message}</td><td>{$member_name}</td></tr>\n"; } ?> </table> <?php include "footer.php";
$ma_url = get_first_service_of_type(SR_SERVICE_TYPE::MEMBER_AUTHORITY); $conn = portal_conn(); $sql = "SELECT *" . " FROM lead_request WHERE status='open'"; $rows = db_fetch_rows($sql, "fetch all lead requests for admin page"); $lead_requests = $rows[RESPONSE_ARGUMENT::VALUE]; $requester_uuids = array(); foreach ($lead_requests as $lead_request) { $requester_uuids[] = $lead_request['requester_uuid']; } $requester_details = lookup_member_details($ma_url, $user, $requester_uuids); print "<table><tr><th>Name</th><th>Link</th><th>Requested At</th><th>Email</th><th>Admin Notes</th><th>Actions</th></tr>"; $open_requests = 0; foreach ($lead_requests as $lead_request) { $requester_uuid = $lead_request['requester_uuid']; $notes = $lead_request['notes'] == "" ? "None" : $lead_request['notes']; $timestamp = dateUIFormat($lead_request['request_ts']); $request_id = $lead_request['id']; $details = $requester_details[$requester_uuid]; make_user_info_rows($details, $requester_uuid, $request_id, $notes, $timestamp); $open_requests++; } // Returns what's between the '@' and the "." in a user's affiliation. Likely their school/ institution function get_school($affiliation) { if ($affiliation == NULL) { return ""; } $tmp = explode("@", $affiliation); if (count($tmp) == 1) { return $affiliation; }
function setup_jacks_slice_context() { global $user; global $slice; global $slice_id; global $slice_name; global $ma_url; global $sa_url; global $all_ams; global $slice_ams; global $slice_urn; global $slice_expiration; // Set globals for variables used in slice jacks page later global $owner_email; global $slice_date_expiration; global $member_names; global $slice_creation; global $slice_desc; global $slice_owner_name; global $members; unset($slice); include "tool-lookupids.php"; if (!isset($sa_url)) { $sa_url = get_first_service_of_type(SR_SERVICE_TYPE::SLICE_AUTHORITY); } if (!isset($ma_url)) { $ma_url = get_first_service_of_type(SR_SERVICE_TYPE::MEMBER_AUTHORITY); } if (isset($slice)) { $slice_name = $slice[SA_ARGUMENT::SLICE_NAME]; // error_log("SLICE = " . print_r($slice, true)); $slice_desc = $slice[SA_ARGUMENT::SLICE_DESCRIPTION]; $slice_creation_db = $slice[SA_ARGUMENT::CREATION]; $slice_creation = dateUIFormat($slice_creation_db); $slice_expiration_db = $slice[SA_ARGUMENT::EXPIRATION]; $slice_expiration = dateUIFormat($slice_expiration_db); $slice_date_expiration = dateOnlyUIFormat($slice_expiration_db); $slice_urn = $slice[SA_ARGUMENT::SLICE_URN]; $slice_owner_id = $slice[SA_ARGUMENT::OWNER_ID]; $owner = $user->fetchMember($slice_owner_id); $slice_owner_name = $owner->prettyName(); $owner_email = $owner->email(); $project_name = $project[PA_PROJECT_TABLE_FIELDNAME::PROJECT_NAME]; //error_log("slice project_name result: $project_name\n"); // Fill in members of slice member table $members = get_slice_members($sa_url, $user, $slice_id); $member_names = lookup_member_names_for_rows($ma_url, $user, $members, SA_SLICE_MEMBER_TABLE_FIELDNAME::MEMBER_ID); //find only ams that slice has resources on $slivers = lookup_sliver_info_by_slice($sa_url, $user, $slice_urn); //find aggregates to be able to return just am_id $all_aggs = get_services_of_type(SR_SERVICE_TYPE::AGGREGATE_MANAGER); $aggs_with_resources = array(); //do the comparison and find ams foreach ($slivers as $sliver) { foreach ($all_aggs as $agg) { if ($sliver[SA_SLIVER_INFO_TABLE_FIELDNAME::SLIVER_INFO_AGGREGATE_URN] == $agg[SR_TABLE_FIELDNAME::SERVICE_URN]) { $aggs_with_resources[] = $agg[SR_TABLE_FIELDNAME::SERVICE_ID]; break; } } } //return unique ids $slice_ams = array_unique($aggs_with_resources, SORT_REGULAR); // Now restore the array to a numerically ordered array because // array_unique preserves keys, so it could turn into, in effect, a // dictionary. $slice_ams = array_values($slice_ams); } else { print "Unable to load slice<br/>\n"; $_SESSION['lasterror'] = "Unable to load slice"; relative_redirect("home.php"); exit; } if (!isset($all_ams)) { $am_list = get_services_of_type(SR_SERVICE_TYPE::AGGREGATE_MANAGER); $all_ams = array(); foreach ($am_list as $am) { $single_am = array(); $service_id = $am[SR_TABLE_FIELDNAME::SERVICE_ID]; $single_am['name'] = $am[SR_TABLE_FIELDNAME::SERVICE_NAME]; $single_am['url'] = $am[SR_TABLE_FIELDNAME::SERVICE_URL]; $single_am['urn'] = $am[SR_TABLE_FIELDNAME::SERVICE_URN]; $all_ams[$service_id] = $single_am; } } }