Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: mantisbt/mantisbt
base: 277681c
...
head fork: mantisbt/mantisbt
compare: bfd83a1
  • 4 commits
  • 5 files changed
  • 0 commit comments
  • 1 contributor
Commits on Oct 06, 2011
Damien Regad dregad Fixes moving of bugs without category
Prior to this, attempting to move an issue with no category set
(allowed with $g_allow_no_category = ON) to another project generated
error 1502.

Now, Mantis will successfully move the issue, and also set the category
to the default value if it is mandatory in the target project.

Fixes #13341
978b17a
Damien Regad dregad 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
47d3558
Damien Regad dregad 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 #12450
1f9c4bd
Damien Regad dregad Add config for new bug relationships
Adds a new global config $g_default_bug_relationship, which presets the
relation type in the selection list.
Defaults to BUG_RELATED.

This slightly changes the behavior compared to earlier versions, as the
default was BUG_REL_ANY (-1); however, since this is not a valid entry
in the selection list, the first value (BUG_DEPENDANT) was used instead.
bfd83a1
2  bug_report_page.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( config_get( 'default_bug_relationship_clone' ), "rel_type", false, true ) ?>
<?php echo '<strong>' . lang_get( 'bug' ) . ' ' . bug_format_id( $f_master_bug_id ) . '</strong>' ?>
</td>
</tr>
16 config_defaults_inc.php
View
@@ -1226,6 +1226,18 @@
$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 for new bug relationships
+ * @global int $g_default_bug_relationship
+ */
+$g_default_bug_relationship = BUG_RELATED;
+
+/**
* 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.
@@ -4059,7 +4071,7 @@
* 4 Options currently exist for log destination:
* a) '': The default value (empty string) means default PHP error log settings
* b) 'file': Log to a specific file - specified as 'file:/var/log/mantis.log'
- * c) 'firebug': make use of firefox's firebug addon from http://getfirebug.com/ - Note: if user is
+ * c) 'firebug': make use of firefox's firebug addon from http://getfirebug.com/ - Note: if user is
* not running firefox, this options falls through to the default php error log settings.
* d) 'page': Display log output at bottom of the page.
* @global string $g_log_destination
@@ -4068,7 +4080,7 @@
/**
* Indicates the access level required for a user to see the log output (if log_destination is page)
- * Note that this threshold is compared against the user's default global access level rather than
+ * Note that this threshold is compared against the user's default global access level rather than
* the threshold based on the current active project.
*
* @global int $g_show_log_threshold
57 core/bug_api.php
View
@@ -247,9 +247,9 @@ private function is_extended_field( $p_field_name ) {
/**
* Returns the number of bugnotes for the given bug_id
* @return int number of bugnotes
- * @access private
+ * @access private
* @uses database_api.php
- */
+ */
private function bug_get_bugnote_count() {
if( !access_has_project_level( config_get( 'private_bugnote_threshold' ), $this->project_id ) ) {
$t_restriction = 'AND view_state=' . VS_PUBLIC;
@@ -1072,21 +1072,32 @@ function bug_move( $p_bug_id, $p_target_project_id ) {
// Move the issue to the new project.
bug_set_field( $p_bug_id, 'project_id', $p_target_project_id );
- // Check if the category for the issue is global or not.
+ // Update the category if needed
$t_category_id = bug_get_field( $p_bug_id, 'category_id' );
- $t_category_project_id = category_get_field( $t_category_id, 'project_id' );
-
- // If not global, then attempt mapping it to the new project.
- if ( $t_category_project_id != ALL_PROJECTS && !project_hierarchy_inherit_parent( $p_target_project_id, $t_category_project_id ) ) {
- // Map by name
- $t_category_name = category_get_field( $t_category_id, 'name' );
- $t_target_project_category_id = category_get_id_by_name( $t_category_name, $p_target_project_id, /* triggerErrors */ false );
- if ( $t_target_project_category_id === false ) {
- // Use default category after moves, since there is no match by name.
- $t_target_project_category_id = config_get( 'default_category_for_moves' );
- }
- bug_set_field( $p_bug_id, 'category_id', $t_target_project_category_id );
+ // Bug has no category
+ if( $t_category_id == 0 ) {
+ // Category is required in target project, set it to default
+ if( ON != config_get( 'allow_no_category', null, null, $p_target_project_id ) ) {
+ bug_set_field( $p_bug_id, 'category_id', config_get( 'default_category_for_moves' ) );
+ }
+ }
+ // Check if the category is global, and if not attempt mapping it to the new project
+ else {
+ $t_category_project_id = category_get_field( $t_category_id, 'project_id' );
+
+ if ( $t_category_project_id != ALL_PROJECTS
+ && !project_hierarchy_inherit_parent( $p_target_project_id, $t_category_project_id )
+ ) {
+ // Map by name
+ $t_category_name = category_get_field( $t_category_id, 'name' );
+ $t_target_project_category_id = category_get_id_by_name( $t_category_name, $p_target_project_id, /* triggerErrors */ false );
+ if ( $t_target_project_category_id === false ) {
+ // Use default category after moves, since there is no match by name.
+ $t_target_project_category_id = config_get( 'default_category_for_moves' );
+ }
+ bug_set_field( $p_bug_id, 'category_id', $t_target_project_category_id );
+ }
}
}
@@ -1761,15 +1772,15 @@ function bug_monitor( $p_bug_id, $p_user_id ) {
/**
* Returns the list of users monitoring the specified bug
- *
+ *
* @param int $p_bug_id
*/
function bug_get_monitors( $p_bug_id ) {
-
- if ( ! access_has_bug_level( config_get( 'show_monitor_list_threshold' ), $p_bug_id ) ) {
- return Array();
- }
-
+
+ if ( ! access_has_bug_level( config_get( 'show_monitor_list_threshold' ), $p_bug_id ) ) {
+ return Array();
+ }
+
$c_bug_id = db_prepare_int( $p_bug_id );
$t_bug_monitor_table = db_get_table( 'bug_monitor' );
$t_user_table = db_get_table( 'user' );
@@ -1787,9 +1798,9 @@ function bug_get_monitors( $p_bug_id ) {
$row = db_fetch_array( $result );
$t_users[$i] = $row['user_id'];
}
-
+
user_cache_array_rows( $t_users );
-
+
return $t_users;
}
2  core/constant_inc.php
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 );
8 core/relationship_api.php
View
@@ -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( config_get( 'default_bug_relationship' ) )?>
<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>

No commit comments for this range

Something went wrong with that request. Please try again.