[freeside-commits] branch FREESIDE_3_BRANCH updated. 1437328351c06d1addc673dd1532c8959c77f426

Mark Wells mark at 420.am
Wed Jul 15 13:30:26 PDT 2015


The branch, FREESIDE_3_BRANCH has been updated
       via  1437328351c06d1addc673dd1532c8959c77f426 (commit)
      from  aa31501ee44d7a1ab5cc0ea0c6d7c272136c0891 (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 1437328351c06d1addc673dd1532c8959c77f426
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