function admin_display_cat_auth($cat_parent = 0, $depth = 0)
 {
     global $pafiledb, $template;
     global $cat_auth_fields, $cat_auth_const, $cat_auth_levels, $lang;
     $pre = str_repeat('        ', $depth);
     if (isset($pafiledb->subcat_rowset[$cat_parent])) {
         foreach ($pafiledb->subcat_rowset[$cat_parent] as $sub_cat_id => $cat_data) {
             $template->assign_block_vars('cat_row', array('CATEGORY_NAME' => $cat_data['cat_name'], 'IS_HIGHER_CAT' => $cat_data['cat_allow_file'] ? false : true, 'PRE' => $pre, 'U_CAT' => append_sid('admin_pa_catauth.' . PHP_EXT . '?cat_parent=' . $sub_cat_id)));
             for ($j = 0; $j < sizeof($cat_auth_fields); $j++) {
                 $custom_auth[$j] = '&nbsp;<select name="' . $cat_auth_fields[$j] . '[' . $sub_cat_id . ']' . '">';
                 for ($k = 0; $k < sizeof($cat_auth_levels); $k++) {
                     $selected = $cat_data[$cat_auth_fields[$j]] == $cat_auth_const[$k] ? ' selected="selected"' : '';
                     $custom_auth[$j] .= '<option value="' . $cat_auth_const[$k] . '"' . $selected . '>' . $lang['Category_' . $cat_auth_levels[$k]] . '</option>';
                 }
                 $custom_auth[$j] .= '</select>&nbsp;';
                 $template->assign_block_vars('cat_row.cat_auth_data', array('S_AUTH_LEVELS_SELECT' => $custom_auth[$j]));
             }
             admin_display_cat_auth($sub_cat_id, $depth + 1);
         }
         return;
     }
     return;
 }
// Output the authorization details if an id was specified
$template->set_filenames(array('body' => ADM_TPL . 'pa_auth_cat_body.tpl'));
$permissions_menu = array(append_sid('admin_pa_catauth.' . PHP_EXT) => $lang['Cat_Permissions'], append_sid('admin_pa_ug_auth.' . PHP_EXT . '?mode=user') => $lang['User_Permissions'], append_sid('admin_pa_ug_auth.' . PHP_EXT . '?mode=group') => $lang['Group_Permissions'], append_sid('admin_pa_ug_auth.' . PHP_EXT . '?mode=glob_user') => $lang['User_Global_Permissions'], append_sid('admin_pa_ug_auth.' . PHP_EXT . '?mode=glob_group') => $lang['Group_Global_Permissions']);
foreach ($permissions_menu as $url => $l_name) {
    $template->assign_block_vars('pertype', array('U_NAME' => $url, 'L_NAME' => $l_name));
}
//
// Output values of individual
// fields
//
for ($j = 0; $j < sizeof($cat_auth_fields); $j++) {
    $cell_title = $field_names[$cat_auth_fields[$j]];
    $template->assign_block_vars('cat_auth_titles', array('CELL_TITLE' => $cell_title));
}
if (empty($cat_id)) {
    admin_display_cat_auth($cat_parent);
    $cat_name = '';
} elseif (!empty($cat_id)) {
    $template->assign_block_vars('cat_row', array('CATEGORY_NAME' => $pafiledb->cat_rowset[$cat_id]['cat_name'], 'IS_HIGHER_CAT' => $pafiledb->cat_rowset[$cat_id] ? false : true, 'U_CAT' => append_sid('admin_pa_catauth.' . PHP_EXT . "?cat_parent={$pafiledb->cat_rowset[$cat_id]['cat_parent']}")));
    for ($j = 0; $j < sizeof($cat_auth_fields); $j++) {
        $custom_auth[$j] = '&nbsp;<select name="' . $cat_auth_fields[$j] . '[' . $cat_id . ']' . '">';
        for ($k = 0; $k < sizeof($cat_auth_levels); $k++) {
            $selected = $pafiledb->cat_rowset[$cat_id][$cat_auth_fields[$j]] == $cat_auth_const[$k] ? ' selected="selected"' : '';
            $custom_auth[$j] .= '<option value="' . $cat_auth_const[$k] . '"' . $selected . '>' . $lang['Category_' . $cat_auth_levels[$k]] . '</option>';
        }
        $custom_auth[$j] .= '</select>&nbsp;';
        $template->assign_block_vars('cat_row.cat_auth_data', array('S_AUTH_LEVELS_SELECT' => $custom_auth[$j]));
    }
    $s_hidden_fields = '<input type="hidden" name="cat_id" value="' . $cat_id . '" />';
    $cat_name = $pafiledb->cat_rowset[$cat_id]['cat_name'];
}