[freeside-commits] freeside/FS/FS router.pm, 1.5, 1.5.8.1 addr_block.pm, 1.10, 1.10.8.1
Erik Levinson
levinse at wavetail.420.am
Wed Jun 22 16:39:39 PDT 2011
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv17451/FS/FS
Modified Files:
Tag: FREESIDE_2_1_BRANCH
router.pm addr_block.pm
Log Message:
add router and addr_block delete features, RT13197
Index: addr_block.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/addr_block.pm,v
retrieving revision 1.10
retrieving revision 1.10.8.1
diff -u -w -d -r1.10 -r1.10.8.1
--- addr_block.pm 27 Sep 2008 03:01:43 -0000 1.10
+++ addr_block.pm 22 Jun 2011 23:39:37 -0000 1.10.8.1
@@ -76,14 +76,35 @@
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;
+ return 'Block must be deallocated and have no services before deletion'
+ if $self->router || $self->svc_broadband;
- $self->SUPER::delete;
+ 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,
Index: router.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/router.pm,v
retrieving revision 1.5
retrieving revision 1.5.8.1
diff -u -w -d -r1.5 -r1.5.8.1
--- router.pm 3 Sep 2008 19:08:27 -0000 1.5
+++ router.pm 22 Jun 2011 23:39:37 -0000 1.5.8.1
@@ -2,7 +2,7 @@
use strict;
use vars qw( @ISA );
-use FS::Record qw( qsearchs qsearch );
+use FS::Record qw( qsearchs qsearch dbh );
use FS::addr_block;
@ISA = qw( FS::Record FS::m2m_Common );
@@ -90,6 +90,39 @@
$self->SUPER::check;
}
+=item delete
+
+Deletes this router if and only if no address blocks (see L<FS::addr_block>)
+are currently allocated to it.
+
+=cut
+
+sub delete {
+ my $self = shift;
+
+ return 'Router has address blocks allocated to it' if $self->addr_block;
+
+ 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 addr_block
Returns a list of FS::addr_block objects (address blocks) associated
@@ -139,8 +172,6 @@
=back
-=head1 BUGS
-
=head1 SEE ALSO
FS::svc_broadband, FS::router, FS::addr_block, FS::part_svc,
More information about the freeside-commits
mailing list