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 #=====================================================================
40 $main::lxdebug->enter_sub();
42 my ($type, $menufile) = @_;
45 my $inifile = Inifile->new($menufile);
47 map { $self->{$_} = $inifile->{$_} } keys %{ $inifile };
49 $main::lxdebug->leave_sub();
55 $main::lxdebug->enter_sub();
57 my ($self, $myconfig, $form, $item) = @_;
59 my $module = $form->{script};
60 my $action = "section_menu";
63 if ($self->{$item}{module}) {
64 $module = $self->{$item}{module};
66 if ($self->{$item}{action}) {
67 $action = $self->{$item}{action};
69 if ($self->{$item}{target}) {
70 $target = $self->{$item}{target};
73 my $level = $form->escape($item);
76 qq|<a style="vertical-align:top" href=$module?action=$action&level=$level&login=$form->{login}&password=$form->{password}|;
78 my @vars = qw(module action target href);
80 if ($self->{$item}{href}) {
81 $str = qq|<a href=$self->{$item}{href}|;
82 @vars = qw(module target href);
85 map { delete $self->{$item}{$_} } @vars;
88 foreach my $key (keys %{ $self->{$item} }) {
89 $str .= "&" . $form->escape($key, 1) . "=";
90 ($value, $conf) = split(/=/, $self->{$item}{$key}, 2);
91 $value = $myconfig->{$value} . "/$conf" if ($conf);
92 $str .= $form->escape($value, 1);
96 $str .= qq| target=$target|;
101 $main::lxdebug->leave_sub();
107 $main::lxdebug->enter_sub();
109 my ($self, $myconfig, $form, $item, $other) = @_;
111 my $module = $form->{script};
112 my $action = "section_menu";
115 if ($self->{$item}{module}) {
116 $module = $self->{$item}{module};
118 if ($self->{$item}{action}) {
119 $action = $self->{$item}{action};
121 if ($self->{$item}{target}) {
122 $target = $self->{$item}{target};
125 my $level = $form->escape($item);
127 my $str = qq|<a href="$module?action=| . $form->escape($action) .
128 qq|&level=| . $form->escape($level);
129 map({ $str .= "&${_}=" . $form->escape($form->{$_}); } qw(login password));
131 my @vars = qw(module action target href);
133 if ($self->{$item}{href}) {
134 $str = qq|<a href=$self->{$item}{href}|;
135 @vars = qw(module target href);
138 map { delete $self->{$item}{$_} } @vars;
141 foreach my $key (keys %{ $self->{$item} }) {
142 $str .= "&" . $form->escape($key, 1) . "=";
143 ($value, $conf) = split(/=/, $self->{$item}{$key}, 2);
144 $value = $myconfig->{$value} . "/$conf" if ($conf);
145 $str .= $form->escape($value, 1);
151 $str .= qq| target="| . $form->quote($target) . qq|"|;
155 foreach my $key (keys(%{$other})) {
156 $str .= qq| ${key}="| . $form->quote($other->{$key}) . qq|"|;
162 $main::lxdebug->leave_sub();
168 my ($self, $myconfig, $form, $item) = @_;
170 my $module = $form->{script};
171 my $action = "section_menu";
173 #if ($self->{$item}{module}) {
174 $module = $self->{$item}{module};
177 if ($self->{$item}{action}) {
178 $action = $self->{$item}{action};
181 my $level = $form->escape($item);
183 qq|$module?action=$action&level=$level&login=$form->{login}&password=$form->{password}|;
184 my @vars = qw(module action target href);
186 if ($self->{$item}{href}) {
187 $str = qq|$self->{$item}{href}|;
188 @vars = qw(module target href);
191 map { delete $self->{$item}{$_} } @vars;
194 foreach my $key (keys %{ $self->{$item} }) {
195 $str .= "&" . $form->escape($key, 1) . "=";
196 ($value, $conf) = split(/=/, $self->{$item}{$key}, 2);
197 $value = $myconfig->{$value} . "/$conf" if ($conf);
198 $str .= $form->escape($value, 1);
206 $main::lxdebug->enter_sub(2);
208 my ($self, $myconfig, $menulevel) = @_;
212 if ($menulevel eq "") {
213 @menu = grep { !/--/ } @{ $self->{ORDER} };
215 @menu = grep { /^${menulevel}--/ } @{ $self->{ORDER} };
218 my @a = split(/;/, $myconfig->{acs});
221 # remove --AR, --AP from array
222 grep { ($a, $b) = split(/--/); s/--$a$//; } @a;
224 map { $excl{$_} = 1 } @a;
227 map { push @a, $_ unless $excl{$_} } (@menu);
229 $main::lxdebug->leave_sub(2);
235 my ($self, $menulevel, $hash) = @_;
237 my @items = $self->access_control(\%main::myconfig, $menulevel);
239 $menulevel =~ s/[^A-Za-z_\/\.\+\-]/_/g;
240 $hash->{"access_" . lc($menulevel)} = 1 if ($menulevel);
242 foreach my $item (@items) {
243 $self->generate_acl($item, $hash); #unless ($menulevel);