X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=inline;f=SL%2FMenu.pm;h=89a6ffd15e06cb1b16b94388e40ccb40186c5bfb;hb=088f6a9721fece191bcc8d11a144b3b958b6c0c8;hp=a3fa3e5647450ff09a524da3e7f1da0ca134569b;hpb=8c6efb2a9d807818596d7bee4fa9693ab833274c;p=kivitendo-erp.git
diff --git a/SL/Menu.pm b/SL/Menu.pm
index a3fa3e564..89a6ffd15 100644
--- a/SL/Menu.pm
+++ b/SL/Menu.pm
@@ -34,13 +34,17 @@
package Menu;
+use SL::Inifile;
+
sub new {
$main::lxdebug->enter_sub();
- my ($type, $menufile, $level) = @_;
+ my ($type, $menufile) = @_;
+
+ my $self = {};
+ my $inifile = Inifile->new($menufile);
- use SL::Inifile;
- my $self = Inifile->new($menufile, $level);
+ map { $self->{$_} = $inifile->{$_} } keys %{ $inifile };
$main::lxdebug->leave_sub();
@@ -69,7 +73,7 @@ sub menuitem {
my $level = $form->escape($item);
my $str =
- qq|{path}&action=$action&level=$level&login=$form->{login}&password=$form->{password}|;
+ qq|{login}&password=$form->{password}|;
my @vars = qw(module action target href);
@@ -83,7 +87,7 @@ sub menuitem {
# add other params
foreach my $key (keys %{ $self->{$item} }) {
$str .= "&" . $form->escape($key, 1) . "=";
- ($value, $conf) = split /=/, $self->{$item}{$key}, 2;
+ ($value, $conf) = split(/=/, $self->{$item}{$key}, 2);
$value = $myconfig->{$value} . "/$conf" if ($conf);
$str .= $form->escape($value, 1);
}
@@ -99,6 +103,67 @@ sub menuitem {
return $str;
}
+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($form->{$_}); } qw(login password));
+
+ my @vars = qw(module action target href);
+
+ if ($self->{$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);
+ }
+
+ $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 menuitemNew {
my ($self, $myconfig, $form, $item) = @_;
@@ -115,7 +180,7 @@ sub menuitemNew {
my $level = $form->escape($item);
my $str =
- qq|$module?path=$form->{path}&action=$action&level=$level&login=$form->{login}&password=$form->{password}|;
+ qq|$module?action=$action&level=$level&login=$form->{login}&password=$form->{password}|;
my @vars = qw(module action target href);
if ($self->{$item}{href}) {
@@ -128,7 +193,7 @@ sub menuitemNew {
# add other params
foreach my $key (keys %{ $self->{$item} }) {
$str .= "&" . $form->escape($key, 1) . "=";
- ($value, $conf) = split /=/, $self->{$item}{$key}, 2;
+ ($value, $conf) = split(/=/, $self->{$item}{$key}, 2);
$value = $myconfig->{$value} . "/$conf" if ($conf);
$str .= $form->escape($value, 1);
}
@@ -150,11 +215,11 @@ sub access_control {
@menu = grep { /^${menulevel}--/ } @{ $self->{ORDER} };
}
- my @a = split /;/, $myconfig->{acs};
+ my @a = split(/;/, $myconfig->{acs});
my $excl = ();
# remove --AR, --AP from array
- grep { ($a, $b) = split /--/; s/--$a$//; } @a;
+ grep { ($a, $b) = split(/--/); s/--$a$//; } @a;
map { $excl{$_} = 1 } @a;
@@ -166,5 +231,18 @@ sub access_control {
return @a;
}
+sub generate_acl {
+ my ($self, $menulevel, $hash) = @_;
+
+ my @items = $self->access_control(\%main::myconfig, $menulevel);
+
+ $menulevel =~ s/[^A-Za-z_\/\.\+\-]/_/g;
+ $hash->{"access_" . lc($menulevel)} = 1 if ($menulevel);
+
+ foreach my $item (@items) {
+ $self->generate_acl($item, $hash); #unless ($menulevel);
+ }
+}
+
1;