Revision 891411c1
Von Moritz Bunkus vor mehr als 13 Jahren hinzugefügt
SL/Controller/Base.pm | ||
---|---|---|
68 | 68 |
AUTH => $::auth, |
69 | 69 |
FLASH => $::form->{FLASH}, |
70 | 70 |
FORM => $::form, |
71 |
INSTANCE_CONF => $::instance_conf, |
|
71 | 72 |
LOCALE => $::locale, |
72 | 73 |
LXCONFIG => \%::lx_office_conf, |
73 | 74 |
LXDEBUG => $::lxdebug, |
SL/Dispatcher.pm | ||
---|---|---|
23 | 23 |
use SL::Common; |
24 | 24 |
use SL::Form; |
25 | 25 |
use SL::Helper::DateTime; |
26 |
use SL::InstanceConfiguration; |
|
26 | 27 |
use SL::Template::Plugin::HTMLFixes; |
27 | 28 |
|
28 | 29 |
# Trailing new line is added so that Perl will not add the line |
... | ... | |
172 | 173 |
$::locale = Locale->new($::lx_office_conf{system}->{language}); |
173 | 174 |
$::form = Form->new; |
174 | 175 |
%::called_subs = (); |
176 |
$::instance_conf = SL::InstanceConfiguration->new; |
|
175 | 177 |
|
176 | 178 |
my $session_result = $::auth->restore_session; |
177 | 179 |
$::auth->create_or_refresh_session; |
... | ... | |
219 | 221 |
delete $::form->{password}; |
220 | 222 |
|
221 | 223 |
if ($action) { |
224 |
$::instance_conf->init; |
|
225 |
|
|
222 | 226 |
map { $::form->{$_} = $::myconfig{$_} } qw(stylesheet charset) |
223 | 227 |
unless $action eq 'save' && $::form->{type} eq 'preferences'; |
224 | 228 |
|
SL/Form.pm | ||
---|---|---|
842 | 842 |
$additional_params->{"conf_parts_image_css"} = $::lx_office_conf{features}->{parts_image_css}; |
843 | 843 |
$additional_params->{"conf_parts_listing_images"} = $::lx_office_conf{features}->{parts_listing_images}; |
844 | 844 |
$additional_params->{"conf_parts_show_image"} = $::lx_office_conf{features}->{parts_show_image}; |
845 |
$additional_params->{"INSTANCE_CONF"} = $::instance_conf; |
|
845 | 846 |
|
846 | 847 |
if (%main::debug_options) { |
847 | 848 |
map { $additional_params->{'DEBUG_' . uc($_)} = $main::debug_options{$_} } keys %main::debug_options; |
SL/InstanceConfiguration.pm | ||
---|---|---|
1 |
package SL::InstanceConfiguration; |
|
2 |
|
|
3 |
use strict; |
|
4 |
|
|
5 |
use SL::DBUtils; |
|
6 |
|
|
7 |
sub new { |
|
8 |
my ($class) = @_; |
|
9 |
|
|
10 |
return bless {}, $class; |
|
11 |
} |
|
12 |
|
|
13 |
sub init { |
|
14 |
my ($self) = @_; |
|
15 |
|
|
16 |
$self->{data} = selectfirst_hashref_query($::form, $::form->get_standard_dbh, qq|SELECT * FROM defaults|); |
|
17 |
|
|
18 |
my $curr = $self->{data}->{curr} || ''; |
|
19 |
$curr =~ s/\s+//g; |
|
20 |
$self->{currencies} = [ split m/:/, $curr ]; |
|
21 |
|
|
22 |
return $self; |
|
23 |
} |
|
24 |
|
|
25 |
sub get_default_currency { |
|
26 |
my ($self) = @_; |
|
27 |
|
|
28 |
return ($self->get_currencies)[0]; |
|
29 |
} |
|
30 |
|
|
31 |
sub get_currencies { |
|
32 |
my ($self) = @_; |
|
33 |
|
|
34 |
return $self->{currencies} ? @{ $self->{currencies} } : (); |
|
35 |
} |
|
36 |
|
|
37 |
1; |
|
38 |
|
|
39 |
__END__ |
|
40 |
|
|
41 |
=pod |
|
42 |
|
|
43 |
=encoding utf8 |
|
44 |
|
|
45 |
=head1 NAME |
|
46 |
|
|
47 |
SL::InstanceConfiguration - Provide instance-specific configuration data |
|
48 |
|
|
49 |
=head1 SYNOPSIS |
|
50 |
|
|
51 |
Lx-Office has two configuration levels: installation specific |
|
52 |
(provided by the global variable C<%::lxoffice_conf>) and instance |
|
53 |
specific. The latter is provided by a global instance of this class, |
|
54 |
C<$::instance_conf>. |
|
55 |
|
|
56 |
=head1 FUNCTIONS |
|
57 |
|
|
58 |
=over 4 |
|
59 |
|
|
60 |
=item C<new> |
|
61 |
|
|
62 |
Creates a new instance. Does not read the configuration. |
|
63 |
|
|
64 |
=item C<init> |
|
65 |
|
|
66 |
Reads the configuration from the database. Returns C<$self>. |
|
67 |
|
|
68 |
=item C<get_currencies> |
|
69 |
|
|
70 |
Returns an array of configured currencies. |
|
71 |
|
|
72 |
=item C<get_default_currency> |
|
73 |
|
|
74 |
Returns the default currency or undef if no currency has been |
|
75 |
configured. |
|
76 |
|
|
77 |
=back |
|
78 |
|
|
79 |
=head1 BUGS |
|
80 |
|
|
81 |
Updates to the I<defaults> table require that the instance |
|
82 |
configuration is re-read. This has not been implemented yet. |
|
83 |
|
|
84 |
=head1 AUTHOR |
|
85 |
|
|
86 |
Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt> |
|
87 |
|
|
88 |
=cut |
scripts/console | ||
---|---|---|
44 | 44 |
use SL::Auth; |
45 | 45 |
use SL::Form; |
46 | 46 |
use SL::Helper::DateTime; |
47 |
use SL::InstanceConfiguration; |
|
47 | 48 |
use SL::Locale; |
48 | 49 |
use SL::LXDebug; |
49 | 50 |
use Data::Dumper; |
... | ... | |
64 | 65 |
$::cgi = CGI->new qw(); |
65 | 66 |
$::form = Form->new; |
66 | 67 |
$::auth = SL::Auth->new; |
68 |
$::instance_conf = SL::InstanceConfiguration->new; |
|
67 | 69 |
|
68 | 70 |
die 'cannot reach auth db' unless $::auth->session_tables_present; |
69 | 71 |
|
... | ... | |
77 | 79 |
|
78 | 80 |
die "cannot find locale for user $login" unless $::locale = Locale->new($::myconfig{countrycode}); |
79 | 81 |
|
82 |
$::instance_conf->init; |
|
80 | 83 |
|
81 | 84 |
return "logged in as $login"; |
82 | 85 |
} |
Auch abrufbar als: Unified diff
Eine Klasse & globale Variable zur Verwaltung von mandantenbasierter Konfiguration