From 58c266eacda69e1a0dc2e4a201974bb9afd493f5 Mon Sep 17 00:00:00 2001 From: Martin Helmling Date: Tue, 17 Jan 2017 15:36:51 +0100 Subject: [PATCH] =?utf8?q?Eigenes=20Recht=20f=C3=BCr=20E-Mail-Journal?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit -E-Mail Journal Icon hinzugefügt -Recht für E-Mail Journal hinzugefügt, von "productivity" abgeleitet -Recht für Zugriff auf mails von Mitarbeitern von "admin" abgeleitet -Das Recht "email_journal" im EmailJournal - Controller eingebaut --- SL/Controller/EmailJournal.pm | 8 ++- image/icons/svg/mail_journal.svg | 54 +++++++++++++++++++++ locale/de/all | 3 +- menus/user/00-erp.yaml | 1 + sql/Pg-upgrade2-auth/mail_journal_rights.pl | 34 +++++++++++++ 5 files changed, 98 insertions(+), 2 deletions(-) create mode 100644 image/icons/svg/mail_journal.svg create mode 100644 sql/Pg-upgrade2-auth/mail_journal_rights.pl diff --git a/SL/Controller/EmailJournal.pm b/SL/Controller/EmailJournal.pm index 6dfed906d..a4ffc62b5 100644 --- a/SL/Controller/EmailJournal.pm +++ b/SL/Controller/EmailJournal.pm @@ -27,6 +27,8 @@ __PACKAGE__->run_before('add_stylesheet'); sub action_list { my ($self) = @_; + $::auth->assert('email_journal'); + if ( $::instance_conf->get_email_journal == 0 ) { flash('info', $::locale->text('Storing the emails in the journal is currently disabled in the client configuration.')); } @@ -39,6 +41,8 @@ sub action_list { sub action_show { my ($self) = @_; + $::auth->assert('email_journal'); + my $back_to = $::form->{back_to} || $self->url_for(action => 'list'); $self->entry(SL::DB::EmailJournal->new(id => $::form->{id})->load); @@ -55,6 +59,8 @@ sub action_show { sub action_download_attachment { my ($self) = @_; + $::auth->assert('email_journal'); + my $attachment = SL::DB::EmailJournalAttachment->new(id => $::form->{id})->load; if (!$self->can_view_all && ($attachment->email_journal->sender_id != SL::DB::Manager::Employee->current->id)) { @@ -80,7 +86,7 @@ sub add_stylesheet { # helpers # -sub init_can_view_all { $::auth->assert('admin', 1) } +sub init_can_view_all { $::auth->assert('email_employee_readall', 1) } sub init_models { my ($self) = @_; diff --git a/image/icons/svg/mail_journal.svg b/image/icons/svg/mail_journal.svg new file mode 100644 index 000000000..07a286618 --- /dev/null +++ b/image/icons/svg/mail_journal.svg @@ -0,0 +1,54 @@ + + + +image/svg+xml + + \ No newline at end of file diff --git a/locale/de/all b/locale/de/all index 7e89c20f1..cfc16351f 100644 --- a/locale/de/all +++ b/locale/de/all @@ -1043,7 +1043,8 @@ $self->{texts} = { 'Duplicate in CSV file' => 'Duplikat in CSV-Datei', 'Duplicate in database' => 'Duplikat in Datenbank', 'During the next update a taxkey 0 with tax rate of 0 will automatically created.' => 'Beim nächsten Ausführen des Updates wird ein Steuerschlüssel 0 mit einem Steuersatz von 0% automatisch erzeugt.', - 'E-Mail is sent to #1' => 'E-Mail wurde an #1 gesendet', + 'E-Mail is sent to #1' => 'Die E-Mail wurde an \'#1\' gesendet', + 'E-Mail-Journal' => 'E-Mail-Journal', 'E-mail' => 'E-Mail', 'E-mail Statement to' => 'Fälligkeitsabrechnung als E-Mail an', 'E-mail address missing!' => 'E-Mail-Adresse fehlt!', diff --git a/menus/user/00-erp.yaml b/menus/user/00-erp.yaml index 1b99707f4..ced4c586f 100644 --- a/menus/user/00-erp.yaml +++ b/menus/user/00-erp.yaml @@ -993,6 +993,7 @@ name: Email journal order: 200 module: controller.pl + icon: mail_journal params: action: EmailJournal/list - id: system diff --git a/sql/Pg-upgrade2-auth/mail_journal_rights.pl b/sql/Pg-upgrade2-auth/mail_journal_rights.pl new file mode 100644 index 000000000..7d2bacbac --- /dev/null +++ b/sql/Pg-upgrade2-auth/mail_journal_rights.pl @@ -0,0 +1,34 @@ +# @tag: mail_journal_rights +# @description: Extra right for email journal +# @depends: master_rights_position_gaps +# @locales: E-Mail-Journal +# @locales: Read all employee e-mails + +package SL::DBUpgrade2::mail_journal_rights; + +use strict; +use utf8; + +use parent qw(SL::DBUpgrade2::Base); + +use SL::DBUtils; + +sub run { + my ($self) = @_; + + $self->db_query("INSERT INTO auth.master_rights (position, name, description) VALUES (?, ?, ?)", bind => $_) for + [ 4450, 'email_journal' , 'E-Mail-Journal' ], + [ 4480, 'email_employee_readall', 'Read all employee e-mails' ]; + + my $groups = $main::auth->read_groups(); + + foreach my $group (values %{$groups}) { + $group->{rights}->{email_journal} = $group->{rights}->{productivity}; + $group->{rights}->{email_employee_readall} = $group->{rights}->{admin}; + $main::auth->save_group($group); + } + + return 1; +} # end run + +1; -- 2.20.1