From 119f418d6627eb0939778a5a9bcd6a64223ab225 Mon Sep 17 00:00:00 2001 From: einhverfr Date: Fri, 16 Mar 2007 03:46:18 +0000 Subject: Added LedgerSMB::is_run_mode git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@914 4979c152-3d1c-0410-bac9-87ea11338e46 --- LedgerSMB.pm | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'LedgerSMB.pm') diff --git a/LedgerSMB.pm b/LedgerSMB.pm index a894727b..6a11706d 100755 --- a/LedgerSMB.pm +++ b/LedgerSMB.pm @@ -47,6 +47,10 @@ HTML/SGML/XML or LaTeX. This function returns true if $self->{$string} only consists of whitespace characters or is an empty string. +=item is_run_mode ('(cli|cgi|mod_perl)') +This function returns 1 if the run mode is what is specified. Otherwise +returns 0. + =item num_text_rows (string => $string, cols => $number, max => $number); This function determines the likely number of rows needed to hold text in a @@ -201,6 +205,21 @@ sub is_blank { $rc; } +sub is_run_mode { + my $self = shift @_; + my $mode = lc shift @_; + my $rc = 0; + if ($mode eq 'cgi' && $ENV{GATEWAY_INTERFACE}){ + $rc = 1; + } + elsif ($mode eq 'cli' && ! ($ENV{GATEWAY_INTERFACE} || $ENV{MOD_PERL})){ + $rc = 1; + } elsif ($mode eq 'mod_perl' && $ENV{MOD_PERL}){ + $rc = 1; + } + $rc; +} + sub num_text_rows { my $self = shift @_; my %args = @_; @@ -546,10 +565,10 @@ sub db_init { sub redo_rows { - $self = shift @_; - %args = @_; - @flds = @{$args{fields}}; - $count = $args{count}; + my $self = shift @_; + my %args = @_; + my @flds = @{$args{fields}}; + my $count = $args{count}; } @@ -566,6 +585,7 @@ sub merge { @keys = keys %{$src}; } for my $arg (keys %$src){ + my $dst_arg; if ($index){ $dst_arg = $arg . "_$index"; } else { -- cgit v1.2.3