X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FAuth.pm;h=bbf4b32e5ec16027fa9e6695e9a8da35d1440958;hb=910fbe45fb7f53305b8711e43eae7b6ee8636235;hp=184468e56552d53bc1a96f803cfaf53409d40588;hpb=9fdaa1e38014b80609af2fbddb737d6c8e6734d1;p=kivitendo-erp.git diff --git a/SL/Auth.pm b/SL/Auth.pm index 184468e56..bbf4b32e5 100644 --- a/SL/Auth.pm +++ b/SL/Auth.pm @@ -34,12 +34,10 @@ use Rose::Object::MakeMethods::Generic ( sub new { $main::lxdebug->enter_sub(); - my $type = shift; - my $self = {}; + my ($type, %params) = @_; + my $self = bless {}, $type; - bless $self, $type; - - $self->_read_auth_config(); + $self->_read_auth_config(%params); $self->reset; $main::lxdebug->leave_sub(); @@ -50,6 +48,7 @@ sub new { sub reset { my ($self, %params) = @_; + delete $self->{dbh}; $self->{SESSION} = { }; $self->{FULL_RIGHTS} = { }; $self->{RIGHTS} = { }; @@ -100,15 +99,21 @@ sub mini_error { sub _read_auth_config { $main::lxdebug->enter_sub(); - my $self = shift; + my ($self, %params) = @_; map { $self->{$_} = $::lx_office_conf{authentication}->{$_} } keys %{ $::lx_office_conf{authentication} }; # Prevent password leakage to log files when dumping Auth instances. $self->{admin_password} = sub { $::lx_office_conf{authentication}->{admin_password} }; - $self->{DB_config} = $::lx_office_conf{'authentication/database'}; - $self->{LDAP_config} = $::lx_office_conf{'authentication/ldap'}; + if ($params{unit_tests_database}) { + $self->{DB_config} = $::lx_office_conf{'testing/database'}; + $self->{module} = 'DB'; + + } else { + $self->{DB_config} = $::lx_office_conf{'authentication/database'}; + $self->{LDAP_config} = $::lx_office_conf{'authentication/ldap'}; + } if ($self->{module} eq 'DB') { $self->{authenticator} = SL::Auth::DB->new($self); @@ -251,7 +256,7 @@ sub dbconnect { $main::lxdebug->message(LXDebug->DEBUG1, "Auth::dbconnect DSN: $dsn"); - $self->{dbh} = SL::DBConnect->connect($dsn, $cfg->{user}, $cfg->{password}, { pg_enable_utf8 => $::locale->is_utf8, AutoCommit => 1 }); + $self->{dbh} = SL::DBConnect->connect($dsn, $cfg->{user}, $cfg->{password}, { pg_enable_utf8 => 1, AutoCommit => 1 }); if (!$may_fail && !$self->{dbh}) { $main::form->error($main::locale->text('The connection to the authentication database failed:') . "\n" . $DBI::errstr); @@ -326,18 +331,13 @@ sub create_database { $main::lxdebug->message(LXDebug->DEBUG1(), "Auth::create_database DSN: $dsn"); - my $charset = $::lx_office_conf{system}->{dbcharset}; - $charset ||= Common::DEFAULT_CHARSET; - my $encoding = $Common::charset_to_db_encoding{$charset}; - $encoding ||= 'UNICODE'; - - my $dbh = SL::DBConnect->connect($dsn, $params{superuser}, $params{superuser_password}, { pg_enable_utf8 => scalar($charset =~ m/^utf-?8$/i) }); + my $dbh = SL::DBConnect->connect($dsn, $params{superuser}, $params{superuser_password}, { pg_enable_utf8 => 1 }); if (!$dbh) { $main::form->error($main::locale->text('The connection to the template database failed:') . "\n" . $DBI::errstr); } - my $query = qq|CREATE DATABASE "$cfg->{db}" OWNER "$cfg->{user}" TEMPLATE "$params{template}" ENCODING '$encoding'|; + my $query = qq|CREATE DATABASE "$cfg->{db}" OWNER "$cfg->{user}" TEMPLATE "$params{template}" ENCODING 'UNICODE'|; $main::lxdebug->message(LXDebug->DEBUG1(), "Auth::create_database query: $query"); @@ -349,8 +349,8 @@ sub create_database { $query = qq|SELECT pg_encoding_to_char(encoding) FROM pg_database WHERE datname = 'template0'|; my ($cluster_encoding) = $dbh->selectrow_array($query); - if ($cluster_encoding && ($cluster_encoding =~ m/^(?:UTF-?8|UNICODE)$/i) && ($encoding !~ m/^(?:UTF-?8|UNICODE)$/i)) { - $error = $main::locale->text('Your PostgreSQL installationen uses UTF-8 as its encoding. Therefore you have to configure kivitendo to use UTF-8 as well.'); + if ($cluster_encoding && ($cluster_encoding !~ m/^(?:UTF-?8|UNICODE)$/i)) { + $error = $::locale->text('Your PostgreSQL installationen does not use Unicode as its encoding. This is not supported anymore.'); } $dbh->disconnect(); @@ -369,11 +369,8 @@ sub create_tables { my $self = shift; my $dbh = $self->dbconnect(); - my $charset = $::lx_office_conf{system}->{dbcharset}; - $charset ||= Common::DEFAULT_CHARSET; - $dbh->rollback(); - SL::DBUpgrade2->new(form => $::form)->process_query($dbh, 'sql/auth_db.sql', undef, $charset); + SL::DBUpgrade2->new(form => $::form)->process_query($dbh, 'sql/auth_db.sql'); $main::lxdebug->leave_sub(); } @@ -1053,6 +1050,7 @@ sub all_rights_full { ["customer_vendor_edit", $locale->text("Create customers and vendors. Edit all vendors. Edit only customers where salesman equals employee (login)")], ["customer_vendor_all_edit", $locale->text("Create customers and vendors. Edit all vendors. Edit all customers")], ["part_service_assembly_edit", $locale->text("Create and edit parts, services, assemblies")], + ["part_service_assembly_details", $locale->text("Show details and reports of parts, services, assemblies")], ["project_edit", $locale->text("Create and edit projects")], ["--ar", $locale->text("AR")], ["sales_quotation_edit", $locale->text("Create and edit sales quotations")], @@ -1079,10 +1077,11 @@ sub all_rights_full { ["advance_turnover_tax_return", $locale->text('Advance turnover tax return')], ["--batch_printing", $locale->text("Batch Printing")], ["batch_printing", $locale->text("Batch Printing")], + ["--configuration", $locale->text("Configuration")], + ["config", $locale->text("Change kivitendo installation settings (most entries in the 'System' menu)")], + ["admin", $locale->text("Client administration: configuration, editing templates, task server control, background jobs (remaining entries in the 'System' menu)")], ["--others", $locale->text("Others")], ["email_bcc", $locale->text("May set the BCC field when sending emails")], - ["config", $locale->text("Change kivitendo installation settings (all menu entries beneath 'System')")], - ["admin", $locale->text("Administration (Used to access instance administration from user logins)")], ["productivity", $locale->text("Productivity")], ["display_admin_link", $locale->text("Show administration link")], );