X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=inline;f=SL%2FMenu.pm;h=ab35fed1a48bfc108ece19b371c6be7ba34186c2;hb=9c228f168c91f538bd70278a481462618a782e0b;hp=26e3512eb03a0e7016199f006526b0d3bc645d5e;hpb=84d90a036bc1638f752061d2da80cb5d6e3842cb;p=kivitendo-erp.git
diff --git a/SL/Menu.pm b/SL/Menu.pm
index 26e3512eb..ab35fed1a 100644
--- a/SL/Menu.pm
+++ b/SL/Menu.pm
@@ -37,6 +37,8 @@ package Menu;
use SL::Auth;
use SL::Inifile;
+use strict;
+
sub new {
$main::lxdebug->enter_sub();
@@ -61,46 +63,35 @@ sub menuitem {
my ($self, $myconfig, $form, $item) = @_;
- my $module = $form->{script};
- my $action = "section_menu";
- my $target = "";
+ my $module = $self->{$item}{module} || $form->{script};
+ my $action = $self->{$item}{action} || "section_menu";
+ my $target = $self->{$item}{target} || "";
- if ($self->{$item}{module}) {
- $module = $self->{$item}{module};
- }
- if ($self->{$item}{action}) {
- $action = $self->{$item}{action};
- }
- if ($self->{$item}{target}) {
- $target = $self->{$item}{target};
- }
+ my $level = $form->escape($item);
- my $level = $form->escape($item);
+ my $style = 'style="vertical-align:top"';
+ my $target_token = ($target)
+ ? "target='$target'" : '';
- my $str = qq|{$item}{href})
+ ? $form->escape($self->{$item}{href})
+ : "$module?action=$action&level=$level";
- my @vars = qw(module action target href);
+ my @vars = ($self->{$item}{href})
+ ? qw(module target href)
+ : qw(module action target href);
- if ($self->{$item}{href}) {
- $str = qq|{$item}{href}|;
- @vars = qw(module target href);
- }
-
- map { delete $self->{$item}{$_} } @vars;
+# map { delete $self->{$item}{$_} } @vars;
# add other params
foreach my $key (keys %{ $self->{$item} }) {
- $str .= "&" . $form->escape($key, 1) . "=";
- ($value, $conf) = split(/=/, $self->{$item}{$key}, 2);
+ $href .= "&" . $form->escape($key, 1) . "=";
+ my ($value, $conf) = split(/=/, $self->{$item}{$key}, 2);
$value = $myconfig->{$value} . "/$conf" if ($conf);
- $str .= $form->escape($value, 1);
+ $href .= $form->escape($value, 1);
}
- if ($target) {
- $str .= qq| target=$target|;
- }
-
- $str .= ">";
+ my $str = "";
$main::lxdebug->leave_sub();
@@ -135,7 +126,7 @@ sub menuitem_js {
# add other params
foreach my $key (keys %{ $self->{$item} }) {
$str .= "&" . $form->escape($key, 1) . "=";
- ($value, $conf) = split(/=/, $self->{$item}{$key}, 2);
+ my ($value, $conf) = split(/=/, $self->{$item}{$key}, 2);
$value = $myconfig->{$value} . "/$conf" if ($conf);
$str .= $form->escape($value, 1);
}
@@ -149,7 +140,8 @@ sub menuitem_new {
my ($self, $name, $item) = @_;
- my $form = $main::form;
+ my $form = $main::form;
+ my $myconfig = \%main::myconfig;
my $module = $self->{$name}->{module} || $form->{script};
my $action = $self->{$name}->{action};
@@ -207,7 +199,7 @@ sub menuitem_v3 {
# add other params
foreach my $key (keys %{ $self->{$item} }) {
$str .= "&" . $form->escape($key, 1) . "=";
- ($value, $conf) = split(/=/, $self->{$item}{$key}, 2);
+ my ($value, $conf) = split(/=/, $self->{$item}{$key}, 2);
$value = $myconfig->{$value} . "/$conf" if ($conf);
$str .= $form->escape($value, 1);
}
@@ -267,7 +259,7 @@ sub menuitem_XML {
# add other params
foreach my $key (keys %{ $self->{$item} }) {
$str .= "&" . $form->escape($key, 1) . "=";
- ($value, $conf) = split(/=/, $self->{$item}{$key}, 2);
+ my ($value, $conf) = split(/=/, $self->{$item}{$key}, 2);
$value = $myconfig->{$value} . "/$conf" if ($conf);
$str .= $form->escape($value, 1);
}
@@ -311,6 +303,10 @@ sub parse_access_string {
my $key = shift;
my $access = shift;
+ my $form = $main::form;
+ my $auth = $main::auth;
+ my $myconfig = \%main::myconfig;
+
my @stack;
my $cur_ary = [];
@@ -331,7 +327,7 @@ sub parse_access_string {
} elsif ($token eq ")") {
pop @stack;
if (!@stack) {
- $main::form->error("Error in menu.ini for entry ${key}: missing '('");
+ $form->error("Error in menu.ini for entry ${key}: missing '('");
}
$cur_ary = $stack[-1];
@@ -339,16 +335,16 @@ sub parse_access_string {
push @{$cur_ary}, $token;
} else {
- push @{$cur_ary}, $main::auth->check_right($main::form->{login}, $token, 1);
+ push @{$cur_ary}, $auth->check_right($form->{login}, $token, 1);
}
}
if ($access) {
- $main::form->error("Error in menu.ini for entry ${name}: unrecognized token at the start of '$access'\n");
+ $form->error("Error in menu.ini for entry ${key}: unrecognized token at the start of '$access'\n");
}
if (1 < scalar @stack) {
- $main::form->error("Error in menu.ini for entry ${name}: Missing ')'\n");
+ $main::form->error("Error in menu.ini for entry ${key}: Missing ')'\n");
}
return SL::Auth::evaluate_rights_ary($stack[0]);
@@ -393,7 +389,10 @@ sub set_access {
$self->{ORDER} = [ grep { $self->{$_}->{VISIBLE} } @{ $self->{ORDER} } ];
+ { no strict 'refs';
+ # ToDO: fix this. nuke and pave algorithm without type checking screams for problems.
map { delete @{$self->{$_}}{qw(GRANTED IS_MENU NUM_VISIBLE_CHILDREN VISIBLE ACCESS)} if ($_ ne 'ORDER') } keys %{ $self };
+ }
}
sub dump_visible {