1 #=====================================================================
4 # Based on SQL-Ledger Version 2.1.9
5 # Web http://www.lx-office.org
7 #=====================================================================
8 # SQL-Ledger Accounting
11 # Author: Dieter Simader
12 # Email: dsimader@sql-ledger.org
13 # Web: http://www.sql-ledger.org
17 # This program is free software; you can redistribute it and/or modify
18 # it under the terms of the GNU General Public License as published by
19 # the Free Software Foundation; either version 2 of the License, or
20 # (at your option) any later version.
22 # This program is distributed in the hope that it will be useful,
23 # but WITHOUT ANY WARRANTY; without even the implied warranty of
24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 # GNU General Public License for more details.
26 # You should have received a copy of the GNU General Public License
27 # along with this program; if not, write to the Free Software
28 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 #=====================================================================
31 # routines for menu items
33 #=====================================================================
38 $main::lxdebug->enter_sub();
40 my ($type, $menufile, $level) = @_;
43 my $self = Inifile->new($menufile, $level);
45 $main::lxdebug->leave_sub();
51 $main::lxdebug->enter_sub();
53 my ($self, $myconfig, $form, $item) = @_;
55 my $module = $form->{script};
56 my $action = "section_menu";
59 if ($self->{$item}{module}) {
60 $module = $self->{$item}{module};
62 if ($self->{$item}{action}) {
63 $action = $self->{$item}{action};
65 if ($self->{$item}{target}) {
66 $target = $self->{$item}{target};
69 my $level = $form->escape($item);
72 qq|<a style="vertical-align:top" href=$module?path=$form->{path}&action=$action&level=$level&login=$form->{login}&password=$form->{password}|;
74 my @vars = qw(module action target href);
76 if ($self->{$item}{href}) {
77 $str = qq|<a href=$self->{$item}{href}|;
78 @vars = qw(module target href);
81 map { delete $self->{$item}{$_} } @vars;
84 foreach my $key (keys %{ $self->{$item} }) {
85 $str .= "&" . $form->escape($key, 1) . "=";
86 ($value, $conf) = split(/=/, $self->{$item}{$key}, 2);
87 $value = $myconfig->{$value} . "/$conf" if ($conf);
88 $str .= $form->escape($value, 1);
92 $str .= qq| target=$target|;
97 $main::lxdebug->leave_sub();
103 $main::lxdebug->enter_sub();
105 my ($self, $myconfig, $form, $item, $other) = @_;
107 my $module = $form->{script};
108 my $action = "section_menu";
111 if ($self->{$item}{module}) {
112 $module = $self->{$item}{module};
114 if ($self->{$item}{action}) {
115 $action = $self->{$item}{action};
117 if ($self->{$item}{target}) {
118 $target = $self->{$item}{target};
121 my $level = $form->escape($item);
123 my $str = qq|<a href="$module?action=| . $form->escape($action) .
124 qq|&level=| . $form->escape($level);
125 map({ $str .= "&${_}=" . $form->escape($form->{$_}); } qw(path login password));
127 my @vars = qw(module action target href);
129 if ($self->{$item}{href}) {
130 $str = qq|<a href=$self->{$item}{href}|;
131 @vars = qw(module target href);
134 map { delete $self->{$item}{$_} } @vars;
137 foreach my $key (keys %{ $self->{$item} }) {
138 $str .= "&" . $form->escape($key, 1) . "=";
139 ($value, $conf) = split(/=/, $self->{$item}{$key}, 2);
140 $value = $myconfig->{$value} . "/$conf" if ($conf);
141 $str .= $form->escape($value, 1);
147 $str .= qq| target="| . $form->quote($target) . qq|"|;
151 foreach my $key (keys(%{$other})) {
152 $str .= qq| ${key}="| . $form->quote($other->{$key}) . qq|"|;
158 $main::lxdebug->leave_sub();
164 my ($self, $myconfig, $form, $item) = @_;
166 my $module = $form->{script};
167 my $action = "section_menu";
169 #if ($self->{$item}{module}) {
170 $module = $self->{$item}{module};
173 if ($self->{$item}{action}) {
174 $action = $self->{$item}{action};
177 my $level = $form->escape($item);
179 qq|$module?path=$form->{path}&action=$action&level=$level&login=$form->{login}&password=$form->{password}|;
180 my @vars = qw(module action target href);
182 if ($self->{$item}{href}) {
183 $str = qq|$self->{$item}{href}|;
184 @vars = qw(module target href);
187 map { delete $self->{$item}{$_} } @vars;
190 foreach my $key (keys %{ $self->{$item} }) {
191 $str .= "&" . $form->escape($key, 1) . "=";
192 ($value, $conf) = split(/=/, $self->{$item}{$key}, 2);
193 $value = $myconfig->{$value} . "/$conf" if ($conf);
194 $str .= $form->escape($value, 1);
202 $main::lxdebug->enter_sub(2);
204 my ($self, $myconfig, $menulevel) = @_;
208 if ($menulevel eq "") {
209 @menu = grep { !/--/ } @{ $self->{ORDER} };
211 @menu = grep { /^${menulevel}--/ } @{ $self->{ORDER} };
214 my @a = split(/;/, $myconfig->{acs});
217 # remove --AR, --AP from array
218 grep { ($a, $b) = split /--/; s/--$a$//; } @a;
220 map { $excl{$_} = 1 } @a;
223 map { push @a, $_ unless $excl{$_} } (@menu);
225 $main::lxdebug->leave_sub(2);
231 my ($self, $menulevel, $hash) = @_;
233 my @items = $self->access_control(\%main::myconfig, $menulevel);
235 $menulevel =~ s/[^A-Za-z_\/\.\+\-]/_/g;
236 $hash->{"access_" . lc($menulevel)} = 1 if ($menulevel);
238 foreach my $item (@items) {
239 $self->generate_acl($item, $hash); #unless ($menulevel);