}
if (!$user->isAllowed(PA_ACTION::REMOVE_PROJECT_MEMBER, CS_CONTEXT_TYPE::PROJECT, $project_id) and !$user->isAllowed(PA_ACTION::CHANGE_MEMBER_ROLE, CS_CONTEXT_TYPE::PROJECT, $project_id)) {
    error_log($user->prettyName() . " not allowed to edit project membership for {$project_name}");
    relative_redirect("project.php?project_id={$project_id}");
}
$members = array();
foreach (array_keys($_REQUEST) as $input) {
    if ($input == "project_id" or $input == "submit" or $input == "edit") {
        continue;
    }
    $members[] = $input;
}
if (!isset($ma_url)) {
    $ma_url = get_first_service_of_type(SR_SERVICE_TYPE::MEMBER_AUTHORITY);
}
$member_names = lookup_member_names($ma_url, $user, $members);
$member_roles = get_project_members($sa_url, $user, $project_id);
$edits = array();
global $CS_ATTRIBUTE_TYPE_NAME;
foreach (array_keys($_REQUEST) as $input) {
    if ($input == "project_id" or $input == "submit" or $input == "edit") {
        continue;
    }
    $value = $_REQUEST[$input];
    $member_name = $member_names[$input];
    error_log("edit_project_membership: Requested {$value} for {$member_name} in project {$project_name}");
    foreach ($member_roles as $memberR) {
        if ($memberR['member_id'] == $input) {
            $member_id = $memberR['member_id'];
            $member_role_index = $memberR['role'];
            $member_role = $CS_ATTRIBUTE_TYPE_NAME[$member_role_index];
}
$selections = $_REQUEST;
// error_log("SELECTIONS = " . print_r($selections, true));
$project_details = lookup_project($sa_url, $user, $project_id);
if (!isset($project_details) or is_null($project_details)) {
    error_log("Couldn't find project by ID in do-handle-project-request: {$project_id}");
    //  $_SESSION['lasterror'] = "Project $project_id unknown";
    relative_redirect("home.php");
}
$project_name = $project_details[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");
}
$lead_id = $project_details[PA_PROJECT_TABLE_FIELDNAME::LEAD_ID];
$lead_name = lookup_member_names($ma_url, $user, array($lead_id));
$lead_name = $lead_name[$lead_id];
$num_members_added = 0;
$num_members_rejected = 0;
// If the member for this request is already a member of the given project, then cancel this request
$members = get_project_members($sa_url, $user, $project_id);
foreach ($selections as $select_id => $attribs) {
    if ($select_id == 'yesmessage' or $select_id == 'nomessage') {
        continue;
    }
    $attribs_parts = explode(',', $attribs);
    if (count($attribs_parts) < 4) {
        error_log("Malformed selection row in do-handle-project-request: {$select_id}={$attribs}");
        continue;
    }
    $role = $attribs_parts[0];
Example #3
0
function lookup_member_names_for_rows($ma_url, $signer, $rows, $field)
{
    if (sizeof($rows) == 0) {
        return array();
    }
    $member_uuids = array();
    foreach ($rows as $row) {
        $member_id = $row[$field];
        if ($member_id == $signer->account_id || in_array($member_id, $member_uuids)) {
            continue;
        }
        $member_uuids[] = $member_id;
    }
    $names_by_id = array();
    $result = generate_response(RESPONSE_ERROR::NONE, $names_by_id, '');
    if (count($member_uuids) > 0) {
        $names_by_id = lookup_member_names($ma_url, $signer, $member_uuids);
    }
    $names_by_id[$signer->account_id] = $signer->prettyName();
    return $names_by_id;
}