-<%
-#
-# $Id: svc_acct.cgi,v 1.1 2001-07-30 07:36:04 ivan Exp $
-#
-# Usage: svc_acct.cgi {svcnum} | pkgnum{pkgnum}-svcpart{svcpart}
-# http://server.name/path/svc_acct.cgi? {svcnum} | pkgnum{pkgnum}-svcpart{svcpart}
-#
-# ivan@voicenet.com 96-dec-18
-#
-# rewrite ivan@sisd.com 98-mar-8
-#
-# Changes to allow page to work at a relative position in server
-# Changed 'password' to '_password' because Pg6.3 reserves the password word
-# bmccane@maxbaud.net 98-apr-3
-#
-# use conf/shells and dbdef username length ivan@sisd.com 98-jul-13
-#
-# $Log: svc_acct.cgi,v $
-# Revision 1.1 2001-07-30 07:36:04 ivan
-# templates!!!
-#
-# Revision 1.10 1999/04/14 11:27:06 ivan
-# showpasswords config option to show passwords
-#
-# Revision 1.9 1999/02/28 00:03:37 ivan
-# removed misleading comments
-#
-# Revision 1.8 1999/02/23 08:09:22 ivan
-# beginnings of one-screen new customer entry and some other miscellania
-#
-# Revision 1.7 1999/02/07 09:59:22 ivan
-# more mod_perl fixes, and bugfixes Peter Wemm sent via email
-#
-# Revision 1.6 1999/01/19 05:13:43 ivan
-# for mod_perl: no more top-level my() variables; use vars instead
-# also the last s/create/new/;
-#
-# Revision 1.5 1999/01/18 09:41:32 ivan
-# all $cgi->header calls now include ( '-expires' => 'now' ) for mod_perl
-# (good idea anyway)
-#
-# Revision 1.4 1998/12/30 23:03:22 ivan
-# bugfixes; fields isn't exported by derived classes
-#
-# Revision 1.3 1998/12/17 06:17:08 ivan
-# fix double // in relative URLs, s/CGI::Base/CGI/;
-#
-
-use strict;
-use vars qw( $conf $cgi @shells $action $svcnum $svc_acct $pkgnum $svcpart
- $part_svc $svc $otaker $username $password $ulen $ulen2 $p1
- $popnum $uid $gid $finger $dir $shell $quota $slipip );
-use CGI;
-use CGI::Carp qw(fatalsToBrowser);
-use FS::UID qw(cgisuidsetup getotaker);
-use FS::CGI qw(header popurl);
-use FS::Record qw(qsearch qsearchs fields);
-use FS::svc_acct;
-use FS::Conf;
-
-$cgi = new CGI;
-&cgisuidsetup($cgi);
-
-$conf = new FS::Conf;
-@shells = $conf->config('shells');
-
+<& /elements/header.html, mt("$action [_1] account",$svc) &>
+
+<& /elements/error.html &>
+
+% if ( $cust_main ) {
+
+ <& /elements/small_custview.html, $cust_main, '', 1,
+ popurl(2) . "view/cust_main.cgi" &>
+ <BR>
+% }
+
+<FORM NAME="OneTrueForm" ACTION="<% $p1 %>process/svc_acct.cgi" METHOD=POST>
+<INPUT TYPE="hidden" NAME="svcnum" VALUE="<% $svcnum %>">
+<INPUT TYPE="hidden" NAME="pkgnum" VALUE="<% $pkgnum %>">
+<INPUT TYPE="hidden" NAME="svcpart" VALUE="<% $svcpart %>">
+
+% if ( $svcnum ) {
+% my $svclabel = emt("Service #[_1]",$svcnum);
+% $svclabel =~ s/$svcnum/<B>$svcnum<\/B>/;
+<% $svclabel %>
+% } else {
+<% mt("Service # (NEW)") |h %>
+% }
+<BR>
+
+<% ntable("#cccccc",2) %>
+
+<TR>
+ <TD ALIGN="right"><% mt('Service') |h %></TD>
+ <TD BGCOLOR="#eeeeee"><% $part_svc->svc %></TD>
+</TR>
+
+<% include('/elements/tr-td-label.html',
+ 'label' => mt('Username'),
+ 'required' => $part_svc->part_svc_column('username')->required ) %>
+% if ( $svcnum && $conf->exists('svc_acct-no_edit_username') ) {
+ <TD BGCOLOR="#eeeeee"><% $svc_acct->username() %></TD>
+ <INPUT TYPE="hidden" NAME="username" VALUE="<% $username %>">
+% } else {
+ <TD>
+ <INPUT TYPE="text" NAME="username" VALUE="<% $username %>" SIZE=<% $ulen2 %> MAXLENGTH=<% $ulen %>>
+ </TD>
+% }
+</TR>
+
+%if ( $part_svc->part_svc_column('_password')->columnflag ne 'F' ) {
+% #XXX eventually should require "Edit Password" ACL
+<% include('/elements/tr-td-label.html',
+ 'label' => mt('Password'),
+ 'required' => $part_svc->part_svc_column('_password')->required ) %>
+ <TD>
+ <INPUT TYPE="text" ID="clear_password" NAME="clear_password" VALUE="<% $password %>" SIZE=<% $pmax2 %> MAXLENGTH=<% $pmax %>>
+ <& /elements/random_pass.html, 'clear_password' &><BR>
+ <DIV ID="clear_password_result" STYLE="font-size: smaller"></DIV>
+ <& '/elements/validate_password.html',
+ 'fieldid' => 'clear_password',
+ 'svcnum' => $svcnum
+ &>
+ </TD>
+</TR>
+%}else{
+ <INPUT TYPE="hidden" NAME="clear_password" VALUE="<% $password %>">
+%}
+<INPUT TYPE="hidden" NAME="_password_encoding" VALUE="<% $svc_acct->_password_encoding %>">
+%
+%my $sec_phrase = $svc_acct->sec_phrase;
+%if ( $conf->exists('security_phrase')
+% && $part_svc->part_svc_column('sec_phrase')->columnflag ne 'F' ) {
+
+<% include('/elements/tr-td-label.html',
+ 'label' => mt('Security phrase'),
+ 'required' => $part_svc->part_svc_column('sec_phrase')->required ) %>
+ <TD>
+ <INPUT TYPE="text" NAME="sec_phrase" VALUE="<% $sec_phrase %>" SIZE=32>
+ (<% mt('for forgotten passwords') |h %>)
+ </TD>
+ </TD>
+% } else {
+
+ <INPUT TYPE="hidden" NAME="sec_phrase" VALUE="<% $sec_phrase %>">
+% }
+%
+%#domain
+%my $domsvc = $svc_acct->domsvc || 0;
+%if ( $part_svc->part_svc_column('domsvc')->columnflag eq 'F' ) {
+%
+
+ <INPUT TYPE="hidden" NAME="domsvc" VALUE="<% $domsvc %>">
+% } else {
+%
+% my %svc_domain = ();
+%
+% if ( $domsvc ) {
+% my $svc_domain = qsearchs('svc_domain', { 'svcnum' => $domsvc, } );
+% if ( $svc_domain ) {
+% $svc_domain{$svc_domain->svcnum} = $svc_domain->domain;
+% } else {
+% warn "unknown svc_domain.svcnum for svc_acct.domsvc: $domsvc";
+% }
+% }
+%
+% %svc_domain = (%svc_domain,
+% domain_select_hash FS::svc_acct('svcpart' => $svcpart,
+% 'pkgnum' => $pkgnum,
+% )
+% );
+
+<% include('/elements/tr-td-label.html',
+ 'label' => mt('Domain'),
+ 'required' => $part_svc->part_svc_column('domsvc')->required ) %>
+ <TD>
+ <SELECT NAME="domsvc" SIZE=1>
+% foreach my $svcnum (
+% sort { $svc_domain{$a} cmp $svc_domain{$b} }
+% keys %svc_domain
+% ) {
+% my $svc_domain = $svc_domain{$svcnum};
+%
+
+ <OPTION VALUE="<% $svcnum %>" <% $svcnum == $domsvc ? ' SELECTED' : '' %>><% $svc_domain{$svcnum} %>
+% }
+
+ </SELECT>
+ </TD>
+ </TR>
+% }
+
+
+% if ( $communigate ) {
+
+ <TR>
+ <TD ALIGN="right"><% mt('Aliases') |h %></TD>
+ <TD><INPUT TYPE="text" NAME="cgp_aliases" VALUE="<% $svc_acct->cgp_aliases %>"></TD>
+ </TR>
+
+% } else {
+ <INPUT TYPE="hidden" NAME="cgp_aliases" VALUE="<% $svc_acct->cgp_aliases %>">
+% }
+
+
+<& /elements/tr-select-svc_pbx.html,
+ 'curr_value' => $svc_acct->pbxsvc,
+ 'part_svc' => $part_svc,
+ 'cust_pkg' => $cust_pkg,
+&>
+
+%#pop
+%my $popnum = $svc_acct->popnum || 0;
+%if ( $part_svc->part_svc_column('popnum')->columnflag eq 'F' ) {
+%
+
+ <INPUT TYPE="hidden" NAME="popnum" VALUE="<% $popnum %>">
+% } else {
+
+<% include('/elements/tr-td-label.html',
+ 'label' => mt('Access number'),
+ 'required' => $part_svc->part_svc_column('popnum')->required ) %>
+ <TD><% FS::svc_acct_pop::popselector($popnum) %></TD>
+ </TR>
+% }
+
+%#tower (huh)
+%if ( $conf->exists('svc_acct-tower_sector')
+% && $part_svc->part_svc_column('sectornum')->columnflag ne 'F' ) {
+ <& /elements/tr-select-tower_sector.html,
+ 'curr_value' => $svc_acct->sectornum,
+ #'part_svc' => $part_svc,
+ #'cust_pkg' => $cust_pkg,
+ 'required' => $part_svc->part_svc_column('sectornum')->required,
+ &>
+%} else {
+ <INPUT TYPE="hidden" NAME="sectornum" VALUE="<% $svc_acct->sectornum %>">
+%}
+
+<& /elements/tr-svc_export_machine.html,
+ 'svc' => $svc_acct,
+ 'part_svc' => $part_svc,
+ 'cgi' => $cgi,
+&>
+
+% #uid/gid
+% foreach my $xid (qw( uid gid )) {
+%
+% if ( $part_svc->part_svc_column($xid)->columnflag =~ /^[FA]$/
+% || ! $conf->exists("svc_acct-edit_$xid")
+% ) {
+%
+% if ( length($svc_acct->$xid()) ) {
+
+<% include('/elements/tr-td-label.html',
+ 'label' => uc($xid),
+ 'required' => $part_svc->part_svc_column($xid)->required ) %>
+ <TR>
+ <TD ALIGN="right"><% uc($xid) %></TD>
+ <TD BGCOLOR="#eeeeee"><% $svc_acct->$xid() %></TD>
+ <TD>
+ </TD>
+ </TR>
+% }
+
+ <INPUT TYPE="hidden" NAME="<% $xid %>" VALUE="<% $svc_acct->$xid() %>">
+% } else {
+
+<% include('/elements/tr-td-label.html',
+ 'label' => uc($xid),
+ 'required' => $part_svc->part_svc_column($xid)->required ) %>
+ <TD>
+ <INPUT TYPE="text" NAME="<% $xid %>" SIZE=8 MAXLENGTH=6 VALUE="<% $svc_acct->$xid() %>">
+ </TD>
+ </TR>
+% }
+% }
+%
+%#finger
+%if ( $part_svc->part_svc_column('uid')->columnflag eq 'F'
+% && ! $svc_acct->finger ) {
+%
+
+ <INPUT TYPE="hidden" NAME="finger" VALUE="">
+% } else {
+
+
+<% include('/elements/tr-td-label.html',
+ 'label' => mt('Real Name'),
+ 'required' => $part_svc->part_svc_column('finger')->required ) %>
+ <TD>
+ <INPUT TYPE="text" NAME="finger" VALUE="<% $svc_acct->finger %>">
+ </TD>
+ </TR>
+% }
+%
+%#dir
+%if ( $part_svc->part_svc_column('dir')->columnflag eq 'F'
+% || !$curuser->access_right('Edit home dir')
+% ) {
+
+
+<INPUT TYPE="hidden" NAME="dir" VALUE="<% $svc_acct->dir %>">
+% } else {
+
+
+<% include('/elements/tr-td-label.html',
+ 'label' => mt('Home directory'),
+ 'required' => $part_svc->part_svc_column('dir')->required ) %>
+ <TD><INPUT TYPE="text" NAME="dir" VALUE="<% $svc_acct->dir %>"></TD>
+ </TR>
+% }
+%
+%#shell
+%my $shell = $svc_acct->shell;
+%if ( $part_svc->part_svc_column('shell')->columnflag eq 'F'
+% || ( !$shell && $part_svc->part_svc_column('uid')->columnflag eq 'F' )
+% ) {
+%
+
+ <INPUT TYPE="hidden" NAME="shell" VALUE="<% $shell %>">
+% } else {
+
+
+<% include('/elements/tr-td-label.html',
+ 'label' => mt('Shell'),
+ 'required' => $part_svc->part_svc_column('shell')->required ) %>
+ <TD>
+ <SELECT NAME="shell" SIZE=1>
+%
+% my($etc_shell);
+% foreach $etc_shell (@shells) {
+%
+
+ <OPTION<% $etc_shell eq $shell ? ' SELECTED' : '' %>><% $etc_shell %>
+% }
+
+
+ </SELECT>
+ </TD>
+ </TR>
+% }
+
+<& svc_acct/communigate.html,
+ 'svc_acct' => $svc_acct,
+ 'part_svc' => $part_svc,
+ 'communigate' => $communigate,
+&>
+
+% if ( $conf->exists('svc_acct-ip_addr') ) {
+% # router/block selection UI
+% # (should we show this if slipip is fixed?)
+<& /elements/tr-select-router_block_ip.html,
+ 'object' => $svc_acct,
+ 'ip_field' => 'slipip',
+ 'required' => $part_svc->part_svc_column('routernum')->required,
+ 'ip_addr_required' => $part_svc->part_svc_column('slipip')->required,
+&>
+% } else {
+% # don't expose these to the user--they're only useful in the other case
+ <INPUT TYPE="hidden" NAME="routernum" VALUE="<% $svc_acct->routernum %>">
+ <INPUT TYPE="hidden" NAME="blocknum" VALUE="<% $svc_acct->blocknum %>">
+% if ( $part_svc->part_svc_column('slipip')->columnflag =~ /^[FA]$/ ) {
+ <INPUT TYPE="hidden" NAME="slipip" VALUE="<% $svc_acct->slipip %>">
+% } else {
+<% include('/elements/tr-td-label.html',
+ 'label' => mt('IP'),
+ 'required' => $part_svc->part_svc_column('slipip')->required ) %>
+ <TD><INPUT TYPE="text" NAME="slipip" VALUE="<% $svc_acct->slipip %>"></TD>
+ </TR>
+% }
+% }
+
+% my %label = ( seconds => 'Time',
+% upbytes => 'Upload bytes',
+% downbytes => 'Download bytes',
+% totalbytes => 'Total bytes',
+% );
+% foreach my $uf (keys %label) {
+% my $tf = $uf . "_threshold";
+% if ( $curuser->access_right('Edit usage') ) {
+ <TR>
+ <TD ALIGN="right"><% mt("[_1] remaining",$label{$uf}) |h %> </TD>
+ <TD><INPUT TYPE="text" NAME="<% $uf %>" VALUE="<% $svc_acct->$uf %>">(<% mt('blank disables') |h %>)</TD>
+ </TR>
+ <TR>
+ <TD ALIGN="right"><% mt("[_1] threshold",$label{$uf}) |h %> </TD>
+ <TD><INPUT TYPE="text" NAME="<% $tf %>" VALUE="<% $svc_acct->$tf %>">(<% mt('blank disables') |h %>)</TD>
+ </TR>
+% }else{
+ <INPUT TYPE="hidden" NAME="<% $uf %>" VALUE="<% $svc_acct->$uf %>">
+ <INPUT TYPE="hidden" NAME="<% $tf %>" VALUE="<% $svc_acct->$tf %>">
+% }
+% }
+%
+%foreach my $r ( grep { /^r(adius|[cr])_/ } fields('svc_acct') ) {
+% $r =~ /^^r(adius|[cr])_(.+)$/ or next; #?
+% my $a = $2;
+%
+% if ( $part_svc->part_svc_column($r)->columnflag =~ /^[FA]$/ ) {
+
+ <INPUT TYPE="hidden" NAME="<% $r %>" VALUE="<% $svc_acct->getfield($r) %>">
+% } else {
+
+ <TR>
+ <TD ALIGN="right"><% $FS::raddb::attrib{$a} %></TD>
+ <TD><INPUT TYPE="text" NAME="<% $r %>" VALUE="<% $svc_acct->getfield($r) %>"></TD>
+ </TR>
+% }
+% }
+
+
+<% include('/elements/tr-td-label.html',
+ 'label' => mt('RADIUS groups'),
+ 'required' => $part_svc->part_svc_column('usergroup')->required ) %>
+% if ( $part_svc_usergroup->columnflag eq 'F' ) {
+ <TD BGCOLOR="#eeeeee"><% join('<BR>', @groupnames) %></TD>
+% } else {
+% my $radius_group_selected = '';
+% if ( $svc_acct->svcnum ) {
+% $radius_group_selected = join(',',$svc_acct->radius_groups('groupnum'));
+% }
+% elsif ( !$svc_acct->svcnum && $part_svc_usergroup->columnflag eq 'D' ) {
+% $radius_group_selected = $part_svc_usergroup->columnvalue;
+% }
+ <TD><& /elements/select-radius_group.html,
+ curr_value => $radius_group_selected,
+ element_name => 'radius_usergroup',
+ multiple => 1,
+ &>
+ </TD>
+% }
+
+</TR>
+
+% if ( $part_svc->has_router ) {
+<& /elements/hidden.html,
+ field => 'router_routernum',
+ curr_value => $svc_acct->router_routernum
+&>
+<& /elements/tr-input-text.html,
+ label => 'Attached router name',
+ field => 'router_routername',
+ size => 32,
+ curr_value => $svc_acct->router_routername
+&>
+<& /elements/tr-select-table.html,
+ label => 'Attached address block',
+ field => 'router_blocknum',
+ table => 'addr_block',
+ hashref => { 'routernum' => '0' },
+ extra_sql => ($svc_acct->router_routernum ?
+ ' OR routernum = '.$svc_acct->router_routernum : ''),
+ agent_virt => 1,
+ agent_null => 1,
+ name_col => 'cidr',
+ order_by => 'ORDER BY ip_gateway, ip_netmask',
+ empty_label => '(none)',
+ disable_empty => 0,
+ curr_value => $svc_acct->router_blocknum
+&>
+% }
+
+% foreach my $field ($svc_acct->virtual_fields) {
+% # If the flag is X, it won't even show up in $svc_acct->virtual_fields.
+% if ( $part_svc->part_svc_column($field)->columnflag ne 'F' ) {
+
+ <% $svc_acct->pvf($field)->widget('HTML', 'edit', $svc_acct->getfield($field)) %>
+% }
+% }
+
+</TABLE>
+<BR>
+
+% if ( $captcha_url ) {
+<IMG SRC="<% $captcha_url %>"><BR>
+<% mt('Enter the word shown above:') |h %> <INPUT TYPE="text" NAME="captcha_response"><BR>
+<BR>
+% }
+
+<INPUT TYPE="submit" VALUE="Submit">
+
+</FORM>
+
+<& /elements/footer.html &>
+
+<%init>
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Provision customer service'); #something else more specific?
+
+my $conf = new FS::Conf;
+my @shells = $conf->config('shells');
+
+my $curuser = $FS::CurrentUser::CurrentUser;
+
+my($svcnum, $pkgnum, $svcpart, $part_svc, $svc_acct, @groups);
if ( $cgi->param('error') ) {
+
$svc_acct = new FS::svc_acct ( {
map { $_, scalar($cgi->param($_)) } fields('svc_acct')
} );
$svcnum = $svc_acct->svcnum;
$pkgnum = $cgi->param('pkgnum');
$svcpart = $cgi->param('svcpart');
+ $part_svc = qsearchs( 'part_svc', { 'svcpart' => $svcpart } );
+ die "No part_svc entry for svcpart $svcpart!" unless $part_svc;
+ @groups = $cgi->param('radius_usergroup');
+
+} elsif ( $cgi->param('pkgnum') && $cgi->param('svcpart') ) { #adding
+
+ $cgi->param('pkgnum') =~ /^(\d+)$/ or die 'unparsable pkgnum';
+ $pkgnum = $1;
+ $cgi->param('svcpart') =~ /^(\d+)$/ or die 'unparsable svcpart';
+ $svcpart = $1;
+
$part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart});
die "No part_svc entry!" unless $part_svc;
-} else {
+
+ $svc_acct = new FS::svc_acct({svcpart => $svcpart});
+
+ $svcnum='';
+
+ $svc_acct->password_recover('Y'); #default. hmm.
+
+} else { #editing
+
my($query) = $cgi->keywords;
- if ( $query =~ /^(\d+)$/ ) { #editing
- $svcnum=$1;
- $svc_acct=qsearchs('svc_acct',{'svcnum'=>$svcnum})
- or die "Unknown (svc_acct) svcnum!";
+ $query =~ /^(\d+)$/ or die "unparsable svcnum";
+ $svcnum=$1;
+ $svc_acct=qsearchs('svc_acct',{'svcnum'=>$svcnum})
+ or die "Unknown (svc_acct) svcnum!";
+
+ my($cust_svc)=qsearchs('cust_svc',{'svcnum'=>$svcnum})
+ or die "Unknown (cust_svc) svcnum!";
- my($cust_svc)=qsearchs('cust_svc',{'svcnum'=>$svcnum})
- or die "Unknown (cust_svc) svcnum!";
+ $pkgnum=$cust_svc->pkgnum;
+ $svcpart=$cust_svc->svcpart;
- $pkgnum=$cust_svc->pkgnum;
- $svcpart=$cust_svc->svcpart;
+ $part_svc = qsearchs( 'part_svc', { 'svcpart' => $svcpart } );
+ die "No part_svc entry for svcpart $svcpart!" unless $part_svc;
- $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart});
- die "No part_svc entry!" unless $part_svc;
+ @groups = $svc_acct->radius_groups;
- } else { #adding
+}
- $svc_acct = new FS::svc_acct({});
+my $communigate = scalar($part_svc->part_export('communigate_pro'));
+ # || scalar($part_svc->part_export('communigate_pro_singledomain'));
- foreach $_ (split(/-/,$query)) {
- $pkgnum=$1 if /^pkgnum(\d+)$/;
- $svcpart=$1 if /^svcpart(\d+)$/;
- }
- $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart});
- die "No part_svc entry!" unless $part_svc;
+my( $cust_pkg, $cust_main ) = ( '', '' );
+if ( $pkgnum ) {
+ $cust_pkg = qsearchs('cust_pkg', { 'pkgnum' => $pkgnum } );
+ $cust_main = $cust_pkg->cust_main;
+}
- $svcnum='';
+unless ( $svcnum || $cgi->param('error') ) { #adding
- #set gecos
- my($cust_pkg)=qsearchs('cust_pkg',{'pkgnum'=>$pkgnum});
- if ($cust_pkg) {
- my($cust_main)=qsearchs('cust_main',{'custnum'=> $cust_pkg->custnum } );
+ #set gecos
+ if ($cust_main) {
+ unless ( $part_svc->part_svc_column('uid')->columnflag eq 'F' ) {
$svc_acct->setfield('finger',
$cust_main->getfield('first') . " " . $cust_main->getfield('last')
- ) ;
+ );
}
+ }
- #set fixed and default fields from part_svc
- my($field);
- foreach $field ( fields('svc_acct') ) {
- if ( $part_svc->getfield('svc_acct__'. $field. '_flag') ne '' ) {
- $svc_acct->setfield($field,$part_svc->getfield('svc_acct__'. $field) );
- }
- }
+ $svc_acct->set_default_and_fixed( {
+ #false laziness w/svc-acct::_fieldhandlers
+ 'usergroup' => sub {
+ my( $self, $groups ) = @_;
+ if ( ref($groups) eq 'ARRAY' ) {
+ @groups = @$groups;
+ $groups;
+ } elsif ( length($groups) ) {
+ @groups = split(/\s*,\s*/, $groups);
+ [ @groups ];
+ } else {
+ @groups = ();
+ [];
+ }
+ }
+ } );
- }
}
-$action = $svcnum ? 'Edit' : 'Add';
-$svc = $part_svc->getfield('svc');
+my $part_svc_usergroup = $part_svc->part_svc_column('usergroup');
+#fixed radius groups always override & display
+my @groupnames; # only used for display of Fixed RADIUS groups
+if ( $part_svc_usergroup->columnflag eq 'F' ) {
+ @groups = split(',',$part_svc_usergroup->columnvalue);
+ @groupnames = map { $_->long_description }
+ qsearch({ 'table' => 'radius_group',
+ 'extra_sql' => "where groupnum in (".$part_svc_usergroup->columnvalue.")",
+ }) if length($part_svc_usergroup->columnvalue);
+}
-$otaker = getotaker;
+my $action = $svcnum ? 'Edit' : 'Add';
-$username = $svc_acct->username;
-if ( $svc_acct->_password ) {
- if ( $conf->exists('showpasswords') ) {
- $password = $svc_acct->_password;
- } else {
- $password = "*HIDDEN*";
- }
-} else {
- $password = '';
-}
+my $svc = $part_svc->getfield('svc');
-$ulen = $svc_acct->dbdef_table->column('username')->length;
-$ulen2 = $ulen+2;
-
-$p1 = popurl(1);
-print $cgi->header( '-expires' => 'now' ), header("$action $svc account");
-
-print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $cgi->param('error'),
- "</FONT>"
- if $cgi->param('error');
-
-print <<END;
- <FORM ACTION="${p1}process/svc_acct.cgi" METHOD=POST>
- <INPUT TYPE="hidden" NAME="svcnum" VALUE="$svcnum">
- <INPUT TYPE="hidden" NAME="pkgnum" VALUE="$pkgnum">
- <INPUT TYPE="hidden" NAME="svcpart" VALUE="$svcpart">
-Username:
-<INPUT TYPE="text" NAME="username" VALUE="$username" SIZE=$ulen2 MAXLENGTH=$ulen>
-<BR>Password:
-<INPUT TYPE="text" NAME="_password" VALUE="$password" SIZE=10 MAXLENGTH=8>
-(blank to generate)
-END
-
-#pop
-$popnum = $svc_acct->popnum || 0;
-if ( $part_svc->svc_acct__popnum_flag eq "F" ) {
- print qq!<INPUT TYPE="hidden" NAME="popnum" VALUE="$popnum">!;
-} else {
- print qq!<BR>POP: <SELECT NAME="popnum" SIZE=1><OPTION>\n!;
- my($svc_acct_pop);
- foreach $svc_acct_pop ( qsearch ('svc_acct_pop',{} ) ) {
- print "<OPTION", $svc_acct_pop->popnum == $popnum ? ' SELECTED' : '', ">",
- $svc_acct_pop->popnum, ": ",
- $svc_acct_pop->city, ", ",
- $svc_acct_pop->state,
- " (", $svc_acct_pop->ac, ")/",
- $svc_acct_pop->exch, "\n"
- ;
- }
- print "</SELECT>";
-}
+my $username = $svc_acct->username;
-($uid,$gid,$finger,$dir)=(
- $svc_acct->uid,
- $svc_acct->gid,
- $svc_acct->finger,
- $svc_acct->dir,
-);
-
-print <<END;
-<INPUT TYPE="hidden" NAME="uid" VALUE="$uid">
-<INPUT TYPE="hidden" NAME="gid" VALUE="$gid">
-<BR>GECOS: <INPUT TYPE="text" NAME="finger" VALUE="$finger">
-<INPUT TYPE="hidden" NAME="dir" VALUE="$dir">
-END
-
-$shell = $svc_acct->shell;
-if ( $part_svc->svc_acct__shell_flag eq "F" ) {
- print qq!<INPUT TYPE="hidden" NAME="shell" VALUE="$shell">!;
-} else {
- print qq!<BR>Shell: <SELECT NAME="shell" SIZE=1>!;
- my($etc_shell);
- foreach $etc_shell (@shells) {
- print "<OPTION", $etc_shell eq $shell ? ' SELECTED' : '', ">",
- $etc_shell, "\n";
+my $password = '';
+if ( $cgi->param('error') ) {
+ $password = $cgi->param('clear_password');
+} elsif ( $svcnum ) {
+ my $password_encryption = $svc_acct->_password_encryption;
+ if ( $password = $svc_acct->get_cleartext_password ) {
+ $password = '*HIDDEN*' unless $conf->exists('showpasswords');
+ } elsif( $svc_acct->_password and $password_encryption ne 'plain' ) {
+ $password = "(".uc($password_encryption)." encrypted)";
}
- print "</SELECT>";
}
-($quota,$slipip)=(
- $svc_acct->quota,
- $svc_acct->slipip,
-);
+my $ulen =
+ $conf->exists('usernamemax')
+ ? $conf->config('usernamemax')
+ : dbdef->table('svc_acct')->column('username')->length;
+my $ulen2 = $ulen+2;
-print qq!<INPUT TYPE="hidden" NAME="quota" VALUE="$quota">!;
+my $pmax = max($conf->config('passwordmax') || 13);
+my $pmax2 = $pmax+2;
-if ( $part_svc->svc_acct__slipip_flag eq "F" ) {
- print qq!<INPUT TYPE="hidden" NAME="slipip" VALUE="$slipip">!;
-} else {
- print qq!<BR>IP: <INPUT TYPE="text" NAME="slipip" VALUE="$slipip">!;
-}
+my $p1 = popurl(1);
-#submit
-print qq!<P><INPUT TYPE="submit" VALUE="Submit">!;
+sub max {
+ (sort(@_))[-1]
+}
-print <<END;
- </FORM>
- </BODY>
-</HTML>
-END
+my $captcha_url;
+my ($export_google) = $part_svc->part_export('acct_google');
+if ( $export_google ) {
+ my $error = $export_google->auth_error;
+ if ( $error ) {
+ if ( $error->{'captcha_url'} ) {
+ $captcha_url = $error->{'captcha_url'};
+ }
+ else {
+ $cgi->param('error', $error->{'message'});
+ }
+ } #if $error
+}
+if ( $part_svc->has_router ) { # duplicates the one in elements/svc_Common
+ if ( $svcnum ) {
+ my $router = qsearchs('router', {svcnum => $svc_acct->svcnum});
+ if ( $router ) {
+ $svc_acct->set("router_$_", $router->get($_))
+ foreach ('routername', 'routernum');
+ my ($block) = $router->addr_block;
+ $svc_acct->set('router_blocknum', $block->blocknum) if ( $block );
+ }
+ }
+ foreach (qw(router_routername router_routernum router_blocknum)) {
+ if ( $cgi->param($_) =~ /^(\w+)$/ ) {
+ $svc_acct->set($_, $1);
+ }
+ }
+}
-%>
+</%init>