summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan>2003-10-25 02:05:44 +0000
committerivan <ivan>2003-10-25 02:05:44 +0000
commit9ae101389f2fe652575c6ab314a5e95c2283b72e (patch)
treedb21c8ac10e3da4ef6def0b5e07bd279dc5c0cf2
parent42ea96aceed291c4cb92cf475cb715b6ad7832c3 (diff)
signups with snarf info!
-rw-r--r--FS/FS/ClientAPI/Signup.pm16
-rw-r--r--FS/FS/acct_snarf.pm8
-rw-r--r--FS/FS/svc_Common.pm18
-rw-r--r--FS/FS/svc_acct.pm8
-rwxr-xr-xfs_signup/FS-SignupClient/cgi/signup.cgi6
5 files changed, 48 insertions, 8 deletions
diff --git a/FS/FS/ClientAPI/Signup.pm b/FS/FS/ClientAPI/Signup.pm
index 92fc636..60639b1 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 7c51d69..b4e88bf 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 524e550..2fed5dd 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 B<jobnum>s 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 3fb28c0..4ea7734 100644
--- a/FS/FS/svc_acct.pm
+++ b/FS/FS/svc_acct.pm
@@ -188,10 +188,16 @@ The additional field I<usergroup> can optionally be defined; if so it should
contain an arrayref of group names. See L<FS::radius_usergroup>. (used in
sqlradius export only)
+The additional field I<child_objects> 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<FS::queue> and L<freeside-queued>)
(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 70facb5..5ca93d2 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();