]> wagnertech.de Git - mfinanz.git/blobdiff - bin/mozilla/admin.pl
Alle Vorkommen von dbdriver, sid, Oracle entfernt
[mfinanz.git] / bin / mozilla / admin.pl
index 67c5969fd36a39575d619e8e3bf39ec7c131a21e..d1194ee8a7fb9f3b445f967019ec111476174ef7 100755 (executable)
@@ -60,8 +60,6 @@ use SL::DBUtils;
 use SL::Template;
 
 require "bin/mozilla/common.pl";
-require "bin/mozilla/admin_groups.pl";
-require "bin/mozilla/admin_printer.pl";
 
 use strict;
 
@@ -77,15 +75,6 @@ our $form;
 our $locale;
 our $auth;
 
-my @valid_dateformats = qw(mm/dd/yy dd/mm/yy dd.mm.yy yyyy-mm-dd);
-my @valid_numberformats = ('1,000.00', '1000.00', '1.000,00', '1000,00');
-my @all_stylesheets = qw(lx-office-erp.css Mobile.css kivitendo.css);
-my @all_menustyles = (
-  { id => 'old', title => $::locale->text('Old (on the side)') },
-  { id => 'v3',  title => $::locale->text('Top (CSS)') },
-  { id => 'neu', title => $::locale->text('Top (Javascript)') },
-);
-
 sub run {
   $::lxdebug->enter_sub;
   my $session_result = shift;
@@ -101,7 +90,7 @@ sub run {
   if ($form->{action}) {
     if ($auth->authenticate_root($form->{'{AUTH}admin_password'}) != $auth->OK()) {
       $auth->punish_wrong_login;
-      $form->{error} = $locale->text('Incorrect Password!');
+      $form->{error} = $locale->text('Incorrect password!');
       $auth->delete_session_value('admin_password');
       adminlogin();
     } else {
@@ -112,10 +101,6 @@ sub run {
       call_sub($locale->findsub($form->{action}));
     }
   } else {
-    # if there are no drivers bail out
-    $form->error($locale->text('No Database Drivers available!'))
-      unless (User->dbdrivers);
-
     adminlogin();
   }
   $::lxdebug->leave_sub;
@@ -131,241 +116,6 @@ sub adminlogin {
   print $form->parse_html_template('admin/adminlogin');
 }
 
-sub add_user {
-  $::form->{title}   = "kivitendo " . $::locale->text('Administration') . " / " . $::locale->text('Add User');
-
-  # User does not have a well behaved new constructor, so we'll just have to build one ourself
-  my $user     = bless {
-    "vclimit"      => 200,
-    "countrycode"  => "de",
-    "numberformat" => "1.000,00",
-    "dateformat"   => "dd.mm.yy",
-    "stylesheet"   => "kivitendo.css",
-    "menustyle"    => "neu",
-    dbport         => $::auth->{DB_config}->{port} || 5432,
-    dbuser         => $::auth->{DB_config}->{user} || 'lxoffice',
-    dbhost         => $::auth->{DB_config}->{host} || 'localhost',
-  }, 'User';
-
-  edit_user_form($user);
-}
-
-sub edit_user {
-  $::form->{title} = "kivitendo " . $::locale->text('Administration') . " / " . $::locale->text('Edit User');
-  $::form->{edit}  = 1;
-
-  # get user
-  my $user = User->new(id => $::form->{user}{id});
-
-  edit_user_form($user);
-}
-
-sub edit_user_form {
-  my ($user) = @_;
-
-  my %cc = $user->country_codes;
-  my @all_countrycodes = map { id => $_, title => $cc{$_} }, sort { $cc{$a} cmp $cc{$b} } keys %cc;
-  my ($all_dir, $all_master) = _search_templates();
-  my $groups = [];
-
-  if ($::form->{edit}) {
-    my $user_id    = $::auth->get_user_id($user->{login});
-    my $all_groups = $::auth->read_groups();
-
-    for my $group (values %{ $all_groups }) {
-      push @{ $groups }, $group if (grep { $user_id == $_ } @{ $group->{members} });
-    }
-
-    $groups = [ sort { lc $a->{name} cmp lc $b->{name} } @{ $groups } ];
-  }
-
-  $::form->header;
-  print $::form->parse_html_template("admin/edit_user", {
-    GROUPS               => $groups,
-    CAN_CHANGE_PASSWORD  => $::auth->can_change_password,
-    user                 => $user->data,
-    all_stylesheets      => \@all_stylesheets,
-    all_numberformats    => \@valid_numberformats,
-    all_dateformats      => \@valid_dateformats,
-    all_countrycodes     => \@all_countrycodes,
-    all_menustyles       => \@all_menustyles,
-    all_templates        => $all_dir,
-    all_master_templates => $all_master,
-  });
-}
-
-sub save_user {
-  my $form          = $main::form;
-  my $locale        = $main::locale;
-
-  my $user = $form->{user};
-
-  $user->{dbdriver} = 'Pg';
-
-  if (!$::form->{edit}) {
-    # no spaces allowed in login name
-    $user->{login} =~ s/\s//g;
-    $::form->show_generic_error($::locale->text('Login name missing!')) unless $user->{login};
-
-    # check for duplicates
-    my %members = $::auth->read_all_users;
-    if ($members{$user->{login}}) {
-      $::form->show_generic_error($locale->text('Another user with the login #1 does already exist.', $user->{login}), 'back_button' => 1);
-    }
-  }
-
-  # no spaces allowed in directories
-  ($::form->{newtemplates}) = split / /, $::form->{newtemplates};
-  $user->{templates} = $::form->{newtemplates} || $::form->{usetemplates} || $user->{login};
-
-  # is there a basedir
-  if (!-d $::lx_office_conf{paths}->{templates}) {
-    $::form->error(sprintf($::locale->text("The directory %s does not exist."), $::lx_office_conf{paths}->{templates}));
-  }
-
-  # add base directory to $form->{templates}
-  $user->{templates} =~ s|.*/||;
-  $user->{templates} =  $::lx_office_conf{paths}->{templates} . "/$user->{templates}";
-
-  my $myconfig = new User(id => $user->{id});
-
-  $::form->show_generic_error($::locale->text('Dataset missing!'))       unless $user->{dbname};
-  $::form->show_generic_error($::locale->text('Database User missing!')) unless $user->{dbuser};
-
-  foreach my $item (keys %{$user}) {
-    $myconfig->{$item} = $user->{$item};
-  }
-
-  $myconfig->save_member;
-
-  $user->{templates}       =~ s|.*/||;
-  $user->{templates}       =  $::lx_office_conf{paths}->{templates} . "/$user->{templates}";
-  $::form->{mastertemplates} =~ s|.*/||;
-
-  # create user template directory and copy master files
-  if (!-d "$user->{templates}") {
-    umask(002);
-
-    if (mkdir "$user->{templates}", oct("771")) {
-
-      umask(007);
-
-      # copy templates to the directory
-
-      my $oldcurrdir = getcwd();
-      if (!chdir("$::lx_office_conf{paths}->{templates}/print/$::form->{mastertemplates}")) {
-        $form->error("$ERRNO: chdir $::lx_office_conf{paths}->{templates}/print/$::form->{mastertemplates}");
-      }
-
-      my $newdir = File::Spec->catdir($oldcurrdir, $user->{templates});
-
-      find(
-        sub
-        {
-          next if ($_ eq ".");
-
-          if (-d $_) {
-            if (!mkdir (File::Spec->catdir($newdir, $File::Find::name))) {
-              chdir($oldcurrdir);
-              $form->error("$ERRNO: mkdir $File::Find::name");
-            }
-          } elsif (-l $_) {
-            if (!symlink (readlink($_),
-                          File::Spec->catfile($newdir, $File::Find::name))) {
-              chdir($oldcurrdir);
-              $form->error("$ERRNO: symlink $File::Find::name");
-            }
-          } elsif (-f $_) {
-            if (!copy($_, File::Spec->catfile($newdir, $File::Find::name))) {
-              chdir($oldcurrdir);
-              $form->error("$ERRNO: cp $File::Find::name");
-            }
-          }
-        }, "./");
-
-      chdir($oldcurrdir);
-
-    } else {
-      $form->error("$ERRNO: $user->{templates}");
-    }
-  }
-
-  # Add new user to his groups.
-  if (ref $form->{new_user_group_ids} eq 'ARRAY') {
-    my $all_groups = $main::auth->read_groups();
-    my %user       = $main::auth->read_user(login => $myconfig->{login});
-
-    foreach my $group_id (@{ $form->{new_user_group_ids} }) {
-      my $group = $all_groups->{$group_id};
-
-      next if !$group;
-
-      push @{ $group->{members} }, $user{id};
-      $main::auth->save_group($group);
-    }
-  }
-
-  if ($main::auth->can_change_password()
-      && defined $::form->{new_password}
-      && ($::form->{new_password} ne '********')) {
-    my $verifier = SL::Auth::PasswordPolicy->new;
-    my $result   = $verifier->verify($::form->{new_password}, 1);
-
-    if ($result != SL::Auth::PasswordPolicy->OK()) {
-      $form->error($::locale->text('The settings were saved, but the password was not changed.') . ' ' . join(' ', $verifier->errors($result)));
-    }
-
-    $main::auth->change_password($myconfig->{login}, $::form->{new_password});
-  }
-
-  $::form->redirect($::locale->text('User saved!'));
-}
-
-sub save_user_as_new {
-  my $form       = $main::form;
-
-  $form->{user}{login} = $::form->{new_user_login};
-  delete $form->{user}{id};
-  delete @{$form}{qw(id edit new_user_login)};
-
-  save_user();
-}
-
-sub delete_user {
-  my $form      = $main::form;
-  my $locale    = $main::locale;
-
-  my $user = $::form->{user} || {};
-
-  $::form->show_generic_error($::locale->text('Missing user id!')) unless $user->{id};
-
-  my $loaded_user = User->new(id => $user->{id});
-
-  my %members   = $main::auth->read_all_users();
-  my $templates = $members{$loaded_user->{login}}->{templates};
-
-  $main::auth->delete_user($loaded_user->{login});
-
-  if ($templates) {
-    my $templates_in_use = 0;
-
-    foreach my $login (keys %members) {
-      next if $loaded_user->{login} eq $login;
-      next if $members{$login}->{templates} ne $templates;
-      $templates_in_use = 1;
-      last;
-    }
-
-    if (!$templates_in_use && -d $templates) {
-      unlink <$templates/*>;
-      rmdir $templates;
-    }
-  }
-
-  $form->redirect($locale->text('User deleted!'));
-
-}
-
 sub login_name {
   my $login = shift;
 
@@ -389,10 +139,7 @@ sub get_value {
 
 sub pg_database_administration {
   my $form = $main::form;
-
-  $form->{dbdriver} = 'Pg';
   dbselect_source();
-
 }
 
 sub dbselect_source {
@@ -417,7 +164,6 @@ sub test_db_connection {
   my $form   = $main::form;
   my $locale = $main::locale;
 
-  $form->{dbdriver} = 'Pg';
   User::dbconnect_vars($form, $form->{dbname});
 
   my $dbh = DBI->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd});
@@ -471,7 +217,7 @@ sub dbupdate {
     restore_form($saved_form);
 
     %::myconfig = ();
-    map { $form->{$_} = $::myconfig{$_} = $form->{"${_}_${i}"} } qw(dbname dbdriver dbhost dbport dbuser dbpasswd);
+    map { $form->{$_} = $::myconfig{$_} = $form->{"${_}_${i}"} } qw(dbname dbhost dbport dbuser dbpasswd);
 
     print $form->parse_html_template("admin/dbupgrade_header");
 
@@ -479,7 +225,7 @@ sub dbupdate {
     $form->{$form->{dbname}} = 1;
 
     User->dbupdate($form);
-    User->dbupdate2($form, SL::DBUpgrade2->new(form => $form, dbdriver => $form->{dbdriver})->parse_dbupdate_controls);
+    User->dbupdate2($form, SL::DBUpgrade2->new(form => $form)->parse_dbupdate_controls);
 
     print $form->parse_html_template("admin/dbupgrade_footer");
   }