if ($forum_auth_fields[$j] == 'auth_vote') {
                if ($_POST['auth_vote'][$forum_id] == AUTH_ALL) {
                    $value = AUTH_REG;
                }
            }
            $sql .= ($sql != '' ? ', ' : '') . $forum_auth_fields[$j] . ' = ' . $value;
        }
        $sql = "UPDATE " . FORUMS_TABLE . " SET {$sql} WHERE forum_id = {$forum_id}";
        $db->sql_query($sql);
    }
    // Delete notifications for not auth users
    if (!class_exists('class_notifications')) {
        include IP_ROOT_PATH . 'includes/class_notifications.' . PHP_EXT;
        $class_notifications = new class_notifications();
    }
    $class_notifications->delete_not_auth_notifications();
    cache_tree(true);
    $redirect_url = append_sid(ADM . '/admin_forumauth_list.' . PHP_EXT);
    meta_refresh(3, $redirect_url);
    $message = $lang['Forum_auth_updated'] . '<br /><br />' . sprintf($lang['Click_return_forumauth'], '<a href="' . append_sid('admin_forumauth_list.' . PHP_EXT) . '">', '</a>');
    message_die(GENERAL_MESSAGE, $message);
}
// Default page
$colspan = sizeof($forum_auth_fields) + 2;
// Output the authorization details
$template->set_filenames(array('body' => ADM_TPL . 'auth_forum_list_body.tpl'));
$template->assign_vars(array('L_AUTH_LIST_TITLE' => $lang['Auth_list_Control_Forum'], 'L_AUTH_LIST_EXPLAIN' => $lang['Forum_auth_list_explain'], 'L_SUBMIT' => $lang['Submit'], 'L_RESET' => $lang['Reset'], 'COLSPAN' => $colspan, 'S_FORM_ACTION' => append_sid('admin_forumauth_list.' . PHP_EXT)));
$template->assign_block_vars('forum_auth_titles', array('CELL_TITLE' => $lang['Forum']));
for ($i = 0; $i < sizeof($forum_auth_fields); $i++) {
    $template->assign_block_vars('forum_auth_titles', array('CELL_TITLE' => $field_names[$forum_auth_fields[$i]]));
}
            $value = intval($_POST[$forum_auth_fields[$i]]);
            if ($forum_auth_fields[$i] == 'auth_vote') {
                if ($_POST['auth_vote'] == AUTH_ALL) {
                    $value = AUTH_REG;
                }
            }
            $sql .= ($sql != '' ? ', ' : '') . $forum_auth_fields[$i] . ' = ' . $value;
        }
        $sql = "UPDATE " . FORUMS_TABLE . "\n\t\t\t\t\t\tSET {$sql}\n\t\t\t\t\t\tWHERE forum_id IN ('" . $forums_to_auth . "')";
        $db->sql_query($sql);
        // Delete notifications for not auth users
        if (!class_exists('class_notifications')) {
            include IP_ROOT_PATH . 'includes/class_notifications.' . PHP_EXT;
            $class_notifications = new class_notifications();
        }
        $class_notifications->delete_not_auth_notifications($data['forums']);
    }
    // End of submit
    cache_tree(true);
    $redirect_url = append_sid(ADM . '/admin_forumauth_adv.' . PHP_EXT);
    meta_refresh(3, $redirect_url);
    $message = $lang['Forum_auth_updated'] . '<br /><br />' . sprintf($lang['Click_return_forumauth'], '<a href="' . append_sid('admin_forumauth_adv.' . PHP_EXT) . '">', '</a>');
    message_die(GENERAL_MESSAGE, $message);
}
// Get required information, either all forums if no id was specified or just the requsted if it was
// Output the authorization details if an id was specified
$template->set_filenames(array('body' => ADM_TPL . 'auth_forum_adv_body.tpl'));
$forumlist = get_tree_option_optg('', true, false);
// Output values of individual fields
for ($j = 0; $j < sizeof($forum_auth_fields); $j++) {
    $custom_auth[$j] = '&nbsp;<select name="' . $forum_auth_fields[$j] . '">';
                $value = intval($_POST[$forum_auth_fields[$i]]);
                if ($forum_auth_fields[$i] == 'auth_vote') {
                    if ($_POST['auth_vote'] == AUTH_ALL) {
                        $value = AUTH_REG;
                    }
                }
                $sql .= ($sql != '' ? ', ' : '') . $forum_auth_fields[$i] . ' = ' . $value;
            }
            $sql = "UPDATE " . FORUMS_TABLE . " SET {$sql} WHERE forum_id = {$forum_id}";
        }
        // Delete notifications for not auth users
        if (!class_exists('class_notifications')) {
            include IP_ROOT_PATH . 'includes/class_notifications.' . PHP_EXT;
            $class_notifications = new class_notifications();
        }
        $class_notifications->delete_not_auth_notifications($forum_id);
        if ($sql != '') {
            $db->sql_query($sql);
        }
        $forum_sql = '';
        $adv = 0;
    }
    cache_tree(true);
    $redirect_url = append_sid(ADM . '/admin_forumauth.' . PHP_EXT . '?' . POST_FORUM_URL . '=' . $forum_id);
    meta_refresh(3, $redirect_url);
    $message = $lang['Forum_auth_updated'] . '<br /><br />' . sprintf($lang['Click_return_forumauth'], '<a href="' . append_sid('admin_forumauth.' . PHP_EXT) . '">', '</a>');
    message_die(GENERAL_MESSAGE, $message);
}
// End of submit
//
// Get required information, either all forums if