Example #1
0
function deleteGroupUser()
{
    $groupid = getContinuationVar("groupid");
    $userid = getContinuationVar("userid");
    $test = getUserUnityID($userid);
    if (!empty($test)) {
        deleteUserGroupMember($userid, $groupid);
    }
    editOrAddGroup(0);
}
Example #2
0
function XMLRPCremoveUsersFromGroup($name, $affiliation, $users)
{
    global $user, $findAffilFuncs;
    if (!in_array('groupAdmin', $user['privileges'])) {
        return array('status' => 'error', 'errorcode' => 16, 'errormsg' => 'access denied for managing user groups');
    }
    $validate = array('name' => $name, 'affiliation' => $affiliation);
    $rc = validateAPIgroupInput($validate, 1);
    if ($rc['status'] == 'error') {
        return $rc;
    }
    $query = "SELECT ownerid, " . "editusergroupid AS editgroupid " . "FROM usergroup " . "WHERE id = {$rc['id']}";
    $qh = doQuery($query, 101);
    if (!($row = mysql_fetch_assoc($qh))) {
        return array('status' => 'error', 'errorcode' => 18, 'errormsg' => 'user group with submitted name and affiliation does not exist');
    }
    # if not owner and not member of managing group, no access
    if ($user['id'] != $row['ownerid'] && !array_key_exists($row['editgroupid'], $user['groups'])) {
        return array('status' => 'error', 'errorcode' => 28, 'errormsg' => 'access denied to user group with submitted name and affiliation');
    }
    $fails = array();
    foreach ($users as $_user) {
        if (empty($_user)) {
            continue;
        }
        $esc_user = mysql_escape_string($_user);
        # check that affiliation of user can be determined because getUserlistID
        #   will abort if it can't find it
        $affilok = 0;
        foreach ($findAffilFuncs as $func) {
            if ($func($_user, $dump)) {
                $affilok = 1;
            }
        }
        if (!$affilok) {
            $fails[] = $_user;
            continue;
        }
        $userid = getUserlistID($esc_user, 1);
        if (is_null($userid)) {
            $fails[] = $_user;
        } else {
            deleteUserGroupMember($userid, $rc['id']);
        }
    }
    if (count($fails)) {
        $cnt = 'some';
        $code = 36;
        if (count($fails) == count($users)) {
            $cnt = 'any';
            $code = 37;
        }
        return array('status' => 'warning', 'failedusers' => $fails, 'warningcode' => $code, 'warningmsg' => "failed to remove {$cnt} users from user group");
    }
    return array('status' => 'success');
}