use constant COOKIE_SES => 'ses';
use constant COOKIE_ORIG_LOC => 'eg_orig_loc';
+use constant COOKIE_ANON_CACHE => 'anoncache';
+use constant ANON_CACHE_MYLIST => 'mylist';
+use constant ANON_CACHE_STAFF_SEARCH => 'staffsearch';
+
sub new {
my($class, $apache, $ctx) = @_;
use OpenILS::Application::AppUtils;
my $U = 'OpenILS::Application::AppUtils';
-use constant COOKIE_ANON_CACHE => 'anoncache';
-use constant ANON_CACHE_MYLIST => 'mylist';
-
# Retrieve the users cached records AKA 'My List'
# Returns an empty list if there are no cached records
sub fetch_mylist {
my ($self, $with_marc_xml) = @_;
my $list = [];
- my $cache_key = $self->cgi->cookie(COOKIE_ANON_CACHE);
+ my $cache_key = $self->cgi->cookie((ref $self)->COOKIE_ANON_CACHE);
if($cache_key) {
$list = $U->simplereq(
'open-ils.actor',
'open-ils.actor.anon_cache.get_value',
- $cache_key, ANON_CACHE_MYLIST);
+ $cache_key, (ref $self)->ANON_CACHE_MYLIST);
if(!$list) {
$cache_key = undef;
$cache_key = $U->simplereq(
'open-ils.actor',
'open-ils.actor.anon_cache.set_value',
- $cache_key, ANON_CACHE_MYLIST, $list);
+ $cache_key, (ref $self)->ANON_CACHE_MYLIST, $list);
return $self->mylist_action_redirect($cache_key);
}
$cache_key = $U->simplereq(
'open-ils.actor',
'open-ils.actor.anon_cache.set_value',
- $cache_key, ANON_CACHE_MYLIST, $list);
+ $cache_key, (ref $self)->ANON_CACHE_MYLIST, $list);
return $self->mylist_action_redirect($cache_key);
}
$cache_key = $U->simplereq(
'open-ils.actor',
'open-ils.actor.anon_cache.set_value',
- $cache_key, ANON_CACHE_MYLIST, \@keep
+ $cache_key, (ref $self)->ANON_CACHE_MYLIST, \@keep
);
if ($self->ctx->{user} and $action =~ /^\d+$/) {
my $self = shift;
my $field = shift;
- my $cache_key = $self->cgi->cookie(COOKIE_ANON_CACHE) or return;
+ my $cache_key = $self->cgi->cookie((ref $self)->COOKIE_ANON_CACHE) or return;
$U->simplereq(
'open-ils.actor',
return $self->generic_redirect(
$url,
$self->cgi->cookie(
- -name => COOKIE_ANON_CACHE,
+ -name => (ref $self)->COOKIE_ANON_CACHE,
-path => '/',
-value => ($cache_key) ? $cache_key : '',
-expires => ($cache_key) ? undef : '-1h'
my $rec_id = $ctx->{page_args}->[0]
or return Apache2::Const::HTTP_BAD_REQUEST;
+ $self->get_staff_search_settings;
+ if ($ctx->{staff_saved_search_size}) {
+ $ctx->{saved_searches} = ($self->staff_load_searches)[1];
+ }
+
# run copy retrieval in parallel to bib retrieval
# XXX unapi
my $cstore = OpenSRF::AppSession->create('open-ils.cstore');
my ($query, $site, $depth) = _prepare_biblio_search($cgi, $ctx);
+ $self->get_staff_search_settings;
+
+ if ($ctx->{staff_saved_search_size}) {
+ my ($key, $list) = $self->staff_save_search($query);
+ if ($key) {
+ $self->apache->headers_out->add(
+ "Set-Cookie" => $self->cgi->cookie(
+ -name => (ref $self)->COOKIE_ANON_CACHE,
+ -path => "/",
+ -value => ($key || ''),
+ -expires => ($key ? undef : "-1h")
+ )
+ );
+ $ctx->{saved_searches} = $list;
+ }
+ }
+
if ($metarecord) {
# TODO: other limits, like SVF/format, etc.
return Apache2::Const::OK;
}
+sub get_staff_search_settings {
+ my ($self) = @_;
+
+ unless ($self->ctx->{is_staff}) {
+ $self->ctx->{staff_saved_search_size} = 0;
+ return;
+ }
+
+ my $sss_size = $self->ctx->{get_org_setting}->(
+ $self->ctx->{orig_loc} || $self->ctx->{aou_tree}->()->id,
+ "opac.staff_saved_search.size",
+ );
+
+ # Sic: 0 is 0 (off), but undefined is 10.
+ $sss_size = 10 unless defined $sss_size;
+
+ $self->ctx->{staff_saved_search_size} = $sss_size;
+}
+
+sub staff_load_searches {
+ my ($self) = @_;
+
+ my $cache_key = $self->cgi->cookie((ref $self)->COOKIE_ANON_CACHE);
+
+ my $list = [];
+ if ($cache_key) {
+ $list = $U->simplereq(
+ "open-ils.actor",
+ "open-ils.actor.anon_cache.get_value",
+ $cache_key, (ref $self)->ANON_CACHE_STAFF_SEARCH
+ );
+
+ unless ($list) {
+ undef $cache_key;
+ $list = [];
+ }
+ }
+
+ return ($cache_key, $list);
+}
+
+sub staff_save_search {
+ my ($self, $query) = @_;
+
+ my $sss_size = $self->ctx->{staff_saved_search_size};
+ return unless $sss_size > 0;
+
+ my ($cache_key, $list) = $self->staff_load_searches;
+ my %already = ( map { $_ => 1 } @$list );
+
+ unshift @$list, $query unless $already{$query};
+
+ splice @$list, $sss_size;
+
+ $cache_key = $U->simplereq(
+ "open-ils.actor",
+ "open-ils.actor.anon_cache.set_value",
+ $cache_key, (ref $self)->ANON_CACHE_STAFF_SEARCH, $list
+ );
+
+ return ($cache_key, $list);
+}
+
1;
'URL for remote directory containing list column settings. The format and naming convention for the files found in this directory match those in the local settings directory for a given workstation. An administrator could create the desired settings locally and then copy all the tree_columns_for_* files to the remote directory.',
'coust', 'description'),
'string', null)
+,( 'opac.staff_saved_search.size', 'opac',
+ oils_i18n_gettext('opac.staff_saved_search.size',
+ 'OPAC: Number of staff client saved searches to display on left side of results and record details pages',
+ 'coust', 'label'),
+ oils_i18n_gettext('opac.staff_saved_search.size',
+ 'If unset, the OPAC (only when wrapped in the staff client!) will default to showing you your ten most recent searches on the left side of the results and record details pages. If you actually don''t want to see this feature at all, set this value to zero at the top of your organizational tree.',
+ 'coust', 'description'),
+ 'integer', null)
+
;
UPDATE config.org_unit_setting_type
--- /dev/null
+-- Evergreen DB patch XYXY.data.opac_staff_saved_search_size.sql
+
+BEGIN;
+
+SELECT evergreen.upgrade_deps_block_check('XYXY', :eg_version);
+
+INSERT into config.org_unit_setting_type (name, grp, label, description, datatype)
+VALUES (
+ 'opac.staff_saved_search.size', 'opac',
+ oils_i18n_gettext('opac.staff_saved_search.size',
+ 'OPAC: Number of staff client saved searches to display on left side of results and record details pages', 'coust', 'label'),
+ oils_i18n_gettext('opac.staff_saved_search.size',
+ 'If unset, the OPAC (only when wrapped in the staff client!) will default to showing you your ten most recent searches on the left side of the results and record details pages. If you actually don''t want to see this feature at all, set this value to zero at the top of your organizational tree.', 'coust', 'description'),
+ 'integer'
+);
+
+COMMIT;
--- /dev/null
+[% IF ctx.saved_searches.size %]
+ <div class="saved-searches-header big-strong">[% l("Your recent searches:") %]</div>
+ [% FOR s IN ctx.saved_searches %]
+ <ul>
+ <li><a href="[% ctx.opac_root %]/results?query=[% s | uri %]&_adv=1">[% s | html %]</a></li>
+ </ul>
+ [% END %]
+[% END %]
[% INCLUDE "opac/parts/printnav.tt2" %]
[% INCLUDE "opac/parts/searchbar.tt2" %]
</div>
+ <br class="clear-both" />
<div id="content-wrapper" class="content-wrapper-record-page">
- <div id="main-content">
+ [% IF ctx.staff_saved_search_size %]
+ <div id="results-side-bar">
+ <div id="staff-saved-search">
+ [% INCLUDE "opac/parts/staff_saved_searches.tt2" %]
+ </div>
+ </div>
+ [% END %]
+ <div id="[% ctx.staff_saved_search_size ? 'main-content-after-bar' : 'main-content' %]">
[% INCLUDE "opac/parts/record/body.tt2" %]
<div class="common-full-pad"></div>
</div>
+ <br class="clear-both" />
</div>
[% END %]
</div>
</div>
</form>
+ <br class="clear-both" />
<div id="content-wrapper">
- <div id="main-content">
- <div id="tehResultsPage">
+ [% IF ctx.staff_saved_search_size %]
+ <div id="results-side-bar">
+ <div id="staff-saved-search">
+ [% INCLUDE "opac/parts/staff_saved_searches.tt2" %]
+ </div>
+ <!-- XXX facet display here one day? -->
+ </div>
+ [% END %]
+ <div id="[% ctx.staff_saved_search_size ? 'main-content-after-bar' : 'main-content' %]">
+ <div id="results-page">
[% path = "opac/parts/result/" _
(ctx.records.size ? "table.tt2" : "lowhits.tt2");
INCLUDE $path %]
</div>
<div class="common-full-pad"></div>
</div>
+ <br class="clear-both" />
</div>
[% END %]
#main-content-home { width: 694px; margin: auto; padding-left: 17px; }
#main-content { width: 974px; margin:auto; padding-left: 0px; }
+#main-content-after-bar { float: left; width: 700px; margin: auto; padding-left: 4px; }
+
+#results-side-bar { float: left; width: 274px; background-color: #ddd; color: black; height: 500px; /* XXX to height of container*/ }
+
#main-content .login_boxes {
border: 1px solid #dedede;
background:url('/images/login-bg.jpg') top repeat-x;