DB-Handle Caches: DATESTYLE korrekt setzen
[kivitendo-erp.git] / SL / Menu.pm
index 0fb1b1a..530a468 100644 (file)
@@ -42,14 +42,19 @@ use strict;
 sub new {
   $main::lxdebug->enter_sub();
 
-  my ($type, $menufile) = @_;
+  my ($type, @menufiles) = @_;
+  my $self               = bless {}, $type;
 
-  my $self    = {};
-  my $inifile = Inifile->new($menufile);
+  my @order;
 
-  map { $self->{$_} = $inifile->{$_} } keys %{ $inifile };
+  foreach my $menufile (grep { -f } @menufiles) {
+    my $inifile = Inifile->new($menufile);
 
-  bless $self, $type;
+    push @order, @{ delete($inifile->{ORDER}) || [] };
+    $self->{$_} = $inifile->{$_} for keys %{ $inifile };
+  }
+
+  $self->{ORDER} = \@order;
 
   $self->set_access();
 
@@ -142,7 +147,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 +162,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 +176,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;