From: berick Date: Wed, 6 Apr 2011 19:54:44 +0000 (-0400) Subject: added support for updating opt-in settings preferences X-Git-Tag: sprint4-merge-nov22~5128^2~72^2~122^2~2 X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=4bff85c5da3484abd509bb14508397194d18a7bd;p=working%2FEvergreen.git added support for updating opt-in settings preferences --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm index f210dfad08..342217c213 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm @@ -199,10 +199,7 @@ sub load_common { } else { - # For now, keep an eye out for any pages being unceremoniously redirected to logout... - $self->apache->log->info("catloader: loading " . $ctx->{path_info} . - "; auth session " . $e->authtoken . " no longer valid; redirecting to logout"); - + # authtoken is no longer valid, log out to clean up return $self->load_logout; } } diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm index 8cec166348..e7a961db41 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm @@ -5,6 +5,7 @@ use OpenSRF::Utils::Logger qw/$logger/; use OpenILS::Utils::CStoreEditor qw/:funcs/; use OpenILS::Utils::Fieldmapper; use OpenILS::Application::AppUtils; +use OpenSRF::Utils::JSON; my $U = 'OpenILS::Application::AppUtils'; @@ -31,6 +32,19 @@ sub load_myopac_prefs_notify { my $self = shift; my $e = $self->editor; + my $user_prefs = $self->fetch_optin_prefs; + $user_prefs = $self->update_optin_prefs($user_prefs) + if $self->cgi->request_method eq 'POST'; + + $self->ctx->{opt_in_settings} = $user_prefs; + + return Apache2::Const::OK; +} + +sub fetch_optin_prefs { + my $self = shift; + my $e = $self->editor; + # fetch all of the opt-in settings the user has access to # XXX: user's should in theory have options to opt-in to notices # for remote locations, but that opens the door for a large @@ -49,8 +63,41 @@ sub load_myopac_prefs_notify { [map {$_->name} @$opt_ins] ); - $self->ctx->{opt_in_settings} = [map { {cust => $_, value => $user_set->{$_->name} } } @$opt_ins]; - return Apache2::Const::OK; + return [map { {cust => $_, value => $user_set->{$_->name} } } @$opt_ins]; +} + +sub update_optin_prefs { + my $self = shift; + my $user_prefs = shift; + my $e = $self->editor; + my @settings = $self->cgi->param('setting'); + my %newsets; + + # apply now-true settings + for my $applied (@settings) { + # see if setting is already applied to this user + next if grep { $_->{cust}->name eq $applied and $_->{value} } @$user_prefs; + $newsets{$applied} = OpenSRF::Utils::JSON->true; + } + + # remove now-false settings + for my $pref (grep { $_->{value} } @$user_prefs) { + $newsets{$pref->{cust}->name} = undef + unless grep { $_ eq $pref->{cust}->name } @settings; + } + + $U->simplereq( + 'open-ils.actor', + 'open-ils.actor.patron.settings.update', + $e->authtoken, $e->requestor->id, \%newsets); + + # update the local prefs to match reality + for my $pref (@$user_prefs) { + $pref->{value} = $newsets{$pref->{cust}->name} + if exists $newsets{$pref->{cust}->name}; + } + + return $user_prefs; } sub load_myopac_prefs_settings { diff --git a/Open-ILS/web/templates/default/opac/myopac/prefs/notify.tt2 b/Open-ILS/web/templates/default/opac/myopac/prefs/notify.tt2 index 5d1077a849..e8486224a0 100644 --- a/Open-ILS/web/templates/default/opac/myopac/prefs/notify.tt2 +++ b/Open-ILS/web/templates/default/opac/myopac/prefs/notify.tt2 @@ -2,117 +2,123 @@ WRAPPER "default/opac/myopac/prefs.tt2"; myopac_page = "prefs/notify" %] - - - - - - - [% IF optin.size == 0 %] - [% l('No notification preferences are configured') %] - [% END %] - [% FOR optin IN ctx.opt_in_settings %] - - - - - [% END %] - -
[% l('Notifation Type') %][% l('Enabled') %]
[% optin.cust.label %] - -
+
+
+ +
- + + + + + + + + Pick Up Notice for + Holds
+
+ + (Temporarily phone notification will generate a + mailed paper notice.) + + + + Expire Notice for + Holds
+ + + + + Cancel Notice for + Holds
+ + + + + Overdue First + Notice
+ +
+ + + (Temporarily phone notification will generate a + mailed paper notice.) + + + + Courtesy + Notice
+
+ + + +--> [% END %]