From: Jan Büren Date: Tue, 8 Mar 2011 09:11:45 +0000 (+0100) Subject: Merge branch 'master' of git@lx-office.linet-services.de:lx-office-erp X-Git-Tag: release-2.6.3~53 X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/commitdiff_plain/7b5835061e81d1af578e1572e435d6f3e61d2989?hp=fd69a37d9aa596195873b658d7a42d7e8c0ea6a3 Merge branch 'master' of git@lx-office.linet-services.de:lx-office-erp --- diff --git a/DEBIAN/DEBIAN/postinst b/DEBIAN/DEBIAN/postinst index 5604cd99c..a681b98da 100755 --- a/DEBIAN/DEBIAN/postinst +++ b/DEBIAN/DEBIAN/postinst @@ -78,17 +78,14 @@ config_postgresql_sql_routines() { set_lx_office_erp_web_admin_password() { - if ! [ -f /etc/lx-office-erp/lx_office.conf ] ; then - cp /etc/lx-office-erp/lx_office.conf.default /etc/lx-office-erp/lx_office.conf - fi db_get lx-office-erp/admin-password ADMINPASSWORD="$RET" - cat /etc/lx-office-erp/lx_office.conf | \ - sed --expression "s/admin_password = /admin_password = $ADMINPASSWORD/g" \ + cat /etc/lx-office-erp/authentication.pl | \ + sed --expression "s/{admin_password} = /{admin_password} = '$ADMINPASSWORD';#/g" \ > /tmp/1.txt - mv /tmp/1.txt /etc/lx-office-erp/lx_office.conf + mv /tmp/1.txt /etc/lx-office-erp/authentication.pl } @@ -97,13 +94,13 @@ set_lx_office_erp_authentication_db_user_password() { db_get lx-office-erp/lx-office-erp-user-postgresql-password PASSWORD="$RET" - cat /etc/lx-office-erp/lx_office.conf | \ - sed --expression "s/^password = /password = $PASSWORD/g" \ + cat /etc/lx-office-erp/authentication.pl | \ + sed --expression "s/'password' => /'password' => '$PASSWORD', #/g" \ > /tmp/1.txt cat /tmp/1.txt | \ sed --expression "s/^user = postgres/user = lxoffice/g" \ - > /etc/lx-office-erp/lx_office.conf + > /etc/lx-office-erp/authentication.pl } @@ -111,9 +108,12 @@ set_lx_office_erp_authentication_db_user_password() { set_user_rights() { chown -R www-data:www-data /usr/lib/lx-office-erp/users chown -R www-data:www-data /usr/lib/lx-office-erp/templates - chown www-data:www-data /etc/lx-office-erp/lx_office.conf + chown www-data:www-data /etc/lx-office-erp/lx-erp.conf + chown www-data:www-data /etc/lx-office-erp/authentication.pl + chown www-data:www-data /etc/lx-office-erp/console.conf chown www-data:www-data /usr/lib/lx-office-erp/menu.ini - chmod 0600 /etc/lx-office-erp/lx_office.conf + chmod 0600 /etc/lx-office-erp/lx-erp.conf + chmod 0600 /etc/lx-office-erp/authentication.pl } disable_ipv6_on_lo_interface() { @@ -142,20 +142,23 @@ mk_new_menu() { } mk_new_config() { - if ! [ -f /etc/lx-office-erp/lx_office.conf ] ; then - cp /etc/lx-office-erp/lx_office.conf.default /etc/lx-office-erp/lx_office.conf + if ! [ -f /etc/lx-office-erp/lx-erp.conf ] ; then + cp /etc/lx-office-erp/lx-erp.conf.default /etc/lx-office-erp/lx-erp.conf + fi + if ! [ -f /etc/lx-office-erp/authentication.pl ] ; then + cp /etc/lx-office-erp/authentication.pl.default /etc/lx-office-erp/authentication.pl + fi + if ! [ -f /etc/lx-office-erp/console.conf ] ; then + cp /etc/lx-office-erp/console.conf.default /etc/lx-office-erp/console.conf fi } mk_links() { - if ! [ -f /usr/lib/lx-office-erp/config/lx_office.conf ] ; then - ln -s /etc/lx-office-erp/lx_office.conf /usr/lib/lx-office-erp/config/lx_office.conf - fi; - if ! [ -f /usr/lib/lx-office-erp/config/lx_office.conf.default ] ; then - ln -s /etc/lx-office-erp/lx_office.conf.default /usr/lib/lx-office-erp/config/lx_office.conf.default + if ! [ -f /usr/lib/lx-office-erp/config/lx-erp.conf ] ; then + ln -s /etc/lx-office-erp/lx-erp.conf /usr/lib/lx-office-erp/config/lx-erp.conf fi; - if [ -e /etc/lx-office-erp/authentication.pl ] ; then - rm /etc/lx-office-erp/authentication.pl + if ! [ -f /usr/lib/lx-office-erp/config/authentication.pl ] ; then + ln -s /etc/lx-office-erp/authentication.pl /usr/lib/lx-office-erp/config/authentication.pl fi if [ -e /etc/apache2 ] ; then if ! [ -f /etc/apache2/conf.d/lx-office-erp.apache2.conf ] ; then diff --git a/SL/Auth/DB.pm b/SL/Auth/DB.pm index 0168896f9..dd6350623 100644 --- a/SL/Auth/DB.pm +++ b/SL/Auth/DB.pm @@ -3,6 +3,7 @@ package SL::Auth::DB; use strict; use Carp; +use Scalar::Util qw(weaken); use SL::Auth::Constants qw(:all); use SL::DBUtils; @@ -14,6 +15,7 @@ sub new { my $self = {}; $self->{auth} = shift; + weaken $self->{auth}; bless $self, $type; diff --git a/SL/Auth/LDAP.pm b/SL/Auth/LDAP.pm index ea9326275..70e963d47 100644 --- a/SL/Auth/LDAP.pm +++ b/SL/Auth/LDAP.pm @@ -2,6 +2,7 @@ package SL::Auth::LDAP; use English '-no_match_vars'; +use Scalar::Util qw(weaken); use SL::Auth::Constants qw(:all); use strict; @@ -17,6 +18,7 @@ sub new { my $self = {}; $self->{auth} = shift; + weaken $self->{auth}; bless $self, $type; diff --git a/SL/Controller/Base.pm b/SL/Controller/Base.pm index d80fca16d..d50d519b7 100644 --- a/SL/Controller/Base.pm +++ b/SL/Controller/Base.pm @@ -5,6 +5,7 @@ use strict; use parent qw(Rose::Object); use Carp; +use IO::File; use List::Util qw(first); # @@ -83,6 +84,22 @@ sub render { return $output; } +sub send_file { + my ($self, $file_name, %params) = @_; + + my $file = IO::File->new($file_name, 'r') || croak("Cannot open file '${file_name}'"); + my $content_type = $params{type} || 'application/octet_stream'; + my $attachment_name = $params{name} || $file_name; + $attachment_name =~ s:.*//::g; + + print $::form->create_http_response(content_type => $content_type, + content_disposition => 'attachment; filename="' . $attachment_name . '"', + content_length => -s $file); + + $::locale->with_raw_io(\*STDOUT, sub { print while <$file> }); + $file->close; +} + # # Before/after run hooks # @@ -368,6 +385,21 @@ browser. Typical use for actions called via AJAX: $self->render('todo/single_item', { type => 'js' }, item => $employee->most_important_todo_item); +=item C + +Sends the file C<$file_name> to the browser including appropriate HTTP +headers for a download. C<%params> can include the following: + +=over 2 + +=item * C -- the file's content type; defaults to +'application/octet_stream' + +=item * C -- the name presented to the browser; defaults to +C<$file_name> + +=back + =item C =item C diff --git a/SL/Dispatcher.pm b/SL/Dispatcher.pm index b48506342..8a8d5bbcf 100644 --- a/SL/Dispatcher.pm +++ b/SL/Dispatcher.pm @@ -156,10 +156,10 @@ sub handle_request { $self->unrequire_bin_mozilla; - $::auth = SL::Auth->new; $::cgi = CGI->new(''); $::locale = Locale->new($::lx_office_conf{system}->{language}); $::form = Form->new; + $::auth = SL::Auth->new; %::called_subs = (); eval { ($routing_type, $script_name, $action) = _route_request($script_name); 1; } or return; @@ -231,6 +231,7 @@ sub handle_request { # cleanup $::locale = undef; $::form = undef; + $::auth = undef; $::myconfig = (); Form::disconnect_standard_dbh; $::auth->expire_session_keys->save_session; diff --git a/SL/Form.pm b/SL/Form.pm index 1db5a6541..33b3d04bf 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -629,6 +629,8 @@ sub create_http_response { $cgi_params{'-charset'} = $params{charset} if ($params{charset}); $cgi_params{'-cookie'} = $session_cookie if ($session_cookie); + map { $cgi_params{'-' . $_} = $params{$_} if exists $params{$_} } qw(content_disposition content_length); + my $output = $cgi->header(%cgi_params); $main::lxdebug->leave_sub();