From: ivan Date: Fri, 25 Sep 2009 10:14:30 +0000 (+0000) Subject: nomadix, RT#5876 X-Git-Tag: root_of_svc_elec_features~841 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=81e426fe755eaea508041bc2d7b25ac44c777434 nomadix, RT#5876 --- diff --git a/FS/FS/ClientAPI/Signup.pm b/FS/FS/ClientAPI/Signup.pm index 01c756e3f..c376476c3 100644 --- a/FS/FS/ClientAPI/Signup.pm +++ b/FS/FS/ClientAPI/Signup.pm @@ -107,6 +107,8 @@ sub signup_info { 'security_phrase' => $conf->exists('security_phrase'), + 'nomadix' => $conf->exists('signup_server-nomadix'), + 'payby' => [ $conf->config('signup_server-payby') ], 'card_types' => card_types(), @@ -512,14 +514,14 @@ sub new_customer { #return { 'error' => $error } if $error; #should be all auto-magic and shit - my $svc; + my @svc = (); if ( $svc_x eq 'svc_acct' ) { - $svc = new FS::svc_acct ( { + my $svc = new FS::svc_acct { 'svcpart' => $svcpart, map { $_ => $packet->{$_} } qw( username _password sec_phrase popnum ), - } ); + }; my @acct_snarf; my $snarfnum = 1; @@ -536,21 +538,48 @@ sub new_customer { } $svc->child_objects( \@acct_snarf ); + push @svc, $svc; + } elsif ( $svc_x eq 'svc_phone' ) { - $svc = new FS::svc_phone ( { + my $svc = new FS::svc_phone ( { 'svcpart' => $svcpart, map { $_ => $packet->{$_} } qw( countrycode phonenum sip_password pin ), } ); + push @svc, $svc; + } else { die "unknown signup service $svc_x"; } - - my $y = $svc->setdefault; # arguably should be in new method + my $y = $svc[0]->setdefault; # arguably should be in new method return { 'error' => $y } if $y && !ref($y); + if ($packet->{'mac_addr'} && $conf->exists('signup_server-mac_addr_svcparts')) + { + + my %mac_addr_svcparts = map { $_ => 1 } + $conf->config('signup_server-mac_addr_svcparts'); + my @pkg_svc = grep { $_->quantity && $mac_addr_svcparts{$_->svcpart} } + $cust_pkg->part_pkg->pkg_svc; + + return { 'error' => 'No service defined to assign mac address' } + unless @pkg_svc; + + my $svc = new FS::svc_acct { + 'svcpart' => $pkg_svc[0]->svcpart, #multiple matches? alas.. + 'username' => $packet->{'mac_addr'}, + '_password' => '', #blank as requested (set passwordmin to 0) + }; + + my $y = $svc->setdefault; # arguably should be in new method + return { 'error' => $y } if $y && !ref($y); + + push @svc, $svc; + + } + #$error = $svc->check; #return { 'error' => $error } if $error; @@ -564,7 +593,7 @@ sub new_customer { use Tie::RefHash; tie my %hash, 'Tie::RefHash'; - %hash = ( $cust_pkg => [ $svc ] ); + %hash = ( $cust_pkg => \@svc ); #msgcat $error = $cust_main->insert( \%hash, @@ -648,9 +677,9 @@ sub new_customer { ); if ( $svc_x eq 'svc_acct' ) { - $return{$_} = $svc->$_() for qw( username _password ); + $return{$_} = $svc[0]->$_() for qw( username _password ); } elsif ( $svc_x eq 'svc_phone' ) { - $return{$_} = $svc->$_() for qw( countrycode phonenum sip_password pin ); + $return{$_} = $svc[0]->$_() for qw( countrycode phonenum sip_password pin ); } else { die "unknown signup service $svc_x"; } diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index bd1c004f4..048f47f42 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -1452,22 +1452,23 @@ worry that config_items is freeside-specific and icky. { 'key' => 'signup_server-default_svcpart', 'section' => '', - 'description' => 'Default svcpart for the signup server - only necessary for services that trigger special provisioning widgets (such as DID provisioning).', - 'type' => 'select-sub', - 'options_sub' => sub { require FS::Record; - require FS::part_svc; - map { $_->svcpart => $_->svc } - FS::Record::qsearch( 'part_svc', - { 'disabled' => ''} - ); - }, - 'option_sub' => sub { require FS::Record; - require FS::part_svc; - my $part_svc = FS::Record::qsearchs( - 'part_svc', { 'svcpart'=>shift } - ); - $part_svc ? $part_svc->svc : ''; - }, + 'description' => 'Default service definition for the signup server - only necessary for services that trigger special provisioning widgets (such as DID provisioning).', + 'type' => 'select-part_svc', + }, + + { + 'key' => 'signup_server-mac_addr_svcparts', + 'section' => '', + 'description' => 'Service definitions which can receive mac addresses (current mapped to username for svc_acct).', + 'type' => 'select-part_svc', + 'multiple' => 1, + }, + + { + 'key' => 'signup_server-nomadix', + 'section' => '', + 'description' => 'Signup page Nomadix integration', + 'type' => 'checkbox', }, { @@ -1866,7 +1867,7 @@ worry that config_items is freeside-specific and icky. 'key' => 'svc_www-usersvc_svcpart', 'section' => '', 'description' => 'Allowable service definition svcparts for virtual hosts, one per line.', - 'type' => 'textarea', + 'type' => 'textarea', #select-part_svc ... multiple }, { @@ -2827,7 +2828,7 @@ worry that config_items is freeside-specific and icky. 'key' => 'mcp_svcpart', 'section' => '', 'description' => 'Master Control Program svcpart. Leave this blank.', - 'type' => 'text', + 'type' => 'text', #select-part_svc }, { diff --git a/FS/FS/svc_acct.pm b/FS/FS/svc_acct.pm index e2f79291f..9f54317c6 100644 --- a/FS/FS/svc_acct.pm +++ b/FS/FS/svc_acct.pm @@ -56,7 +56,8 @@ FS::UID->install_callback( sub { @shells = $conf->config('shells'); $usernamemin = $conf->config('usernamemin') || 2; $usernamemax = $conf->config('usernamemax'); - $passwordmin = $conf->config('passwordmin') || 6; + $passwordmin = $conf->config('passwordmin'); # || 6; + $passwordmin = ( $passwordmin =~ /\d+/ ) ? $passwordmin : 6; #blank->6, keep 0 $passwordmax = $conf->config('passwordmax') || 8; $username_letter = $conf->exists('username-letter'); $username_letterfirst = $conf->exists('username-letterfirst'); @@ -1231,7 +1232,7 @@ sub check { #carp "warning: _password_encoding unspecified\n"; #generate a password if it is blank - unless ( length( $recref->{_password} ) ) { + unless ( length($recref->{_password}) || ! $passwordmin ) { $recref->{_password} = join('',map($pw_set[ int(rand $#pw_set) ], (0..7) ) ); diff --git a/fs_selfservice/FS-SelfService/cgi/signup.cgi b/fs_selfservice/FS-SelfService/cgi/signup.cgi index 12452e686..fb4a7c551 100755 --- a/fs_selfservice/FS-SelfService/cgi/signup.cgi +++ b/fs_selfservice/FS-SelfService/cgi/signup.cgi @@ -229,6 +229,7 @@ if ( $magic eq 'process' || $action eq 'process_signup' ) { invoicing_list referral_custnum promo_code reg_code pkgpart refnum agentnum username sec_phrase _password popnum + mac_addr countrycode phonenum sip_password pin ), grep { /^snarf_/ } $cgi->param diff --git a/fs_selfservice/FS-SelfService/cgi/signup.html b/fs_selfservice/FS-SelfService/cgi/signup.html index ae7b2226a..3f8e4a3f7 100755 --- a/fs_selfservice/FS-SelfService/cgi/signup.html +++ b/fs_selfservice/FS-SelfService/cgi/signup.html @@ -38,7 +38,7 @@ %> <%= - $OUT = join("\n", map { qq|| } qw / promo_code reg_code pkgpart username _password _password2 sec_phrase popnum countrycode phonenum sip_password pin / ); + $OUT = join("\n", map { qq|| } qw / promo_code reg_code pkgpart username _password _password2 sec_phrase popnum mac_addr countrycode phonenum sip_password pin / ); %> Where did you hear about our service? $OUT .= '