diff options
author | Mark Wells <mark@freeside.biz> | 2015-07-15 13:13:44 -0700 |
---|---|---|
committer | Mark Wells <mark@freeside.biz> | 2015-07-15 13:24:56 -0700 |
commit | d11b7a6d930140a7487546727e5a1e9423fc83f4 (patch) | |
tree | e50afceee16cab144bfad09d8314ad69997dbbe3 /FS/FS/TicketSystem | |
parent | 02ca2b327abd13fb7a05422a936792d20b1f3eaf (diff) |
let selfservice users view tickets linked to their services, #33241
Diffstat (limited to 'FS/FS/TicketSystem')
-rw-r--r-- | FS/FS/TicketSystem/RT_Internal.pm | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/FS/FS/TicketSystem/RT_Internal.pm b/FS/FS/TicketSystem/RT_Internal.pm index d0913d8..6fb2c18 100644 --- a/FS/FS/TicketSystem/RT_Internal.pm +++ b/FS/FS/TicketSystem/RT_Internal.pm @@ -454,23 +454,21 @@ sub get_ticket_object { my $self = shift; my ($session, %opt) = @_; $session = $self->session(shift); - my $Ticket = RT::Ticket->new($session->{CurrentUser}); - $Ticket->Load($opt{'ticket_id'}); - return if ( !$Ticket->id ); - my $custnum = $opt{'custnum'}; - if ( defined($custnum) && $custnum =~ /^\d+$/ ) { - # probably the most efficient way to check ticket ownership - my $Link = RT::Link->new($session->{CurrentUser}); - $Link->LoadByCols( LocalBase => $opt{'ticket_id'}, - Type => 'MemberOf', - Target => "freeside://freeside/cust_main/$custnum", - ); - return if ( !$Link->id ); + # use a small search here so we can check ticket ownership + my $query; + if ( $opt{'ticket_id'} =~ /^(\d+)$/ ) { + $query = "id = $1"; + } else { + return; + } + if ( $opt{'custnum'} =~ /^(\d+)$/ ) { + $query .= " AND Customer.number = $1"; # also checks ownership via services } - return $Ticket; + my $Tickets = RT::Tickets->new($session->{CurrentUser}); + $Tickets->FromSQL($query); + return $Tickets->First; } - =item correspond_ticket SESSION_HASHREF, OPTION => VALUE ... Class method. Correspond on a ticket. If there is an error, returns the scalar |