From fb1d12dd95929bec06dd1d5eaab19cb1bad12545 Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Mon, 25 Jun 2012 20:26:27 -0400 Subject: [PATCH] Add a warning when the user adds a record to a temporary list. TPAC has been modified so that a user will see a warning before adding a record to a temporary bookbag. This message serves to inform the user that they are adding to a temporary list that will disappear when their session ends. A new org. unit setting has been added, opac.patron.temporary_list_warn, that will enable this warning when set. Sites may choose not to display this warning. The user may also set a preference in their search preferences to disable this warning. The setting only works when a user is logged in, of course. Signed-off-by: Jason Stephenson --- .../perlmods/lib/OpenILS/WWW/EGCatLoader.pm | 2 + .../lib/OpenILS/WWW/EGCatLoader/Container.pm | 58 +++++++++++++++++++ .../lib/OpenILS/WWW/EGCatLoader/Util.pm | 2 +- Open-ILS/src/templates/opac/temp_warn.tt2 | 28 +++++++++ 4 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 Open-ILS/src/templates/opac/temp_warn.tt2 diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm index 63f919aaaf..6ce61b7cef 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm @@ -127,6 +127,8 @@ sub load { return $self->load_mylist_move if $path =~ m|opac/mylist/move|; return $self->load_mylist if $path =~ m|opac/mylist|; return $self->load_cache_clear if $path =~ m|opac/cache/clear|; + return $self->load_temp_warn_post if $path =~ m|opac/temp_warn/post|; + return $self->load_temp_warn if $path =~ m|opac/temp_warn|; # ---------------------------------------------------------------- # Everything below here requires SSL diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Container.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Container.pm index 6cc67966cf..269cbc271e 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Container.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Container.pm @@ -59,6 +59,12 @@ sub load_mylist_add { 'open-ils.actor.anon_cache.set_value', $cache_key, (ref $self)->ANON_CACHE_MYLIST, $list); + # Check if we need to warn patron about adding to a "temporary" + # list: + if ($self->check_for_temp_list_warning) { + return $self->mylist_warning_redirect($cache_key); + } + return $self->mylist_action_redirect($cache_key); } @@ -151,6 +157,38 @@ sub mylist_action_redirect { ); } +# called after an anon-cache / my list addition when we are configured +# to show a warning to the user. + +sub mylist_warning_redirect { + my $self = shift; + my $cache_key = shift; + + my $base_url = sprintf( + "%s://%s%s/temp_warn", + $self->cgi->https ? 'https' : 'http', + $self->apache->hostname, + $self->ctx->{opac_root} + ); + + my $redirect = $self->ctx->{referer}; + if (my $anchor = $self->cgi->param('anchor')) { + $redirect =~ s/#.*|$/#$anchor/; + } + + $base_url .= '?redirect_to=' . uri_escape($redirect); + + return $self->generic_redirect( + $base_url, + $self->cgi->cookie( + -name => (ref $self)->COOKIE_ANON_CACHE, + -path => '/', + -value => ($cache_key) ? $cache_key : '', + -expires => ($cache_key) ? undef : '-1h' + ) + ); +} + sub load_mylist { my ($self) = shift; (undef, $self->ctx->{mylist}, $self->ctx->{mylist_marc_xml}) = @@ -159,4 +197,24 @@ sub load_mylist { return Apache2::Const::OK; } +sub load_temp_warn_post { + my $self = shift; + my $url = $self->cgi->param('redirect_to'); + return $self->generic_redirect( + $url, + $self->cgi->cookie( + -name => 'no_temp_list_warn', + -path => '/', + -value => ($self->cgi->param('no_temp_list_warn')) ? '1' : '', + -expires => ($self->cgi->param('no_temp_list_warn')) ? undef : '-1h' + ) + ); +} + +sub load_temp_warn { + my $self = shift; + $self->ctx->{'redirect_to'} = $self->cgi->param('redirect_to'); + return Apache2::Const::OK; +} + 1; diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm index 1733d49a4a..166875c631 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm @@ -551,7 +551,7 @@ sub check_for_temp_list_warning { my $cgi = $self->cgi; my $lib = $self->_get_search_lib; - my $warn = ($ctx->{get_org_setting}->($lib, 'opac.patron_temporary_list_warn')) ? 1 : 0; + my $warn = ($ctx->{get_org_setting}->($lib || 1, 'opac.patron.temporary_list_warn')) ? 1 : 0; if ($warn && $ctx->{user}) { $self->_load_user_with_prefs; diff --git a/Open-ILS/src/templates/opac/temp_warn.tt2 b/Open-ILS/src/templates/opac/temp_warn.tt2 new file mode 100644 index 0000000000..d6be0b30c1 --- /dev/null +++ b/Open-ILS/src/templates/opac/temp_warn.tt2 @@ -0,0 +1,28 @@ +[% PROCESS "opac/parts/header.tt2"; + PROCESS "opac/parts/misc_util.tt2"; + WRAPPER "opac/parts/base.tt2"; + INCLUDE "opac/parts/topnav.tt2"; + ctx.page_title = l("Temporary List Warning") %] +
+ [% INCLUDE "opac/parts/searchbar.tt2" %] +
+
+
+

[% l('You are adding to a temporary list.') %] + [% IF ctx.user ; + l('This information will disappear when you logout, unless you save it to a permanent list.'); + ELSE; + l('This information will disappear when you end your session, unless you login and save it to a permanent list.'); + END + %]

+
+ + + +
+ +
+
+
+
+[% END %] -- 2.43.2