From 9ae101389f2fe652575c6ab314a5e95c2283b72e Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 25 Oct 2003 02:05:44 +0000 Subject: [PATCH] signups with snarf info! --- FS/FS/ClientAPI/Signup.pm | 16 ++++++++++++++++ FS/FS/acct_snarf.pm | 8 ++++---- FS/FS/svc_Common.pm | 18 ++++++++++++++++-- FS/FS/svc_acct.pm | 8 +++++++- fs_signup/FS-SignupClient/cgi/signup.cgi | 6 +++++- 5 files changed, 48 insertions(+), 8 deletions(-) diff --git a/FS/FS/ClientAPI/Signup.pm b/FS/FS/ClientAPI/Signup.pm index 92fc6361d..60639b132 100644 --- a/FS/FS/ClientAPI/Signup.pm +++ b/FS/FS/ClientAPI/Signup.pm @@ -10,6 +10,8 @@ use FS::part_pkg; use FS::svc_acct_pop; use FS::cust_main; use FS::cust_pkg; +use FS::svc_acct; +use FS::acct_snarf; use FS::Msgcat qw(gettext); use FS::ClientAPI; #hmm @@ -155,6 +157,20 @@ sub new_customer { qw( username _password sec_phrase popnum ), } ); + my @acct_snarf; + my $snarfnum = 1; + while ( length($packet->{"snarf_machine$snarfnum"}) ) { + my $acct_snarf = new FS::acct_snarf ( { + 'machine' => $packet->{"snarf_machine$snarfnum"}, + 'protocol' => $packet->{"snarf_protocol$snarfnum"}, + 'username' => $packet->{"snarf_username$snarfnum"}, + '_password' => $packet->{"snarf_password$snarfnum"}, + } ); + $snarfnum++; + push @acct_snarf, $acct_snarf; + } + $svc_acct->child_objects( \@acct_snarf ); + my $y = $svc_acct->setdefault; # arguably should be in new method return { 'error' => $y } if $y && !ref($y); diff --git a/FS/FS/acct_snarf.pm b/FS/FS/acct_snarf.pm index 7c51d6945..b4e88bfc9 100644 --- a/FS/FS/acct_snarf.pm +++ b/FS/FS/acct_snarf.pm @@ -90,9 +90,9 @@ returns the error, otherwise returns false. =item check -Checks all fields to make sure this is a valid example. If there is -an error, returns the error, otherwise returns false. Called by the insert -and replace methods. +Checks all fields to make sure this is a valid external mail account. If +there is an error, returns the error, otherwise returns false. Called by the +insert and replace methods. =cut @@ -103,7 +103,7 @@ sub check { || $self->ut_number('svcnum') || $self->ut_foreign_key('svcnum', 'svc_acct', 'svcnum') || $self->ut_domain('machine') - || $self->alphan('protocol') + || $self->ut_alphan('protocol') || $self->ut_textn('username') ; return $error if $error; diff --git a/FS/FS/svc_Common.pm b/FS/FS/svc_Common.pm index 524e55086..2fed5dd8a 100644 --- a/FS/FS/svc_Common.pm +++ b/FS/FS/svc_Common.pm @@ -80,7 +80,7 @@ sub check { $self->SUPER::check; } -=item insert [ JOBNUM_ARRAYREF ] +=item insert [ JOBNUM_ARRAYREF [ OBJECTS_ARRAYREF ] ] Adds this record to the database. If there is an error, returns the error, otherwise returns false. @@ -91,11 +91,16 @@ defined. An FS::cust_svc record will be created and inserted. If an arrayref is passed as parameter, the Bs of any export jobs will be added to the array. +If an arrayref of FS::tablename objects (for example, FS::acct_snarf objects) +is passed as the optional second parameter, they will have their svcnum fields +set and will be inserted after this record, but before any exports are run. + =cut sub insert { my $self = shift; local $FS::queue::jobnums = shift if @_; + my $objects = scalar(@_) ? shift : []; my $error; local $SIG{HUP} = 'IGNORE'; @@ -142,6 +147,15 @@ sub insert { return $error; } + foreach my $object ( @$objects ) { + $object->svcnum($self->svcnum); + $error = $object->insert; + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return $error; + } + } + #new-style exports! unless ( $noexport_hack ) { foreach my $part_export ( $self->cust_svc->part_svc->part_export ) { @@ -416,7 +430,7 @@ sub cancel { ''; } =head1 VERSION -$Id: svc_Common.pm,v 1.13 2003-08-05 00:20:47 khoff Exp $ +$Id: svc_Common.pm,v 1.14 2003-10-25 02:05:44 ivan Exp $ =head1 BUGS diff --git a/FS/FS/svc_acct.pm b/FS/FS/svc_acct.pm index 3fb28c054..4ea7734d4 100644 --- a/FS/FS/svc_acct.pm +++ b/FS/FS/svc_acct.pm @@ -188,10 +188,16 @@ The additional field I can optionally be defined; if so it should contain an arrayref of group names. See L. (used in sqlradius export only) +The additional field I can optionally be defined; if so it +should contain an arrayref of FS::tablename objects. They will have their +svcnum fields set and will be inserted after this record, but before any +exports are run. + (TODOC: L and L) (TODOC: new exports!) + =cut sub insert { @@ -319,7 +325,7 @@ sub insert { #see? i told you it was more complicated my @jobnums; - $error = $self->SUPER::insert(\@jobnums); + $error = $self->SUPER::insert(\@jobnums, $self->child_objects || [] ); if ( $error ) { $dbh->rollback if $oldAutoCommit; return $error; diff --git a/fs_signup/FS-SignupClient/cgi/signup.cgi b/fs_signup/FS-SignupClient/cgi/signup.cgi index 70facb570..5ca93d289 100755 --- a/fs_signup/FS-SignupClient/cgi/signup.cgi +++ b/fs_signup/FS-SignupClient/cgi/signup.cgi @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: signup.cgi,v 1.47 2003-10-24 19:28:49 ivan Exp $ +# $Id: signup.cgi,v 1.48 2003-10-25 02:05:44 ivan Exp $ use strict; use vars qw( @payby $cgi $locales $packages @@ -266,6 +266,7 @@ if ( defined $cgi->param('magic') ) { '_password' => $password, 'popnum' => $popnum, 'agentnum' => $agentnum, + map { $_ => $cgi->param($_) } grep { /^snarf_/ } $cgi->param } ); } @@ -273,6 +274,9 @@ if ( defined $cgi->param('magic') ) { if ( $error eq '_decline' ) { print_decline(); } elsif ( $error ) { + #fudge the snarf info + no strict 'refs'; + ${$_} = $cgi->param($_) foreach grep { /^snarf_/ } $cgi->param; print_form(); } else { print_okay(); -- 2.11.0