Skip to content

Commit

Permalink
Allow Reporters to Clone issues
Browse files Browse the repository at this point in the history
Pull request #130
  • Loading branch information
dregad committed Feb 12, 2014
2 parents 7fef194 + 274f267 commit b59f66f
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 34 deletions.
46 changes: 26 additions & 20 deletions bug_report.php
Expand Up @@ -78,6 +78,7 @@
form_security_validate( 'bug_report' );

$t_project_id = null;

$f_master_bug_id = gpc_get_int( 'm_id', 0 );
if ( $f_master_bug_id > 0 ) {
bug_ensure_exists( $f_master_bug_id );
Expand All @@ -86,19 +87,18 @@
trigger_error( ERROR_BUG_READ_ONLY_ACTION_DENIED, ERROR );
}
$t_master_bug = bug_get( $f_master_bug_id, true );
project_ensure_exists( $t_master_bug->project_id );
access_ensure_bug_level( config_get( 'update_bug_threshold', null, null, $t_master_bug->project_id ), $f_master_bug_id );
$t_project_id = $t_master_bug->project_id;
} else {
$f_project_id = gpc_get_int( 'project_id' );
project_ensure_exists( $f_project_id );
$t_project_id = $f_project_id;
}
project_ensure_exists( $t_project_id );

if ( $t_project_id != helper_get_current_project() ) {
$g_project_override = $t_project_id;
}

access_ensure_project_level( config_get('report_bug_threshold' ) );
access_ensure_project_level( config_get( 'report_bug_threshold' ) );

$t_bug_data = new BugData;
$t_bug_data->project_id = $t_project_id;
Expand Down Expand Up @@ -128,6 +128,7 @@
$t_bug_data->due_date = date_get_null();
}

$f_rel_type = gpc_get_int( 'rel_type', BUG_REL_NONE );
$f_files = gpc_get_file( 'ufile', null ); /** @todo (thraxisp) Note that this always returns a structure */
$f_report_stay = gpc_get_bool( 'report_stay', false );
$f_copy_notes_from_parent = gpc_get_bool( 'copy_notes_from_parent', false);
Expand Down Expand Up @@ -213,9 +214,6 @@
}
}

$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 ) {
# it's a child generation... let's create the relationship and add some lines in the history

Expand All @@ -226,7 +224,7 @@
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 );

if ( $f_rel_type >= 0 ) {
if ( $f_rel_type > BUG_REL_ANY ) {
# Add the relationship
relationship_add( $t_bug_id, $f_master_bug_id, $f_rel_type );

Expand All @@ -244,22 +242,30 @@
# copy notes from parent
if ( $f_copy_notes_from_parent ) {

$t_parent_bugnotes = bugnote_get_all_bugnotes( $f_master_bug_id );

foreach ( $t_parent_bugnotes as $t_parent_bugnote ) {

$t_private = $t_parent_bugnote->view_state == VS_PRIVATE;

bugnote_add( $t_bug_id, $t_parent_bugnote->note, $t_parent_bugnote->time_tracking,
$t_private, $t_parent_bugnote->note_type, $t_parent_bugnote->note_attr,
$t_parent_bugnote->reporter_id, /* send_email */ FALSE , /* date submitted */ 0,
/* date modified */ 0, /* log history */ FALSE);
}
$t_parent_bugnotes = bugnote_get_all_bugnotes( $f_master_bug_id );

foreach ( $t_parent_bugnotes as $t_parent_bugnote ) {
$t_private = $t_parent_bugnote->view_state == VS_PRIVATE;

bugnote_add(
$t_bug_id,
$t_parent_bugnote->note,
$t_parent_bugnote->time_tracking,
$t_private,
$t_parent_bugnote->note_type,
$t_parent_bugnote->note_attr,
$t_parent_bugnote->reporter_id,
/* send_email */ FALSE,
/* date submitted */ 0,
/* date modified */ 0,
/* log history */ FALSE
);
}
}

# copy attachments from parent
if ( $f_copy_attachments_from_parent ) {
file_copy_attachments( $f_master_bug_id, $t_bug_id );
file_copy_attachments( $f_master_bug_id, $t_bug_id );
}
}

Expand Down
26 changes: 14 additions & 12 deletions bug_report_page.php
Expand Up @@ -91,9 +91,6 @@

$t_bug = bug_get( $f_master_bug_id, true );

# the user can at least update the master bug (needed to add the relationship)...
access_ensure_bug_level( config_get( 'update_bug_threshold', null, null, $t_bug->project_id ), $f_master_bug_id );

#@@@ (thraxisp) Note that the master bug is cloned into the same project as the master, independent of
# what the current project is set to.
if( $t_bug->project_id != helper_get_current_project() ) {
Expand Down Expand Up @@ -481,13 +478,17 @@
</th>
<td>
<select <?php echo helper_get_tab_index() ?> name="status">
<?php
$resolution_options = get_status_option_list(access_get_project_level( $t_project_id),
config_get('bug_submit_status'), true,
ON == config_get( 'allow_reporter_close' ), $t_project_id );
<?php
$resolution_options = get_status_option_list(
access_get_project_level( $t_project_id ),
config_get( 'bug_submit_status' ),
true,
ON == config_get( 'allow_reporter_close' ),
$t_project_id
);
foreach ( $resolution_options as $key => $value ) {
?>
<option value="<?php echo $key ?>" <?php check_selected($key, config_get('bug_submit_status')); ?> >
<option value="<?php echo $key ?>" <?php check_selected( $key, config_get( 'bug_submit_status') ); ?> >
<?php echo $value ?>
</option>
<?php } ?>
Expand All @@ -503,8 +504,8 @@
</th>
<td>
<select <?php echo helper_get_tab_index() ?> name="resolution">
<?php
print_enum_string_option_list('resolution', config_get('default_bug_resolution'));
<?php
print_enum_string_option_list( 'resolution', config_get( 'default_bug_resolution' ) );
?>
</select>
</td>
Expand Down Expand Up @@ -628,9 +629,10 @@
<label><input <?php echo helper_get_tab_index() ?> type="radio" name="view_state" value="<?php echo VS_PRIVATE ?>" <?php check_checked( $f_view_state, VS_PRIVATE ) ?> /> <?php echo lang_get( 'private' ) ?></label>
</td>
</tr>
<?php
<?php
}
//Relationship (in case of cloned bug creation...)

# Relationship (in case of cloned bug creation...)
if( $f_master_bug_id > 0 ) {
?>
<tr>
Expand Down
4 changes: 2 additions & 2 deletions core/html_api.php
Expand Up @@ -1618,12 +1618,12 @@ function html_button_bug_move( $p_bug_id ) {
}

/**
* Print a button to move the given bug to a different project
* Print a button to clone the given bug
* @param int $p_bug_id
* @return null
*/
function html_button_bug_create_child( $p_bug_id ) {
if( access_has_bug_level( config_get( 'update_bug_threshold' ), $p_bug_id ) ) {
if( access_has_bug_level( config_get( 'report_bug_threshold' ), $p_bug_id ) ) {
html_button( string_get_bug_report_url(), lang_get( 'create_child_bug_button' ), array( 'm_id' => $p_bug_id ) );
}
}
Expand Down

0 comments on commit b59f66f

Please sign in to comment.