$imported_plugins = get_checked_plugins($_POST);
    list($name, $descr, $plugins) = validate_post_params($conn, POST('name'), POST('descr'), POST('sids'), $imported_plugins);
    // Insert section
    //
    $group_id = Util::uuid();
    Plugin_group::insert($conn, $group_id, $name, $descr, $plugins, $imported_plugins);
    header("Location: modifyplugingroupsform.php?action=edit&id={$group_id}");
    exit;
    //
    // Edit group
    //
} elseif (GET('action') == 'edit') {
    //print_r(POST('sids'));
    //print_r($_SESSION);
    $imported_plugins = get_checked_plugins($_POST);
    list($name, $descr, $plugins) = validate_post_params($conn, POST('name'), POST('descr'), POST('sids'), $imported_plugins);
    $group_id = GET('id');
    ossim_valid($group_id, OSS_HEX, 'illegal:ID');
    if (ossim_error()) {
        die(ossim_error());
    }
    Plugin_group::edit($conn, $group_id, $name, $descr, $plugins, $imported_plugins);
    if (intval(POST('pluginid')) > 0) {
        header("Location: modifyplugingroupsform.php?action=edit&id={$group_id}");
        exit;
    }
    if (intval(POST('redirec')) == 1) {
        header("Location: modifyplugingroupsform.php?action=edit&id={$group_id}");
        exit;
    }
    //
if (GET('action') == 'new') {
    $imported_plugins = get_checked_plugins($_POST);
    list($group_id, $name, $descr, $plugins, $error) = validate_post_params($conn, POST('name'), POST('descr'), POST('sids'), $imported_plugins);
    if (empty($error)) {
        // Insert section
        //
        $group_id = Util::uuid();
        Plugin_group::insert($conn, $group_id, $name, $descr, $plugins, $imported_plugins);
        $location = "modifyplugingroupsform.php?action=edit&id={$group_id}";
    } else {
        $location = "modifyplugingroupsform.php?action=new";
    }
} else {
    if (GET('action') == 'edit') {
        $imported_plugins = get_checked_plugins($_POST);
        list($group_id, $name, $descr, $plugins, $error) = validate_post_params($conn, POST('name'), POST('descr'), POST('sids'), $imported_plugins, GET('id'));
        if (empty($error) && !ossim_error()) {
            Plugin_group::edit($conn, $group_id, $name, $descr, $plugins, $imported_plugins);
            if (intval(POST('pluginid')) > 0 || intval(POST('redirec')) == 1) {
                $location = "modifyplugingroupsform.php?action=edit&id={$group_id}";
            }
        } else {
            $location = "modifyplugingroupsform.php?action=edit&id={$group_id}";
        }
    } else {
        if (GET('action') == 'delete') {
            $group_id = GET('id');
            ossim_valid($group_id, OSS_HEX, 'illegal:ID');
            if (ossim_error()) {
                $error = ossim_error();
                $location = 'plugingroups.php';