X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FController%2FAdmin.pm;h=2145f05641b60caf3de781965f764a9b360e3047;hb=c264d7c975209abe5cd41073e1c073d02763129d;hp=698fdb1262890d849eb7c7f9432b43d43d08dba0;hpb=6ac47be4e3e318ea212ca595195b0b55a9c386a3;p=kivitendo-erp.git diff --git a/SL/Controller/Admin.pm b/SL/Controller/Admin.pm index 698fdb126..2145f0564 100644 --- a/SL/Controller/Admin.pm +++ b/SL/Controller/Admin.pm @@ -11,10 +11,12 @@ use SL::Common (); use SL::DB::AuthUser; use SL::DB::AuthGroup; use SL::DB::Printer; +use SL::DBUtils; use SL::Helper::Flash; use SL::Locale::String qw(t8); use SL::System::InstallationLock; use SL::User; +use SL::Layout::AdminLogin; use Rose::Object::MakeMethods::Generic ( @@ -80,18 +82,18 @@ sub action_create_auth_tables { $::auth->set_session_value('admin_password', $::lx_office_conf{authentication}->{admin_password}); $::auth->create_or_refresh_session; + return if $self->apply_dbupgrade_scripts; + my $group = (SL::DB::Manager::AuthGroup->get_all(limit => 1))[0]; if (!$group) { SL::DB::AuthGroup->new( name => t8('Full Access'), description => t8('Full access to all functions'), - rights => [ map { SL::DB::AuthGroupRight->new(right => $_, granted => 1) } SL::Auth::all_rights() ], + rights => [ map { SL::DB::AuthGroupRight->new(right => $_, granted => 1) } $::auth->all_rights ], )->save; } - if (!$self->apply_dbupgrade_scripts) { - $self->action_login; - } + $self->action_login; } # @@ -109,12 +111,11 @@ sub action_show { sub action_new_user { my ($self) = @_; - $self->user(SL::DB::AuthUser->new( config_values => { vclimit => 200, countrycode => "de", - numberformat => "1.000,00", + numberformat => scalar(grep(/^Switzerland/, get_default_coa($self))) ? "1'000.00" : "1.000,00", dateformat => "dd.mm.yy", stylesheet => "kivitendo.css", menustyle => "neu", @@ -166,6 +167,10 @@ sub action_delete_user { my @clients = @{ $self->user->clients || [] }; + # backup user metadata (email, name, etc) + my $user_config_values_ref = $self->user->config_values(); + my $login =$self->user->login; + if (!$self->user->delete) { flash('error', t8('The user could not be deleted.')); $self->edit_user_form(title => t8('Edit User')); @@ -173,9 +178,15 @@ sub action_delete_user { } # Flag corresponding entries in 'employee' as deleted. + # and restore the most important user data in employee + # TODO try and catch the whole transaction {user->delete; update employee} {exception} foreach my $client (@clients) { my $dbh = $client->dbconnect(AutoCommit => 1) || next; - $dbh->do(qq|UPDATE employee SET deleted = TRUE WHERE login = ?|, undef, $self->user->login); + $dbh->do(qq|UPDATE employee SET deleted = TRUE, name = ?, deleted_email = ?, + deleted_tel = ?, deleted_fax = ?, deleted_signature = ? WHERE login = ?|,undef, + $user_config_values_ref->{name}, $user_config_values_ref->{email}, + $user_config_values_ref->{tel}, $user_config_values_ref->{fax}, + $user_config_values_ref->{signature}, $self->user->login); $dbh->disconnect; } @@ -408,7 +419,7 @@ sub action_do_create_dataset { User->new->dbcreate($::form); flash_later('info', t8("The dataset #1 has been created.", $::form->{db})); - $self->redirect_to(action => 'database_administration'); + $self->redirect_to(action => 'show'); } sub action_delete_dataset_login { @@ -439,7 +450,7 @@ sub action_do_delete_dataset { User->new->dbdelete($::form); flash_later('info', t8("The dataset #1 has been deleted.", $::form->{db})); - $self->redirect_to(action => 'database_administration'); + $self->redirect_to(action => 'show'); } # @@ -486,7 +497,7 @@ sub init_all_users { SL::DB::Manager::AuthUser ->get_all_sorted sub init_all_groups { SL::DB::Manager::AuthGroup ->get_all_sorted } sub init_all_printers { SL::DB::Manager::Printer ->get_all_sorted } sub init_all_dateformats { [ qw(mm/dd/yy dd/mm/yy dd.mm.yy yyyy-mm-dd) ] } -sub init_all_numberformats { [ '1,000.00', '1000.00', '1.000,00', '1000,00' ] } +sub init_all_numberformats { [ '1,000.00', '1000.00', '1.000,00', '1000,00', "1'000.00" ] } sub init_all_stylesheets { [ qw(lx-office-erp.css Mobile.css kivitendo.css) ] } sub init_all_dbsources { [ sort User->dbsources($::form) ] } sub init_all_used_dbsources { { map { (join(':', $_->dbhost || 'localhost', $_->dbport || 5432, $_->dbname) => $_->name) } @{ $_[0]->all_clients } } } @@ -517,13 +528,13 @@ sub init_all_rights { my (@sections, $current_section); foreach my $entry ($::auth->all_rights_full) { - if ($entry->[0] =~ m/^--/) { - push @sections, { description => $entry->[1], rights => [] }; + if ($entry->[2]) { + push @sections, { description => t8($entry->[1]), rights => [] }; } elsif (@sections) { push @{ $sections[-1]->{rights} }, { name => $entry->[0], - description => $entry->[1], + description => t8($entry->[1]), }; } else { @@ -575,8 +586,8 @@ sub use_multiselect_js { sub login_form { my ($self, %params) = @_; + $::request->layout(SL::Layout::AdminLogin->new); my $version = $::form->read_version; - $::request->layout->no_menu(1); $self->render('admin/adminlogin', title => t8('kivitendo v#1 administration', $version), %params, version => $version); } @@ -661,4 +672,18 @@ sub authenticate_root { return undef; } +sub get_default_coa { + my ( $self ) = @_; + my $coa = undef; + eval { + my $client = first { $_->is_default } @{ $self->all_clients }; + my $dbconnect = 'dbi:Pg:dbname=' . $client->dbname . ';host=' . $client->dbhost . ';port=' . $client->dbport; + my $dbh = DBI->connect($dbconnect, $client->dbuser, $client->dbpasswd); + my $query = q{ SELECT coa FROM defaults }; + ($coa) = selectrow_query($::form, $dbh, $query); + $dbh->disconnect; + }; + return $coa; +} + 1;