use Mail::Header;
use Date::Format;
use Net::Whois 1.0;
-use FS::Record qw(fields qsearch qsearchs);
+use FS::Record qw(fields qsearch qsearchs dbh);
use FS::Conf;
use FS::svc_Common;
use FS::cust_svc;
local $SIG{TSTP} = 'IGNORE';
local $SIG{PIPE} = 'IGNORE';
+ my $oldAutoCommit = $FS::UID::AutoCommit;
+ local $FS::UID::AutoCommit = 0;
+ my $dbh = dbh;
+
$error = $self->check;
return $error if $error;
if qsearchs( 'svc_domain', { 'domain' => $self->domain } );
my $whois = $self->whois;
- return "Domain in use (see whois)"
- if ( $self->action eq "N" && $whois );
- return "Domain not found (see whois)"
- if ( $self->action eq "M" && ! $whois );
+ if ( $self->action eq "N" && ! $whois_hack && $whois ) {
+ $dbh->rollback if $oldAutoCommit;
+ return "Domain in use (see whois)";
+ }
+ if ( $self->action eq "M" && ! $whois ) {
+ $dbh->rollback if $oldAutoCommit;
+ return "Domain not found (see whois)";
+ }
$error = $self->SUPER::insert;
- return $error if $error;
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return $error;
+ }
$self->submit_internic unless $whois_hack;
'reczone' => '@',
'recaf' => 'IN',
'rectype' => 'SOA',
- 'recdata' => "$soamachine $soaemail ( ". time2str("%Y%m%e", time). "00 ".
- "$soarefresh $soarety $soaexpire $soadefaultttl )"
+ 'recdata' => "$soamachine $soaemail ( ". time2str("%Y%m%d", time). "00 ".
+ "$soarefresh $soaretry $soaexpire $soadefaultttl )"
};
$error = $soa->insert;
- warn "WARNING: couldn't insert SOA record for new domain: $error" if $error;
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return "couldn't insert SOA record for new domain: $error";
+ }
- foreach $nsmachine ( @nsmachines ) {
+ foreach my $nsmachine ( @nsmachines ) {
my $ns = new FS::domain_record {
'svcnum' => $self->svcnum,
'reczone' => '@',
'recdata' => $nsmachine,
};
my $error = $ns->insert;
- warn "WARNING: couldn't insert NS record for new domain: $error"
- if $error;
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return "couldn't insert NS record for new domain: $error";
+ }
}
- foreach $mxmachine ( @mxmachines ) {
+ foreach my $mxmachine ( @mxmachines ) {
my $mx = new FS::domain_record {
'svcnum' => $self->svcnum,
'reczone' => '@',
'recaf' => 'IN',
- 'rectype' => 'mx',
+ 'rectype' => 'MX',
'recdata' => $mxmachine,
};
my $error = $mx->insert;
- warn "WARNING: couldn't insert MX record for new domain: $error"
- if $error;
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return "couldn't insert MX record for new domain: $error";
+ }
}
}
+ $dbh->commit or die $dbh->errstr if $oldAutoCommit;
''; #no error
}
=head1 VERSION
-$Id: svc_domain.pm,v 1.5 2000-02-03 05:16:52 ivan Exp $
+$Id: svc_domain.pm,v 1.12 2001-06-03 17:22:52 ivan Exp $
=head1 BUGS
=head1 SEE ALSO
L<FS::svc_Common>, L<FS::Record>, L<FS::Conf>, L<FS::cust_svc>,
-L<FS::part_svc>, L<FS::cust_pkg>, L<FS::SSH>, L<Net::Whois>, L<ssh>,
+L<FS::part_svc>, L<FS::cust_pkg>, L<Net::Whois>, L<ssh>,
L<dot-qmail>, schema.html from the base documentation, config.html from the
base documentation.