From: Sven Schöling Date: Sun, 27 Feb 2011 14:05:49 +0000 (+0100) Subject: delay_flash X-Git-Tag: release-2.7.0beta2~5^2~9 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=fa1257877ee5cb147b44a1b833287716f62c1925;p=kivitendo-erp.git delay_flash --- diff --git a/SL/Helper/Flash.pm b/SL/Helper/Flash.pm index 1ed6562b2..07b22c081 100644 --- a/SL/Helper/Flash.pm +++ b/SL/Helper/Flash.pm @@ -5,7 +5,7 @@ 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)), @@ -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 } }, @_; @@ -109,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