From 0bdec843e4a9bb7f947c9ba980a40f7bf37020fb Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 9 Feb 2002 18:24:02 +0000 Subject: [PATCH] no more exit() in templates --- FS/FS/CGI.pm | 14 +++++- htetc/global.asa | 2 +- htetc/handler.pl | 2 +- httemplate/edit/process/agent_type.cgi | 52 +++++++++++----------- .../edit/process/cust_main_county-expand.cgi | 4 +- httemplate/edit/process/cust_main_county.cgi | 4 +- httemplate/edit/process/cust_pay.cgi | 3 +- httemplate/edit/process/part_pkg.cgi | 6 +-- httemplate/search/cust_main.cgi | 2 +- httemplate/search/cust_pkg.cgi | 4 +- httemplate/search/svc_domain.cgi | 4 +- 11 files changed, 54 insertions(+), 43 deletions(-) diff --git a/FS/FS/CGI.pm b/FS/FS/CGI.pm index d1c56a254..35d2e2839 100644 --- a/FS/FS/CGI.pm +++ b/FS/FS/CGI.pm @@ -10,7 +10,7 @@ use FS::UID; @ISA = qw(Exporter); @EXPORT_OK = qw(header menubar idiot eidiot popurl table itable ntable - small_custview); + small_custview myexit); =head1 NAME @@ -132,6 +132,18 @@ Sends an HTML error message, then exits. sub eidiot { warn "eidiot depriciated"; idiot(@_); + &myexit(); +} + +=item myexit + +You probably shouldn't use this; but if you must: + +If running under mod_perl, calles Apache::exit, otherwise, calls exit. + +=cut + +sub myexit { if (exists $ENV{MOD_PERL}) { $main::Response->End() if defined $main::Response diff --git a/htetc/global.asa b/htetc/global.asa index cf6b0f679..daf1c397f 100644 --- a/htetc/global.asa +++ b/htetc/global.asa @@ -13,7 +13,7 @@ use FS::UID qw(cgisuidsetup dbh getotaker datasrc); use FS::Record qw(qsearch qsearchs fields dbdef); use FS::Conf; use FS::CGI qw(header menubar popurl table itable ntable idiot eidiot - small_custview); + small_custview myexit); use FS::agent; use FS::agent_type; diff --git a/htetc/handler.pl b/htetc/handler.pl index 5be19c443..29e759a68 100644 --- a/htetc/handler.pl +++ b/htetc/handler.pl @@ -68,7 +68,7 @@ sub handler use FS::Record qw(qsearch qsearchs fields dbdef); use FS::Conf; use FS::CGI qw(header menubar popurl table itable ntable idiot eidiot - small_custview); + small_custviewm myexit); use FS::agent; use FS::agent_type; diff --git a/httemplate/edit/process/agent_type.cgi b/httemplate/edit/process/agent_type.cgi index 2d1159708..4e98cf113 100755 --- a/httemplate/edit/process/agent_type.cgi +++ b/httemplate/edit/process/agent_type.cgi @@ -1,4 +1,4 @@ - + <% my $typenum = $cgi->param('typenum'); @@ -21,35 +21,35 @@ if ( $typenum ) { if ( $error ) { $cgi->param('error', $error); print $cgi->redirect(popurl(2). "agent_type.cgi?". $cgi->query_string ); - exit; -} +} else { + + foreach my $part_pkg (qsearch('part_pkg',{})) { + my($pkgpart)=$part_pkg->getfield('pkgpart'); -foreach my $part_pkg (qsearch('part_pkg',{})) { - my($pkgpart)=$part_pkg->getfield('pkgpart'); - - my($type_pkgs)=qsearchs('type_pkgs',{ - 'typenum' => $typenum, - 'pkgpart' => $pkgpart, - }); - if ( $type_pkgs && ! $cgi->param("pkgpart$pkgpart") ) { - my($d_type_pkgs)=$type_pkgs; #need to save $type_pkgs for below. - $error=$d_type_pkgs->delete; - die $error if $error; - - } elsif ( $cgi->param("pkgpart$pkgpart") - && ! $type_pkgs - ) { - #ok to clobber it now (but bad form nonetheless?) - $type_pkgs=new FS::type_pkgs ({ - 'typenum' => $typenum, - 'pkgpart' => $pkgpart, + my($type_pkgs)=qsearchs('type_pkgs',{ + 'typenum' => $typenum, + 'pkgpart' => $pkgpart, }); - $error= $type_pkgs->insert; - die $error if $error; + if ( $type_pkgs && ! $cgi->param("pkgpart$pkgpart") ) { + my($d_type_pkgs)=$type_pkgs; #need to save $type_pkgs for below. + $error=$d_type_pkgs->delete; + die $error if $error; + + } elsif ( $cgi->param("pkgpart$pkgpart") + && ! $type_pkgs + ) { + #ok to clobber it now (but bad form nonetheless?) + $type_pkgs=new FS::type_pkgs ({ + 'typenum' => $typenum, + 'pkgpart' => $pkgpart, + }); + $error= $type_pkgs->insert; + die $error if $error; + } + } + print $cgi->redirect(popurl(3). "browse/agent_type.cgi"); } -print $cgi->redirect(popurl(3). "browse/agent_type.cgi"); - %> diff --git a/httemplate/edit/process/cust_main_county-expand.cgi b/httemplate/edit/process/cust_main_county-expand.cgi index b16fab4fe..342779048 100755 --- a/httemplate/edit/process/cust_main_county-expand.cgi +++ b/httemplate/edit/process/cust_main_county-expand.cgi @@ -1,4 +1,4 @@ - + <% $cgi->param('taxnum') =~ /^(\d+)$/ or die "Illegal taxnum!"; @@ -19,7 +19,7 @@ if ( $cgi->param('delim') eq 'n' ) { unless ( /^\s*([\w\- ]+)\s*$/ ) { $cgi->param('error', "Illegal item in expansion"); print $cgi->redirect(popurl(2). "cust_main_county-expand.cgi?". $cgi->query_string ); - exit; + myexit(); } $1; } @expansion; diff --git a/httemplate/edit/process/cust_main_county.cgi b/httemplate/edit/process/cust_main_county.cgi index 0f0246b73..e9d130897 100755 --- a/httemplate/edit/process/cust_main_county.cgi +++ b/httemplate/edit/process/cust_main_county.cgi @@ -1,4 +1,4 @@ - + <% foreach ( $cgi->param ) { @@ -14,7 +14,7 @@ foreach ( $cgi->param ) { if ( $error ) { $cgi->param('error', $error); print $cgi->redirect(popurl(2). "cust_main_county.cgi?". $cgi->query_string ); - exit; + myexit(); } } diff --git a/httemplate/edit/process/cust_pay.cgi b/httemplate/edit/process/cust_pay.cgi index c75e53280..953ff3edb 100755 --- a/httemplate/edit/process/cust_pay.cgi +++ b/httemplate/edit/process/cust_pay.cgi @@ -1,4 +1,4 @@ - + <% $cgi->param('linknum') =~ /^(\d+)$/ @@ -22,7 +22,6 @@ my $error = $new->insert; if ($error) { $cgi->param('error', $error); print $cgi->redirect(popurl(2). 'cust_pay.cgi?'. $cgi->query_string ); - exit; } elsif ( $link eq 'invnum' ) { print $cgi->redirect(popurl(3). "view/cust_bill.cgi?$linknum"); } elsif ( $link eq 'custnum' ) { diff --git a/httemplate/edit/process/part_pkg.cgi b/httemplate/edit/process/part_pkg.cgi index 2ba1cbeb0..5240d8cc2 100755 --- a/httemplate/edit/process/part_pkg.cgi +++ b/httemplate/edit/process/part_pkg.cgi @@ -1,4 +1,4 @@ - + <% my $dbh = dbh; @@ -34,7 +34,7 @@ foreach my $part_svc ( qsearch('part_svc', {} ) ) { unless ( $quantity =~ /^(\d+)$/ ) { $cgi->param('error', "Illegal quantity" ); print $cgi->redirect(popurl(2). "part_pkg.cgi?". $cgi->query_string ); - exit; + myexit(); } } @@ -58,7 +58,7 @@ if ( $error ) { $dbh->rollback; $cgi->param('error', $error ); print $cgi->redirect(popurl(2). "part_pkg.cgi?". $cgi->query_string ); - exit; + myexit(); } foreach $part_svc (qsearch('part_svc',{})) { diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi index f21dd7ed1..89e325d09 100755 --- a/httemplate/search/cust_main.cgi +++ b/httemplate/search/cust_main.cgi @@ -150,7 +150,7 @@ if ( scalar(@cust_main) == 1 && ! $cgi->param('referral_custnum') ) { } else { print $cgi->redirect(popurl(2). "view/cust_main.cgi?". $cust_main[0]->custnum); } - exit; + #exit; } elsif ( scalar(@cust_main) == 0 ) { eidiot "No matching customers found!\n"; } else { diff --git a/httemplate/search/cust_pkg.cgi b/httemplate/search/cust_pkg.cgi index 9705bd658..b2199e9dc 100755 --- a/httemplate/search/cust_pkg.cgi +++ b/httemplate/search/cust_pkg.cgi @@ -1,4 +1,4 @@ - + <% my $conf = new FS::Conf; @@ -76,7 +76,7 @@ my @cust_pkg = qsearch('cust_pkg',{}, '', "$unconf ORDER BY pkgnum $limit" ); if ( scalar(@cust_pkg) == 1 ) { my($pkgnum)=$cust_pkg[0]->pkgnum; print $cgi->redirect(popurl(2). "view/cust_pkg.cgi?$pkgnum"); - exit; + #exit; } elsif ( scalar(@cust_pkg) == 0 ) { #error eidiot("No packages found"); } else { diff --git a/httemplate/search/svc_domain.cgi b/httemplate/search/svc_domain.cgi index 4ec5eb053..c274750aa 100755 --- a/httemplate/search/svc_domain.cgi +++ b/httemplate/search/svc_domain.cgi @@ -1,4 +1,4 @@ - + <% my $conf = new FS::Conf; @@ -34,7 +34,7 @@ if ( $query eq 'svcnum' ) { if ( scalar(@svc_domain) == 1 ) { print $cgi->redirect(popurl(2). "view/svc_domain.cgi?". $svc_domain[0]->svcnum); - exit; + #exit; } elsif ( scalar(@svc_domain) == 0 ) { eidiot "No matching domains found!\n"; } else { -- 2.11.0