X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=rt%2Flib%2FRT%2FTicket_Vendor.pm;h=4a7883888bd435f5fb48ff13a08d2882d1f93498;hb=a8478341db106d63ae4114f0e94b4072394c073b;hp=9fa24a2a887a058279325dc7fe58c2689d581c74;hpb=4c8c18409f82d56320a80f6c94f275fa15486897;p=freeside.git diff --git a/rt/lib/RT/Ticket_Vendor.pm b/rt/lib/RT/Ticket_Vendor.pm index 9fa24a2a8..4a7883888 100644 --- a/rt/lib/RT/Ticket_Vendor.pm +++ b/rt/lib/RT/Ticket_Vendor.pm @@ -13,6 +13,37 @@ sub SetPriority { $Ticket->SUPER::SetPriority($value); } +=head2 Touch + +Creates a Touch transaction (a null transaction). Like Comment and +Correspond but without any content. + +=cut + +sub Touch { + my $self = shift; + my %args = ( + TimeTaken => 0, + ActivateScrips => 1, + CommitScrips => 1, + CustomFields => {}, + @_ + ); + unless ( $self->CurrentUserHasRight('ModifyTicket') + or $self->CurrentUserHasRight('CommentOnTicket') + or $self->CurrentUserHasRight('ReplyToTicket')) { + return ( 0, $self->loc("Permission Denied")); + } + $self->_NewTransaction( + Type => 'Touch', + TimeTaken => $args{'TimeTaken'}, + ActivateScrips => $args{'ActivateScrips'}, + CommitScrips => $args{'CommitScrips'}, + CustomFields => $args{'CustomFields'}, + ); +} + + =head2 MissingRequiredFields { Return all custom fields with the Required flag set for which this object @@ -61,5 +92,28 @@ sub WillResolveAsString { return $self->WillResolveObj->AsString(); } +=head2 IsUnreplied + +Returns true if there's a Correspond or Create transaction more recent than +the Told date of this ticket (or the ticket has no Told date) and the ticket +is not rejected or resolved. + +=cut + +sub IsUnreplied { + my $self = shift; + return 0 if $self->Status eq 'resolved' + or $self->Status eq 'rejected'; + + my $Told = $self->Told || '1970-01-01'; + my $Txns = $self->Transactions; + $Txns->Limit(FIELD => 'Type', + OPERATOR => 'IN', + VALUE => [ 'Correspond', 'Create' ]); + $Txns->Limit(FIELD => 'Created', + OPERATOR => '>', + VALUE => $Told); + $Txns->Count ? 1 : 0; +} 1;