Example #1
0
function log_action($op, $user, $agg, $slice = NULL, $rspec = NULL, $slice_id = NULL)
{
    $log_url = get_first_service_of_type(SR_SERVICE_TYPE::LOGGING_SERVICE);
    $user_id = $user->account_id;
    if (!is_array($agg)) {
        $aggs[] = $agg;
    } else {
        $aggs = $agg;
    }
    foreach ($aggs as $am) {
        $attributes['aggregate'] = $am;
        $msg = "{$op} at {$am}";
        if ($slice) {
            $msg .= " on {$slice}";
            $slice_attributes = get_attribute_for_context(CS_CONTEXT_TYPE::SLICE, $slice_id);
            $attributes = array_merge($attributes, $slice_attributes);
        }
        if ($rspec) {
            $attributes['rspec'] = $rspec;
        }
        $result = log_event($log_url, $user, $msg, $attributes);
    }
}
Example #2
0
*/
$retVal = create_sliver($am_urls, $user, $slice_users, $slice_credential, $slice_urn, $omni_invocation_dir, $slice['slice_id'], $bound_rspec, $stitch_rspec);
if ($retVal and $retVal != "Invalid AM URL" and $retVal != "Missing AM URL" and $retVal != "Missing slice credential") {
    // Really we want to come here if we spawned the process OK only
    // Set up link to results page
    $invoke_id = get_invocation_id_from_dir($omni_invocation_dir);
    $link = "sliceresource.php?invocation_user="******"&invocation_id={$invoke_id}&slice_id={$slice_id}";
    // if am_id specified, append it to link
    if (isset($am_id) && $am_id) {
        $link .= "&am_id={$am_id}";
    }
    $full_link = relative_url($link);
    // Write URL to 'Recent slice events' log
    $log_url = get_first_service_of_type(SR_SERVICE_TYPE::LOGGING_SERVICE);
    $project_attributes = get_attribute_for_context(CS_CONTEXT_TYPE::PROJECT, $slice['project_id']);
    $slice_attributes = get_attribute_for_context(CS_CONTEXT_TYPE::SLICE, $slice['slice_id']);
    $log_attributes = array_merge($project_attributes, $slice_attributes);
    if ($stitch_rspec) {
        log_event($log_url, $user, "Add resource request submitted for slice " . $slice_name . " from " . "stitching RSpec.<br><a href='{$full_link}'>Click here</a> for results.", $log_attributes);
    } else {
        log_event($log_url, $user, "Add resource request submitted for slice " . $slice_name . " at " . implode(", ", $am_names) . ".<br><a href='{$full_link}'>Click here</a> for results.", $log_attributes);
    }
    // Do redirection
    create_sliver_success($link, $full_link);
} else {
    $msg = "Failed to start an <tt>omni</tt> process.";
    if ($retVal == "Invalid AM URL" or $retVal == "Missing AM URL" or $retVal == "Missing slice credential") {
        $msg = $msg . " {$retVal}";
    }
    create_sliver_error($msg);
}
if (in_array($project_id, $rpids)) {
    error_log($user->prettyName() . " already requested to join project " . $project_id);
    $_SESSION['lasterror'] = "You already requested to join that project.";
    relative_redirect('home.php');
}
if (isset($message) && !is_null($message) && (!isset($error) || is_null($error))) {
    $request_id = create_request($sa_url, $user, CS_CONTEXT_TYPE::PROJECT, $project_id, RQ_REQUEST_TYPE::JOIN, $message);
    // FIXME: sub handle-project-request.php with handle-project-request.php?project_id=$project_id&member_id=$user->account_id&request_id=$request_id
    //  $ind = strpos($message, "handle-project-request.php");
    $hostname = $_SERVER['SERVER_NAME'];
    $message .= "To handle my request, go to the GENI Portal here:\nhttps://{$hostname}/secure/handle-project-request.php?project_id={$project_id}&member_id=" . $user->account_id . "&request_id={$request_id}\n\nRemember that when you approve this request, you agree to take\nresponsibility for my use of GENI resources within the project. \nYou should not approve unsolicited requests to join your project.\n\nThank you,\n" . $user->prettyName() . "\n";
    //  $message = substr_replace($message, "handle-project-request.php?project_id=" . $project_id . "&member_id=" . $user->account_id . "&request_id=" . $request_id, $ind, strlen("handle-project-request.php"));
    // Log the request
    // contexts include project and member
    $project_attributes = get_attribute_for_context(CS_CONTEXT_TYPE::PROJECT, $project_id);
    $member_attributes = get_attribute_for_context(CS_CONTEXT_TYPE::MEMBER, $user->account_id);
    $attributes = array_merge($project_attributes, $member_attributes);
    if (!isset($log_url)) {
        $log_url = get_first_service_of_type(SR_SERVICE_TYPE::LOGGING_SERVICE);
        if (!isset($log_url) || is_null($log_url) || $log_url == '') {
            error_log("Found no Log Service in SR!'");
        }
    }
    $name = $user->prettyName();
    if (isset($log_url)) {
        log_event($log_url, Portal::getInstance(), "{$name} requested to join project {$project_name}", $attributes);
    }
    // Send the email
    $prettyEmail = $user->prettyEmailAddress();
    $email = $user->email();
    if (count($admin_emails) > 0) {
            // log this
            $project_attributes = get_attribute_for_context(CS_CONTEXT_TYPE::PROJECT, $project_id);
            $member_attributes = get_attribute_for_context(CS_CONTEXT_TYPE::MEMBER, $member_id);
            $attributes = array_merge($project_attributes, $member_attributes);
            $log_url = get_first_service_of_type(SR_SERVICE_TYPE::LOGGING_SERVICE);
            log_event($log_url, Portal::getInstance(), "Canceled join request: {$member_name} in project {$project_name}", $attributes);
        } else {
            $_SESSION['lasterror'] = "Failed to cancel request: " . $cancelres['output'];
        }
    } else {
        if ($cancelres == 1) {
            error_log("cancel-p-req canceled add of {$member_name} to project {$project_name}");
            $_SESSION['lastmessage'] = "Canceled add of {$member_name} to project {$project_name}";
            // log this
            $project_attributes = get_attribute_for_context(CS_CONTEXT_TYPE::PROJECT, $project_id);
            $member_attributes = get_attribute_for_context(CS_CONTEXT_TYPE::MEMBER, $member_id);
            $attributes = array_merge($project_attributes, $member_attributes);
            $log_url = get_first_service_of_type(SR_SERVICE_TYPE::LOGGING_SERVICE);
            log_event($log_url, Portal::getInstance(), "Canceled join request: {$member_name} in project {$project_name}", $attributes);
        } else {
            error_log("cancel-p-req: malformed result from resolve_req: " . print_r($request));
            $_SESSION['lasterror'] = "Error cancelling request";
        }
    }
    relative_redirect('home.php');
}
show_header('GENI Portal: Projects');
include "tool-breadcrumbs.php";
print "<h2>Cancel Project Join Request</h2>\n";
print "Cancel Request to join project <b>{$project_name}</b>:<br/>\n";
print "<br/>\n";
 }
 if ($to === "") {
     if ($in_projects !== "") {
         print "<p class='warn'>Skipped email addresses of project members: {$in_projects}</p>\n";
     }
     if ($skips !== "") {
         print "<p class='warn'>Skipped invalid email addresses: {$skips}</p>\n";
     }
     exit;
 }
 $email = $user->email();
 $name = $user->prettyName();
 $headers = "Reply-To: {$email}" . "\r\n" . "From: \"{$name} (via the GENI Portal)\" <*****@*****.**>\r\nContent-Type: text/plain; charset=UTF-8\r\nContent-Transfer-Encoding: 8bit";
 mail($to, "Join my GENI project {$project_name}!", $message, $headers, "-f {$email}");
 // This tells sendmail directly to resend the envelope-sender, so the portal users gets bounces
 $attributes = get_attribute_for_context(CS_CONTEXT_TYPE::PROJECT, $project_id);
 $msg = "{$name} invited people to project {$project_name}: {$to}";
 $log_url = get_first_service_of_type(SR_SERVICE_TYPE::LOGGING_SERVICE);
 log_event($log_url, $user, $msg, $attributes);
 // Put up a page saying we invited them.
 print "<h1>Invite Someone to Project {$project_name}</h1>\n";
 print "<p>\n";
 print "<b>Sent</b> Project {$project_name} invitation to:<br/>\n" . "{$to}.</p>\n";
 if ($skips !== "") {
     print "<p class='warn'>Skipped invalid email addresses: {$skips}</p>\n";
 }
 if ($in_projects !== "") {
     print "<p class='warn'>Skipped email addresses of project members: {$in_projects}</p>\n";
 }
 $lines = explode("\r\n", $message);
 print "<p><b>Message</b>: </p><pre style='margin-left:80px;'>\n";