From: Bill Erickson Date: Mon, 20 Feb 2012 19:48:45 +0000 (-0500) Subject: copy loc groups: tpac X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=79d33f108864f2c3cff2bf50d9af40885cddb5d0;p=evergreen%2Fequinox.git copy loc groups: tpac * added 'locg' param to org selector which contains location:copy_loc_group * determine 'loc' from 'locg' if set * for consistency, use ctx.search_ou everywhere instead of cgi.param('loc') Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm index 9f4a642e55..5546e4b98b 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm @@ -251,11 +251,15 @@ sub load_common { return $self->load_logout($self->apache->unparsed_uri); } } - $ctx->{search_ou} = $self->_get_search_lib(); - $self->staff_saved_searches_set_expansion_state if $ctx->{is_staff}; + # load copy location search groups and see if there is a "logc" + # paremeter set. If so, use it to set/override the "loc" parameter + # as well as the copy_location_group context var $self->load_copy_location_groups; + $ctx->{search_ou} = $self->_get_search_lib(); + $self->staff_saved_searches_set_expansion_state if $ctx->{is_staff}; + return Apache2::Const::OK; } @@ -283,12 +287,24 @@ sub staff_saved_searches_set_expansion_state { $self->ctx->{saved_searches_expanded} = $value; } +# If "locg" is set, we extract the org unit and copy location. +# The org unit from 'locg' overrides the local CGI variable 'loc'. +# Overridding it here will not override it globaly though (i.e. in +# the template environment), unless the same CGI ref is used everywhere, +# which is usually isn't. To be safe, always use ctx.search_ou +# to determine the context org unit. sub load_copy_location_groups { my $self = shift; my $grps = $self->editor->search_asset_copy_location_group({opac_visible => 't'}); my %buckets; push(@{$buckets{$_->owner}}, $_) for @$grps; $self->ctx->{copy_location_groups} = \%buckets; + + if (my $clump = $self->cgi->param('locg')) { + my ($org, $grp) = split(/:/, $clump); + $self->ctx->{copy_location_group} = $grp if $grp; + $self->cgi->param('loc', $org); + } } # physical_loc (i.e. "original location") passed in as a URL diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm index b8907a6148..ecf8ef0b04 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm @@ -112,6 +112,10 @@ sub _prepare_biblio_search { $query .= " site($site)"; } + if (my $grp = $ctx->{copy_location_group}) { + $query .= " location_groups($grp)"; + } + if(!$site) { ($site) = ($query =~ /site\(([^\)]+)\)/); $site ||= $ctx->{aou_tree}->()->shortname; diff --git a/Open-ILS/src/templates/opac/advanced.tt2 b/Open-ILS/src/templates/opac/advanced.tt2 index 17cb74f334..220c56fd20 100644 --- a/Open-ILS/src/templates/opac/advanced.tt2 +++ b/Open-ILS/src/templates/opac/advanced.tt2 @@ -1,9 +1,9 @@ -[%- PROCESS "opac/parts/header.tt2"; +[%- PROCESS "opac/parts/header.tt2"; WRAPPER "opac/parts/base.tt2"; INCLUDE "opac/parts/topnav.tt2"; ctx.page_title = l("Advanced Search"); pane = CGI.param("pane") || "advanced"; - loc = CGI.param("loc"); + loc = ctx.search_ou; -%]