View Issue Details

IDProjectCategoryView StatusLast Update
0012450mantisbtbugtrackerpublic2014-09-23 18:05
Reportercproensa Assigned Todregad  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version1.2.3 
Target Version1.2.9Fixed in Version1.2.9 
Summary0012450: default relation type is hardcoded on bug_report_page.php
Description

it calls:
relationship_list_box( / none / -2, "rel_type", false, true )

it would be nice to have it defined on configuration

its v1.2.3 but also in current git

TagsNo tags attached.
Attached Files
fix-12450.patch (3,479 bytes)   
diff --git a/bug_report_page.php b/bug_report_page.php
index eb3a180..95d3ec7 100644
--- a/bug_report_page.php
+++ b/bug_report_page.php
@@ -498,7 +498,7 @@
 			<?php echo lang_get( 'relationship_with_parent' ) ?>
 		</td>
 		<td>
-			<?php relationship_list_box( /* none */ -2, "rel_type", false, true ) ?>
+			<?php relationship_list_box( config_get( 'default_bug_relationship_clone' ), "rel_type", false, true ) ?>
 			<?php echo '<b>' . lang_get( 'bug' ) . ' ' . bug_format_id( $f_master_bug_id ) . '</b>' ?>
 		</td>
 	</tr>
diff --git a/config_defaults_inc.php b/config_defaults_inc.php
index 59b4764..8b8dceb 100644
--- a/config_defaults_inc.php
+++ b/config_defaults_inc.php
@@ -1159,6 +1159,12 @@
 	$g_default_bug_eta = ETA_NONE;

 	/**
+	 * Default relationship between a new bug and its parent when cloning it
+	 * @global int $g_default_bug_relationship_clone
+	 */
+	$g_default_bug_relationship_clone = BUG_REL_NONE;
+
+	/**
 	 * Default global category to be used when an issue is moved from a project to another
 	 * that doesn't have a category with a matching name.  The default is 1 which is the "General"
 	 * category that is created in the default database.
diff --git a/core/constant_inc.php b/core/constant_inc.php
index 982fcf0..2db57f9 100644
--- a/core/constant_inc.php
+++ b/core/constant_inc.php
@@ -200,6 +200,8 @@ define( 'REV_ADDITIONAL_INFO', 3 );
 define( 'REV_BUGNOTE', 4 );

 # bug relationship constants
+define( 'BUG_REL_NONE', -2 );
+define( 'BUG_REL_ANY', -1 );
 define( 'BUG_DUPLICATE', 0 );
 define( 'BUG_RELATED', 1 );
 define( 'BUG_DEPENDANT', 2 );
diff --git a/core/relationship_api.php b/core/relationship_api.php
index b0949ea..0f33222 100644
--- a/core/relationship_api.php
+++ b/core/relationship_api.php
@@ -772,17 +772,17 @@ function relationship_get_summary_text( $p_bug_id ) {
  * @param int $p_bug_id Bug id
  * @return null
  */
-function relationship_list_box( $p_default_rel_type = -1, $p_select_name = "rel_type", $p_include_any = false, $p_include_none = false ) {
+function relationship_list_box( $p_default_rel_type = BUG_REL_ANY, $p_select_name = "rel_type", $p_include_any = false, $p_include_none = false ) {
 	global $g_relationships;
 	?>
 <select name="<?php echo $p_select_name?>">
 <?php if( $p_include_any ) {?>
-<option value="-1" <?php echo( $p_default_rel_type == -1 ? ' selected="selected"' : '' )?>>[<?php echo lang_get( 'any' )?>]</option>
+<option value="<?php BUG_REL_ANY ?>" <?php echo( $p_default_rel_type == BUG_REL_ANY ? ' selected="selected"' : '' )?>>[<?php echo lang_get( 'any' )?>]</option>
 <?php
 	}

 	if( $p_include_none ) {?>
-<option value="-2" <?php echo( $p_default_rel_type == -2 ? ' selected="selected"' : '' )?>>[<?php echo lang_get( 'none' )?>]</option>
+<option value="<?php BUG_REL_NONE ?>" <?php echo( $p_default_rel_type == BUG_REL_NONE ? ' selected="selected"' : '' )?>>[<?php echo lang_get( 'none' )?>]</option>
 <?php
 	}

@@ -833,7 +833,7 @@ function relationship_view_box( $p_bug_id ) {
 		<form method="post" action="bug_relationship_add.php">
 		<?php echo form_security_field( 'bug_relationship_add' ) ?>
 		<input type="hidden" name="src_bug_id" value="<?php echo $p_bug_id?>" size="4" />
-		<?php relationship_list_box( -1 )?>
+		<?php relationship_list_box( BUG_REL_ANY )?>
 		<input type="text" name="dest_bug_id" value="" />
 		<input type="submit" name="add_relationship" class="button" value="<?php echo lang_get( 'add_new_relationship_button' )?>" />
 		</form>
fix-12450.patch (3,479 bytes)   

Relationships

related to 0015721 closedgrangeway Functionality to consider porting to master-2.0.x 

Activities

vincent_sels

vincent_sels

2011-09-18 13:11

reporter   ~0029793

I agree. I added a setting:

$g_default_relation_on_clone = BUG_RELATED;

And changed the code in bug_report_page.api to:

<?php relationship_list_box( config_get( 'default_relation_on_clone' ), "rel_type", false, true ) ?>

dregad

dregad

2011-09-19 07:35

developer   ~0029802

Last edited: 2011-09-19 09:19

Please try the attached patch, let me know if that works for you.

I'll bounce it off the rest of the dev team [1], to see how they feel about adding a new config option, before committing.

[1] https://github.com/mantisbt/mantisbt/pull/14

grangeway

grangeway

2013-04-05 17:57

reporter   ~0036328

Marking as 'acknowledged' not resolved/closed to track that change gets ported to master-2.0.x branch

Related Changesets

MantisBT: master-1.2.x 93bbb36c

2011-09-18 22:35

dregad


Details Diff
Use constants not hardcoded values for relationship lists

Defines 2 new constants BUG_REL_NONE and BUG_REL_ANY referenced when
building relationship selection lists, instead of using hardcoded
values -2 and -1 respectively.

Affects issue 0012450
Affected Issues
0012450
mod - bug_report_page.php Diff File
mod - core/constant_inc.php Diff File
mod - core/relationship_api.php Diff File

MantisBT: master 47d35580

2011-09-18 22:35

dregad


Details Diff
Use constants not hardcoded values for relationship lists

Defines 2 new constants BUG_REL_NONE and BUG_REL_ANY referenced when
building relationship selection lists, instead of using hardcoded
values -2 and -1 respectively.

Affects issue 0012450
Affected Issues
0012450
mod - bug_report_page.php Diff File
mod - core/constant_inc.php Diff File
mod - core/relationship_api.php Diff File

MantisBT: master-1.2.x b8b8da14

2011-09-18 23:11

dregad


Details Diff
Add config for default relationship when cloning a bug

Introduce a new global config $g_default_bug_relationship_clone, used to
preset the selection list relationship of a cloned bug with its parent.

Defaults to BUG_REL_NONE.

Fix 0012450
Affected Issues
0012450
mod - bug_report_page.php Diff File
mod - config_defaults_inc.php Diff File

MantisBT: master 1f9c4bd1

2011-09-18 23:11

dregad


Details Diff
Add config for default relationship when cloning a bug

Introduce a new global config $g_default_bug_relationship_clone, used to
preset the selection list relationship of a cloned bug with its parent.

Defaults to BUG_REL_NONE.

Fix 0012450
Affected Issues
0012450
mod - bug_report_page.php Diff File
mod - config_defaults_inc.php Diff File