Upgradescripte für auth.* nur ausführen, wenn Authentifizierungstabellen bereits...
[kivitendo-erp.git] / bin / mozilla / admin.pl
index 0e61c3c..3258a31 100755 (executable)
@@ -43,6 +43,7 @@ use Sys::Hostname;
 
 use SL::Auth;
 use SL::Form;
+use SL::Iconv;
 use SL::Mailer;
 use SL::User;
 use SL::Common;
@@ -83,7 +84,9 @@ sub run {
       if ($auth->session_tables_present()) {
         $::auth->set_session_value('rpw', $::form->{rpw});
         $::auth->create_or_refresh_session();
+        _apply_dbupgrade_scripts();
       }
+
       call_sub($locale->findsub($form->{action}));
     }
   } else {
@@ -646,10 +649,10 @@ sub dbselect_source {
   my $form           = $main::form;
   my $locale         = $main::locale;
 
-  $form->{dbport}    = '5432';
-  $form->{dbuser}    = 'lxoffice';
+  $form->{dbport}    = $::auth->{DB_config}->{port} || 5432;
+  $form->{dbuser}    = $::auth->{DB_config}->{user} || 'lxoffice';
   $form->{dbdefault} = 'template1';
-  $form->{dbhost}    = 'localhost';
+  $form->{dbhost}    = $::auth->{DB_config}->{host} || 'localhost';
 
   $form->{title}     = "Lx-Office ERP / " . $locale->text('Database Administration');
 
@@ -1162,4 +1165,8 @@ sub dispatcher {
   $form->error($locale->text('No action defined.'));
 }
 
+sub _apply_dbupgrade_scripts {
+  ::end_of_request() if SL::DBUpgrade2->new(form => $::form, dbdriver => 'Pg', auth => 1)->apply_admin_dbupgrade_scripts(1);
+}
+
 1;