View Issue Details

IDProjectCategoryView StatusLast Update
0013177mantisbtfilterspublic2018-03-31 19:58
Reportersagrawal Assigned Tocproensa  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version1.2.5 
Target Version2.13.0Fixed in Version2.13.0 
Summary0013177: On ‘View Issues’ Page the filter does not allow user to select ‘blank’ ('No Category') Category
Description

Even if (No category) is allowed through configuration $g_allow_no_category = ON and some issues are opened with 'no category', filtering on those issues are not supported by existing category filter. The item '(No Category)' is not available in the drop down of category filter.

TagsNo tags attached.
Attached Files
category.patch (3,466 bytes)   
diff -Naur mantisbt-1.2.5/bug_actiongroup.php mantisbt-1.2.5-patch/bug_actiongroup.php
--- mantisbt-1.2.5/bug_actiongroup.php	2011-04-05 23:54:17.000000000 +0530
+++ mantisbt-1.2.5-patch/bug_actiongroup.php	2011-07-15 16:05:59.000000000 +0530
@@ -199,7 +199,7 @@
 		case 'UP_CATEGORY':
 			$f_category_id = gpc_get_int( 'category' );
 			if ( access_has_bug_level( config_get( 'update_bug_threshold' ), $t_bug_id ) ) {
-				if ( category_exists( $f_category_id ) ) {
+				if ( category_exists( $f_category_id ) || $f_category_id === 0) {
 					/** @todo we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) ); */
 					bug_set_field( $t_bug_id, 'category_id', $f_category_id );
 					helper_call_custom_function( 'issue_update_notify', array( $t_bug_id ) );
diff -Naur mantisbt-1.2.5/core/filter_api.php mantisbt-1.2.5-patch/core/filter_api.php
--- mantisbt-1.2.5/core/filter_api.php	2011-04-05 23:54:17.000000000 +0530
+++ mantisbt-1.2.5-patch/core/filter_api.php	2011-07-15 16:29:36.000000000 +0530
@@ -1307,22 +1307,36 @@
 	if( !filter_field_is_any( $t_filter[FILTER_PROPERTY_CATEGORY] ) ) {
 		$t_clauses = array();
 
+		$no_category = lang_get( 'no_category' );
+		
 		foreach( $t_filter[FILTER_PROPERTY_CATEGORY] as $t_filter_member ) {
 			if( !filter_field_is_none( $t_filter_member ) ) {
 				array_push( $t_clauses, $t_filter_member );
 			}
 		}
-
 		if( 1 < count( $t_clauses ) ) {
 			$t_where_tmp = array();
 			foreach( $t_clauses as $t_clause ) {
+				if($t_clause === $no_category){
+					$t_where_params[] = '0';
+					continue;
+				}				
 				$t_where_tmp[] = db_param();
 				$t_where_params[] = $t_clause;
+			}			
+			if(in_array($no_category, $t_clauses)){					
+				array_push( $t_where_clauses, "( $t_bug_table.category_id=".db_param()." or $t_bug_table.category_id in ( SELECT id FROM $t_category_table WHERE name in (" . implode( ', ', $t_where_tmp ) . ") ) )" );
+			}else {
+				array_push( $t_where_clauses, "( $t_bug_table.category_id in ( SELECT id FROM $t_category_table WHERE name in (" . implode( ', ', $t_where_tmp ) . ") ) )" );
+			}			
+		} else {						
+			if($t_clauses[0] === $no_category){
+				$t_where_params[] = '0';
+				array_push( $t_where_clauses, "( $t_bug_table.category_id=".db_param()." )");
+			}else {
+				$t_where_params[] = $t_clauses[0];
+				array_push( $t_where_clauses, "( $t_bug_table.category_id in ( SELECT id FROM $t_category_table WHERE name=" . db_param() . ") )" );	
 			}
-			array_push( $t_where_clauses, "( $t_bug_table.category_id in ( SELECT id FROM $t_category_table WHERE name in (" . implode( ', ', $t_where_tmp ) . ") ) )" );
-		} else {
-			$t_where_params[] = $t_clauses[0];
-			array_push( $t_where_clauses, "( $t_bug_table.category_id in ( SELECT id FROM $t_category_table WHERE name=" . db_param() . ") )" );
 		}
 	}
 
@@ -3558,6 +3572,9 @@
 		<!-- Category -->
 		<select <?php echo $t_select_modifier;?> name="<?php echo FILTER_PROPERTY_CATEGORY;?>[]">
 			<option value="<?php echo META_FILTER_ANY?>" <?php check_selected( $t_filter[FILTER_PROPERTY_CATEGORY], META_FILTER_ANY );?>>[<?php echo lang_get( 'any' )?>]</option>
+			<?php if (config_get('allow_no_category') == ON){?>
+				<option value="<?php echo lang_get( 'no_category' )?>"><?php echo lang_get( 'no_category' )?></option>
+			<?php }?>
 			<?php print_category_filter_option_list( $t_filter[FILTER_PROPERTY_CATEGORY] )?>
 		</select>
 		<?php
category.patch (3,466 bytes)   

Relationships

related to 0023501 closedcproensa Filter "monitored by" does not have option for "none" 
has duplicate 0023467 closedatrol Filter issues with no category 

Activities

sagrawal

sagrawal

2011-07-26 08:39

reporter   ~0029296

Last edited: 2011-07-26 08:42

I have created a patch named category.patch to fix this issue.

This patch can be install using command 'patch -p1 < category.patch' on root mantis folder.

Please note that this patch also fix the related issue opened by me 13176 (On update Category option...)

Related Changesets

MantisBT: master 8a0d4210

2017-10-19 16:01

cproensa

Committer: dregad


Details Diff
Add option to filter by category "none"

Fixes: 0013177
Affected Issues
0013177
mod - core/filter_form_api.php Diff File