diff options
author | mark <mark> | 2011-08-23 21:45:51 +0000 |
---|---|---|
committer | mark <mark> | 2011-08-23 21:45:51 +0000 |
commit | 4c8c18409f82d56320a80f6c94f275fa15486897 (patch) | |
tree | deeb2cb64572fb1cd00cb55be48eaa68a69d9984 /rt/lib/RT | |
parent | 006b2392be94f9670eddf3d01ba89c00f9c16c05 (diff) |
RT future ticket resolve, #13853
Diffstat (limited to 'rt/lib/RT')
-rw-r--r-- | rt/lib/RT/Action/ScheduledResolve.pm | 37 | ||||
-rw-r--r-- | rt/lib/RT/Action/SetWillResolve.pm | 27 | ||||
-rw-r--r-- | rt/lib/RT/Interface/Web_Vendor.pm | 56 | ||||
-rw-r--r-- | rt/lib/RT/Ticket_Vendor.pm | 29 | ||||
-rw-r--r-- | rt/lib/RT/Tickets_Overlay.pm | 2 | ||||
-rw-r--r-- | rt/lib/RT/Transaction_Vendor.pm | 35 |
6 files changed, 185 insertions, 1 deletions
diff --git a/rt/lib/RT/Action/ScheduledResolve.pm b/rt/lib/RT/Action/ScheduledResolve.pm new file mode 100644 index 000000000..6b323cb6f --- /dev/null +++ b/rt/lib/RT/Action/ScheduledResolve.pm @@ -0,0 +1,37 @@ +package RT::Action::ScheduledResolve; + +use strict; +use warnings; + +use base qw(RT::Action); + +=head1 DESCRIPTION + +If the ticket's WillResolve date is in the past, set its status to resolved. + +=cut + +sub Prepare { + my $self = shift; + + return undef if grep { $self->TicketObj->Status eq $_ } ( + 'resolved', + 'rejected', + 'deleted' + ); # don't resolve from any of these states. + my $time = $self->TicketObj->WillResolveObj->Unix; + return ( $time > 0 and $time < time() ); +} + +sub Commit { + my $self = shift; + + my $never = RT::Date->new($self->CurrentUser); + $never->Unix(-1); + $self->TicketObj->SetWillResolve($never->ISO); + $self->TicketObj->SetStatus('resolved'); +} + +RT::Base->_ImportOverlays(); + +1; diff --git a/rt/lib/RT/Action/SetWillResolve.pm b/rt/lib/RT/Action/SetWillResolve.pm new file mode 100644 index 000000000..807b3c64c --- /dev/null +++ b/rt/lib/RT/Action/SetWillResolve.pm @@ -0,0 +1,27 @@ +package RT::Action::SetWillResolve; +use base 'RT::Action'; + +use strict; + +sub Describe { + my $self = shift; + return (ref $self ." will set a ticket's future resolve date to the argument."); +} + +sub Prepare { + return 1; +} + +sub Commit { + my $self = shift; + my $DateObj = RT::Date->new( $self->CurrentUser ); + $DateObj->Set( + Format => 'unknown', + Value => $self->Argument, + ); + $self->TicketObj->SetWillResolve( $DateObj->ISO ); +} + +RT::Base->_ImportOverlays(); + +1; diff --git a/rt/lib/RT/Interface/Web_Vendor.pm b/rt/lib/RT/Interface/Web_Vendor.pm index c79222be5..27c647f18 100644 --- a/rt/lib/RT/Interface/Web_Vendor.pm +++ b/rt/lib/RT/Interface/Web_Vendor.pm @@ -255,8 +255,62 @@ sub ProcessTicketBasics { push( @results, $msg ); } - # }}} + return (@results); +} + +=head2 ProcessTicketDates (TicketObj => RT::Ticket, ARGSRef => {}) + +Process updates to the Starts, Started, Told, Resolved, and WillResolve +fields. + +=cut +sub ProcessTicketDates { + my %args = ( + TicketObj => undef, + ARGSRef => undef, + @_ + ); + + my $Ticket = $args{'TicketObj'}; + my $ARGSRef = $args{'ARGSRef'}; + + my (@results); + + # {{{ Set date fields + my @date_fields = qw( + Told + Resolved + Starts + Started + Due + WillResolve + ); + + #Run through each field in this list. update the value if apropriate + foreach my $field (@date_fields) { + next unless exists $ARGSRef->{ $field . '_Date' }; + next if $ARGSRef->{ $field . '_Date' } eq ''; + + my ( $code, $msg ); + + my $DateObj = RT::Date->new( $session{'CurrentUser'} ); + $DateObj->Set( + Format => 'unknown', + Value => $ARGSRef->{ $field . '_Date' } + ); + + my $obj = $field . "Obj"; + if ( ( defined $DateObj->Unix ) + and ( $DateObj->Unix != $Ticket->$obj()->Unix() ) ) + { + my $method = "Set$field"; + my ( $code, $msg ) = $Ticket->$method( $DateObj->ISO ); + push @results, "$msg"; + } + } + + # }}} return (@results); } diff --git a/rt/lib/RT/Ticket_Vendor.pm b/rt/lib/RT/Ticket_Vendor.pm index 2039f3e2d..9fa24a2a8 100644 --- a/rt/lib/RT/Ticket_Vendor.pm +++ b/rt/lib/RT/Ticket_Vendor.pm @@ -33,4 +33,33 @@ sub MissingRequiredFields { return @results; } +# Declare the 'WillResolve' field +sub _VendorAccessible { + { + WillResolve => + {read => 1, write => 1, sql_type => 11, length => 0, is_blob => 0, is_numeric => 0, type => 'datetime', default => ''}, + }, +}; + +sub WillResolveObj { + my $self = shift; + + my $time = new RT::Date( $self->CurrentUser ); + + if ( my $willresolve = $self->WillResolve ) { + $time->Set( Format => 'sql', Value => $willresolve ); + } + else { + $time->Set( Format => 'unix', Value => -1 ); + } + + return $time; +} + +sub WillResolveAsString { + my $self = shift; + return $self->WillResolveObj->AsString(); +} + + 1; diff --git a/rt/lib/RT/Tickets_Overlay.pm b/rt/lib/RT/Tickets_Overlay.pm index 876f1084e..f6df5530d 100644 --- a/rt/lib/RT/Tickets_Overlay.pm +++ b/rt/lib/RT/Tickets_Overlay.pm @@ -145,9 +145,11 @@ our %FIELD_METADATA = ( WatcherGroup => [ 'MEMBERSHIPFIELD', ], #loc_left_pair HasAttribute => [ 'HASATTRIBUTE', 1 ], HasNoAttribute => [ 'HASATTRIBUTE', 0 ], + #freeside Agentnum => [ 'FREESIDEFIELD', ], Classnum => [ 'FREESIDEFIELD', ], Tagnum => [ 'FREESIDEFIELD', 'cust_tag' ], + WillResolve => [ 'DATE' => 'WillResolve', ], #loc_left_pair ); our %SEARCHABLE_SUBFIELDS = ( diff --git a/rt/lib/RT/Transaction_Vendor.pm b/rt/lib/RT/Transaction_Vendor.pm new file mode 100644 index 000000000..caeb3f72c --- /dev/null +++ b/rt/lib/RT/Transaction_Vendor.pm @@ -0,0 +1,35 @@ +package RT::Transaction; +use strict; +use vars qw(%_BriefDescriptions); + +$_BriefDescriptions{'Set'} = sub { + my $self = shift; + if ( $self->Field eq 'Password' ) { + return $self->loc('Password changed'); + } + elsif ( $self->Field eq 'Queue' ) { + my $q1 = new RT::Queue( $self->CurrentUser ); + $q1->Load( $self->OldValue ); + my $q2 = new RT::Queue( $self->CurrentUser ); + $q2->Load( $self->NewValue ); + return $self->loc("[_1] changed from [_2] to [_3]", + $self->loc($self->Field) , $q1->Name , $q2->Name); + } + + # Write the date/time change at local time: + elsif ($self->Field =~ /Due|Starts|Started|Told|WillResolve/) { + my $t1 = new RT::Date($self->CurrentUser); + $t1->Set(Format => 'ISO', Value => $self->NewValue); + my $t2 = new RT::Date($self->CurrentUser); + $t2->Set(Format => 'ISO', Value => $self->OldValue); + return $self->loc( "[_1] changed from [_2] to [_3]", $self->loc($self->Field), $t2->AsString, $t1->AsString ); + } + else { + return $self->loc( "[_1] changed from [_2] to [_3]", + $self->loc($self->Field), + ($self->OldValue? "'".$self->OldValue ."'" : $self->loc("(no value)")) , "'". $self->NewValue."'" ); + } +}; + +1; + |