X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fedit%2Fsvc_acct.cgi;h=90b26324a25625e77a5bf259af1d51acc619cc5d;hp=063c41fa1c99c5f8f97d1696e1c7309917cc88f0;hb=afb81dcb0fd47759bb5234d7f5989dc8df0aa502;hpb=8a8c9386cbd3383b0134aae8e32b5995f8886fb2 diff --git a/httemplate/edit/svc_acct.cgi b/httemplate/edit/svc_acct.cgi index 063c41fa1..90b26324a 100755 --- a/httemplate/edit/svc_acct.cgi +++ b/httemplate/edit/svc_acct.cgi @@ -1,72 +1,10 @@ + <% -# -# $Id: svc_acct.cgi,v 1.2 2001-08-19 15:53:35 jeff 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.2 2001-08-19 15:53:35 jeff -# added user interface for svc_forward and vpopmail support -# -# 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 $domsvc $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'); +my $conf = new FS::Conf; +my @shells = $conf->config('shells'); + +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') @@ -74,8 +12,9 @@ if ( $cgi->param('error') ) { $svcnum = $svc_acct->svcnum; $pkgnum = $cgi->param('pkgnum'); $svcpart = $cgi->param('svcpart'); - $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); - die "No part_svc entry!" unless $part_svc; + $part_svc = qsearchs( 'part_svc', { 'svcpart' => $svcpart } ); + die "No part_svc entry for svcpart $svcpart!" unless $part_svc; + @groups = $cgi->param('radius_usergroup'); } else { my($query) = $cgi->keywords; if ( $query =~ /^(\d+)$/ ) { #editing @@ -89,8 +28,10 @@ if ( $cgi->param('error') ) { $pkgnum=$cust_svc->pkgnum; $svcpart=$cust_svc->svcpart; - $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); - die "No part_svc entry!" unless $part_svc; + $part_svc = qsearchs( 'part_svc', { 'svcpart' => $svcpart } ); + die "No part_svc entry for svcpart $svcpart!" unless $part_svc; + + @groups = $svc_acct->radius_groups; } else { #adding @@ -100,8 +41,8 @@ if ( $cgi->param('error') ) { $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; + $part_svc = qsearchs( 'part_svc', { 'svcpart' => $svcpart } ); + die "No part_svc entry for svcpart $svcpart!" unless $part_svc; $svcnum=''; @@ -109,30 +50,38 @@ if ( $cgi->param('error') ) { my($cust_pkg)=qsearchs('cust_pkg',{'pkgnum'=>$pkgnum}); if ($cust_pkg) { my($cust_main)=qsearchs('cust_main',{'custnum'=> $cust_pkg->custnum } ); - $svc_acct->setfield('finger', - $cust_main->getfield('first') . " " . $cust_main->getfield('last') - ) ; + 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) ); + foreach my $part_svc_column ( + grep { $_->columnflag } $part_svc->all_part_svc_column + ) { + if ( $part_svc_column->columnname eq 'usergroup' ) { + @groups = split(',', $part_svc_column->columnvalue); + } else { + $svc_acct->setfield( $part_svc_column->columnname, + $part_svc_column->columnvalue, + ); } } } } -$action = $svcnum ? 'Edit' : 'Add'; +my $action = $svcnum ? 'Edit' : 'Add'; -$svc = $part_svc->getfield('svc'); +my $svc = $part_svc->getfield('svc'); -$otaker = getotaker; +my $otaker = getotaker; -$username = $svc_acct->username; +my $username = $svc_acct->username; +my $password; if ( $svc_acct->_password ) { - if ( $conf->exists('showpasswords') ) { + if ( $conf->exists('showpasswords') || ! $svcnum ) { $password = $svc_acct->_password; } else { $password = "*HIDDEN*"; @@ -141,66 +90,115 @@ if ( $svc_acct->_password ) { $password = ''; } -$ulen = $svc_acct->dbdef_table->column('username')->length; -$ulen2 = $ulen+2; +my $ulen = $conf->config('usernamemax') + || $svc_acct->dbdef_table->column('username')->length; +my $ulen2 = $ulen+2; + +my $pmax = $conf->config('passwordmax') || 8; +my $pmax2 = $pmax+2; -$p1 = popurl(1); -print $cgi->header( '-expires' => 'now' ), header("$action $svc account"); +my $p1 = popurl(1); +print header("$action $svc account"); print qq!Error: !, $cgi->param('error'), - "" + "

" if $cgi->param('error'); -print < +print 'Service # '. ( $svcnum ? "$svcnum" : " (NEW)" ). '
'. + 'Service: '. $part_svc->svc. '

'. + < -Username: - -
Password: - -(blank to generate) END +print &ntable("#cccccc",2), <Username + +Password + +(blank to generate) + +END + +my $sec_phrase = $svc_acct->sec_phrase; +if ( $conf->exists('security_phrase') ) { + print <Security phrase + + (for forgotten passwords) + +END +} else { + print qq!!; +} + #domain -$domsvc = $svc_acct->domsvc || 0; -if ( $part_svc->svc_acct__domsvc_flag eq "F" ) { +my $domsvc = $svc_acct->domsvc || 0; +if ( $part_svc->part_svc_column('domsvc')->columnflag eq 'F' ) { print qq!!; } else { - print qq!
Domain: \n!; + foreach my $svcnum ( + sort { $svc_domain{$a}->domain cmp $svc_domain{$b}->domain } + keys %svc_domain + ) { + my $svc_domain = $svc_domain{$svcnum}; + print qq!