[freeside-commits] freeside/FS/FS/ClientAPI MyAccount.pm, 1.116, 1.117
Erik Levinson
levinse at wavetail.420.am
Thu Dec 16 17:16:02 PST 2010
Update of /home/cvs/cvsroot/freeside/FS/FS/ClientAPI
In directory wavetail.420.am:/tmp/cvs-serv3002/FS/FS/ClientAPI
Modified Files:
MyAccount.pm
Log Message:
self-service improvements, RT10883
Index: MyAccount.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/ClientAPI/MyAccount.pm,v
retrieving revision 1.116
retrieving revision 1.117
diff -u -w -d -r1.116 -r1.117
--- MyAccount.pm 15 Dec 2010 15:09:45 -0000 1.116
+++ MyAccount.pm 17 Dec 2010 01:16:00 -0000 1.117
@@ -1789,6 +1789,59 @@
}
+sub get_ticket {
+ my $p = shift;
+ my($context, $session, $custnum) = _custoragent_session_custnum($p);
+ return { 'error' => $session } if $context eq 'error';
+
+ warn "$me get_ticket: initializing ticket system\n" if $DEBUG;
+ FS::TicketSystem->init();
+
+ if(length($p->{'reply'})) {
+ my @err_or_res = FS::TicketSystem->correspond_ticket(
+ '', #create RT session based on FS CurrentUser (fs_selfservice)
+ 'ticket_id' => $p->{'ticket_id'},
+ 'content' => $p->{'reply'},
+ );
+
+ return { 'error' => 'unable to reply to ticket' }
+ unless ( $err_or_res[0] != 0 && defined $err_or_res[2] );
+ }
+
+ warn "$me get_ticket: getting ticket\n" if $DEBUG;
+ my $err_or_ticket = FS::TicketSystem->get_ticket(
+ '', #create RT session based on FS CurrentUser (fs_selfservice)
+ 'ticket_id' => $p->{'ticket_id'},
+ );
+
+ if ( ref($err_or_ticket) ) {
+
+# since we're bypassing the RT security/permissions model by always using
+# fs_selfservice as the RT user (as opposed to a requestor, which we
+# can't do since we want all tickets linked to a cust), we check below whether
+# the requested ticket was actually linked to this customer
+ my @custs = @{$err_or_ticket->{'custs'}};
+ my @txns = @{$err_or_ticket->{'txns'}};
+
+ return { 'error' => 'no customer' } unless ( $custnum && scalar(@custs) );
+
+ return { 'error' => 'invalid ticket requested' }
+ unless grep($_ eq $custnum, @custs);
+
+ warn "$me get_ticket: sucessful: \n"
+ if $DEBUG;
+ return { 'error' => '',
+ 'transactions' => \@txns,
+ 'ticket_id' => $p->{'ticket_id'},
+ };
+ } else {
+ warn "$me create_ticket: unsucessful: $err_or_ticket\n"
+ if $DEBUG;
+ return { 'error' => $err_or_ticket };
+ }
+}
+
+
#--
sub _custoragent_session_custnum {
More information about the freeside-commits
mailing list