X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fprocess%2Fsvc_acct.cgi;h=9cac2c56855488ee47cef93a62ce30ca8dd1756d;hb=bd876bcd42a0ce8d1e44d87ba6c517cf6106ca37;hp=0d2c007f1f475b938148d15195f17b42b3ff226c;hpb=be61853021954c3cf8f6e63a41b1fa693e3af6d8;p=freeside.git diff --git a/httemplate/edit/process/svc_acct.cgi b/httemplate/edit/process/svc_acct.cgi index 0d2c007f1..9cac2c568 100755 --- a/httemplate/edit/process/svc_acct.cgi +++ b/httemplate/edit/process/svc_acct.cgi @@ -31,6 +31,11 @@ foreach (map { $_,$_."_threshold" } qw( upbytes downbytes totalbytes )) { $cgi->param($_, FS::UI::bytecount::parse_bytecount($cgi->param($_)) ); } +#for slipip, convert '(automatic)' to null +my $ip_addr = $cgi->param('slipip'); +$ip_addr =~ s/[^\d\.]//g; +$cgi->param('slipip', $ip_addr); + #unmunge cgp_accessmodes (falze laziness-ish w/part_svc.pm::process &svc_domain) unless ( $cgi->param('cgp_accessmodes') ) { $cgi->param('cgp_accessmodes', @@ -44,39 +49,89 @@ unless ( $cgi->param('cgp_accessmodes') ) { } my %hash = $svcnum ? $old->hash : (); -map { +for ( fields('svc_acct'), qw( pkgnum svcpart usergroup ) ) { $hash{$_} = scalar($cgi->param($_)); - #} qw(svcnum pkgnum svcpart username _password popnum uid gid finger dir - # shell quota slipip) - } (fields('svc_acct'), qw ( pkgnum svcpart usergroup )); +} +if ( $svcnum ) { + for ( grep $old->$_, qw( cf_privatekey ) ) { + $hash{$_} = $old->$_; + } +} my $new = new FS::svc_acct ( \%hash ); my $error = ''; +my $part_svc = $svcnum ? + $old->part_svc : + qsearchs( 'part_svc', + { 'svcpart' => $cgi->param('svcpart') } + ); + +# google captcha auth +if ( $cgi->param('captcha_response') ) { + my ($export) = $part_svc->part_export('acct_google'); + if ( $export and + ! $export->captcha_auth($cgi->param('captcha_response')) ) { + $error = 'Re-enter the security word.'; + } +} + $new->_password($old->_password) if $old; if ( $cgi->param('clear_password') eq '*HIDDEN*' || $cgi->param('clear_password') =~ /^\(.* encrypted\)$/ ) { die "fatal: no previous account to recall hidden password from!" unless $old; } else { - $error = $new->set_password($cgi->param('clear_password')); + $error ||= $new->set_password($cgi->param('clear_password')); } -if ( $svcnum ) { - foreach ( grep { $old->$_ != $new->$_ } - qw( seconds upbytes downbytes totalbytes ) - ) - { - my %hash = map { $_ => $new->$_ } - grep { $new->$_ } - qw( seconds upbytes downbytes totalbytes ); - - $error ||= $new->set_usage(\%hash); #unoverlimit and trigger radius changes - last; #once is enough +if ( ! $error ) { + + my $export_info = FS::part_export::export_info(); + + my @child_objects = + map FS::svc_export_machine->new({ + 'svcnum' => $svcnum, + 'exportnum' => $_->exportnum, + 'machinenum' => scalar($cgi->param('exportnum'.$_->exportnum.'machinenum')), + }), + grep { $_->machine eq '_SVC_MACHINE' } + $part_svc->part_export; + + if ( $part_svc->has_router ) { + my $router = FS::router->new({ + map { $_ => $cgi->param("router_$_") } + qw( routernum routername blocknum ) + }); + if (length($router->routername) == 0) { + #sensible default + $router->set('routername', $new->label); + } + if (length($router->blocknum) == 0) { + #unset it + $router->set('blocknum', 0); + } + push @child_objects, $router; + } + + + if ( $svcnum ) { + foreach ( grep { $old->$_ != $new->$_ } + qw( seconds upbytes downbytes totalbytes ) + ) + { + my %hash = map { $_ => $new->$_ } + grep { $new->$_ } + qw( seconds upbytes downbytes totalbytes ); + + $error ||= "invalid $_" foreach grep { $hash{$_} !~ /^-?\d+$/ } keys %hash; + $error ||= $new->set_usage(\%hash); #unoverlimit and trigger radius changes + last; #once is enough + } + $error ||= $new->replace($old, 'child_objects'=>\@child_objects); + } else { + $error ||= $new->insert('child_objects'=>\@child_objects); + $svcnum = $new->svcnum; } - $error ||= $new->replace($old); -} else { - $error ||= $new->insert; - $svcnum = $new->svcnum; }