X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FController%2FEmailJournal.pm;h=376dfb3d10d36fc7354ef548ade7b8630a96721b;hb=95b5d54bac9dc0cb47c67444c9e19c1d68b0d520;hp=3bfc39b96a72bd718a3a8ba58622e54b57728ce1;hpb=47e66090a3082ad029dd99a19b9c3c8624ab7092;p=kivitendo-erp.git diff --git a/SL/Controller/EmailJournal.pm b/SL/Controller/EmailJournal.pm index 3bfc39b96..376dfb3d1 100644 --- a/SL/Controller/EmailJournal.pm +++ b/SL/Controller/EmailJournal.pm @@ -27,9 +27,12 @@ __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.')); } + $self->setup_list_action_bar; $self->render('email_journal/list', title => $::locale->text('Email journal'), ENTRIES => $self->models->get, @@ -39,14 +42,17 @@ 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); - if (!$self->can_view_all && ($self->entry->sender_id != SL::DB::Manager::Emplyee->current->id)) { + if (!$self->can_view_all && ($self->entry->sender_id != SL::DB::Manager::Employee->current->id)) { $::form->error(t8('You do not have permission to access this entry.')); } + $self->setup_show_action_bar; $self->render('email_journal/show', title => $::locale->text('View sent email'), back_to => $back_to); @@ -55,13 +61,19 @@ 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::Emplyee->current->id)) { + if (!$self->can_view_all && ($attachment->email_journal->sender_id != SL::DB::Manager::Employee->current->id)) { $::form->error(t8('You do not have permission to access this entry.')); } - - $self->send_file(\$attachment->content, name => $attachment->name, type => $attachment->mime_type); + my $ref = \$attachment->content; + if ( $attachment->file_id > 0 ) { + my $file = SL::File->get(id => $attachment->file_id ); + $ref = $file->get_content if $file; + } + $self->send_file($ref, name => $attachment->name, type => $attachment->mime_type); } # @@ -76,7 +88,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) = @_; @@ -124,4 +136,31 @@ sub init_filter_summary { return join ', ', @filter_strings; } +sub setup_list_action_bar { + my ($self) = @_; + + for my $bar ($::request->layout->get('actionbar')) { + $bar->add( + action => [ + t8('Filter'), + submit => [ '#filter_form', { action => 'EmailJournal/list' } ], + accesskey => 'enter', + ], + ); + } +} + +sub setup_show_action_bar { + my ($self) = @_; + + for my $bar ($::request->layout->get('actionbar')) { + $bar->add( + action => [ + t8('Back'), + call => [ 'kivi.history_back' ], + ], + ); + } +} + 1;