X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2FTicketSystem%2FRT_Internal.pm;h=d0913d84d989128c238954bb2e2d61b921a4cc85;hp=ffa8c7c1c5c20f2bab3836f0aaf36250b8f57be8;hb=3564f619654c5cbf22fc2acbe7eff0c08308e859;hpb=1c59bba12621e154765a8255534e94a041dfd200 diff --git a/FS/FS/TicketSystem/RT_Internal.pm b/FS/FS/TicketSystem/RT_Internal.pm index ffa8c7c1c..d0913d84d 100644 --- a/FS/FS/TicketSystem/RT_Internal.pm +++ b/FS/FS/TicketSystem/RT_Internal.pm @@ -50,7 +50,7 @@ sub access_right { sub session { my( $self, $session ) = @_; - if ( $session && $session->{'Current_User'} ) { # does this even work? + if ( $session && $session->{'CurrentUser'} ) { # does this even work? warn "$me session: using existing session and CurrentUser: \n". Dumper($session->{'CurrentUser'}) if $DEBUG; @@ -92,6 +92,7 @@ sub init { # this needs to be done on each fork warn "$me init: initializing RT\n" if $DEBUG; { + local $SIG{__WARN__}; local $SIG{__DIE__}; eval 'RT::Init("NoSignalHandlers"=>1);'; } @@ -110,7 +111,7 @@ properly. # create an RT::Tickets object for a specified custnum or svcnum sub _tickets_search { - my ( $self, $type, $number, $limit, $priority ) = @_; + my( $self, $type, $number, $limit, $priority, $status ) = @_; $type =~ /^Customer|Service$/ or die "invalid type: $type"; $number =~ /^\d+$/ or die "invalid custnum/svcnum: $number"; @@ -135,9 +136,28 @@ sub _tickets_search { } } - $rtql .= ' AND ( ' . - join(' OR ', map { "Status = '$_'" } $self->statuses) . - ' )'; + my @statuses; + if ( defined($status) && $status ) { + if ( ref($status) ) { + if ( ref($status) eq 'HASH' ) { + @statuses = grep $status->{$_}, keys %$status; + } elsif ( ref($status) eq 'ARRAY' ) { + @statuses = @$status; + } else { + #what should be the failure mode here? die? return no tickets? + die 'unknown status ref '. ref($status); + } + } else { + @statuses = ( $status ); + } + @statuses = grep /^\w+$/, @statuses; #injection prevention + } else { + @statuses = $self->statuses; + } + + $rtql .= ' AND ( '. + join(' OR ', map { "Status = '$_'" } @statuses). + ' ) '; warn "$me _customer_tickets_search:\n$rtql\n" if $DEBUG; $Tickets->FromSQL($rtql); @@ -151,7 +171,7 @@ sub _tickets_search { sub href_customer_tickets { my ($self, $custnum) = (shift, shift); if ($custnum =~ /^(\d+)$/) { - return $self->href_search_tickets("Customer.number = $custnum"); + return $self->href_search_tickets("Customer.number = $custnum", @_); } warn "bad custnum $custnum"; ''; } @@ -159,7 +179,7 @@ sub href_customer_tickets { sub href_service_tickets { my ($self, $svcnum) = (shift, shift); if ($svcnum =~ /^(\d+)$/ ) { - return $self->href_search_tickets("Service.number = $svcnum"); + return $self->href_search_tickets("Service.number = $svcnum", @_); } warn "bad svcnum $svcnum"; ''; } @@ -588,7 +608,7 @@ sub _web_external_auth { # we failed to successfully create the user. abort abort abort. delete $session->{'CurrentUser'}; - die "can't auto-create RT user"; #an error message would be nice :/ + die "can't auto-create RT user: $msg"; #an error message would be nice :/ #$m->abort() unless $RT::WebFallbackToInternalAuth; #$m->comp( '/Elements/Login', %ARGS, # Error => loc( 'Cannot create user: [_1]', $msg ) );