summaryrefslogtreecommitdiff
path: root/LedgerSMB
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-06-27 01:28:23 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-06-27 01:28:23 +0000
commit80d758a1abf3d2b696fd14521726806236a2c2b6 (patch)
tree5a36c2e4368553fc87cd760cd30875d78e49e113 /LedgerSMB
parentca4e59a9c2e455bcb05d155e81cc10520d643341 (diff)
Committing first-run of broken infrastructure
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1333 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'LedgerSMB')
-rw-r--r--LedgerSMB/Menu.pm71
1 files changed, 71 insertions, 0 deletions
diff --git a/LedgerSMB/Menu.pm b/LedgerSMB/Menu.pm
new file mode 100644
index 00000000..30aa28c6
--- /dev/null
+++ b/LedgerSMB/Menu.pm
@@ -0,0 +1,71 @@
+=head1 NAME
+
+LedgerSMB::Menu: Menu Handling Back-end Routines for LedgerSMB
+
+=head1 SYNOPSIS
+
+Provides the functions for generating the data structures for the LedgerSMB
+menu.
+
+=head1 COPYRIGHT
+
+Copyright (c) 2007 The LedgerSMB Core Team. Licensed under the GNU General
+Public License version 2 or at your option any later version. Please see the
+included COPYRIGHT and LICENSE files for more information.
+
+=cut
+
+package LedgerSMB::Menu;
+
+use Config::Std;
+use base(qw(LedgerSMB));
+
+1;
+
+=head1 METHODS
+
+=over
+
+=item new({files => ['path/to/file/glob' ... ], user = $user_ref})
+
+Creates a new Menu data structure with the files listed and the files in the
+paths.
+
+=cut
+
+
+sub new {
+ my ($class, $args) = @_;
+ my $self = {};
+ bless ($self, $class);
+ my $index = 1;
+ for $file_glob (@{$args->{files}}){
+ for $file (glob($file_glob)){
+ my %config;
+ read_config($file => %config );
+ for $key (keys %config){
+ next if $args->{user}->{acs} =~ /$key/;
+ my $orig_key = $key;
+ my $ref = $self;
+ while ($key =~ s/^([^-]*)--//){
+ if (!defined $ref->{$1}){
+ $ref->{$1} = {};
+ }
+ if (!defined $ref->{$1}->{subs}){
+ $ref->{$1}->{subs} = {};
+ }
+ $ref = $ref->{$1}->{subs};
+ }
+ for (keys %{$config->{$orig_key}}){
+ $ref->{$_} = $config{$orig_key}->{$_};
+ }
+ $ref->{$key}{id} = $index;
+ $ref->{$key}{label} = $key;
+ ++$index;
+ }
+ }
+ }
+ return $self;
+}
+1;
+=back