Permalink
Browse files

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 #12450
  • Loading branch information...
dregad committed Sep 19, 2011
1 parent 978b17a commit 47d355804701aaeddac3c16f547ee1ff1c4bab9d
Showing with 7 additions and 5 deletions.
  1. +1 −1 bug_report_page.php
  2. +2 −0 core/constant_inc.php
  3. +4 −4 core/relationship_api.php
View
@@ -553,7 +553,7 @@
<?php echo lang_get( 'relationship_with_parent' ) ?>
</th>
<td>
- <?php relationship_list_box( /* none */ -2, "rel_type", false, true ) ?>
+ <?php relationship_list_box( BUG_REL_NONE, "rel_type", false, true ) ?>
<?php echo '<strong>' . lang_get( 'bug' ) . ' ' . bug_format_id( $f_master_bug_id ) . '</strong>' ?>
</td>
</tr>
View
@@ -199,6 +199,8 @@
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 );
@@ -804,17 +804,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
}
@@ -865,7 +865,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>

0 comments on commit 47d3558

Please sign in to comment.