X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FHelper%2FFlash.pm;h=77dda7846496f244050ecf50b5ec8a8fd4747bf7;hb=759e7200b66eced8b4da70dba0f48739d883da2c;hp=f55366c17778714e8ce2cb2d37cb0ea1d12591ed;hpb=aa7f51db81934e47ff7bac0a15cef97572d4c6f2;p=kivitendo-erp.git diff --git a/SL/Helper/Flash.pm b/SL/Helper/Flash.pm index f55366c17..77dda7846 100644 --- a/SL/Helper/Flash.pm +++ b/SL/Helper/Flash.pm @@ -5,11 +5,11 @@ use strict; require Exporter; our @ISA = qw(Exporter); our @EXPORT = qw(flash flash_later); -our @EXPORT_OK = qw(render_flash); +our @EXPORT_OK = qw(render_flash delay_flash); my %valid_categories = ( map({$_ => 'info'} qw(information message)), - map({$_ => $_} qw(info error warning)), + map({$_ => $_} qw(info error warning ok)), ); # @@ -24,6 +24,11 @@ sub flash_later { $::auth->set_session_value({ key => "FLASH", value => _store_flash($::auth->get_session_value('FLASH'), @_), auto_restore => 1 }); } +sub delay_flash { + my $store = $::form->{FLASH} || { }; + flash_later($_ => @{ $store->{$_} || [] }) for keys %$store; +} + sub render_flash { return $::form->parse_html_template('common/flash'); } @@ -36,7 +41,6 @@ sub _store_flash { my $store = shift || { }; my $category = _check_category(+shift); - $store ||= { }; $store->{ $category } ||= [ ]; push @{ $store->{ $category } }, @_; @@ -46,7 +50,11 @@ sub _store_flash { sub _check_category { my ($c) = @_; return $valid_categories{$c} - || die 'invalid category for flash'; + || do { + require Carp; + Carp->import; + croak("invalid category '$c' for flash"); + }; } 1; @@ -105,6 +113,13 @@ file. This function is not exported by default. +=item C + +Delays flash, as if all flash messages in this request would have been +C + +Not exported by default. + =back =head1 AUTHOR