[freeside-commits] freeside/FS/FS svc_pbx.pm,1.5,1.6
Ivan,,,
ivan at wavetail.420.am
Tue Jan 26 02:40:34 PST 2010
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv10463
Modified Files:
svc_pbx.pm
Log Message:
deleting an svc_pbx unlinks svc_phones and deletes svc_accts, RT#7051
Index: svc_pbx.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/svc_pbx.pm,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- svc_pbx.pm 26 Jan 2010 08:35:43 -0000 1.5
+++ svc_pbx.pm 26 Jan 2010 10:40:32 -0000 1.6
@@ -2,8 +2,10 @@
use strict;
use base qw( FS::svc_External_Common );
-use FS::Record qw( qsearchs ); # qsearch );
+use FS::Record qw( qsearch qsearchs dbh );
use FS::cust_svc;
+use FS::svc_phone;
+use FS::svc_acct;
=head1 NAME
@@ -157,11 +159,42 @@
sub delete {
my $self = shift;
- my $error;
- $error = $self->SUPER::delete;
- return $error if $error;
+ local $SIG{HUP} = 'IGNORE';
+ local $SIG{INT} = 'IGNORE';
+ local $SIG{QUIT} = 'IGNORE';
+ local $SIG{TERM} = 'IGNORE';
+ local $SIG{TSTP} = 'IGNORE';
+ local $SIG{PIPE} = 'IGNORE';
+
+ my $oldAutoCommit = $FS::UID::AutoCommit;
+ local $FS::UID::AutoCommit = 0;
+ my $dbh = dbh;
+ foreach my $svc_phone (qsearch('svc_phone', { 'pbxsvc' => $self->svcnum } )) {
+ $svc_phone->pbxsvc('');
+ my $error = $svc_phone->replace;
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return $error;
+ }
+ }
+
+ foreach my $svc_acct (qsearch('svc_acct', { 'pbxsvc' => $self->svcnum } )) {
+ my $error = $svc_acct->delete;
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return $error;
+ }
+ }
+
+ my $error = $self->SUPER::delete;
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return $error;
+ }
+
+ $dbh->commit or die $dbh->errstr if $oldAutoCommit;
'';
}
More information about the freeside-commits
mailing list