X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Faddr_block.pm;h=be42cb50b3204d562faef37c549644aa9d32cee7;hb=3c54c844c665ed108c7892a154fd3972fab1f3e5;hp=0fe2476a2a47dad768a679b86823b882878b1017;hpb=40a7b3dc653e099f7bd0bd762b649b04c4432db2;p=freeside.git diff --git a/FS/FS/addr_block.pm b/FS/FS/addr_block.pm index 0fe2476a2..be42cb50b 100755 --- a/FS/FS/addr_block.pm +++ b/FS/FS/addr_block.pm @@ -76,14 +76,35 @@ otherwise returns false. Deletes this record from the database. If there is an error, returns the error, otherwise returns false. +=cut + sub delete { my $self = shift; - return 'Block must be deallocated before deletion' - if $self->router; - - $self->SUPER::delete; + return 'Block must be deallocated and have no services before deletion' + if $self->router || $self->svc_broadband; + + 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; + + my $error = $self->SUPER::delete; + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return $error; + } + + $dbh->commit or die $dbh->errstr if $oldAutoCommit; + ''; } + =item replace OLD_RECORD Replaces OLD_RECORD with this one in the database. If there is an error,