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 $self = {};
- my $inifile = Inifile->new($menufile);
+ my ($package, @menufiles) = @_;
- map { $self->{$_} = $inifile->{$_} } keys %{ $inifile };
+ my $self = $package->SUPER::new($menufiles[0]);
- 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();
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});
# 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(LXDebug::DEBUG2());
my @menu = ();
- if ($menulevel eq "") {
+ if (!$menulevel) {
@menu = grep { !/--/ } @{ $self->{ORDER} };
} else {
@menu = grep { /^${menulevel}--/ } @{ $self->{ORDER} };
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);
}
}
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;
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;