[freeside-commits] branch master updated. e39c7a239fe3604445ffdef6472d0e41abca0049

Mark Wells mark at 420.am
Wed Apr 18 06:18:42 PDT 2012


The branch, master has been updated
       via  e39c7a239fe3604445ffdef6472d0e41abca0049 (commit)
      from  3ce70fff14b951189273348f4ddd06aa1069eafc (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 e39c7a239fe3604445ffdef6472d0e41abca0049
Author: Mark Wells <mark at freeside.biz>
Date:   Wed Apr 18 06:18:14 2012 -0700

    remove ticket links to deleted services, #17067

diff --git a/FS/FS/cust_svc.pm b/FS/FS/cust_svc.pm
index a527913..6bd8cb8 100644
--- a/FS/FS/cust_svc.pm
+++ b/FS/FS/cust_svc.pm
@@ -98,6 +98,28 @@ Deletes this service from the database.  If there is an error, returns the
 error, otherwise returns false.  Note that this only removes the cust_svc
 record - you should probably use the B<cancel> method instead.
 
+=cut
+
+sub delete {
+  my $self = shift;
+  my $error = $self->SUPER::delete;
+  return $error if $error;
+
+  if ( FS::Conf->new->config('ticket_system') eq 'RT_Internal' ) {
+    FS::TicketSystem->init;
+    my $session = FS::TicketSystem->session;
+    my $links = RT::Links->new($session->{CurrentUser});
+    my $svcnum = $self->svcnum;
+    $links->Limit(FIELD => 'Target', 
+                  VALUE => 'freeside://freeside/cust_svc/'.$svcnum);
+    while ( my $l = $links->Next ) {
+      my ($val, $msg) = $l->Delete;
+      # can't do anything useful on error
+      warn "error unlinking ticket $svcnum: $msg\n" if !$val;
+    }
+  }
+}
+
 =item cancel
 
 Cancels the relevant service by calling the B<cancel> method of the associated

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

Summary of changes:
 FS/FS/cust_svc.pm |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)




More information about the freeside-commits mailing list