Skip to content

Commit

Permalink
Fix #19929: Support 'due date' in group actions
Browse files Browse the repository at this point in the history
PR #737

Signed-off-by: Damien Regad <dregad@mantisbt.org>

Original commit modified to use new date_strtotime() API.
  • Loading branch information
Luke authored and dregad committed Mar 19, 2016
1 parent 8448173 commit 4b66b54
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 2 deletions.
12 changes: 12 additions & 0 deletions bug_actiongroup.php
Expand Up @@ -286,6 +286,18 @@
$t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_access' );
}
break;
case 'UP_DUE_DATE':
$t_due_date = gpc_get_string( 'due_date', null );
if( $t_due_date !== null ) {
$t_due_date = date_strtotime( $t_due_date );

if( access_has_bug_level( config_get( 'due_date_update_threshold' ), $t_bug_id ) ) {
bug_set_field( $t_bug_id, 'due_date', $t_due_date );
} else {
$t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_access' );
}
}
break;
case 'VIEW_STATUS':
if( access_has_bug_level( config_get( 'change_view_status_threshold' ), $t_bug_id ) ) {
$f_view_status = gpc_get_int( 'view_status' );
Expand Down
30 changes: 28 additions & 2 deletions bug_actiongroup_page.php
Expand Up @@ -207,6 +207,11 @@
$t_button_title = lang_get( 'target_version_group_bugs_button' );
$t_form = 'target_version';
break;
case 'UP_DUE_DATE':
$t_question_title = lang_get( 'due_date_bugs_conf_msg' );
$t_button_title = lang_get( 'due_date_group_bugs_button' );
$t_form = 'due_date';
break;
case 'CUSTOM' :
$t_custom_field_def = custom_field_get_definition( $t_custom_field_id );
$t_question_title = sprintf( lang_get( 'actiongroup_menu_update_field' ), lang_get_defaulted( $t_custom_field_def['name'] ) );
Expand All @@ -216,7 +221,12 @@
default:
trigger_error( ERROR_GENERIC, ERROR );
}

if( $f_action === 'UP_DUE_DATE' ) {
require_js( 'jscalendar/calendar.js' );
require_js( 'jscalendar/lang/calendar-en.js' );
require_js( 'jscalendar/calendar-setup.js' );
require_css( 'calendar-blue.css' );
}
bug_group_action_print_top();

if( $t_multiple_projects ) {
Expand Down Expand Up @@ -260,7 +270,23 @@
}

print_custom_field_input( $t_custom_field_def, $t_bug_id );
} else {
} else if ( $f_action === 'UP_DUE_DATE' ) {
$t_bug_id = null;

# if there is only one issue, use its current value as default, otherwise,
# use the current due_date.
if( count( $f_bug_arr ) == 1 ) {
$t_bug_id = $f_bug_arr[0];
$t_bug = bug_get( $t_bug_id );

$t_date_to_display = '';
if( !date_is_null( $t_bug->due_date ) ) {
$t_date_to_display = date( config_get( 'calendar_date_format' ), $t_bug->due_date );
}
}

echo '<input type="text" id="due_date" name="due_date" class="datetime" size="20" maxlength="16" value="' . $t_date_to_display . '" />';
} else {
echo '<select name="' . $t_form . '">';

switch( $f_action ) {
Expand Down
5 changes: 5 additions & 0 deletions core/bug_group_action_api.php
Expand Up @@ -274,6 +274,11 @@ function bug_group_action_get_commands( array $p_project_ids = null ) {
$t_commands['EXT_ATTACH_TAGS'] = lang_get( 'actiongroup_menu_attach_tags' );
}

if( !isset( $t_commands['UP_DUE_DATE'] ) &&
access_has_project_level( config_get( 'due_date_update_threshold', null, null, $t_project_id ), $t_project_id ) ) {
$t_commands['UP_DUE_DATE'] = lang_get( 'actiongroup_menu_update_due_date' );
}

if( !isset( $t_commands['UP_PRODUCT_VERSION'] ) &&
version_should_show_product_version( $t_project_id ) &&
access_has_project_level( config_get( 'update_bug_threshold', null, null, $t_project_id ), $t_project_id ) ) {
Expand Down
3 changes: 3 additions & 0 deletions lang/strings_english.txt
Expand Up @@ -93,6 +93,7 @@ $s_actiongroup_menu_update_product_version = 'Update Product Version';
$s_actiongroup_menu_update_target_version = 'Update Target Version';
$s_actiongroup_menu_update_fixed_in_version = 'Update Fixed in Version';
$s_actiongroup_menu_update_product_build = 'Update Product Build';
$s_actiongroup_menu_update_due_date = 'Update Due Date';
$s_actiongroup_menu_add_note = 'Add Note';
$s_actiongroup_menu_attach_tags = 'Attach Tags';
$s_actiongroup_bugs = 'Selected Issues';
Expand Down Expand Up @@ -202,6 +203,7 @@ $s_set_sticky_bugs_conf_msg = 'Are you sure you wish to set/unset these issues s
$s_product_version_bugs_conf_msg = 'Update Product Version to';
$s_fixed_in_version_bugs_conf_msg = 'Update Fixed in Version to';
$s_target_version_bugs_conf_msg = 'Update Target Version to';
$s_due_date_bugs_conf_msg = 'Update Due Date to';
$s_close_group_bugs_button = 'Close Issues';
$s_delete_group_bugs_button = 'Delete Issues';
$s_move_group_bugs_button = 'Move Issues';
Expand All @@ -216,6 +218,7 @@ $s_set_sticky_group_bugs_button = 'Set/Unset Sticky';
$s_product_version_group_bugs_button = 'Update Product Version';
$s_fixed_in_version_group_bugs_button = 'Update Fixed in Version';
$s_target_version_group_bugs_button = 'Update Target Version';
$s_due_date_group_bugs_button = 'Update Due Date';
$s_update_severity_title = 'Update Severity';
$s_update_severity_msg = 'Choose issue severity';
$s_update_severity_button = 'Update Severity';
Expand Down

0 comments on commit 4b66b54

Please sign in to comment.