Skip to content

Commit

Permalink
Commit of Masc's Patches:
Browse files Browse the repository at this point in the history
Fix 0004506: When cloning a bug you should be able to set the relationship
Fix 0004484: Show which project a related issue belongs to
Fix 0004184: Related issues resolved email should be more informative
Fix 0004224: Can't resolve issue as duplicate of other with existing "related to" relationship


git-svn-id: http://mantisbt.svn.sourceforge.net/svnroot/mantisbt/trunk@3037 f5dc347c-c33d-0410-90a0-b07cc1902cb9
  • Loading branch information
mantis committed Oct 5, 2004
1 parent 5bbfe7d commit 3df7d2c
Show file tree
Hide file tree
Showing 12 changed files with 427 additions and 253 deletions.
85 changes: 23 additions & 62 deletions bug_relationship_add.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: bug_relationship_add.php,v 1.2 2004-07-18 00:07:44 vboctor Exp $
# $Id: bug_relationship_add.php,v 1.3 2004-10-05 21:12:41 prichards Exp $
# --------------------------------------------------------
?>
<?php
Expand Down Expand Up @@ -51,78 +51,39 @@
trigger_error( ERROR_RELATIONSHIP_ACCESS_LEVEL_TO_DEST_BUG_TOO_LOW, ERROR );
}

# there is no other relationship between the same bugs...
if ( relationship_exists($f_src_bug_id, $f_dest_bug_id) > 0 ) {
# check if there is other relationship between the bugs...
$t_old_id_relationship = relationship_same_type_exists( $f_src_bug_id, $f_dest_bug_id, $f_rel_type );

if ( $t_old_id_relationship == -1 ) {
# the relationship type is exactly the same of the new one. No sense to proceed
trigger_error( ERROR_RELATIONSHIP_ALREADY_EXISTS, ERROR );
}
else if ( $t_old_id_relationship > 0 ) {
# there is already a relationship between them -> we have to update it and not to add a new one
helper_ensure_confirmed( lang_get( 'replace_relationship_sure_msg' ), lang_get( 'replace_relationship_button' ) );

switch ( $f_rel_type ) {

case BUG_BLOCKS:
# BUG_BLOCKS -> swap src and dest with relationship BUG_DEPENDANT

# Add relation to the DB
relationship_add( $f_dest_bug_id, $f_src_bug_id, BUG_DEPENDANT );

# Add log line to the history (both bugs)
history_log_event_special( $f_src_bug_id, BUG_ADD_RELATIONSHIP, BUG_BLOCKS, $f_dest_bug_id );
history_log_event_special( $f_dest_bug_id, BUG_ADD_RELATIONSHIP, BUG_DEPENDANT, $f_src_bug_id );

break;

case BUG_DEPENDANT:
# Add relation to the DB
relationship_add( $f_src_bug_id, $f_dest_bug_id, BUG_DEPENDANT );

# Add log line to the history (both bugs)
history_log_event_special( $f_src_bug_id, BUG_ADD_RELATIONSHIP, BUG_DEPENDANT, $f_dest_bug_id );
history_log_event_special( $f_dest_bug_id, BUG_ADD_RELATIONSHIP, BUG_BLOCKS, $f_src_bug_id );

break;

case BUG_HAS_DUPLICATE:
# BUG_HAS_DUPLICATE -> swap src and dest with relationship BUG_DUPLICATE

# Add relation to the DB
relationship_add( $f_dest_bug_id, $f_src_bug_id, BUG_DUPLICATE );
# Update the relationship
relationship_update( $t_old_id_relationship, $f_src_bug_id, $f_dest_bug_id, $f_rel_type );

# Add log line to the history (both bugs)
history_log_event_special( $f_src_bug_id, BUG_ADD_RELATIONSHIP, BUG_HAS_DUPLICATE, $f_dest_bug_id );
history_log_event_special( $f_dest_bug_id, BUG_ADD_RELATIONSHIP, BUG_DUPLICATE, $f_src_bug_id );

break;

case BUG_DUPLICATE:
# Add relation to the DB
relationship_add( $f_src_bug_id, $f_dest_bug_id, BUG_DUPLICATE );

# Add log line to the history (both bugs)
history_log_event_special( $f_src_bug_id, BUG_ADD_RELATIONSHIP, BUG_DUPLICATE, $f_dest_bug_id );
history_log_event_special( $f_dest_bug_id, BUG_ADD_RELATIONSHIP, BUG_HAS_DUPLICATE, $f_src_bug_id );

break;

case BUG_RELATED:
relationship_add( $f_src_bug_id, $f_dest_bug_id, BUG_RELATED );

# Add log line to the history (both bugs)
history_log_event_special( $f_src_bug_id, BUG_ADD_RELATIONSHIP, BUG_RELATED, $f_dest_bug_id );
history_log_event_special( $f_dest_bug_id, BUG_ADD_RELATIONSHIP, BUG_RELATED, $f_src_bug_id );

break;

default:
trigger_error( ERROR_GENERIC, ERROR );
# Add log line to the history (both bugs)
history_log_event_special( $f_src_bug_id, BUG_REPLACE_RELATIONSHIP, $f_rel_type, $f_dest_bug_id );
history_log_event_special( $f_dest_bug_id, BUG_REPLACE_RELATIONSHIP, relationship_get_complementary_type( $f_rel_type ), $f_src_bug_id );
}
else {
# Add the new relationship
relationship_add( $f_src_bug_id, $f_dest_bug_id, $f_rel_type );

break;
# Add log line to the history (both bugs)
history_log_event_special( $f_src_bug_id, BUG_ADD_RELATIONSHIP, $f_rel_type, $f_dest_bug_id );
history_log_event_special( $f_dest_bug_id, BUG_ADD_RELATIONSHIP, relationship_get_complementary_type( $f_rel_type ), $f_src_bug_id );
}

# update bug last updated (just for the src bug)
bug_update_date( $f_src_bug_id );

# send email notification to the users addressed by both the bugs
email_relationship_added( $f_src_bug_id );
email_relationship_added( $f_dest_bug_id );
email_relationship_added( $f_src_bug_id, $f_dest_bug_id, $f_rel_type );
email_relationship_added( $f_dest_bug_id, $f_src_bug_id, relationship_get_complementary_type( $f_rel_type ) );

print_header_redirect_view( $f_src_bug_id );

Expand Down
65 changes: 9 additions & 56 deletions bug_relationship_delete.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: bug_relationship_delete.php,v 1.4 2004-09-16 13:56:48 thraxisp Exp $
# $Id: bug_relationship_delete.php,v 1.5 2004-10-05 21:12:41 prichards Exp $
# --------------------------------------------------------

# --------------------------------------------------------
Expand Down Expand Up @@ -64,61 +64,14 @@
# update bug last updated (just for the src bug)
bug_update_date( $f_bug_id );

# Add log lines to both the histories
switch ( $t_rel_type ) {
case BUG_BLOCKS:
history_log_event_special( $f_bug_id, BUG_DEL_RELATIONSHIP, BUG_BLOCKS, $t_dest_bug_id );
email_relationship_deleted( $f_bug_id );

if ( bug_exists( $t_dest_bug_id )) {
history_log_event_special( $t_dest_bug_id, BUG_DEL_RELATIONSHIP, BUG_DEPENDANT, $f_bug_id );
email_relationship_deleted( $t_dest_bug_id );
}
break;

case BUG_DEPENDANT:
history_log_event_special( $f_bug_id, BUG_DEL_RELATIONSHIP, BUG_DEPENDANT, $t_dest_bug_id );
email_relationship_deleted( $f_bug_id );

if ( bug_exists( $t_dest_bug_id )) {
history_log_event_special( $t_dest_bug_id, BUG_DEL_RELATIONSHIP, BUG_BLOCKS, $f_bug_id );
email_relationship_deleted( $t_dest_bug_id );
}
break;

case BUG_HAS_DUPLICATE:
history_log_event_special( $f_bug_id, BUG_DEL_RELATIONSHIP, BUG_HAS_DUPLICATE, $t_dest_bug_id );
email_relationship_deleted( $f_bug_id );

if ( bug_exists( $t_dest_bug_id )) {
history_log_event_special( $t_dest_bug_id, BUG_DEL_RELATIONSHIP, BUG_DUPLICATE, $f_bug_id );
email_relationship_deleted( $t_dest_bug_id );
}
break;

case BUG_DUPLICATE:
history_log_event_special( $f_bug_id, BUG_DEL_RELATIONSHIP, BUG_DUPLICATE, $t_dest_bug_id );
email_relationship_deleted( $f_bug_id );

if ( bug_exists( $t_dest_bug_id )) {
history_log_event_special( $t_dest_bug_id, BUG_DEL_RELATIONSHIP, BUG_HAS_DUPLICATE, $f_bug_id );
email_relationship_deleted( $t_dest_bug_id );
}
break;

case BUG_RELATED:
history_log_event_special( $f_bug_id, BUG_DEL_RELATIONSHIP, BUG_RELATED, $t_dest_bug_id );
email_relationship_deleted( $f_bug_id );

if ( bug_exists( $t_dest_bug_id )) {
history_log_event_special( $t_dest_bug_id, BUG_DEL_RELATIONSHIP, BUG_RELATED, $f_bug_id );
email_relationship_deleted( $t_dest_bug_id );
}
break;

default:
trigger_error( ERROR_GENERIC, ERROR );
break;
# send email and update the history for the src issue
history_log_event_special( $f_bug_id, BUG_DEL_RELATIONSHIP, $t_rel_type, $t_dest_bug_id );
email_relationship_deleted( $f_bug_id, $t_dest_bug_id, $t_rel_type );

if ( bug_exists( $t_dest_bug_id )) {
# send email and update the history for the dest issue
history_log_event_special( $t_dest_bug_id, BUG_DEL_RELATIONSHIP, relationship_get_complementary_type( $t_rel_type ), $f_bug_id );
email_relationship_deleted( $t_dest_bug_id, $f_bug_id, relationship_get_complementary_type( $t_rel_type ) );
}

print_header_redirect_view( $f_bug_id );
Expand Down
22 changes: 13 additions & 9 deletions bug_report.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: bug_report.php,v 1.38 2004-08-21 13:27:25 prichards Exp $
# $Id: bug_report.php,v 1.39 2004-10-05 21:12:41 prichards Exp $
# --------------------------------------------------------

# This page stores the reported bug
Expand Down Expand Up @@ -120,23 +120,27 @@
}

$f_master_bug_id = gpc_get_int( 'm_id', 0 );
$f_rel_type = gpc_get_int( 'rel_type', -1 );

if( $f_master_bug_id > 0 ) {
if( $f_master_bug_id > 0 && $f_rel_type >= 0 ) {
# it's a child generation... let's create the relationship and add some lines in the history

# update master bug last updated
bug_update_date( $f_master_bug_id );

# Add log line to record the cloning action
history_log_event_special( $t_bug_id, BUG_CREATED_FROM, '', $f_master_bug_id );
history_log_event_special( $f_master_bug_id, BUG_CLONED_TO, '', $t_bug_id );

# Add relation
relationship_add( $f_master_bug_id, $t_bug_id, BUG_DEPENDANT );
# Add the relationship
relationship_add( $t_bug_id, $f_master_bug_id, $f_rel_type );

# Add log line to the history (both bugs)
history_log_event_special( $f_master_bug_id, BUG_ADD_RELATIONSHIP, BUG_DEPENDANT, $t_bug_id );
history_log_event_special( $t_bug_id, BUG_ADD_RELATIONSHIP, BUG_BLOCKS, $f_master_bug_id );
# Add log line to the history (both issues)
history_log_event_special( $f_master_bug_id, BUG_ADD_RELATIONSHIP, relationship_get_complementary_type( $f_rel_type ), $t_bug_id );
history_log_event_special( $t_bug_id, BUG_ADD_RELATIONSHIP, $f_rel_type, $f_master_bug_id );

# send email notification to the users addressed by the master bug
email_relationship_added( $f_master_bug_id );
# Send the email notification
email_relationship_added( $f_master_bug_id, $t_bug_id, relationship_get_complementary_type( $f_rel_type ) );
}

email_new_bug( $t_bug_id );
Expand Down
19 changes: 18 additions & 1 deletion bug_report_advanced_page.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: bug_report_advanced_page.php,v 1.43 2004-09-22 08:52:37 bpfennigschmidt Exp $
# $Id: bug_report_advanced_page.php,v 1.44 2004-10-05 21:12:41 prichards Exp $
# --------------------------------------------------------

# This file POSTs data to report_bug.php
Expand Down Expand Up @@ -418,6 +418,23 @@
</td>
</tr>

<!-- Relationship (in case of cloned bug creation...) -->
<?php
if( $f_master_bug_id > 0 ) {
?>
<tr <?php echo helper_alternate_class() ?>>
<td class="category">
<?php echo lang_get( 'relationship_with_parent' ) ?>
</td>
<td>
<?php relationship_list_box_for_cloned_bug( BUG_BLOCKS ) ?>
<?php PRINT '<b>' . lang_get( 'bug' ) . ' ' . bug_format_id( $f_master_bug_id ) . '</b>' ?>
</td>
</tr>
<?php
}
?>

<!-- Report Stay (report more bugs) -->
<tr <?php echo helper_alternate_class() ?>>
<td class="category">
Expand Down
19 changes: 18 additions & 1 deletion bug_report_page.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: bug_report_page.php,v 1.45 2004-09-22 08:52:37 bpfennigschmidt Exp $
# $Id: bug_report_page.php,v 1.46 2004-10-05 21:12:41 prichards Exp $
# --------------------------------------------------------

# This file POSTs data to report_bug.php
Expand Down Expand Up @@ -304,6 +304,23 @@
</td>
</tr>

<!-- Relationship (in case of cloned bug creation...) -->
<?php
if( $f_master_bug_id > 0 ) {
?>
<tr <?php echo helper_alternate_class() ?>>
<td class="category">
<?php echo lang_get( 'relationship_with_parent' ) ?>
</td>
<td>
<?php relationship_list_box_for_cloned_bug( BUG_BLOCKS ) ?>
<?php PRINT '<b>' . lang_get( 'bug' ) . ' ' . bug_format_id( $f_master_bug_id ) . '</b>' ?>
</td>
</tr>
<?php
}
?>

<!-- Report Stay (report more bugs) -->
<tr <?php echo helper_alternate_class() ?>>
<td class="category">
Expand Down
39 changes: 19 additions & 20 deletions core/bug_api.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: bug_api.php,v 1.85 2004-10-04 16:53:13 thraxisp Exp $
# $Id: bug_api.php,v 1.86 2004-10-05 21:10:14 prichards Exp $
# --------------------------------------------------------

$t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR;
Expand Down Expand Up @@ -1108,34 +1108,33 @@ function bug_resolve( $p_bug_id, $p_resolution, $p_fixed_in_version = '', $p_bug
bug_ensure_exists( $p_duplicate_id );

if( ON == config_get( 'enable_relationship' ) ) {
$t_relationship_id = relationship_exists( $p_bug_id, $p_duplicate_id );
if( $t_relationship_id > 0 ) {
# there is already a relationship between the bugs... we check if it's of the right type (otherwise error)

$t_relationship = relationship_get( $t_relationship_id );
if( $t_relationship != null ) {
if( ( $t_relationship->type != BUG_DUPLICATE ) && ( $t_relationship->type != BUG_HAS_DUPLICATE )) {
# the relationship is not duplicates/has duplicated -> error
trigger_error( ERROR_RELATIONSHIP_ALREADY_EXISTS, ERROR );
}
}
# check if there is other relationship between the bugs...
$t_id_relationship = relationship_same_type_exists( $p_bug_id, $p_duplicate_id, BUG_DUPLICATE );

if ( $t_id_relationship == -1 ) {
# the relationship type is already set. Nothing to do
}
else {
# no relationship found... we add the duplicate relationship
else if ( $t_id_relationship > 0 ) {
# there is already a relationship between them -> we have to update it and not to add a new one
helper_ensure_confirmed( lang_get( 'replace_relationship_sure_msg' ), lang_get( 'replace_relationship_button' ) );

# user can access to the related bug at least as viewer...
if( !access_has_bug_level( VIEWER, $p_duplicate_id ) ) {
error_parameters( $p_duplicate_id );
trigger_error( ERROR_RELATIONSHIP_ACCESS_LEVEL_TO_DEST_BUG_TOO_LOW, ERROR );
}
# Update the relationship
relationship_update( $t_id_relationship, $p_bug_id, $p_duplicate_id, BUG_DUPLICATE );

# Relationship feature active
# Add log line to the history (both bugs)
history_log_event_special( $p_bug_id, BUG_REPLACE_RELATIONSHIP, BUG_DUPLICATE, $p_duplicate_id );
history_log_event_special( $p_duplicate_id, BUG_REPLACE_RELATIONSHIP, BUG_HAS_DUPLICATE, $p_bug_id );
}
else {
# Add the new relationship
relationship_add( $p_bug_id, $p_duplicate_id, BUG_DUPLICATE );

# Add log line to the history (both bugs)
history_log_event_special( $p_bug_id, BUG_ADD_RELATIONSHIP, BUG_DUPLICATE, $p_duplicate_id );
history_log_event_special( $p_duplicate_id, BUG_ADD_RELATIONSHIP, BUG_HAS_DUPLICATE, $p_bug_id );
}
}

bug_set_field( $p_bug_id, 'duplicate_id', (int)$p_duplicate_id );
# MASC RELATIONSHIP
}
Expand Down
3 changes: 2 additions & 1 deletion core/constant_inc.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: constant_inc.php,v 1.32 2004-10-05 17:20:33 thraxisp Exp $
# $Id: constant_inc.php,v 1.33 2004-10-05 21:10:14 prichards Exp $
# --------------------------------------------------------

### CONSTANTS ###
Expand Down Expand Up @@ -141,6 +141,7 @@
define( 'BUG_CLONED_TO', 20 );
define( 'BUG_CREATED_FROM', 21 );
define( 'CHECKIN', 22 );
define( 'BUG_REPLACE_RELATIONSHIP', 23 );

# bug relationship constants
define( 'BUG_DUPLICATE', 0 );
Expand Down

0 comments on commit 3df7d2c

Please sign in to comment.