[freeside-commits] branch master updated. a63a7c017dd67aba394bd97605aa12b9321542f7

Mark Wells mark at 420.am
Wed Jul 15 13:28:39 PDT 2015


The branch, master has been updated
       via  a63a7c017dd67aba394bd97605aa12b9321542f7 (commit)
      from  917ff4fd80bac4f492d30ab251d626095f4dd939 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit a63a7c017dd67aba394bd97605aa12b9321542f7
Author: Mark Wells <mark at freeside.biz>
Date:   Wed Jul 15 13:13:44 2015 -0700

    let selfservice users view tickets linked to their services, #33241

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

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/TicketSystem/RT_Internal.pm |   26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)




More information about the freeside-commits mailing list