X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FCGI.pm;h=5ac31dbecd3385f2b9a862b454cc8c41fa9195fe;hb=8c84e8692d48eff3b03822dcd18c1766fd0b9bca;hp=4c2693db856ea0dd4d302057bc382d02b6c83469;hpb=3ccc60c2a0aca859a43210b8110757783f9f8ef1;p=freeside.git diff --git a/FS/FS/CGI.pm b/FS/FS/CGI.pm index 4c2693db8..5ac31dbec 100644 --- a/FS/FS/CGI.pm +++ b/FS/FS/CGI.pm @@ -6,11 +6,11 @@ use Exporter; use CGI; use URI::URL; #use CGI::Carp qw(fatalsToBrowser); -use FS::UID; +use FS::UID qw( cgi ); @ISA = qw(Exporter); -@EXPORT_OK = qw(header menubar idiot eidiot popurl rooturl table itable ntable - small_custview myexit http_header); +@EXPORT_OK = qw( header menubar idiot eidiot popurl rooturl table itable ntable + myexit http_header); =head1 NAME @@ -194,16 +194,24 @@ sub myexit { } } -=item popurl LEVEL +=item popurl LEVEL [URL] -Returns current URL with LEVEL levels of path removed from the end (default 0). +Returns current (or, optionally, passed) URL with LEVEL levels of path removed +from the end (default 0). =cut sub popurl { - my($up)=@_; - my $cgi = &FS::UID::cgi; - my $url_string = $cgi->isa('Apache') ? $cgi->uri : $cgi->url; + my $up = shift; + + my $url_string; + if ( scalar(@_) ) { + $url_string = shift; + } else { + my $cgi = &FS::UID::cgi; + $url_string = $cgi->isa('Apache') ? $cgi->uri : $cgi->url; + } + $url_string =~ s/\?.*//; my $url = new URI::URL ( $url_string ); my(@path)=$url->path_components; @@ -219,9 +227,15 @@ sub popurl { =cut sub rooturl { - # better to start with the client-provided URL - my $cgi = &FS::UID::cgi; - my $url_string = $cgi->isa('Apache') ? $cgi->uri : $cgi->url; + my $url_string; + if ( scalar(@_) ) { + $url_string = shift; + } else { + # better to start with the client-provided URL + my $cgi = cgi; + $url_string = $cgi->isa('Apache') ? $cgi->uri : $cgi->url; + } + $url_string =~ s/\?.*//; #even though this is kludgy @@ -230,10 +244,9 @@ sub rooturl { $url_string =~ s{ / - (browse|config|docs|edit|graph|misc|search|view|pref|rt|elements) - / - (process/)? - ([\w\-\.\/]+) + (browse|config|docs|edit|graph|misc|search|view|loginout|pref|elements|rt|torrus) + (/process)? + ([\w\-\.\/]*) $ } {}x; @@ -300,110 +313,6 @@ sub ntable { } -=item small_custview CUSTNUM || CUST_MAIN_OBJECT, COUNTRYDEFAULT, NOBALANCE_FLAG, URL - -Sheesh. I should just switch to Mason. - -=cut - -sub small_custview { - use FS::Record qw(qsearchs); - use FS::cust_main; - - my $arg = shift; - my $countrydefault = shift || 'US'; - my $nobalance = shift; - my $url = shift; - - my $cust_main = ref($arg) ? $arg - : qsearchs('cust_main', { 'custnum' => $arg } ) - or die "unknown custnum $arg"; - - my $html; - - $html = qq!View ' - if $url; - - $html .= 'Customer #'. $cust_main->custnum. ''. - ' - '. - ucfirst($cust_main->status). ''. - ntable('#e8e8e8'). '