summaryrefslogtreecommitdiff
path: root/FS/FS/TicketSystem
diff options
context:
space:
mode:
authorlevinse <levinse>2010-12-17 01:16:00 +0000
committerlevinse <levinse>2010-12-17 01:16:00 +0000
commit0a9c2506f72162e9fc99679a35a6540b27a22848 (patch)
treeb65354c18a350814780193cb13617bdba8350e9a /FS/FS/TicketSystem
parent95c2cfba9666f31c5444f8f6c207e7a728a5e96f (diff)
self-service improvements, RT10883
Diffstat (limited to 'FS/FS/TicketSystem')
-rw-r--r--FS/FS/TicketSystem/RT_Internal.pm85
1 files changed, 85 insertions, 0 deletions
diff --git a/FS/FS/TicketSystem/RT_Internal.pm b/FS/FS/TicketSystem/RT_Internal.pm
index 4036d90..6fc2bb6 100644
--- a/FS/FS/TicketSystem/RT_Internal.pm
+++ b/FS/FS/TicketSystem/RT_Internal.pm
@@ -215,6 +215,91 @@ sub create_ticket {
$Ticket;
}
+=item get_ticket SESSION_HASHREF, OPTION => VALUE ...
+
+Class method. Retrieves a ticket. If there is an error, returns the scalar
+error. Otherwise, currently returns a slightly tricky data structure containing
+a list of the linked customers and each transaction's content, description, and
+create time.
+
+Accepts the following options:
+
+=over 4
+
+=item ticket_id
+
+The ticket id
+
+=back
+
+=cut
+
+sub get_ticket {
+ my($self, $session, %param) = @_;
+
+ $session = $self->session($session);
+
+ my $Ticket = RT::Ticket->new($session->{'CurrentUser'});
+ my $ticketid = $Ticket->Load( $param{'ticket_id'} );
+ return 'Could not load ticket' unless $ticketid;
+
+ my @custs = ();
+ foreach my $link ( @{ $Ticket->Customers->ItemsArrayRef } ) {
+ my $cust = $link->Target;
+ push @custs, $1 if $cust =~ /\/(\d+)$/;
+ }
+
+ my @txns = ();
+ my $transactions = $Ticket->Transactions;
+ while ( my $transaction = $transactions->Next ) {
+ my $t = { created => $transaction->Created,
+ content => $transaction->Content,
+ description => $transaction->Description,
+ };
+ push @txns, $t;
+ }
+
+ { txns => [ @txns ],
+ custs => [ @custs ],
+ };
+}
+
+
+=item correspond_ticket SESSION_HASHREF, OPTION => VALUE ...
+
+Class method. Correspond on a ticket. If there is an error, returns the scalar
+error. Otherwise, returns the transaction id, error message, and
+RT::Transaction object.
+
+Accepts the following options:
+
+=over 4
+
+=item ticket_id
+
+The ticket id
+
+=item content
+
+Correspondence content
+
+=back
+
+=cut
+
+sub correspond_ticket {
+ my($self, $session, %param) = @_;
+
+ $session = $self->session($session);
+
+ my $Ticket = RT::Ticket->new($session->{'CurrentUser'});
+ my $ticketid = $Ticket->Load( $param{'ticket_id'} );
+ return 'Could not load ticket' unless $ticketid;
+ return 'No content' unless $param{'content'};
+
+ $Ticket->Correspond( Content => $param{'content'} );
+}
+
#shameless false laziness w/RT::Interface::Web::AttemptExternalAuth
# to get logged into RT from afar
sub _web_external_auth {