Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: mantisbt/mantisbt
base: 7fef194b3918
...
head fork: mantisbt/mantisbt
compare: b59f66f9ac3d
Checking mergeability… Don't worry, you can still create the pull request.
  • 5 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
Commits on Feb 12, 2014
@dregad dregad Allow Reporters to Clone issues
Pull request #130
b59f66f
Commits on Feb 13, 2014
@dregad dregad Whitespace, code layout and guidelines cbc9382
@dregad dregad Code cleanup in bug_report.php
- Move $f_rel_type init to where others form vars are set
- Remove duplicate initialization of form variable $f_master_bug_id
- Use defined $t_project_id instead of $t_master_bug->project_id
- Replace hardcoded numbers with relationship constants
a0ae5ce
@dregad dregad Allow Reporters to Clone issues
Previously, users needed to have update_bug_threshold to be able to
clone issues, since the creation of a relationship with the parent bug
requires to update it.

This patch lets Reporters clone issues and allows them to create a
relationship with the parent, even if they lack updater access.

Fixes #11290 (implements option 3)
8aafaaf
@dregad dregad Correct comparison operator 274f267
Showing with 42 additions and 34 deletions.
  1. +26 −20 bug_report.php
  2. +14 −12 bug_report_page.php
  3. +2 −2 core/html_api.php
View
46 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 );
}
}
View
26 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 @@
</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 } ?>
@@ -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>
@@ -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>
View
4 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 ) );
}
}

No commit comments for this range

Something went wrong with that request. Please try again.