コード例 #1
0
ファイル: pa_client.php プロジェクト: ahelsing/geni-portal
function change_member_role($sa_url, $signer, $project_id, $member_id, $role)
{
    $member_roles = array($member_id => $role);
    $result = modify_project_membership($sa_url, $signer, $project_id, array(), $member_roles, array());
    return $result;
}
コード例 #2
0
if (!isset($user) || is_null($user) || !$user->isActive()) {
    exit;
}
// This admin functionality is for OPERATORS only
if (!$user->isAllowed(CS_ACTION::ADMINISTER_MEMBERS, CS_CONTEXT_TYPE::MEMBER, null)) {
    exit;
}
$sa_url = get_first_service_of_type(SR_SERVICE_TYPE::SLICE_AUTHORITY);
$ma_url = get_first_service_of_type(SR_SERVICE_TYPE::MEMBER_AUTHORITY);
$signer = $user;
// Handle the request, determine which action to perform
if (array_key_exists('action', $_REQUEST)) {
    $action = $_REQUEST['action'];
    if ($action == "remove") {
        if (array_key_exists('project_id', $_REQUEST) && array_key_exists('member_id', $_REQUEST)) {
            modify_project_membership($sa_url, $signer, $_REQUEST['project_id'], array(), array(), array($_REQUEST['member_id']));
        } else {
            print "Insufficient information given to remove user";
            exit;
        }
    } else {
        if ($action == "disable") {
            if (array_key_exists('member_urn', $_REQUEST)) {
                disable_user($ma_url, $signer, $_REQUEST['member_urn']);
            }
        } else {
            print "No action requested";
            exit;
        }
    }
}
コード例 #3
0
function do_modify_project_membership($selections, $project_id, $project_members_by_role)
{
    global $user;
    global $sa_url;
    $members_to_add = array();
    $members_to_change_role = array();
    $members_to_remove = array();
    //  error_log("Selections = " . print_r($selections, true));
    //  error_log("PMBR = " . print_r($project_members_by_role, true));
    foreach ($selections as $member_id => $selection_id) {
        $is_member = array_key_exists($member_id, $project_members_by_role);
        if ($is_member) {
            $role = $project_members_by_role[$member_id];
            if ($selection_id == 0) {
                // Remove this member from this slice
                $members_to_remove[] = $member_id;
            } else {
                if ($selection_id != $role) {
                    // Change the role of this member on this slice
                    $members_to_change_role[$member_id] = $selection_id;
                }
            }
        } else {
            if ($selection_id > 0) {
                // Add member to slice
                $members_to_add[$member_id] = $selection_id;
            }
        }
    }
    // Publish changes atomically to SA
    $result = modify_project_membership($sa_url, $user, $project_id, $members_to_add, $members_to_change_role, $members_to_remove);
    return $result;
}