Merge branch 'master' of git@lx-office.linet-services.de:lx-office-erp
authorJan Büren <jan@lx-office-hosting.de>
Tue, 8 Mar 2011 09:11:45 +0000 (10:11 +0100)
committerJan Büren <jan@lx-office-hosting.de>
Tue, 8 Mar 2011 09:11:45 +0000 (10:11 +0100)
DEBIAN/DEBIAN/postinst
SL/Auth/DB.pm
SL/Auth/LDAP.pm
SL/Controller/Base.pm
SL/Dispatcher.pm
SL/Form.pm

index 5604cd9..a681b98 100755 (executable)
@@ -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
index 0168896..dd63506 100644 (file)
@@ -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;
 
index ea93262..70e963d 100644 (file)
@@ -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;
 
index d80fca1..d50d519 100644 (file)
@@ -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<send_file $file_name, [%params]>
+
+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<type> -- the file's content type; defaults to
+'application/octet_stream'
+
+=item * C<name> -- the name presented to the browser; defaults to
+C<$file_name>
+
+=back
+
 =item C<url_for $url>
 
 =item C<url_for $params>
index b485063..8a8d5bb 100644 (file)
@@ -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;
index 1db5a65..33b3d04 100644 (file)
@@ -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();