diff --git a/bug_report.php b/bug_report.php index 8870a59acf..e91a7b1a37 100644 --- a/bug_report.php +++ b/bug_report.php @@ -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 ); @@ -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; @@ -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); @@ -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 @@ -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 ); @@ -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 ); } } diff --git a/bug_report_page.php b/bug_report_page.php index 6cd6388a27..c23507fdbf 100644 --- a/bug_report_page.php +++ b/bug_report_page.php @@ -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() ) { @@ -481,13 +478,17 @@ name="resolution"> - @@ -628,9 +629,10 @@ - 0 ) { ?> diff --git a/core/html_api.php b/core/html_api.php index 867b55a6bd..d84359fe89 100644 --- a/core/html_api.php +++ b/core/html_api.php @@ -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 ) ); } }