From 7629ad85ca64dd1fc4c75ab8d6a8618c30e9818f Mon Sep 17 00:00:00 2001 From: Victor Boctor Date: Wed, 4 Feb 2015 08:28:13 -0800 Subject: [PATCH] Handling single category case If there is a single category and it is required to set the category field, then auto-select such category. Fixes #19264 --- core/print_api.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/core/print_api.php b/core/print_api.php index bfc099d28c..2246bd5141 100644 --- a/core/print_api.php +++ b/core/print_api.php @@ -698,6 +698,9 @@ function print_category_option_list( $p_category_id = 0, $p_project_id = null ) } else { $t_project_id = $p_project_id; } + + $t_cat_arr = category_get_all_rows( $t_project_id, null, true ); + if( config_get( 'allow_no_category' ) ) { echo ''; + if( count( $t_cat_arr ) == 1 ) { + $p_category_id = (int) $t_cat_arr[0]['id']; + } else { + echo ''; + } } } - $t_cat_arr = category_get_all_rows( $t_project_id, null, true ); - foreach( $t_cat_arr as $t_category_row ) { $t_category_id = (int)$t_category_row['id']; echo '