]> wagnertech.de Git - mfinanz.git/blobdiff - SL/Menu.pm
Layout/empty: empty.json und emty.html ermöglichen
[mfinanz.git] / SL / Menu.pm
index 48ac6229daa2b672aa74ad6fb7cdbb24883c1fed..873701616c1a0b9d8809992b05326f43e0d056d3 100644 (file)
 
 package Menu;
 
+use strict;
+
 use SL::Auth;
 use SL::Inifile;
 
-use strict;
+our @ISA = qw(Inifile);
+
 
 sub new {
   $main::lxdebug->enter_sub();
 
-  my ($type, $menufile) = @_;
+  my ($package, @menufiles) = @_;
 
-  my $self    = {};
-  my $inifile = Inifile->new($menufile);
+  my $self = $package->SUPER::new($menufiles[0]);
 
-  map { $self->{$_} = $inifile->{$_} } keys %{ $inifile };
-
-  bless $self, $type;
+  for (@menufiles[1..$#menufiles]) {
+    my $inifile = Inifile->new($_);
+    push @{ $self->{ORDER} }, @{ delete $inifile->{ORDER} };
+    $self->{$_} = $inifile->{$_} for keys %$inifile;
+  }
 
-  $self->set_access();
+  $self->set_access;
 
   $main::lxdebug->leave_sub();
 
@@ -59,18 +63,15 @@ sub new {
 }
 
 sub menuitem_new {
-  $main::lxdebug->enter_sub();
+  $main::lxdebug->enter_sub(LXDebug::DEBUG2());
 
   my ($self, $name, $item) = @_;
 
-  my $form        =  $main::form;
-  my $myconfig    = \%main::myconfig;
-
-  my $module      = $self->{$name}->{module} || $form->{script};
+  my $module      = $self->{$name}->{module} || $::form->{script};
   my $action      = $self->{$name}->{action};
 
   $item->{target} = $self->{$name}->{target} || "main_window";
-  $item->{href}   = $self->{$name}->{href}   || "${module}?action=" . $form->escape($action);
+  $item->{href}   = $self->{$name}->{href}   || "${module}?action=" . $::form->escape($action);
 
   my @vars = qw(module target href);
   push @vars, 'action' unless ($self->{$name}->{href});
@@ -80,11 +81,11 @@ sub menuitem_new {
   # add other params
   foreach my $key (keys %{ $self->{$name} }) {
     my ($value, $conf)  = split(m/=/, $self->{$name}->{$key}, 2);
-    $value              = $myconfig->{$value} . "/$conf" if ($conf);
-    $item->{href}      .= "&" . $form->escape($key) . "=" . $form->escape($value);
+    $value              = $::myconfig->{$value} . "/$conf" if ($conf);
+    $item->{href}      .= "&" . $::form->escape($key) . "=" . $::form->escape($value);
   }
 
-  $main::lxdebug->leave_sub();
+  $main::lxdebug->leave_sub(LXDebug::DEBUG2());
 }
 
 sub access_control {
@@ -94,7 +95,7 @@ sub access_control {
 
   my @menu = ();
 
-  if ($menulevel eq "") {
+  if (!$menulevel) {
     @menu = grep { !/--/ } @{ $self->{ORDER} };
   } else {
     @menu = grep { /^${menulevel}--/ } @{ $self->{ORDER} };
@@ -142,7 +143,7 @@ sub parse_access_string {
       push @{$cur_ary}, $token;
 
     } else {
-      push @{$cur_ary}, $auth->check_right($form->{login}, $token, 1);
+      push @{$cur_ary}, $auth->check_right($::myconfig{login}, $token, 1);
     }
   }
 
@@ -157,6 +158,11 @@ sub parse_access_string {
   return SL::Auth::evaluate_rights_ary($stack[0]);
 }
 
+sub parse_instance_conf_string {
+  my ($self, $setting) = @_;
+  return $::instance_conf->data->{$setting};
+}
+
 sub set_access {
   my $self = shift;
 
@@ -166,6 +172,7 @@ sub set_access {
     my $entry = $self->{$key};
 
     $entry->{GRANTED}              = $entry->{ACCESS} ? $self->parse_access_string($key, $entry->{ACCESS}) : 1;
+    $entry->{GRANTED}            &&= $self->parse_instance_conf_string($entry->{INSTANCE_CONF}) if $entry->{INSTANCE_CONF};
     $entry->{IS_MENU}              = $entry->{submenu} || ($key !~ m/--/);
     $entry->{NUM_VISIBLE_CHILDREN} = 0;