X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FMenu.pm;h=48ac6229daa2b672aa74ad6fb7cdbb24883c1fed;hb=4a12c839937370488b8b8a40bef376e7cb0a2ce6;hp=26e3512eb03a0e7016199f006526b0d3bc645d5e;hpb=84d90a036bc1638f752061d2da80cb5d6e3842cb;p=kivitendo-erp.git
diff --git a/SL/Menu.pm b/SL/Menu.pm
index 26e3512eb..48ac6229d 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();
@@ -56,100 +58,13 @@ sub new {
return $self;
}
-sub menuitem {
- $main::lxdebug->enter_sub();
-
- my ($self, $myconfig, $form, $item) = @_;
-
- my $module = $form->{script};
- my $action = "section_menu";
- my $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 $str = qq|{$item}{href}) {
- $str = qq|{$item}{href}|;
- @vars = qw(module target href);
- }
-
- 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);
- $value = $myconfig->{$value} . "/$conf" if ($conf);
- $str .= $form->escape($value, 1);
- }
-
- if ($target) {
- $str .= qq| target=$target|;
- }
-
- $str .= ">";
-
- $main::lxdebug->leave_sub();
-
- return $str;
-}
-
-sub menuitem_js {
- my ($self, $myconfig, $form, $item) = @_;
-
- my $module = $form->{script};
- my $action = "section_menu";
-
- #if ($self->{$item}{module}) {
- $module = $self->{$item}{module};
-
- #}
- if ($self->{$item}{action}) {
- $action = $self->{$item}{action};
- }
-
- my $level = $form->escape($item);
- my $str = qq|$module?action=$action&level=$level|;
- my @vars = qw(module action target href);
-
- if ($self->{$item}{href}) {
- $str = qq|$self->{$item}{href}|;
- @vars = qw(module target href);
- }
-
- 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);
- $value = $myconfig->{$value} . "/$conf" if ($conf);
- $str .= $form->escape($value, 1);
- }
-
- $str .= " ";
-
-}
-
sub menuitem_new {
$main::lxdebug->enter_sub();
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};
@@ -172,122 +87,6 @@ sub menuitem_new {
$main::lxdebug->leave_sub();
}
-sub menuitem_v3 {
- $main::lxdebug->enter_sub();
-
- my ($self, $myconfig, $form, $item, $other) = @_;
-
- my $module = $form->{script};
- my $action = "section_menu";
- my $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 $str = qq|escape($key, 1) . "=";
- ($value, $conf) = split(/=/, $self->{$item}{$key}, 2);
- $value = $myconfig->{$value} . "/$conf" if ($conf);
- $str .= $form->escape($value, 1);
- }
-
- $str .= '"';
-
- if ($target) {
- $str .= qq| target="| . $form->quote($target) . qq|"|;
- }
-
- if ($other) {
- foreach my $key (keys(%{$other})) {
- $str .= qq| ${key}="| . $form->quote($other->{$key}) . qq|"|;
- }
- }
-
- $str .= ">";
-
- $main::lxdebug->leave_sub();
-
- return $str;
-}
-
-sub menuitem_XML {
- $main::lxdebug->enter_sub();
-
- my ($self, $myconfig, $form, $item, $other) = @_;
-
- my $module = $form->{script};
- my $action = "section_menu";
- my $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 $str = qq| link="$module?action=| . $form->escape($action) .
- qq|&level=| . $form->escape($level);
-
- my @vars = qw(module action target href);
-
- if ($self->{$item}{href}) {
- $str = qq| link=$self->{$item}{href}|;
- @vars = qw(module target href);
- }
-
- 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);
- $value = $myconfig->{$value} . "/$conf" if ($conf);
- $str .= $form->escape($value, 1);
- }
-
- $str .= '"';
-
-
-
- if ($other) {
- foreach my $key (keys(%{$other})) {
- $str .= qq| ${key}="| . $form->quote($other->{$key}) . qq|"|;
- }
- }
-
-
- $main::lxdebug->leave_sub();
-
- return $str;
-}
-
sub access_control {
$main::lxdebug->enter_sub(2);
@@ -311,6 +110,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 +134,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 +142,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 +196,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 {