View Issue Details

IDProjectCategoryView StatusLast Update
0011417mantisbtplug-inspublic2010-02-22 14:34
Reporteram-gtz Assigned Todhx  
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionfixed 
Target Version1.2.0Fixed in Version1.2.0 
Summary0011417: EVENTMENU* does not allow to return null
Description

When the hook for a menu item returns null, an empty item is added, somehow like this

Report Issue | | Change Log

Sometimes it is useful that a plugin decides to not add any menu item, for example based on the current project.

Additional Information

We will attach a patch for this. See also our branch:

issue-event-menu-main-null-return on http://git.mantisforge.org/w/mantisbt/gtz-et.git

Tagspatch
Attached Files
issue11417.patch (2,399 bytes)   
diff --git a/core/html_api.php b/core/html_api.php
index 7ece4da..c78c3d3 100644
--- a/core/html_api.php
+++ b/core/html_api.php
@@ -726,7 +726,9 @@ function print_menu() {
 				if( is_array( $t_callback_menu_options ) ) {
 					$t_menu_options = array_merge( $t_menu_options, $t_callback_menu_options );
 				} else {
-					$t_menu_options[] = $t_callback_menu_options;
+					if (!is_null($t_callback_menu_options)) {
+						$t_menu_options[] = $t_callback_menu_options;
+					}
 				}
 			}
 		}
@@ -774,7 +776,9 @@ function print_menu() {
 				if( is_array( $t_callback_menu_options ) ) {
 					$t_menu_options = array_merge( $t_menu_options, $t_callback_menu_options );
 				} else {
-					$t_menu_options[] = $t_callback_menu_options;
+					if (!is_null($t_callback_menu_options)) {
+						$t_menu_options[] = $t_callback_menu_options;
+					}
 				}
 			}
 		}
@@ -899,7 +903,9 @@ function print_summary_submenu() {
 			if( is_array( $t_callback_menu_options ) ) {
 				$t_menu_options = array_merge( $t_menu_options, $t_callback_menu_options );
 			} else {
-				$t_menu_options[] = $t_callback_menu_options;
+				if (!is_null($t_callback_menu_options)) {
+					$t_menu_options[] = $t_callback_menu_options;
+				}				
 			}
 		}
 	}
@@ -984,7 +990,9 @@ function print_manage_menu( $p_page = '' ) {
 			if( is_array( $t_callback_menu_options ) ) {
 				$t_menu_options = array_merge( $t_menu_options, $t_callback_menu_options );
 			} else {
-				$t_menu_options[] = $t_callback_menu_options;
+				if (!is_null($t_callback_menu_options)) {
+					$t_menu_options[] = $t_callback_menu_options;
+				}				
 			}
 		}
 	}
@@ -1096,7 +1104,9 @@ function print_account_menu( $p_page = '' ) {
 			if( is_array( $t_callback_menu_options ) ) {
 				$t_menu_options = array_merge( $t_menu_options, $t_callback_menu_options );
 			} else {
-				$t_menu_options[] = $t_callback_menu_options;
+				if (!is_null($t_callback_menu_options)) {
+					$t_menu_options[] = $t_callback_menu_options;
+				}				
 			}
 		}
 	}
@@ -1157,7 +1167,9 @@ function print_summary_menu( $p_page = '' ) {
 			if( is_array( $t_callback_menu_options ) ) {
 				$t_menu_options = array_merge( $t_menu_options, $t_callback_menu_options );
 			} else {
-				$t_menu_options[] = $t_callback_menu_options;
+				if (!is_null($t_callback_menu_options)) {
+					$t_menu_options[] = $t_callback_menu_options;
+				}				
 			}
 		}
 	}
issue11417.patch (2,399 bytes)   

Activities

dhx

dhx

2010-01-26 03:04

reporter   ~0024252

Thanks for this patch, I fixed some white space errors and rebased your two commits into one, with a more detailed commit message. Committed to 1.2.x and 1.3.x branches.

Related Changesets

MantisBT: master-1.2.x d1a69cd2

2010-01-20 07:02

Alexander Menk

Committer: dhx


Details Diff
Fix 0011417: Allow EVENT_MENU_MAIN plugin events to return null

A plugin may decide not to print a menu entry via the EVENT_MENU_MAIN
event hook based on which project is currently selected. Therefore the
return value from EVENT_MENU_MAIN should be checked to make sure it
isn't null. If it is null, then don't print anything in the menu.

Signed-off-by: David Hicks <hickseydr@optusnet.com.au>
Affected Issues
0011417
mod - core/html_api.php Diff File

MantisBT: master 321ac71d

2010-01-20 07:02

Alexander Menk

Committer: dhx


Details Diff
Fix 0011417: Allow EVENT_MENU_MAIN plugin events to return null

A plugin may decide not to print a menu entry via the EVENT_MENU_MAIN
event hook based on which project is currently selected. Therefore the
return value from EVENT_MENU_MAIN should be checked to make sure it
isn't null. If it is null, then don't print anything in the menu.

Signed-off-by: David Hicks <hickseydr@optusnet.com.au>
Affected Issues
0011417
mod - core/html_api.php Diff File