Merge branch 'sorted-helper'
[kivitendo-erp.git] / bin / mozilla / admin.pl
index ebf01c6..2819da0 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;
@@ -52,6 +53,7 @@ use SL::DBUtils;
 
 require "bin/mozilla/common.pl";
 require "bin/mozilla/admin_groups.pl";
+require "bin/mozilla/admin_printer.pl";
 
 use strict;
 
@@ -83,13 +85,11 @@ sub run {
         $::auth->set_session_value('rpw', $::form->{rpw});
         $::auth->create_or_refresh_session();
       }
-      call_sub($locale->findsub($form->{action}));
-    }
-  } elsif ($auth->authenticate_root($form->{rpw}, 0) == $auth->OK()) {
 
-    $auth->create_or_refresh_session() if ($auth->session_tables_present());
+      _apply_dbupgrade_scripts();
 
-    login();
+      call_sub($locale->findsub($form->{action}));
+    }
   } else {
     # if there are no drivers bail out
     $form->error($locale->text('No Database Drivers available!'))
@@ -723,15 +723,13 @@ sub dbupdate {
 
     map { $form->{$_} = $form->{"${_}_${i}"} } qw(dbname dbdriver dbhost dbport dbuser dbpasswd);
 
-    my $controls = parse_dbupdate_controls($form, $form->{dbdriver});
-
     print $form->parse_html_template("admin/dbupgrade_header");
 
     $form->{dbupdate}        = $form->{dbname};
     $form->{$form->{dbname}} = 1;
 
     User->dbupdate($form);
-    User->dbupdate2($form, $controls);
+    User->dbupdate2($form, SL::DBUpgrade2->new(form => $form, dbdriver => $form->{dbdriver})->parse_dbupdate_controls);
 
     print $form->parse_html_template("admin/dbupgrade_footer");
   }
@@ -1168,4 +1166,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;