[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[5790] trunk



Revision: 5790
          http://sourceforge.net/p/ledger-smb/code/5790
Author:   einhverfr
Date:     2013-05-14 15:22:40 +0000 (Tue, 14 May 2013)
Log Message:
-----------
To merge to 1.3 after release: fixing variable interpolation for <?lsmb YYMMDD ?> type tags

Modified Paths:
--------------
    trunk/Changelog
    trunk/LedgerSMB/Form.pm
    trunk/LedgerSMB/Setting.pm

Modified: trunk/Changelog
===================================================================
--- trunk/Changelog	2013-05-14 13:28:53 UTC (rev 5789)
+++ trunk/Changelog	2013-05-14 15:22:40 UTC (rev 5790)
@@ -83,6 +83,9 @@
 Initial Release:  Monday, Oct 12 2011
 Supported Presently
 
+Changelog for 1.3.33
+* Fixed <?lsmb YYMMMDD ?> interpolation in settings (Chris T)
+
 Changelog for 1.3.32
 * Fixed em-dash handling for pdfs (Chris T)
 * Fixed multiple blank line handling for pdfs (Chris T)

Modified: trunk/LedgerSMB/Form.pm
===================================================================
--- trunk/LedgerSMB/Form.pm	2013-05-14 13:28:53 UTC (rev 5789)
+++ trunk/LedgerSMB/Form.pm	2013-05-14 15:22:40 UTC (rev 5790)
@@ -3387,22 +3387,17 @@
             }
 
             if ( $param =~ /<\?lsmb (yy|mm|dd)/i ) {
-                my $test_param = $1;
 		# SC: XXX Does this even work anymore?
                 my $p = $param;
-                $p =~ s/(<|>|%)//g;
-                my $spc = $p;
-                $spc =~ s/\w//g;
-                $spc = substr( $spc, 0, 1 );
+                $p =~ s/lsmb//;
+                $p =~ s/[^YyMmDd]//g;
                 my %d = ( yy => 1, mm => 2, dd => 3 );
-                my @p = ();
+                my $str = $p;
 
                 my @a = $self->split_date( $myconfig->{dateformat},
                     $self->{transdate} );
-                for my $k( sort keys %d ) { push @p, $a[ $d{$k} ] 
-                                 if ( $param =~ /$k/i ) }
-                $str = join $spc, @p;
-                $var =~ s/<\?lsmb $test_param \?>/$str/i;
+                for my $k( keys %d ) { $str =~ s/$k/$a[ $d{$k} ]/i}
+                $var =~ s/\Q$param\E/$str/i;
             }
 
             if ( $param =~ /<\?lsmb curr/i ) {
@@ -3422,7 +3417,7 @@
 
     $self->{dbh}->commit if !defined $nocommit;
 
-    $var;
+    return $var;
 }
 
 =item $form->db_prepare_vars(var1, var2, ..., varI<n>)
@@ -3471,6 +3466,7 @@
         $mm = substr( "0$mm", -2 );
         $dd = substr( "0$dd", -2 );
     }
+    $dateformat = 'yyyy-mm-dd' if $date =~ /\d{4}\D\d{2}\D\d{2}/;
 
     if ( $dateformat =~ /^yy/ ) {
 

Modified: trunk/LedgerSMB/Setting.pm
===================================================================
--- trunk/LedgerSMB/Setting.pm	2013-05-14 13:28:53 UTC (rev 5789)
+++ trunk/LedgerSMB/Setting.pm	2013-05-14 15:22:40 UTC (rev 5790)
@@ -140,20 +140,17 @@
             }
 
             if ( $param =~ /<\?lsmb (yy|mm|dd)/i ) {
-
+		# SC: XXX Does this even work anymore?
                 my $p = $param;
-                $p =~ s/(<|>|%)//g;
-                my $spc = $p;
-                $spc =~ s/\w//g;
-                $spc = substr( $spc, 0, 1 );
+                $p =~ s/lsmb//;
+                $p =~ s/[^YyMmDd]//g;
                 my %d = ( yy => 1, mm => 2, dd => 3 );
-                my @p = ();
+                my $str = $p;
 
                 my @a = $self->split_date( $myconfig->{dateformat},
                     $self->{transdate} );
-                for ( sort keys %d ) { push @p, $a[ $d{$_} ] if ( $p =~ /$_/ ) }
-                $str = join $spc, @p;
-                $var =~ s/$param/$str/;
+                for my $k( keys %d ) { $str =~ s/$k/$a[ $d{$k} ]/i}
+                $var =~ s/\Q$param\E/$str/i;
             }
 
             if ( $param =~ /<\?lsmb curr/i ) {

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.