diff options
author | levinse <levinse> | 2011-06-22 23:39:36 +0000 |
---|---|---|
committer | levinse <levinse> | 2011-06-22 23:39:36 +0000 |
commit | 87b88389a0b457d1ba8ca5655696939e1adf652c (patch) | |
tree | fa378dffce8dde67e1e2191b7bc0b9f9003e5682 /FS/FS/addr_block.pm | |
parent | eed7932c6d70767a8b4ae3d04ec19312ad81d885 (diff) |
add router and addr_block delete features, RT13197
Diffstat (limited to 'FS/FS/addr_block.pm')
-rwxr-xr-x | FS/FS/addr_block.pm | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/FS/FS/addr_block.pm b/FS/FS/addr_block.pm index 0fe2476..be42cb5 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, |