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

Re: SF.net SVN: ledger-smb:[4485] branches/1.3/bin



Hi Chris,

How about abstracting these tests into a generic method in the LedgerSMB::Template module: format_available($) which takes the format string as its argument and returns true or not?

The implementation can be as easy as:

sub format_available {
   my ($format) = @_;
   return ! eval { require "LedgerSMB::Template::$format"; };
}

?

Bye,


Erik.

On Fri, Mar 16, 2012 at 11:16 AM, <..hidden..> wrote:
Revision: 4485
         http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4485&view=rev
Author:   ehuelsmann
Date:     2012-03-16 10:16:52 +0000 (Fri, 16 Mar 2012)
Log Message:
-----------
Disable export buttons when the required Perl modules are missing (fixes 3473861).

Modified Paths:
--------------
   branches/1.3/bin/am.pl
   branches/1.3/bin/rp.pl

Modified: branches/1.3/bin/am.pl
===================================================================
--- branches/1.3/bin/am.pl      2012-03-16 07:16:58 UTC (rev 4484)
+++ branches/1.3/bin/am.pl      2012-03-16 10:16:52 UTC (rev 4485)
@@ -252,6 +252,11 @@
        push @rows, \%column_data;
    }

+    my %can_load;
+    $can_load{CSV} = 1;
+    $can_load{XLS} = ! eval { require Excel::Template::Plus };
+    $can_load{ODS} = ! eval { require OpenOffice::OODoc };
+
    my @buttons;
    for my $type (qw(CSV XLS ODS)) {
        push @buttons, {
@@ -260,6 +265,7 @@
            text => $locale->text("[_1] Report", $type),
            type => 'submit',
            class => 'submit',
+            disabled => $can_load{$type} ? "" : "disabled",
        };
    }
    my %hiddens = (

Modified: branches/1.3/bin/rp.pl
===================================================================
--- branches/1.3/bin/rp.pl      2012-03-16 07:16:58 UTC (rev 4484)
+++ branches/1.3/bin/rp.pl      2012-03-16 10:16:52 UTC (rev 4485)
@@ -854,6 +854,12 @@
    $column_data{debit} = $totaldebit;
    $column_data{credit} = $totalcredit;

+
+    my %can_load;
+    $can_load{CSV} = 1;
+    $can_load{XLS} = ! eval { require Excel::Template::Plus };
+    $can_load{ODS} = ! eval { require OpenOffice::OODoc };
+
    my @buttons;
    for my $type (qw(CSV XLS ODS)) {
        push @buttons, {
@@ -862,6 +868,7 @@
            text => $locale->text("[_1] Report", $type),
            type => 'submit',
            class => 'submit',
+            disabled => $can_load{$type} ? "" : "disabled",
        };
    }
    my $format;
@@ -1265,6 +1272,11 @@
 ##        &menubar;
 ##    }

+    my %can_load;
+    $can_load{CSV} = 1;
+    $can_load{XLS} = ! eval { require Excel::Template::Plus };
+    $can_load{ODS} = ! eval { require OpenOffice::OODoc };
+
    for my $type (qw(CSV XLS ODS)) {
        push @buttons, {
            name => 'action',
@@ -1272,6 +1284,7 @@
            text => $locale->text("[_1] Report", $type),
            type => 'submit',
            class => 'submit',
+            disabled => $can_load{$type} ? "" : "disabled",
        };
    }
    my $format;

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


------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Ledger-smb-commits mailing list
..hidden..
https://lists.sourceforge.net/lists/listinfo/ledger-smb-commits