Skip to content

Commit

Permalink
Misc. fixes for my bugobjects/duedate work
Browse files Browse the repository at this point in the history
  • Loading branch information
mantis committed Jun 14, 2009
1 parent 112d3c6 commit 27213a2
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 68 deletions.
2 changes: 1 addition & 1 deletion bug_change_status_page.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
<?php if ( $t_can_update_due_date ) {
$t_date_to_display = '';
if ( !date_is_null( $t_bug->due_date ) ) {
$t_date_to_display = date( config_get( 'short_date_format' ), $t_bug->due_date );
$t_date_to_display = date( config_get( 'calendar_date_format' ), $t_bug->due_date );
}
?>
<tr <?php echo helper_alternate_class() ?>>
Expand Down
4 changes: 2 additions & 2 deletions bug_report_advanced_page.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
$f_steps_to_reproduce = gpc_get_string( 'steps_to_reproduce', config_get( 'default_bug_steps_to_reproduce' ) );
$f_additional_info = gpc_get_string( 'additional_info', config_get ( 'default_bug_additional_info' ) );
$f_view_state = gpc_get_int( 'view_state', config_get( 'default_bug_view_status' ) );
$f_due_date =gpc_get_string( 'due_date', '');
$f_due_date = gpc_get_string( 'due_date', '');

if ( $f_due_date == '' ) {
$f_due_date = date_get_null();
Expand Down Expand Up @@ -213,7 +213,7 @@
<?php if ( $t_can_update_due_date ) {
$t_date_to_display = '';
if ( !date_is_null( $f_due_date ) ) {
$t_date_to_display = date( config_get( 'short_date_format' ), $f_due_date );
$t_date_to_display = date( config_get( 'calendar_date_format' ), $f_due_date );
}
?>
<tr <?php echo helper_alternate_class() ?>>
Expand Down
2 changes: 1 addition & 1 deletion bug_update_advanced_page.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@
if ( access_has_bug_level( config_get( 'due_date_update_threshold' ), $f_bug_id ) ) {
$t_date_to_display = '';
if ( !date_is_null( $t_bug->due_date ) ) {
$t_date_to_display = date( config_get( 'short_date_format' ), $t_bug->due_date );
$t_date_to_display = date( config_get( 'calendar_date_format' ), $t_bug->due_date );
}
print "<input ".helper_get_tab_index()." type=\"text\" id=\"due_date\" name=\"due_date\" size=\"20\" maxlength=\"16\" value=\"".$t_date_to_display."\">";
date_print_calendar();
Expand Down
4 changes: 2 additions & 2 deletions bug_view_advanced_page.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@
?>
<?php
if ( !date_is_null( $t_bug->due_date ) ) {
echo date( config_get( 'short_date_format' ), $t_bug->due_date ); }
echo date( config_get( 'normal_date_format' ), $t_bug->due_date ); }
?>
</td>
<?php } else { ?>
Expand Down Expand Up @@ -643,7 +643,7 @@
include( $t_mantis_dir . 'bug_sponsorship_list_view_inc.php' );

# Bug Relationships
relationship_view_box ( $t_bug );
relationship_view_box ( $t_bug->id );

# File upload box
if ( !bug_is_readonly( $f_bug_id ) ) {
Expand Down
123 changes: 63 additions & 60 deletions core/bug_api.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,20 @@ public function __set($name, $value) {
trigger_error( ERROR_ACCESS_DENIED, ERROR );
}
}
break;
case 'target_version':
if ( !$this->loading ) {
# Only set target_version if user has access to do so
if( !access_has_project_level( config_get( 'roadmap_update_threshold' ) ) ) {
trigger_error( ERROR_ACCESS_DENIED, ERROR );
}
}
break;
case 'due_date':
if ( !is_numeric( $value ) ) {
$value = strtotime($value);
}
break;
}
$this->$name = $value;
}
Expand Down Expand Up @@ -226,7 +233,7 @@ function validate( $p_update_extended = true) {
trigger_error( ERROR_EMPTY_FIELD, ERROR );
}

if( !is_blank( $p_bug_data->duplicate_id ) && ( $p_bug_data->duplicate_id != 0 ) && ( $p_bug_id == $p_bug_data->duplicate_id ) ) {
if( !is_blank( $this->duplicate_id ) && ( $this->duplicate_id != 0 ) && ( $this->id == $this->duplicate_id ) ) {
trigger_error( ERROR_BUG_DUPLICATE_SELF, ERROR );
# never returns
}
Expand All @@ -243,10 +250,8 @@ function create() {
self::validate( true );

# check due_date format
if( !is_blank( $this->due_date ) ) {
$c_due_date = $p_bug_data->due_date;
} else {
$c_due_date = date_get_null();
if( is_blank( $this->due_date ) ) {
$this_due_date = date_get_null();
}

$t_bug_table = db_get_table( 'mantis_bug_table' );
Expand Down Expand Up @@ -335,15 +340,13 @@ function create() {
function update( $p_update_extended = false, $p_bypass_mail = false ) {
self::validate( $p_update_extended );

$c_bug_data = $p_bug_data;
$c_bug_id = $this->id;

if( !is_blank( $p_bug_data->due_date ) ) {
$c_due_date = db_bind_timestamp( $p_bug_data->due_date, true );
} else {
$c_due_date = db_null_date();
if( is_blank( $this->due_date ) ) {
$this->due_date = date_get_null();
}

$t_old_data = bug_get( $p_bug_id, true );
$t_old_data = bug_get( $this->id, true );

$t_bug_table = db_get_table( 'mantis_bug_table' );

Expand Down Expand Up @@ -393,7 +396,7 @@ function update( $p_update_extended = false, $p_bypass_mail = false ) {
$t_fields[] = $this->view_state;
$t_fields[] = $this->summary;
$t_fields[] = $this->sponsorship_total;
$t_fields[] = (bool) $this->sticky;
$t_fields[] = (bool)$this->sticky;
$t_fields[] = $this->due_date;
$t_fields[] = $this->id;

Expand All @@ -402,97 +405,97 @@ function update( $p_update_extended = false, $p_bypass_mail = false ) {
bug_clear_cache( $this->id );

# log changes
history_log_event_direct( $p_bug_id, 'project_id', $t_old_data->project_id, $p_bug_data->project_id );
history_log_event_direct( $p_bug_id, 'reporter_id', $t_old_data->reporter_id, $p_bug_data->reporter_id );
history_log_event_direct( $p_bug_id, 'handler_id', $t_old_data->handler_id, $p_bug_data->handler_id );
history_log_event_direct( $p_bug_id, 'priority', $t_old_data->priority, $p_bug_data->priority );
history_log_event_direct( $p_bug_id, 'severity', $t_old_data->severity, $p_bug_data->severity );
history_log_event_direct( $p_bug_id, 'reproducibility', $t_old_data->reproducibility, $p_bug_data->reproducibility );
history_log_event_direct( $p_bug_id, 'status', $t_old_data->status, $p_bug_data->status );
history_log_event_direct( $p_bug_id, 'resolution', $t_old_data->resolution, $p_bug_data->resolution );
history_log_event_direct( $p_bug_id, 'projection', $t_old_data->projection, $p_bug_data->projection );
history_log_event_direct( $p_bug_id, 'category', category_full_name( $t_old_data->category_id, false ), category_full_name( $p_bug_data->category_id, false ) );
history_log_event_direct( $p_bug_id, 'eta', $t_old_data->eta, $p_bug_data->eta );
history_log_event_direct( $p_bug_id, 'os', $t_old_data->os, $p_bug_data->os );
history_log_event_direct( $p_bug_id, 'os_build', $t_old_data->os_build, $p_bug_data->os_build );
history_log_event_direct( $p_bug_id, 'platform', $t_old_data->platform, $p_bug_data->platform );
history_log_event_direct( $p_bug_id, 'version', $t_old_data->version, $p_bug_data->version );
history_log_event_direct( $p_bug_id, 'build', $t_old_data->build, $p_bug_data->build );
history_log_event_direct( $p_bug_id, 'fixed_in_version', $t_old_data->fixed_in_version, $p_bug_data->fixed_in_version );
history_log_event_direct( $c_bug_id, 'project_id', $t_old_data->project_id, $this->project_id );
history_log_event_direct( $c_bug_id, 'reporter_id', $t_old_data->reporter_id, $this->reporter_id );
history_log_event_direct( $c_bug_id, 'handler_id', $t_old_data->handler_id, $this->handler_id );
history_log_event_direct( $c_bug_id, 'priority', $t_old_data->priority, $this->priority );
history_log_event_direct( $c_bug_id, 'severity', $t_old_data->severity, $this->severity );
history_log_event_direct( $c_bug_id, 'reproducibility', $t_old_data->reproducibility, $this->reproducibility );
history_log_event_direct( $c_bug_id, 'status', $t_old_data->status, $this->status );
history_log_event_direct( $c_bug_id, 'resolution', $t_old_data->resolution, $this->resolution );
history_log_event_direct( $c_bug_id, 'projection', $t_old_data->projection, $this->projection );
history_log_event_direct( $c_bug_id, 'category', category_full_name( $t_old_data->category_id, false ), category_full_name( $this->category_id, false ) );
history_log_event_direct( $c_bug_id, 'eta', $t_old_data->eta, $this->eta );
history_log_event_direct( $c_bug_id, 'os', $t_old_data->os, $this->os );
history_log_event_direct( $c_bug_id, 'os_build', $t_old_data->os_build, $this->os_build );
history_log_event_direct( $c_bug_id, 'platform', $t_old_data->platform, $this->platform );
history_log_event_direct( $c_bug_id, 'version', $t_old_data->version, $this->version );
history_log_event_direct( $c_bug_id, 'build', $t_old_data->build, $this->build );
history_log_event_direct( $c_bug_id, 'fixed_in_version', $t_old_data->fixed_in_version, $this->fixed_in_version );
if( $t_roadmap_updated ) {
history_log_event_direct( $p_bug_id, 'target_version', $t_old_data->target_version, $p_bug_data->target_version );
history_log_event_direct( $c_bug_id, 'target_version', $t_old_data->target_version, $this->target_version );
}
history_log_event_direct( $p_bug_id, 'view_state', $t_old_data->view_state, $p_bug_data->view_state );
history_log_event_direct( $p_bug_id, 'summary', $t_old_data->summary, $p_bug_data->summary );
history_log_event_direct( $p_bug_id, 'sponsorship_total', $t_old_data->sponsorship_total, $p_bug_data->sponsorship_total );
history_log_event_direct( $p_bug_id, 'sticky', $t_old_data->sticky, $p_bug_data->sticky );
history_log_event_direct( $c_bug_id, 'view_state', $t_old_data->view_state, $this->view_state );
history_log_event_direct( $c_bug_id, 'summary', $t_old_data->summary, $this->summary );
history_log_event_direct( $c_bug_id, 'sponsorship_total', $t_old_data->sponsorship_total, $this->sponsorship_total );
history_log_event_direct( $c_bug_id, 'sticky', $t_old_data->sticky, $this->sticky );

history_log_event_direct( $p_bug_id, 'due_date', ( $t_old_data->due_date != date_get_null() ) ? $t_old_data->due_date : null, ( $p_bug_data->due_date != date_get_null() ) ? $p_bug_data->due_date : null );
history_log_event_direct( $c_bug_id, 'due_date', ( $t_old_data->due_date != date_get_null() ) ? $t_old_data->due_date : null, ( $this->due_date != date_get_null() ) ? $this->due_date : null );

# Update extended info if requested
if( $p_update_extended ) {
$t_bug_text_table = db_get_table( 'mantis_bug_text_table' );

$t_bug_text_id = bug_get_field( $p_bug_id, 'bug_text_id' );
$t_bug_text_id = bug_get_field( $c_bug_id, 'bug_text_id' );

$query = "UPDATE $t_bug_text_table
SET description=" . db_param() . ",
steps_to_reproduce=" . db_param() . ",
additional_information=" . db_param() . "
WHERE id=" . db_param();
db_query_bound( $query, Array( $c_bug_data->description, $c_bug_data->steps_to_reproduce, $c_bug_data->additional_information, $t_bug_text_id ) );
db_query_bound( $query, Array( $this->description, $this->steps_to_reproduce, $this->additional_information, $t_bug_text_id ) );

bug_text_clear_cache( $p_bug_id );
bug_text_clear_cache( $c_bug_id );

$t_current_user = auth_get_current_user_id();

if( $t_old_data->description != $p_bug_data->description ) {
if ( bug_revision_count( $p_bug_id, REV_DESCRIPTION ) < 1 ) {
$t_revision_id = bug_revision_add( $p_bug_id, $t_current_user, REV_DESCRIPTION, $t_old_data->description, 0, $t_old_data->last_updated );
if( $t_old_data->description != $this->description ) {
if ( bug_revision_count( $c_bug_id, REV_DESCRIPTION ) < 1 ) {
$t_revision_id = bug_revision_add( $c_bug_id, $t_current_user, REV_DESCRIPTION, $t_old_data->description, 0, $t_old_data->last_updated );
}
$t_revision_id = bug_revision_add( $p_bug_id, $t_current_user, REV_DESCRIPTION, $c_bug_data->description );
history_log_event_special( $p_bug_id, DESCRIPTION_UPDATED, $t_revision_id );
$t_revision_id = bug_revision_add( $c_bug_id, $t_current_user, REV_DESCRIPTION, $this->description );
history_log_event_special( $c_bug_id, DESCRIPTION_UPDATED, $t_revision_id );
}

if( $t_old_data->steps_to_reproduce != $p_bug_data->steps_to_reproduce ) {
if ( bug_revision_count( $p_bug_id, REV_STEPS_TO_REPRODUCE ) < 1 ) {
$t_revision_id = bug_revision_add( $p_bug_id, $t_current_user, REV_STEPS_TO_REPRODUCE, $t_old_data->steps_to_reproduce, 0, $t_old_data->last_updated );
if( $t_old_data->steps_to_reproduce != $this->steps_to_reproduce ) {
if ( bug_revision_count( $c_bug_id, REV_STEPS_TO_REPRODUCE ) < 1 ) {
$t_revision_id = bug_revision_add( $c_bug_id, $t_current_user, REV_STEPS_TO_REPRODUCE, $t_old_data->steps_to_reproduce, 0, $t_old_data->last_updated );
}
$t_revision_id = bug_revision_add( $p_bug_id, $t_current_user, REV_STEPS_TO_REPRODUCE, $c_bug_data->steps_to_reproduce );
history_log_event_special( $p_bug_id, STEP_TO_REPRODUCE_UPDATED, $t_revision_id );
$t_revision_id = bug_revision_add( $c_bug_id, $t_current_user, REV_STEPS_TO_REPRODUCE, $this->steps_to_reproduce );
history_log_event_special( $c_bug_id, STEP_TO_REPRODUCE_UPDATED, $t_revision_id );
}

if( $t_old_data->additional_information != $p_bug_data->additional_information ) {
if ( bug_revision_count( $p_bug_id, REV_ADDITIONAL_INFO ) < 1 ) {
$t_revision_id = bug_revision_add( $p_bug_id, $t_current_user, REV_ADDITIONAL_INFO, $t_old_data->additional_information, 0, $t_old_data->last_updated );
if( $t_old_data->additional_information != $this->additional_information ) {
if ( bug_revision_count( $c_bug_id, REV_ADDITIONAL_INFO ) < 1 ) {
$t_revision_id = bug_revision_add( $c_bug_id, $t_current_user, REV_ADDITIONAL_INFO, $t_old_data->additional_information, 0, $t_old_data->last_updated );
}
$t_revision_id = bug_revision_add( $p_bug_id, $t_current_user, REV_ADDITIONAL_INFO, $c_bug_data->additional_information );
history_log_event_special( $p_bug_id, ADDITIONAL_INFO_UPDATED, $t_revision_id );
$t_revision_id = bug_revision_add( $c_bug_id, $t_current_user, REV_ADDITIONAL_INFO, $this->additional_information );
history_log_event_special( $c_bug_id, ADDITIONAL_INFO_UPDATED, $t_revision_id );
}
}

# Update the last update date
bug_update_date( $p_bug_id );
bug_update_date( $c_bug_id );

# allow bypass if user is sending mail separately
if( false == $p_bypass_mail ) {
# status changed
if( $t_old_data->status != $p_bug_data->status ) {
$t_status = MantisEnum::getLabel( config_get( 'status_enum_string' ), $p_bug_data->status );
if( $t_old_data->status != $this->status ) {
$t_status = MantisEnum::getLabel( config_get( 'status_enum_string' ), $this->status );
$t_status = str_replace( ' ', '_', $t_status );
email_generic( $p_bug_id, $t_status, 'email_notification_title_for_status_bug_' . $t_status );
email_generic( $c_bug_id, $t_status, 'email_notification_title_for_status_bug_' . $t_status );
return true;
}

# bug assigned
if( $t_old_data->handler_id != $p_bug_data->handler_id ) {
email_generic( $p_bug_id, 'owner', 'email_notification_title_for_action_bug_assigned' );
if( $t_old_data->handler_id != $this->handler_id ) {
email_generic( $c_bug_id, 'owner', 'email_notification_title_for_action_bug_assigned' );
return true;
}

# @todo handle priority change if it requires special handling
# generic update notification
email_generic( $p_bug_id, 'updated', 'email_notification_title_for_action_bug_updated' );
email_generic( $c_bug_id, 'updated', 'email_notification_title_for_action_bug_updated' );
}

return true;
Expand Down
4 changes: 2 additions & 2 deletions core/history_api.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,10 +339,10 @@ function history_localize_item( $p_field_name, $p_type, $p_old_value, $p_new_val
break;
case 'due_date':
if( $p_old_value !== '' ) {
$p_old_value = date( config_get( 'short_date_format' ), (int) $p_old_value );
$p_old_value = date( config_get( 'normal_date_format' ), (int) $p_old_value );
}
if( $p_new_value !== '' ) {
$p_new_value = date( config_get( 'short_date_format' ), (int) $p_new_value );
$p_new_value = date( config_get( 'normal_date_format' ), (int) $p_new_value );
}
$t_field_localized = lang_get( 'due_date' );
break;
Expand Down
1 change: 1 addition & 0 deletions lang/strings_english.txt
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ $MANTIS_ERROR[ERROR_FORM_TOKEN_INVALID] = 'Invalid form security token. Did you
$MANTIS_ERROR[ERROR_INVALID_REQUEST_METHOD] = 'This page cannot be accessed using this method.';
$MANTIS_ERROR[ERROR_INVALID_SORT_FIELD] = 'Invalid sort field.';
$MANTIS_ERROR[ERROR_INVALID_DATE_FORMAT] = 'Invalid date format.';
$MANTIS_ERROR[ERROR_UPDATING_TIMEZONE] = 'Unable to update timezone.';

$s_login_error = 'Your account may be disabled or blocked or the username/password you entered is incorrect.';
$s_login_cookies_disabled = 'Your browser either does not know how to handle cookies, or refuses to handle them.';
Expand Down

0 comments on commit 27213a2

Please sign in to comment.