projects
/
kivitendo-erp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Artikelpreishistorie automatisch über Trigger speichern
[kivitendo-erp.git]
/
SL
/
Helper
/
Flash.pm
diff --git
a/SL/Helper/Flash.pm
b/SL/Helper/Flash.pm
index
876de96
..
77dda78
100644
(file)
--- a/
SL/Helper/Flash.pm
+++ b/
SL/Helper/Flash.pm
@@
-5,7
+5,12
@@
use strict;
require Exporter;
our @ISA = qw(Exporter);
our @EXPORT = qw(flash flash_later);
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 ok)),
+);
#
# public functions
#
# public functions
@@
-16,7
+21,12
@@
sub flash {
}
sub flash_later {
}
sub flash_later {
- $::auth->set_session_value(FLASH => _store_flash($::auth->get_session_value('FLASH'), @_));
+ $::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 {
}
sub render_flash {
@@
-29,16
+39,24
@@
sub render_flash {
sub _store_flash {
my $store = shift || { };
sub _store_flash {
my $store = shift || { };
- my $category = shift;
- $category = 'info' if $category eq 'information';
+ my $category = _check_category(+shift);
- $store ||= { };
$store->{ $category } ||= [ ];
push @{ $store->{ $category } }, @_;
return $store;
}
$store->{ $category } ||= [ ];
push @{ $store->{ $category } }, @_;
return $store;
}
+sub _check_category {
+ my ($c) = @_;
+ return $valid_categories{$c}
+ || do {
+ require Carp;
+ Carp->import;
+ croak("invalid category '$c' for flash");
+ };
+}
+
1;
__END__
1;
__END__
@@
-95,6
+113,13
@@
file.
This function is not exported by default.
This function is not exported by default.
+=item C<delay_flash>
+
+Delays flash, as if all flash messages in this request would have been
+C<flash_later>
+
+Not exported by default.
+
=back
=head1 AUTHOR
=back
=head1 AUTHOR