summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FS/FS/ClientAPI/Signup.pm47
-rw-r--r--FS/FS/Conf.pm37
-rw-r--r--FS/FS/svc_acct.pm5
-rwxr-xr-xfs_selfservice/FS-SelfService/cgi/signup.cgi1
-rwxr-xr-xfs_selfservice/FS-SelfService/cgi/signup.html17
-rw-r--r--httemplate/config/config-process.cgi20
-rw-r--r--httemplate/config/config-view.cgi23
-rw-r--r--httemplate/config/config.cgi21
-rw-r--r--httemplate/elements/select-part_svc.html18
-rw-r--r--httemplate/elements/select-table.html11
-rw-r--r--httemplate/elements/tr-select-part_svc.html7
11 files changed, 158 insertions, 49 deletions
diff --git a/FS/FS/ClientAPI/Signup.pm b/FS/FS/ClientAPI/Signup.pm
index 01c756e..c376476 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 bd1c004..048f47f 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 e2f7929..9f54317 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 12452e6..fb4a7c5 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 ae7b222..3f8e4a3 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|<input type="hidden" name="$_" />| } qw / promo_code reg_code pkgpart username _password _password2 sec_phrase popnum countrycode phonenum sip_password pin / );
+ $OUT = join("\n", map { qq|<input type="hidden" name="$_" />| } 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? <SELECT NAME="refnum">
@@ -46,7 +46,7 @@ Where did you hear about our service? <SELECT NAME="refnum">
$OUT .= '<OPTION VALUE="">' unless $refnum;
foreach my $part_referral ( @part_referral ) {
$OUT .= '<OPTION VALUE="'. $part_referral->{'refnum'}. '"';
- $OUT .= ' SELECTED' if $part_referral->{'refnum'} eq $refnum;
+ $OUT .= ' SELECTED' if $part_referral->{'refnum'} == $refnum;
$OUT .= '>'. $part_referral->{'referral'};
}
%>
@@ -316,6 +316,18 @@ SECPHRASE
$OUT .= '<INPUT TYPE="hidden" NAME="sec_phrase" VALUE="">';
}
+ if ( $nomadix ) {
+
+ warn $mac_addr;
+ $mac_addr ||= $MA;
+ warn $mac_addr;
+
+ $OUT .= <<NOMADIX;
+ <INPUT TYPE="hidden" NAME="mac_addr" VALUE="$mac_addr">
+NOMADIX
+
+ }
+
}
if ( @svc_acct_pop ) {
@@ -380,6 +392,7 @@ function fixup_form() {
var signup_elements = new Array (
'promo_code', 'reg_code', 'pkgpart',
'username', '_password', '_password2', 'sec_phrase', 'popnum',
+ 'mac_addr',
'countrycode', 'phonenum', 'sip_password', 'pin'
);
diff --git a/httemplate/config/config-process.cgi b/httemplate/config/config-process.cgi
index f8b64e8..0569197 100644
--- a/httemplate/config/config-process.cgi
+++ b/httemplate/config/config-process.cgi
@@ -41,15 +41,18 @@ foreach my $type ( ref($i->type) ? @{$i->type} : $i->type ) {
} else {
push @delete, $i->key;
}
- } elsif ( $type eq 'text' || $type eq 'select' || $type eq 'select-sub' ) {
- if ( $cgi->param($i->key.$n) ne '' ) {
- $conf->set($i->key, $cgi->param($i->key.$n), $agentnum);
+ } elsif ( $type =~ /^(editlist|selectmultiple)$/
+ or ( $type =~ /^select(-(sub|part_svc))?$/ || $i->multiple )
+ )
+ {
+ if ( scalar(@{[ $cgi->param($i->key.$n) ]}) ) {
+ $conf->set($i->key, join("\n", @{[ $cgi->param($i->key.$n) ]} ), $agentnum);
} else {
$conf->delete($i->key, $agentnum);
}
- } elsif ( $type eq 'editlist' || $type eq 'selectmultiple' ) {
- if ( scalar(@{[ $cgi->param($i->key.$n) ]}) ) {
- $conf->set($i->key, join("\n", @{[ $cgi->param($i->key.$n) ]} ), $agentnum);
+ } elsif ( $type =~ /^(text|select(-(sub|part_svc))?)$/ ) {
+ if ( $cgi->param($i->key.$n) ne '' ) {
+ $conf->set($i->key, $cgi->param($i->key.$n), $agentnum);
} else {
$conf->delete($i->key, $agentnum);
}
@@ -101,6 +104,11 @@ $conf->delete($_, $agentnum) foreach @delete;
% } elsif ( $type eq 'text' || $type eq 'select' ) {
configCell.innerHTML = <% $conf->exists($i->key, $agentnum) ? $conf->config($i->key, $agentnum) : '' |js_string %>;
+% } elsif ( $type eq 'select-part_svc' && ! $i->multiple ) {
+ configCell.innerHTML =
+ <% $conf->config($i->key, $agentnum) |js_string %>
+%# + ': ' +
+%# <% &{ $i->option_sub }( $conf->config($i->key, $agentnum) ) |js_string %>;
% } elsif ( $type eq 'select-sub' ) {
configCell.innerHTML =
<% $conf->config($i->key, $agentnum) |js_string %> + ': ' +
diff --git a/httemplate/config/config-view.cgi b/httemplate/config/config-view.cgi
index 0f6c992..80a65d0 100644
--- a/httemplate/config/config-view.cgi
+++ b/httemplate/config/config-view.cgi
@@ -156,7 +156,9 @@ Click on a configuration value to change it.
% } elsif ( $type eq 'textarea'
% || $type eq 'editlist'
-% || $type eq 'selectmultiple' ) {
+% || $type eq 'selectmultiple'
+% )
+% {
<tr>
<td id="<% $agentnum.$i->key.$n %>" bgcolor="#ffffff">
@@ -197,7 +199,7 @@ Click on a configuration value to change it.
</td>
</tr>
-% } elsif ( $type eq 'select-sub' ) {
+% } elsif ( $type eq 'select-sub' ) {
<tr>
<td id="<% $agentnum.$i->key.$n %>" bgcolor="#ffffff">
@@ -206,12 +208,25 @@ Click on a configuration value to change it.
</td>
</tr>
-% } else {
+% } elsif ( $type eq 'select-part_svc' ) {
+% my @svcparts = $conf->config($i->key, $agentnum);
+
+ <tr>
+ <td id="<% $agentnum.$i->key.$n %>" bgcolor="#ffffff">
+ <% join('<BR>', map { $_ # ': '. $svc
+ }
+ @svcparts
+ )
+ %>
+ </td>
+ </tr>
+
+% } else {
<tr><td>
<font color="#ff0000">unknown type <% $type %></font>
</td></tr>
-% }
+% }
% $n++;
% }
diff --git a/httemplate/config/config.cgi b/httemplate/config/config.cgi
index 8d5b1ae..4ebedc1 100644
--- a/httemplate/config/config.cgi
+++ b/httemplate/config/config.cgi
@@ -267,9 +267,24 @@ Setting <b><% $key %></b>
<td><input type="button" value="add" onClick="doadd<% "$key$n" %>(this.form)"></td>
</tr></table>
+% } elsif ( $element_types{$type} ) {
+%
+% my %opt = ( 'element_name' => "$key$n",
+% 'empty_label' => ' ',
+% );
+% if ( $config_item->multiple ) {
+% $opt{'multiple'} = 1 if $config_item->multiple;
+% $opt{'curr_value'} = [ $conf->config($key, $agentnum) ];
+% } else {
+% $opt{'curr_value'} =
+% $conf->exists($key, $agentnum) ? $conf->config($key, $agentnum) : '';
+% }
+
+ <% include("/elements/$type.html", %opt ) %>
+
% } else {
- <font color="#ff0000">unknown type <% $type %></font>
+ <font color="#ff0000">unknown type <% $type %></font>
% }
% $n++;
@@ -292,6 +307,10 @@ my $conf = new FS::Conf;
my @config_items = $conf->config_items;
my %confitems = map { $_->key => $_ } @config_items;
+my %element_types = map { $_ => 1 } qw(
+ select-part_svc
+);
+
</%once>
<%init>
diff --git a/httemplate/elements/select-part_svc.html b/httemplate/elements/select-part_svc.html
new file mode 100644
index 0000000..72ab7f6
--- /dev/null
+++ b/httemplate/elements/select-part_svc.html
@@ -0,0 +1,18 @@
+<% include( '/elements/select-table.html',
+ 'table' => 'part_svc',
+ 'name_col' => 'svc',
+ 'label_showkey' => 1,
+ #N/A 'empty_label' => '(none)',
+ %opt,
+ )
+%>
+<%init>
+
+my( %opt ) = @_;
+
+$opt{'records'} = delete $opt{'part_svc'}
+ if $opt{'part_svc'};
+
+$opt{'records'} ||= [ qsearch( 'part_svc', {} ) ]; # { disabled=>'' } )
+
+</%init>
diff --git a/httemplate/elements/select-table.html b/httemplate/elements/select-table.html
index 1a440f0..10a8b27 100644
--- a/httemplate/elements/select-table.html
+++ b/httemplate/elements/select-table.html
@@ -34,6 +34,7 @@ Example:
'empty_label' => '', #better specify it though, the default might change
'multiple' => 0, # bool
'disable_empty' => 0, # bool (implied by multiple)
+ 'label_showkey' => 0, # bool
'label_callback' => sub { my $record = shift; return "label"; },
#more params controlling HTML stuff about the <SELECT>
@@ -77,13 +78,19 @@ Example:
<OPTION VALUE=""><% $opt{'empty_label'} || 'all' %>
% }
-% foreach my $record ( sort { $a->$name_col() cmp $b->$name_col() } @records ) {
+% foreach my $record ( sort { $a->$name_col() cmp $b->$name_col()
+% || $a->$key() <=> $b->$key()
+% }
+% @records
+% )
+% {
% my $recvalue = $record->$key();
<OPTION VALUE="<% $recvalue %>"
<% ref($value) && $value->{$recvalue} || $value == $recvalue
? ' SELECTED' : ''
%>
- ><% $opt{'label_callback'}
+ ><% $opt{'label_showkey'} ? "$recvalue: " : '' %>
+ <% $opt{'label_callback'}
? &{ $opt{'label_callback'} }( $record )
: $record->$name_col()
%>
diff --git a/httemplate/elements/tr-select-part_svc.html b/httemplate/elements/tr-select-part_svc.html
index 0274ef1..af51487 100644
--- a/httemplate/elements/tr-select-part_svc.html
+++ b/httemplate/elements/tr-select-part_svc.html
@@ -7,11 +7,8 @@
<TR>
<TD ALIGN="right"><% $opt{'label'} || 'Package definition' %></TD>
<TD>
- <% include( '/elements/select-table.html',
- 'table' => 'part_svc',
- 'name_col' => 'svc',
- 'multiple' => 1,
- #N/A 'empty_label' => '(none)',
+ <% include( '/elements/select-part_svc.html',
+ 'multiple' => 1,
%opt,
)
%>