コード例 #1
0
ファイル: request_test.php プロジェクト: ahelsing/geni-portal
function test_requests_for_url($url, $context_type, $context_id)
{
    global $signer;
    $insert_result = create_request($url, $signer, $context_type, $context_id, RQ_REQUEST_TYPE::JOIN, 'foobar', '');
    error_log("IR = " . print_r($insert_result, true));
    $request_id = $insert_result;
    $rows = get_requests_for_context($url, $signer, $context_type, $context_id);
    dump_rows($rows);
    $rows = get_requests_by_user($url, $signer, $signer->account_id, $context_type, $context_id);
    dump_rows($rows);
    $row = get_request_by_id($url, $signer, $request_id, $context_type);
    dump_row($row);
    $num_pending = get_number_of_pending_requests_for_user($url, $signer, $signer->account_id, $context_type, $context_id);
    error_log("Num_pending(pre) = " . print_r($num_pending, true));
    $pending = get_pending_requests_for_user($url, $signer, $signer->account_id, $context_type, $context_id);
    dump_rows($pending);
    resolve_pending_request($url, $signer, $context_type, $request_id, RQ_REQUEST_STATUS::APPROVED, 'resolved');
    $num_pending = get_number_of_pending_requests_for_user($url, $signer, $signer->account_id, $context_type, $context_id);
    error_log("Num_pending(post) = " . print_r($num_pending, true));
}
コード例 #2
0
        $num_members_added = $num_members_added + 1;
        $resolution_description = "Added as " . $CS_ATTRIBUTE_TYPE_NAME[$role];
        if (array_key_exists('yesmessage', $_REQUEST)) {
            $yesm = $_REQUEST['yesmessage'];
            if (!is_null($yesm)) {
                $reason = $yesm;
            }
        }
        // This is an 'add' selection
        // Add member
        add_project_member($sa_url, $user, $project_id, $member_id, $role);
        // I _believe_ we'll have been redirected to the error page if the add fails
        // and send acceptance letter
    }
    // Resolve pending request
    resolve_pending_request($sa_url, $user, CS_CONTEXT_TYPE::PROJECT, $request_id, $resolution_status, $resolution_description);
    // FIXME: Do not send the rejection mail if the user is already in the project - ticket #410
    // FIXME: Allow the person rejecting your join request to edit/specify the email contents, so they can explain the rejection
    // -- ticket #876
    // Send acceptance/rejection letter
    $hostname = $_SERVER['SERVER_NAME'];
    $email_message = "Your request to join GENI project " . $project_name . " has been " . $resolution_status_label . " by " . $user->prettyName() . ".\n\n";
    if (isset($reason) && $reason != '') {
        $email_message = $email_message . "\n{$reason}\n\n";
    }
    $email_message = $email_message . "GENI Portal Operations";
    $headers = "Cc: " . $user->prettyEmailAddress() . "\r\nContent-Type: text/plain; charset=UTF-8\r\nContent-Transfer-Encoding: 8bit";
    mail($email_address, $email_subject, $email_message, $headers);
}
// end of loop over rows to process
$_SESSION['lastmessage'] = "Added {$num_members_added} members; Rejected {$num_members_rejected} members";
コード例 #3
0
$reason = null;
$error = null;
if (array_key_exists('submit', $_REQUEST)) {
    $submit = $_REQUEST['submit'];
    if (array_key_exists('reason', $_REQUEST)) {
        $reason = $_REQUEST['reason'];
    } else {
        error_log("cancel-p-req got no reason");
        $reason = "";
    }
}
// OK, inputs validated
// Handle form submission
if (isset($submit)) {
    // Cancel project join request
    $cancelres = resolve_pending_request($sa_url, $user, CS_CONTEXT_TYPE::PROJECT, $request_id, RQ_REQUEST_STATUS::CANCELLED, $reason);
    // FIXME: Handle result
    if (isset($cancelres) && is_array($cancelres) && array_key_exists('code', $cancelres)) {
        if ($cancelres['code'] == RESPONSE_ERROR::NONE) {
            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 {
            $_SESSION['lasterror'] = "Failed to cancel request: " . $cancelres['output'];
        }
    } else {
コード例 #4
0
    if ($user_is_project_member) {
        error_log("handle-p-req canceling open request for member to join a project they are already in. Request " . $request[RQ_REQUEST_TABLE_FIELDNAME::ID] . " for member " . $request[RQ_REQUEST_TABLE_FIELDNAME::REQUESTOR] . " to join project " . $request[RQ_REQUEST_TABLE_FIELDNAME::CONTEXT_ID]);
        resolve_pending_request($sa_url, $user, CS_CONTEXT_TYPE::PROJECT, $request[RQ_REQUEST_TABLE_FIELDNAME::ID], RQ_REQUEST_STATUS::CANCELLED, "User already in this project");
        continue;
    }
    // If we already have in newrs a request by the same member to join the same project, then cancel this request
    $dupid = NULL;
    foreach ($newrs as $newr) {
        if ($newr[RQ_REQUEST_TABLE_FIELDNAME::REQUESTOR] == $request[RQ_REQUEST_TABLE_FIELDNAME::REQUESTOR] && $newr[RQ_REQUEST_TABLE_FIELDNAME::CONTEXT_ID] == $request[RQ_REQUEST_TABLE_FIELDNAME::CONTEXT_ID]) {
            error_log("handle-p-req canceling duplicate request " . $request[RQ_REQUEST_TABLE_FIELDNAME::ID] . " == older request " . $newr[RQ_REQUEST_TABLE_FIELDNAME::ID] . " for member " . $request[RQ_REQUEST_TABLE_FIELDNAME::REQUESTOR] . " to join project " . $request[RQ_REQUEST_TABLE_FIELDNAME::CONTEXT_ID]);
            $dupid = $newr[RQ_REQUEST_TABLE_FIELDNAME::ID];
            break;
        }
    }
    if (!is_null($dupid)) {
        resolve_pending_request($sa_url, $user, CS_CONTEXT_TYPE::PROJECT, $request[RQ_REQUEST_TABLE_FIELDNAME::ID], RQ_REQUEST_STATUS::CANCELLED, "Duplicate of request " . $dupid);
        continue;
    }
    $newrs[] = $request;
}
$requests = $newrs;
if (count($requests) == 0) {
    relative_redirect('error-text.php?error=' . urlencode("All requests are invalid: only pending project join requests are handled here."));
}
$project = lookup_project($sa_url, $user, $project_id);
$project_name = $project[PA_PROJECT_TABLE_FIELDNAME::PROJECT_NAME];
if (!$user->isAllowed(PA_ACTION::ADD_PROJECT_MEMBER, CS_CONTEXT_TYPE::PROJECT, $project_id)) {
    error_log("User " . $user->prettyName() . " not allowed to handle project requests on this project " . $project_name);
    relative_redirect("home.php");
}
// OK, inputs validated