[Rt-commit] r16484 - rt/branches/3.999-DANGEROUS/lib/RT/Model
ruz at bestpractical.com
ruz at bestpractical.com
Tue Oct 21 22:54:44 EDT 2008
Author: ruz
Date: Tue Oct 21 22:54:44 2008
New Revision: 16484
Modified:
rt/branches/3.999-DANGEROUS/lib/RT/Model/Ticket.pm
Log:
* use status schemas in ticket create and set_status to set started and resolved dates
Modified: rt/branches/3.999-DANGEROUS/lib/RT/Model/Ticket.pm
==============================================================================
--- rt/branches/3.999-DANGEROUS/lib/RT/Model/Ticket.pm (original)
+++ rt/branches/3.999-DANGEROUS/lib/RT/Model/Ticket.pm Tue Oct 21 22:54:44 2008
@@ -416,7 +416,7 @@
my $started = RT::Date->new();
if ( defined $args{'started'} ) {
$started->set( format => 'ISO', value => $args{'started'} );
- } elsif ( $args{'status'} ne 'new' ) {
+ } elsif ( !$queue_obj->status_schema->is_initial( $args{'status'} ) ) {
$started->set_to_now;
}
@@ -2466,24 +2466,23 @@
}
}
- if ( !$args{Force}
- && ( $args{'status'} eq 'resolved' )
+ my $schema = $self->queue->status_schema;
+ unless ( $schema->is_valid( $args{'status'} ) ) {
+ return ( 0, _( "'%1' is an invalid value for status", $args{'status'} ) );
+ }
+
+ if ( !$args{force}
+ && $schema->is_inactive( $args{'status'} ) )
&& $self->has_unresolved_dependencies )
{
return ( 0, _('That ticket has unresolved dependencies') );
}
- unless ( $self->queue->status_schema->is_valid( $args{'status'} ) ) {
- return ( 0, _( "'%1' is an invalid value for status", $args{'status'} ) );
- }
-
my $now = RT::Date->new;
$now->set_to_now();
- #If we're changing the status from new, record that we've started
- if ( $self->status eq 'new' && $args{status} ne 'new' ) {
-
- #Set the started time to "now"
+ #If we're changing the status from intial to non-initial, record that we've started
+ if ( $schema->is_initial( $self->status ) && !$schema->is_initial( $args{status} ) ) {
$self->_set(
column => 'started',
value => $now->iso,
@@ -2493,7 +2492,7 @@
#When we close a ticket, set the 'resolved' attribute to now.
# It's misnamed, but that's just historical.
- if ( $self->queue->status_schema->is_inactive( $args{status} ) ) {
+ if ( $schema->is_inactive( $args{status} ) ) {
$self->_set(
column => 'resolved',
value => $now->iso,
@@ -2513,9 +2512,6 @@
return ( $val, $msg );
}
-
-
-
=head2 set_told ISO [TIMETAKEN]
Updates the told and records a transaction
More information about the Rt-commit
mailing list