[open-ils-commits] [GIT] Evergreen ILS branch master updated. eef093193ef5d5a0bf21972dca4147c0d0c573be

Evergreen Git git at git.evergreen-ils.org
Mon Sep 19 11:37:56 EDT 2011


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, master has been updated
       via  eef093193ef5d5a0bf21972dca4147c0d0c573be (commit)
      from  6a83b31d3129d82aff77d1b1ca95af1cca8c331a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit eef093193ef5d5a0bf21972dca4147c0d0c573be
Author: Lebbeous Fogle-Weekley <lebbeous at esilibrary.com>
Date:   Fri Sep 16 19:13:12 2011 -0400

    Staff saved searches when browsing catalog in staff client
    
    By default, show a user's ten most recent searches to them on the left
    side of the results and record details pages.  Configurable by org unit
    setting 'opac.staff_saved_searches.size'
    
    Signed-off-by: Lebbeous Fogle-Weekley <lebbeous at esilibrary.com>
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm
index b6281ce..60d7e8f 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm
@@ -27,6 +27,10 @@ my $U = 'OpenILS::Application::AppUtils';
 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) = @_;
 
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 a51ddc5..a80549f 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Container.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Container.pm
@@ -7,23 +7,20 @@ use OpenILS::Utils::Fieldmapper;
 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;
@@ -51,7 +48,7 @@ sub load_mylist_add {
     $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);
 }
@@ -66,7 +63,7 @@ sub load_mylist_delete {
     $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);
 }
@@ -88,7 +85,7 @@ sub load_mylist_move {
     $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+$/) {
@@ -111,7 +108,7 @@ sub clear_anon_cache {
     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',
@@ -137,7 +134,7 @@ sub mylist_action_redirect {
     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'
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm
index 533cb7e..bc60edc 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm
@@ -22,6 +22,11 @@ sub load_record {
     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');
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 376b316..bed087f 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm
@@ -167,6 +167,23 @@ sub load_rresults {
 
     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.
@@ -372,4 +389,67 @@ sub load_cnbrowse {
     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;
diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql
index 42e029c..db3afc2 100644
--- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql
+++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql
@@ -4363,6 +4363,15 @@ INSERT into config.org_unit_setting_type
         '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
diff --git a/Open-ILS/src/sql/Pg/upgrade/XYXY.data.opac_staff_saved_search_size.sql b/Open-ILS/src/sql/Pg/upgrade/XYXY.data.opac_staff_saved_search_size.sql
new file mode 100644
index 0000000..410f1ef
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/XYXY.data.opac_staff_saved_search_size.sql
@@ -0,0 +1,17 @@
+-- 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;
diff --git a/Open-ILS/src/templates/opac/parts/staff_saved_searches.tt2 b/Open-ILS/src/templates/opac/parts/staff_saved_searches.tt2
new file mode 100644
index 0000000..fb8ce21
--- /dev/null
+++ b/Open-ILS/src/templates/opac/parts/staff_saved_searches.tt2
@@ -0,0 +1,8 @@
+[% 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 %]&amp;_adv=1">[% s | html %]</a></li>
+    </ul>
+    [% END %]
+[% END %]
diff --git a/Open-ILS/src/templates/opac/record.tt2 b/Open-ILS/src/templates/opac/record.tt2
index 7434865..5c1e4d8 100644
--- a/Open-ILS/src/templates/opac/record.tt2
+++ b/Open-ILS/src/templates/opac/record.tt2
@@ -7,10 +7,19 @@
         [% 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 %]
diff --git a/Open-ILS/src/templates/opac/results.tt2 b/Open-ILS/src/templates/opac/results.tt2
index dc7d84c..acebea7 100644
--- a/Open-ILS/src/templates/opac/results.tt2
+++ b/Open-ILS/src/templates/opac/results.tt2
@@ -61,14 +61,24 @@
         </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 %]
diff --git a/Open-ILS/web/css/skin/default/opac/style.css b/Open-ILS/web/css/skin/default/opac/style.css
index 6a0cec6..e1536a6 100644
--- a/Open-ILS/web/css/skin/default/opac/style.css
+++ b/Open-ILS/web/css/skin/default/opac/style.css
@@ -551,6 +551,10 @@ div.select-wrapper:hover {
 #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;

-----------------------------------------------------------------------

Summary of changes:
 .../src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm    |    4 +
 .../lib/OpenILS/WWW/EGCatLoader/Container.pm       |   17 ++---
 .../perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm |    5 +
 .../perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm |   80 ++++++++++++++++++++
 Open-ILS/src/sql/Pg/950.data.seed-values.sql       |    9 ++
 .../XYXY.data.opac_staff_saved_search_size.sql     |   17 ++++
 .../templates/opac/parts/staff_saved_searches.tt2  |    8 ++
 Open-ILS/src/templates/opac/record.tt2             |   11 +++-
 Open-ILS/src/templates/opac/results.tt2            |   14 +++-
 Open-ILS/web/css/skin/default/opac/style.css       |    4 +
 10 files changed, 156 insertions(+), 13 deletions(-)
 create mode 100644 Open-ILS/src/sql/Pg/upgrade/XYXY.data.opac_staff_saved_search_size.sql
 create mode 100644 Open-ILS/src/templates/opac/parts/staff_saved_searches.tt2


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list