Revision a1ea659f
Von Sven Schöling vor mehr als 9 Jahren hinzugefügt
SL/Auth.pm | ||
---|---|---|
897 | 897 |
return $self->{api_token} && $provided_api_token && ($self->{api_token} eq $provided_api_token); |
898 | 898 |
} |
899 | 899 |
|
900 |
sub session_tables_present { |
|
901 |
my $self = shift; |
|
900 |
sub _tables_present { |
|
901 |
my ($self, @tables) = @_; |
|
902 |
my $cache_key = join '_', @tables; |
|
902 | 903 |
|
903 | 904 |
# Only re-check for the presence of auth tables if either the check |
904 | 905 |
# hasn't been done before of if they weren't present. |
905 |
if ($self->{session_tables_present}) { |
|
906 |
return $self->{session_tables_present}; |
|
907 |
} |
|
906 |
return $self->{"$cache_key\_tables_present"} ||= do { |
|
907 |
my $dbh = $self->dbconnect(1); |
|
908 | 908 |
|
909 |
my $dbh = $self->dbconnect(1); |
|
909 |
if (!$dbh) { |
|
910 |
return 0; |
|
911 |
} |
|
910 | 912 |
|
911 |
if (!$dbh) { |
|
912 |
return 0; |
|
913 |
} |
|
913 |
my $query = |
|
914 |
qq|SELECT COUNT(*) |
|
915 |
FROM pg_tables |
|
916 |
WHERE (schemaname = 'auth') |
|
917 |
AND (tablename IN (@{[ join ', ', ('?') x @tables ]}))|; |
|
914 | 918 |
|
915 |
my $query = |
|
916 |
qq|SELECT COUNT(*) |
|
917 |
FROM pg_tables |
|
918 |
WHERE (schemaname = 'auth') |
|
919 |
AND (tablename IN ('session', 'session_content'))|; |
|
919 |
my ($count) = selectrow_query($main::form, $dbh, $query, @tables); |
|
920 | 920 |
|
921 |
my ($count) = selectrow_query($main::form, $dbh, $query); |
|
921 |
return scalar @tables == $count; |
|
922 |
} |
|
923 |
} |
|
922 | 924 |
|
923 |
$self->{session_tables_present} = 2 == $count; |
|
925 |
sub session_tables_present { |
|
926 |
$_[0]->_tables_present('session', 'session_content'); |
|
927 |
} |
|
924 | 928 |
|
925 |
return $self->{session_tables_present}; |
|
929 |
sub master_rights_present { |
|
930 |
$_[0]->_tables_present('master_rights'); |
|
926 | 931 |
} |
927 | 932 |
|
928 | 933 |
# -------------------------------------- |
929 | 934 |
|
930 | 935 |
sub all_rights_full { |
931 |
my $locale = $main::locale; |
|
932 |
|
|
933 |
my @all_rights = ( |
|
934 |
["--master_data", $locale->text("Master Data")], |
|
935 |
["customer_vendor_edit", $locale->text("Create customers and vendors. Edit all vendors. Edit only customers where salesman equals employee (login)")], |
|
936 |
["customer_vendor_all_edit", $locale->text("Create customers and vendors. Edit all vendors. Edit all customers")], |
|
937 |
["part_service_assembly_edit", $locale->text("Create and edit parts, services, assemblies")], |
|
938 |
["part_service_assembly_details", $locale->text("Show details and reports of parts, services, assemblies")], |
|
939 |
["project_edit", $locale->text("Create and edit projects")], |
|
940 |
["--ar", $locale->text("AR")], |
|
941 |
["requirement_spec_edit", $locale->text("Create and edit requirement specs")], |
|
942 |
["sales_quotation_edit", $locale->text("Create and edit sales quotations")], |
|
943 |
["sales_order_edit", $locale->text("Create and edit sales orders")], |
|
944 |
["sales_delivery_order_edit", $locale->text("Create and edit sales delivery orders")], |
|
945 |
["invoice_edit", $locale->text("Create and edit invoices and credit notes")], |
|
946 |
["dunning_edit", $locale->text("Create and edit dunnings")], |
|
947 |
["sales_letter_edit", $locale->text("Edit sales letters")], |
|
948 |
["sales_all_edit", $locale->text("View/edit all employees sales documents")], |
|
949 |
["edit_prices", $locale->text("Edit prices and discount (if not used, textfield is ONLY set readonly)")], |
|
950 |
["show_ar_transactions", $locale->text("Show AR transactions as part of AR invoice report")], |
|
951 |
["delivery_plan", $locale->text("Show delivery plan")], |
|
952 |
["delivery_value_report", $locale->text("Show delivery value report")], |
|
953 |
["sales_letter_report", $locale->text("Show sales letters report")], |
|
954 |
["--ap", $locale->text("AP")], |
|
955 |
["request_quotation_edit", $locale->text("Create and edit RFQs")], |
|
956 |
["purchase_order_edit", $locale->text("Create and edit purchase orders")], |
|
957 |
["purchase_delivery_order_edit", $locale->text("Create and edit purchase delivery orders")], |
|
958 |
["vendor_invoice_edit", $locale->text("Create and edit vendor invoices")], |
|
959 |
["show_ap_transactions", $locale->text("Show AP transactions as part of AP invoice report")], |
|
960 |
["--warehouse_management", $locale->text("Warehouse management")], |
|
961 |
["warehouse_contents", $locale->text("View warehouse content")], |
|
962 |
["warehouse_management", $locale->text("Warehouse management")], |
|
963 |
["--general_ledger_cash", $locale->text("General ledger and cash")], |
|
964 |
["general_ledger", $locale->text("Transactions, AR transactions, AP transactions")], |
|
965 |
["datev_export", $locale->text("DATEV Export")], |
|
966 |
["cash", $locale->text("Receipt, payment, reconciliation")], |
|
967 |
["bank_transaction", $locale->text("Bank transactions")], |
|
968 |
["--reports", $locale->text('Reports')], |
|
969 |
["report", $locale->text('All reports')], |
|
970 |
["advance_turnover_tax_return", $locale->text('Advance turnover tax return')], |
|
971 |
["--batch_printing", $locale->text("Batch Printing")], |
|
972 |
["batch_printing", $locale->text("Batch Printing")], |
|
973 |
["--configuration", $locale->text("Configuration")], |
|
974 |
["config", $locale->text("Change kivitendo installation settings (most entries in the 'System' menu)")], |
|
975 |
["admin", $locale->text("Client administration: configuration, editing templates, task server control, background jobs (remaining entries in the 'System' menu)")], |
|
976 |
["--others", $locale->text("Others")], |
|
977 |
["email_bcc", $locale->text("May set the BCC field when sending emails")], |
|
978 |
["productivity", $locale->text("Productivity")], |
|
979 |
["display_admin_link", $locale->text("Show administration link")], |
|
980 |
); |
|
981 |
|
|
982 |
return @all_rights; |
|
936 |
my ($self) = @_; |
|
937 |
|
|
938 |
@{ $self->{master_rights} ||= do { |
|
939 |
$self->dbconnect->selectall_arrayref("SELECT name, description, category FROM auth.master_rights ORDER BY id"); |
|
940 |
} |
|
941 |
} |
|
983 | 942 |
} |
984 | 943 |
|
985 | 944 |
sub all_rights { |
986 |
return grep !/^--/, map { $_->[0] } all_rights_full();
|
|
945 |
return map { $_->[0] } grep { !$_->[2] } $_[0]->all_rights_full;
|
|
987 | 946 |
} |
988 | 947 |
|
989 | 948 |
sub read_groups { |
... | ... | |
1030 | 989 |
$group->{rights}->{$row->{right}} |= $row->{granted}; |
1031 | 990 |
} |
1032 | 991 |
|
1033 |
map { $group->{rights}->{$_} = 0 if (!defined $group->{rights}->{$_}); } all_rights();
|
|
992 |
map { $group->{rights}->{$_} = 0 if (!defined $group->{rights}->{$_}); } $self->all_rights;
|
|
1034 | 993 |
} |
1035 | 994 |
$sth->finish(); |
1036 | 995 |
|
... | ... | |
1212 | 1171 |
my $dbh = $self->dbconnect; |
1213 | 1172 |
my ($query, $sth, $row, $rights); |
1214 | 1173 |
|
1215 |
$rights = { map { $_ => 0 } all_rights() };
|
|
1174 |
$rights = { map { $_ => 0 } $self->all_rights };
|
|
1216 | 1175 |
|
1217 | 1176 |
return $rights if !$self->client || !$login; |
1218 | 1177 |
|
SL/Controller/Admin.pm | ||
---|---|---|
528 | 528 |
my (@sections, $current_section); |
529 | 529 |
|
530 | 530 |
foreach my $entry ($::auth->all_rights_full) { |
531 |
if ($entry->[0] =~ m/^--/) {
|
|
532 |
push @sections, { description => $entry->[1], rights => [] };
|
|
531 |
if ($entry->[2]) {
|
|
532 |
push @sections, { description => t8($entry->[1]), rights => [] };
|
|
533 | 533 |
|
534 | 534 |
} elsif (@sections) { |
535 | 535 |
push @{ $sections[-1]->{rights} }, { |
536 | 536 |
name => $entry->[0], |
537 |
description => $entry->[1],
|
|
537 |
description => t8($entry->[1]),
|
|
538 | 538 |
}; |
539 | 539 |
|
540 | 540 |
} else { |
SL/Controller/LoginScreen.pm | ||
---|---|---|
67 | 67 |
# Auth DB needs update? If so log the user out forcefully. |
68 | 68 |
if (User::LOGIN_AUTH_DBUPDATE_AVAILABLE() == $result) { |
69 | 69 |
$::auth->destroy_session; |
70 |
return $self->render('login_screen/auth_db_needs_update'); |
|
70 |
# must be without layout because menu rights might not exist yet |
|
71 |
return $self->render('login_screen/auth_db_needs_update', { layout => 0 }); |
|
71 | 72 |
} |
72 | 73 |
|
73 | 74 |
# Basic client tables available? If not tell the user to create them |
scripts/locales.pl | ||
---|---|---|
27 | 27 |
use Pod::Usage; |
28 | 28 |
use YAML (); |
29 | 29 |
use YAML::Loader (); # YAML tries to load Y:L at runtime, but can't find it after we chdir'ed |
30 |
use SL::DBUpgrade2; |
|
30 | 31 |
|
31 | 32 |
$OUTPUT_AUTOFLUSH = 1; |
32 | 33 |
|
... | ... | |
125 | 126 |
handle_file(@{ $_ }) for @progfiles; |
126 | 127 |
handle_file(@{ $_ }) for @dbplfiles; |
127 | 128 |
scanmenu($_) for @menufiles; |
129 |
scandbupgrades(); |
|
128 | 130 |
|
129 | 131 |
for my $file_name (grep { /\.(?:js|html)$/i } map({find_files($_)} @javascript_dirs)) { |
130 | 132 |
scan_javascript_file($file_name); |
... | ... | |
515 | 517 |
sub scanmenu { |
516 | 518 |
my $file = shift; |
517 | 519 |
|
518 |
print STDERR "trying to load file $file\n"; |
|
519 | 520 |
my $menu = YAML::LoadFile($file); |
520 | 521 |
|
521 | 522 |
for my $node (@$menu) { |
523 |
# possible for override files |
|
524 |
next unless exists $node->{name}; |
|
525 |
|
|
522 | 526 |
$locale{$node->{name}} = 1; |
523 | 527 |
$alllocales{$node->{name}} = 1; |
528 |
$cached{$file}{all}{$node->{name}} = 1; |
|
529 |
} |
|
530 |
} |
|
531 |
|
|
532 |
sub scandbupgrades { |
|
533 |
# we only need to do this for auth atm, because only auth scripts can include new rights, which are translateable |
|
534 |
my $auth = 1; |
|
535 |
|
|
536 |
my $dbu = SL::DBUpgrade2->new(auth => $auth, path => '../../sql/Pg-upgrade2-auth'); |
|
537 |
|
|
538 |
for my $upgrade ($dbu->sort_dbupdate_controls) { |
|
539 |
for my $string (@{ $upgrade->{locales} || [] }) { |
|
540 |
$locale{$string} = 1; |
|
541 |
$alllocales{$string} = 1; |
|
542 |
$cached{$upgrade->{tag}}{all}{$string} = 1; |
|
543 |
} |
|
524 | 544 |
} |
525 | 545 |
} |
526 | 546 |
|
sql/Pg-upgrade2-auth/add_master_rights.sql | ||
---|---|---|
1 |
-- @tag: add_master_rights |
|
2 |
-- @description: Rechte in die Datenbank migrieren |
|
3 |
-- @depends: release_3_2_0 |
|
4 |
-- @charset: utf-8 |
|
5 |
-- @locales: Master Data |
|
6 |
-- @locales: Create customers and vendors. Edit all vendors. Edit only customers where salesman equals employee (login) |
|
7 |
-- @locales: Create customers and vendors. Edit all vendors. Edit all customers |
|
8 |
-- @locales: Create and edit parts, services, assemblies |
|
9 |
-- @locales: Show details and reports of parts, services, assemblies |
|
10 |
-- @locales: Create and edit projects |
|
11 |
-- @locales: AR |
|
12 |
-- @locales: Create and edit requirement specs |
|
13 |
-- @locales: Create and edit sales quotations |
|
14 |
-- @locales: Create and edit sales orders |
|
15 |
-- @locales: Create and edit sales delivery orders |
|
16 |
-- @locales: Create and edit invoices and credit notes |
|
17 |
-- @locales: Create and edit dunnings |
|
18 |
-- @locales: Edit sales letters |
|
19 |
-- @locales: View/edit all employees sales documents |
|
20 |
-- @locales: Edit prices and discount (if not used, textfield is ONLY set readonly) |
|
21 |
-- @locales: Show AR transactions as part of AR invoice report |
|
22 |
-- @locales: Show delivery plan |
|
23 |
-- @locales: Show delivery value report |
|
24 |
-- @locales: Show sales letters report |
|
25 |
-- @locales: AP |
|
26 |
-- @locales: Create and edit RFQs |
|
27 |
-- @locales: Create and edit purchase orders |
|
28 |
-- @locales: Create and edit purchase delivery orders |
|
29 |
-- @locales: Create and edit vendor invoices |
|
30 |
-- @locales: Show AP transactions as part of AP invoice report |
|
31 |
-- @locales: Warehouse management |
|
32 |
-- @locales: View warehouse content |
|
33 |
-- @locales: Warehouse management |
|
34 |
-- @locales: General ledger and cash |
|
35 |
-- @locales: Transactions, AR transactions, AP transactions |
|
36 |
-- @locales: DATEV Export |
|
37 |
-- @locales: Receipt, payment, reconciliation |
|
38 |
-- @locales: Bank transactions |
|
39 |
-- @locales: Reports |
|
40 |
-- @locales: All reports |
|
41 |
-- @locales: Advance turnover tax return |
|
42 |
-- @locales: Batch Printing |
|
43 |
-- @locales: Batch Printing |
|
44 |
-- @locales: Configuration |
|
45 |
-- @locales: Change kivitendo installation settings (most entries in the 'System' menu) |
|
46 |
-- @locales: Client administration: configuration, editing templates, task server control, background jobs (remaining entries in the 'System' menu) |
|
47 |
-- @locales: Others |
|
48 |
-- @locales: May set the BCC field when sending emails |
|
49 |
-- @locales: Productivity |
|
50 |
-- @locales: Show administration link |
|
51 |
|
|
52 |
CREATE TABLE auth.master_rights ( |
|
53 |
id SERIAL PRIMARY KEY, |
|
54 |
position INTEGER NOT NULL, |
|
55 |
name TEXT NOT NULL UNIQUE, |
|
56 |
description TEXT NOT NULL, |
|
57 |
category BOOLEAN NOT NULL DEFAULT FALSE |
|
58 |
); |
|
59 |
|
|
60 |
|
|
61 |
INSERT INTO auth.master_rights (position, name, description, category) VALUES ( 1, 'master_data', 'Master Data', TRUE); |
|
62 |
INSERT INTO auth.master_rights (position, name, description) VALUES ( 2, 'customer_vendor_edit', 'Create customers and vendors. Edit all vendors. Edit only customers where salesman equals employee (login)'); |
|
63 |
INSERT INTO auth.master_rights (position, name, description) VALUES ( 3, 'customer_vendor_all_edit', 'Create customers and vendors. Edit all vendors. Edit all customers'); |
|
64 |
INSERT INTO auth.master_rights (position, name, description) VALUES ( 4, 'part_service_assembly_edit', 'Create and edit parts, services, assemblies'); |
|
65 |
INSERT INTO auth.master_rights (position, name, description) VALUES ( 5, 'part_service_assembly_details', 'Show details and reports of parts, services, assemblies'); |
|
66 |
INSERT INTO auth.master_rights (position, name, description) VALUES ( 6, 'project_edit', 'Create and edit projects'); |
|
67 |
INSERT INTO auth.master_rights (position, name, description, category) VALUES ( 7, 'ar', 'AR', TRUE); |
|
68 |
INSERT INTO auth.master_rights (position, name, description) VALUES ( 8, 'requirement_spec_edit', 'Create and edit requirement specs'); |
|
69 |
INSERT INTO auth.master_rights (position, name, description) VALUES ( 9, 'sales_quotation_edit', 'Create and edit sales quotations'); |
|
70 |
INSERT INTO auth.master_rights (position, name, description) VALUES (10, 'sales_order_edit', 'Create and edit sales orders'); |
|
71 |
INSERT INTO auth.master_rights (position, name, description) VALUES (11, 'sales_delivery_order_edit', 'Create and edit sales delivery orders'); |
|
72 |
INSERT INTO auth.master_rights (position, name, description) VALUES (12, 'invoice_edit', 'Create and edit invoices and credit notes'); |
|
73 |
INSERT INTO auth.master_rights (position, name, description) VALUES (13, 'dunning_edit', 'Create and edit dunnings'); |
|
74 |
INSERT INTO auth.master_rights (position, name, description) VALUES (14, 'sales_letter_edit', 'Edit sales letters'); |
|
75 |
INSERT INTO auth.master_rights (position, name, description) VALUES (15, 'sales_all_edit', 'View/edit all employees sales documents'); |
|
76 |
INSERT INTO auth.master_rights (position, name, description) VALUES (16, 'edit_prices', 'Edit prices and discount (if not used, textfield is ONLY set readonly)'); |
|
77 |
INSERT INTO auth.master_rights (position, name, description) VALUES (17, 'show_ar_transactions', 'Show AR transactions as part of AR invoice report'); |
|
78 |
INSERT INTO auth.master_rights (position, name, description) VALUES (18, 'delivery_plan', 'Show delivery plan'); |
|
79 |
INSERT INTO auth.master_rights (position, name, description) VALUES (19, 'delivery_value_report', 'Show delivery value report'); |
|
80 |
INSERT INTO auth.master_rights (position, name, description) VALUES (20, 'sales_letter_report', 'Show sales letters report'); |
|
81 |
INSERT INTO auth.master_rights (position, name, description, category) VALUES (21, 'ap', 'AP', TRUE); |
|
82 |
INSERT INTO auth.master_rights (position, name, description) VALUES (22, 'request_quotation_edit', 'Create and edit RFQs'); |
|
83 |
INSERT INTO auth.master_rights (position, name, description) VALUES (23, 'purchase_order_edit', 'Create and edit purchase orders'); |
|
84 |
INSERT INTO auth.master_rights (position, name, description) VALUES (24, 'purchase_delivery_order_edit', 'Create and edit purchase delivery orders'); |
|
85 |
INSERT INTO auth.master_rights (position, name, description) VALUES (25, 'vendor_invoice_edit', 'Create and edit vendor invoices'); |
|
86 |
INSERT INTO auth.master_rights (position, name, description) VALUES (26, 'show_ap_transactions', 'Show AP transactions as part of AP invoice report'); |
|
87 |
INSERT INTO auth.master_rights (position, name, description, category) VALUES (27, 'warehouse', 'Warehouse management', TRUE); |
|
88 |
INSERT INTO auth.master_rights (position, name, description) VALUES (28, 'warehouse_contents', 'View warehouse content'); |
|
89 |
INSERT INTO auth.master_rights (position, name, description) VALUES (29, 'warehouse_management', 'Warehouse management'); |
|
90 |
INSERT INTO auth.master_rights (position, name, description, category) VALUES (30, 'general_ledger_cash', 'General ledger and cash', TRUE); |
|
91 |
INSERT INTO auth.master_rights (position, name, description) VALUES (31, 'general_ledger', 'Transactions, AR transactions, AP transactions'); |
|
92 |
INSERT INTO auth.master_rights (position, name, description) VALUES (32, 'datev_export', 'DATEV Export'); |
|
93 |
INSERT INTO auth.master_rights (position, name, description) VALUES (33, 'cash', 'Receipt, payment, reconciliation'); |
|
94 |
INSERT INTO auth.master_rights (position, name, description) VALUES (34, 'bank_transaction', 'Bank transactions'); |
|
95 |
INSERT INTO auth.master_rights (position, name, description, category) VALUES (35, 'reports', 'Reports', TRUE); |
|
96 |
INSERT INTO auth.master_rights (position, name, description) VALUES (36, 'report', 'All reports'); |
|
97 |
INSERT INTO auth.master_rights (position, name, description) VALUES (37, 'advance_turnover_tax_return', 'Advance turnover tax return'); |
|
98 |
INSERT INTO auth.master_rights (position, name, description, category) VALUES (38, 'batch_printing_category', 'Batch Printing', TRUE); |
|
99 |
INSERT INTO auth.master_rights (position, name, description) VALUES (39, 'batch_printing', 'Batch Printing'); |
|
100 |
INSERT INTO auth.master_rights (position, name, description, category) VALUES (40, 'configuration', 'Configuration', TRUE); |
|
101 |
INSERT INTO auth.master_rights (position, name, description) VALUES (41, 'config', 'Change kivitendo installation settings (most entries in the ''System'' menu)'); |
|
102 |
INSERT INTO auth.master_rights (position, name, description) VALUES (42, 'admin', 'Client administration: configuration, editing templates, task server control, background jobs (remaining entries in the ''System'' menu)'); |
|
103 |
INSERT INTO auth.master_rights (position, name, description, category) VALUES (43, 'others', 'Others', TRUE); |
|
104 |
INSERT INTO auth.master_rights (position, name, description) VALUES (44, 'email_bcc', 'May set the BCC field when sending emails'); |
|
105 |
INSERT INTO auth.master_rights (position, name, description) VALUES (45, 'productivity', 'Productivity'); |
|
106 |
INSERT INTO auth.master_rights (position, name, description) VALUES (46, 'display_admin_link', 'Show administration link'); |
Auch abrufbar als: Unified diff
Rechte: In die Datenbank verlagert