if (!in_array($sortorder, array('ASC', 'DESC'))) {
    $sortorder = 'ASC';
}
$pen_avail = range(0, 9);
if ($edit_user) {
    if ($action === 'insert-group') {
        $ret = gs_group_member_add($group, $edit_user);
        if (isGsError($ret)) {
            echo '<div class="errorbox">', $ret->getMsg(), '</div>', "\n";
        }
        sleep(1);
        //FIXME
        $action = 'view';
    }
    if ($action === 'remove-group') {
        $ret = gs_group_member_del($group, $edit_user);
        if (isGsError($ret)) {
            echo '<div class="errorbox">', $ret->getMsg(), '</div>', "\n";
        }
        sleep(1);
        //FIXME
        $action = 'view';
    }
    $uid = (int) $DB->executeGetOne('SELECT `id` FROM `users` WHERE `user`=\'' . $DB->escape($edit_user) . '\'');
    if ($uid == 0) {
        echo '<div class="errorbox">', "Error. User not Found.", '</div>', "\n";
    }
    $groups = gs_group_info_get(false, 'user');
    $groups_my = gs_group_members_groups_get(array($uid), 'user', false);
}
if ($action === 'del') {
                }
            } else {
                if (in_array($section['id'], $group_members)) {
                    gs_group_member_del($group_id, $section['id']);
                }
            }
        }
        if (array_key_exists('sub', $section)) {
            foreach ($section['sub'] as $module) {
                if (array_key_exists('m' . $module['id'], $_REQUEST) && (int) $_REQUEST['m' . $module['id']] == 1) {
                    if (!in_array($module['id'], $group_members)) {
                        gs_group_member_add($group_id, $module['id']);
                    }
                } else {
                    if (in_array($module['id'], $group_members)) {
                        gs_group_member_del($group_id, $module['id']);
                    }
                }
            }
        }
    }
    $action = '';
}
if ($action == 'edit' && $group_id > 0) {
    $group_members = gs_group_members_get(array($group_id));
    ?>
<table cellspacing="1">
<thead>
<tr>
	<th style="min-width:12em;"><?php 
    echo __('Abschnitt');
####################################################################
#                              groups {
###################################################################
if ($action === 'insert-group') {
    $queue_name = $DB->executeGetOne('SELECT `name` FROM `ast_queues` WHERE ' . '`_id`=' . $queue_id);
    $ret = gs_group_member_add($group, $queue_name);
    if (isGsError($ret)) {
        echo '<div class="errorbox">', $ret->getMsg(), '</div>', "\n";
    }
    sleep(1);
    //FIXME
    $action = 'edit';
}
if ($action === 'remove-group') {
    $queue_name = $DB->executeGetOne('SELECT `name` FROM `ast_queues` WHERE ' . '`_id`=' . $queue_id);
    $ret = gs_group_member_del($group, $queue_name);
    if (isGsError($ret)) {
        echo '<div class="errorbox">', $ret->getMsg(), '</div>', "\n";
    }
    sleep(1);
    //FIXME
    $action = 'edit';
}
####################################################################
#                              groups }
###################################################################
####################################################################
#                              static_agents {
###################################################################
if ($action === 'delstatic') {
    if ($queue_id > 0 && $agent_id > 0) {
    if (isGsError($ret)) {
        echo '<div class="errorbox">', $ret->getMsg(), '</div>', "\n";
    } elseif (!$ret) {
        echo '<div class="errorbox">', __('Mitglied konnte nicht hinzugef&uuml;gt werden.'), '</div>', "\n";
    }
    sleep(1);
    // FIXME
    $action = 'edit';
    # view
}
#####################################################################
# remove member from a group
#####################################################################
if ($action === 'remove-member') {
    $pg_member = trim(@$_REQUEST['member']);
    $ret = gs_group_member_del($group_id, $pg_member);
    if (isGsError($ret)) {
        echo '<div class="errorbox">', $ret->getMsg(), '</div>', "\n";
    } elseif (!$ret) {
        echo '<div class="errorbox">', __('Mitglied konnte nicht entfernt werden.'), '</div>', "\n";
    }
    sleep(1);
    // FIXME
    $action = 'edit';
    # view
}
#####################################################################
# add connection
#####################################################################
if ($action === 'insert-connection') {
    $external = trim(@$_REQUEST['external']);