X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=htdocs%2Fedit%2Fsvc_acct_sm.cgi;h=cb7cbfae0f9502bc1db031b3a96ba084018e60a4;hb=cbccf1d59c49b95ffc26703a4e251052c27ee63a;hp=be5350d84189f6f1d13b28ff4acafca700d38b4d;hpb=d51c41b94bfa87d6c779ac666495151bf6fc3913;p=freeside.git diff --git a/htdocs/edit/svc_acct_sm.cgi b/htdocs/edit/svc_acct_sm.cgi index be5350d84..cb7cbfae0 100755 --- a/htdocs/edit/svc_acct_sm.cgi +++ b/htdocs/edit/svc_acct_sm.cgi @@ -1,14 +1,12 @@ #!/usr/bin/perl -Tw # -# $Id: svc_acct_sm.cgi,v 1.5 1998-12-30 23:03:24 ivan Exp $ +# $Id: svc_acct_sm.cgi,v 1.9 1999-02-28 00:03:38 ivan Exp $ # # Usage: svc_acct_sm.cgi {svcnum} | pkgnum{pkgnum}-svcpart{svcpart} # http://server.name/path/svc_acct_sm.cgi? {svcnum} | pkgnum{pkgnum}-svcpart{svcpart} # # use {svcnum} for edit, pkgnum{pkgnum}-svcpart{svcpart} for add # -# Note: Should be run setuid freeside as user nobody. -# # should error out in a more CGI-friendly way, and should have more error checking (sigh). # # ivan@voicenet.com 97-jan-5 @@ -35,7 +33,21 @@ # /var/spool/freeside/conf/domain ivan@sisd.com 98-jul-26 # # $Log: svc_acct_sm.cgi,v $ -# Revision 1.5 1998-12-30 23:03:24 ivan +# Revision 1.9 1999-02-28 00:03:38 ivan +# removed misleading comments +# +# Revision 1.8 1999/02/07 09:59:24 ivan +# more mod_perl fixes, and bugfixes Peter Wemm sent via email +# +# Revision 1.7 1999/01/19 05:13:45 ivan +# for mod_perl: no more top-level my() variables; use vars instead +# also the last s/create/new/; +# +# Revision 1.6 1999/01/18 09:41:34 ivan +# all $cgi->header calls now include ( '-expires' => 'now' ) for mod_perl +# (good idea anyway) +# +# Revision 1.5 1998/12/30 23:03:24 ivan # bugfixes; fields isn't exported by derived classes # # Revision 1.4 1998/12/23 02:58:45 ivan @@ -49,7 +61,8 @@ # use strict; -use vars qw($conf); +use vars qw( $conf $cgi $mydomain $action $svcnum $svc_acct_sm $pkgnum $svcpart + $part_svc $query %username %domain $p1 $domuser $domsvc $domuid ); use CGI; use CGI::Carp qw(fatalsToBrowser); use FS::UID qw(cgisuidsetup); @@ -58,58 +71,62 @@ use FS::Record qw(qsearch qsearchs fields); use FS::svc_acct_sm; use FS::Conf; -my($cgi) = new CGI; +$cgi = new CGI; &cgisuidsetup($cgi); $conf = new FS::Conf; -my $mydomain = $conf->config('domain'); - -my($action,$svcnum,$svc_acct_sm,$pkgnum,$svcpart,$part_svc); - -my($query) = $cgi->keywords; -if ( $query =~ /^(\d+)$/ ) { #editing - - $svcnum=$1; - $svc_acct_sm=qsearchs('svc_acct_sm',{'svcnum'=>$svcnum}) - or die "Unknown (svc_acct_sm) svcnum!"; - - my($cust_svc)=qsearchs('cust_svc',{'svcnum'=>$svcnum}) - or die "Unknown (cust_svc) svcnum!"; - - $pkgnum=$cust_svc->pkgnum; - $svcpart=$cust_svc->svcpart; - +$mydomain = $conf->config('domain'); + +if ( $cgi->param('error') ) { + $svc_acct_sm = new FS::svc_acct_sm ( { + map { $_, scalar($cgi->param($_)) } fields('svc_acct_sm') + } ); + $svcnum = $svc_acct_sm->svcnum; + $pkgnum = $cgi->param('pkgnum'); + $svcpart = $cgi->param('svcpart'); $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); die "No part_svc entry!" unless $part_svc; +} else { + my($query) = $cgi->keywords; + if ( $query =~ /^(\d+)$/ ) { #editing + $svcnum=$1; + $svc_acct_sm=qsearchs('svc_acct_sm',{'svcnum'=>$svcnum}) + or die "Unknown (svc_acct_sm) svcnum!"; - $action="Edit"; - -} else { #adding + my($cust_svc)=qsearchs('cust_svc',{'svcnum'=>$svcnum}) + or die "Unknown (cust_svc) svcnum!"; - $svc_acct_sm=create FS::svc_acct_sm({}); + $pkgnum=$cust_svc->pkgnum; + $svcpart=$cust_svc->svcpart; + + $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); + die "No part_svc entry!" unless $part_svc; - foreach $_ (split(/-/,$query)) { #get & untaint pkgnum & svcpart - $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; + } else { #adding - $svcnum=''; + $svc_acct_sm = new FS::svc_acct_sm({}); - #set fixed and default fields from part_svc - my($field); - foreach $field ( fields('svc_acct_sm') ) { - if ( $part_svc->getfield('svc_acct_sm__'. $field. '_flag') ne '' ) { - $svc_acct_sm->setfield($field,$part_svc->getfield('svc_acct_sm__'. $field) ); + foreach $_ (split(/-/,$query)) { #get & untaint pkgnum & svcpart + $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; + + $svcnum=''; - $action='Add'; + #set fixed and default fields from part_svc + my($field); + foreach $field ( fields('svc_acct_sm') ) { + if ( $part_svc->getfield('svc_acct_sm__'. $field. '_flag') ne '' ) { + $svc_acct_sm->setfield($field,$part_svc->getfield('svc_acct_sm__'. $field) ); + } + } + } } +$action = $svc_acct_sm->svcnum ? 'Edit' : 'Add'; -my(%username,%domain); if ($pkgnum) { #find all possible uids (and usernames) @@ -167,10 +184,14 @@ if ($pkgnum) { die "\$action eq Add, but \$pkgnum is null!\n"; } -my $p1 = popurl(1); -print $cgi->header, header("Mail Alias $action", ''), < -END +$p1 = popurl(1); +print $cgi->header( '-expires' => 'now' ), header("Mail Alias $action", ''); + +print qq!Error: !, $cgi->param('error'), + "" + if $cgi->param('error'); + +print qq!
!; #display @@ -187,7 +208,7 @@ print qq!!; #svcpart print qq!!; -my($domuser,$domsvc,$domuid)=( +($domuser,$domsvc,$domuid)=( $svc_acct_sm->domuser, $svc_acct_sm->domsvc, $svc_acct_sm->domuid, @@ -199,14 +220,16 @@ print qq!\n\nMail to ( * #domsvc print qq! \@ "; #uid print qq!\nforwards to \@$mydomain mailbox.";