summaryrefslogtreecommitdiff
path: root/rt/lib/RT/Search/UnrepliedTickets.pm
blob: 4bb59d9e32fb4ed9a40fe5362577110a0748ad98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
=head1 NAME

  RT::Search::UnrepliedTickets

=head1 SYNOPSIS

=head1 DESCRIPTION

Find all unresolved tickets owned by the current user where the last
correspondence from a requestor (or ticket creation) is more recent than the
last correspondence from a non-requestor (if there is any).

=head1 METHODS

=cut

package RT::Search::UnrepliedTickets;

use strict;
use warnings;
use base qw(RT::Search);


sub Describe  {
  my $self = shift;
  return ($self->loc("Tickets awaiting a reply"));
}

sub Prepare  {
  my $self = shift;

  my $TicketsObj = $self->TicketsObj;
  $TicketsObj->Limit(
    FIELD => 'Owner',
    VALUE => $TicketsObj->CurrentUser->id
  );
  $TicketsObj->Limit(
    FIELD => 'Status',
    OPERATOR => '!=',
    VALUE => 'resolved'
  );
  $TicketsObj->Limit(
    FIELD => 'Status',
    OPERATOR => '!=',
    VALUE => 'rejected',
  );
  my $txn_alias = $TicketsObj->JoinTransactions;
  $TicketsObj->Limit(
    ALIAS => $txn_alias,
    FIELD => 'Created',
    OPERATOR => '>',
    VALUE => 'COALESCE(main.Told,\'1970-01-01\')',
    QUOTEVALUE => 0,
  );
  $TicketsObj->Limit(
    ALIAS => $txn_alias,
    FIELD => 'Type',
    OPERATOR => 'IN',
    VALUE => [ 'Correspond', 'Create' ],
  );

  return(1);
}

RT::Base->_ImportOverlays();

1;