X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fdomain_record.pm;h=37cc6c9e83baeea26a99f12d2fffec56622bd100;hp=44e70ade18a2c178d447476c2b51166a784869fe;hb=b32a862877102bd755bec2c83713b6f3ffb35dfa;hpb=23186f0338ec248d930c85db08cc997bca42525b diff --git a/FS/FS/domain_record.pm b/FS/FS/domain_record.pm index 44e70ade1..37cc6c9e8 100644 --- a/FS/FS/domain_record.pm +++ b/FS/FS/domain_record.pm @@ -1,10 +1,11 @@ package FS::domain_record; use strict; -use vars qw( @ISA ); +use vars qw( @ISA $noserial_hack ); #use FS::Record qw( qsearch qsearchs ); use FS::Record qw( qsearchs dbh ); use FS::svc_domain; +use FS::svc_www; @ISA = qw(FS::Record); @@ -85,6 +86,16 @@ sub insert { local $FS::UID::AutoCommit = 0; my $dbh = dbh; + if ( $self->rectype eq '_mstr' ) { #delete all other records + foreach my $domain_record ( reverse $self->svc_domain->domain_record ) { + my $error = $domain_record->delete; + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return $error; + } + } + } + my $error = $self->SUPER::insert; if ( $error ) { $dbh->rollback if $oldAutoCommit; @@ -114,6 +125,9 @@ Delete this record from the database. sub delete { my $self = shift; + return "Can't delete a domain record which has a website!" + if qsearchs( 'svc_www', { 'recnum' => $self->recnum } ); + local $SIG{HUP} = 'IGNORE'; local $SIG{INT} = 'IGNORE'; local $SIG{QUIT} = 'IGNORE'; @@ -265,6 +279,7 @@ sub check { =cut sub increment_serial { + return '' if $noserial_hack; my $self = shift; my $soa = qsearchs('domain_record', { @@ -283,11 +298,22 @@ sub increment_serial { $new->replace($soa); } +=item svc_domain + +Returns the domain (see L) for this record. + +=cut + +sub svc_domain { + my $self = shift; + qsearchs('svc_domain', { svcnum => $self->svcnum } ); +} + =back =head1 VERSION -$Id: domain_record.pm,v 1.8 2002-05-22 18:44:01 ivan Exp $ +$Id: domain_record.pm,v 1.11 2002-06-23 19:16:45 ivan Exp $ =head1 BUGS