Bugzilla – Attachment 21047 Details for
Bug 10862
Add an search history for the staff interface
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[SIGNED-OFF] Bug 10862: Add an search history for the intranet interface
SIGNED-OFF-Bug-10862-Add-an-search-history-for-the.patch (text/plain), 19.83 KB, created by
Owen Leonard
on 2013-09-12 17:05:31 UTC
(
hide
)
Description:
[SIGNED-OFF] Bug 10862: Add an search history for the intranet interface
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2013-09-12 17:05:31 UTC
Size:
19.83 KB
patch
obsolete
>From 58c9fed6eed41aebfe3298966650b01173308de8 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Mon, 2 Sep 2013 17:02:02 +0200 >Subject: [PATCH] [SIGNED-OFF] Bug 10862: Add an search history for the > intranet interface >Content-Type: text/plain; charset="utf-8" > >Like OPAC, the search history is now available for intranet. > >Test plan: > 1/ Switch on the 'EnableSearchHistory' syspref. > 3/ Launch some biblio and authority searches. > 4/ Go on your search history page (top right, under "Set library"). > 5/ Check that all yours searches are displayed. > 6/ Click on some links and check that results are consistent. > 7/ Delete your biblio history searches. > 8/ Delete your authority searches history searches. > 9/ Launch some biblio and authority searches >10/ Play with the 4 delete links (current / previous and biblio / >authority). > >Signed-off-by: Owen Leonard <oleonard@myacpl.org> >--- > C4/Auth.pm | 2 + > authorities/authorities-home.pl | 21 +++ > catalogue/search-history.pl | 100 +++++++++++ > catalogue/search.pl | 27 ++- > installer/data/mysql/sysprefs.sql | 1 + > installer/data/mysql/updatedatabase.pl | 20 +++ > .../intranet-tmpl/prog/en/includes/header.inc | 5 + > .../en/modules/admin/preferences/searching.pref | 7 + > .../prog/en/modules/catalogue/search-history.tt | 178 ++++++++++++++++++++ > 9 files changed, 359 insertions(+), 2 deletions(-) > create mode 100755 catalogue/search-history.pl > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/search-history.tt > >diff --git a/C4/Auth.pm b/C4/Auth.pm >index 7b61da0..4c3f4bb 100644 >--- a/C4/Auth.pm >+++ b/C4/Auth.pm >@@ -279,6 +279,8 @@ sub get_template_and_user { > ); > $cookie = [$cookie, $newsearchcookie]; > } >+ } elsif ( $in->{type} eq 'intranet' and C4::Context->preference('EnableSearchHistory') ) { >+ $template->param( EnableSearchHistory => 1 ); > } > } > else { # if this is an anonymous session, setup to display public lists... >diff --git a/authorities/authorities-home.pl b/authorities/authorities-home.pl >index f67f5c9..8128e0c 100755 >--- a/authorities/authorities-home.pl >+++ b/authorities/authorities-home.pl >@@ -31,6 +31,7 @@ use C4::AuthoritiesMarc; > use C4::Acquisition; > use C4::Koha; # XXX subfield_is_koha_internal_p > use C4::Biblio; >+use C4::Search::History; > > my $query = new CGI; > my $dbh = C4::Context->dbh; >@@ -97,6 +98,7 @@ if ( $op eq "do_search" ) { > $orderby > ); > >+ > ( $template, $loggedinuser, $cookie ) = get_template_and_user( > { > template_name => "authorities/searchresultlist.tmpl", >@@ -108,6 +110,25 @@ if ( $op eq "do_search" ) { > } > ); > >+ # search history >+ if (C4::Context->preference('EnableSearchHistory')) { >+ if ( $startfrom == 1) { >+ my $path_info = $query->url(-path_info=>1); >+ my $query_cgi_history = $query->url(-query=>1); >+ $query_cgi_history =~ s/^$path_info\?//; >+ $query_cgi_history =~ s/;/&/g; >+ >+ C4::Search::History::add({ >+ userid => $loggedinuser, >+ sessionid => $query->cookie("CGISESSID"), >+ query_desc => $value, >+ query_cgi => $query_cgi_history, >+ total => $total, >+ type => "authority", >+ }); >+ } >+ } >+ > $template->param( > marclist => $marclist, > and_or => $and_or, >diff --git a/catalogue/search-history.pl b/catalogue/search-history.pl >new file mode 100755 >index 0000000..20e3b82 >--- /dev/null >+++ b/catalogue/search-history.pl >@@ -0,0 +1,100 @@ >+#!/usr/bin/perl >+ >+# This file is part of Koha. >+# >+# Copyright 2013 BibLibre >+# >+# Koha is free software; you can redistribute it and/or modify >+# it under the terms of the GNU General Public License as >+# published by the Free Software Foundation; either version 3 >+# of the License, or (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General >+# Public License along with Koha; if not, see >+# <http://www.gnu.org/licenses> >+ >+use Modern::Perl; >+use CGI; >+ >+use C4::Auth; >+use C4::Search::History; >+use C4::Output; >+ >+my $cgi = new CGI; >+ >+my ($template, $loggedinuser, $cookie) = get_template_and_user({ >+ template_name => 'catalogue/search-history.tt', >+ query => $cgi, >+ type => "intranet", >+ authnotrequired => 0, >+ flagsrequired => {catalogue => 1}, >+}); >+ >+my $type = $cgi->param('type'); >+my $action = $cgi->param('action') || q{list}; >+my $previous = $cgi->param('previous'); >+ >+# Deleting search history >+if ( $action eq 'delete' ) { >+ my $sessionid = defined $previous >+ ? $cgi->cookie("CGISESSID") >+ : q{}; >+ C4::Search::History::delete( >+ { >+ userid => $loggedinuser, >+ sessionid => $sessionid, >+ type => $type, >+ previous => $previous >+ } >+ ); >+ # Redirecting to this same url so the user won't see the search history link in the header >+ my $uri = $cgi->url(); >+ print $cgi->redirect($uri); >+ >+# Showing search history >+} else { >+ my $current_searches = C4::Search::History::get({ >+ userid => $loggedinuser, >+ sessionid => $cgi->cookie("CGISESSID") >+ }); >+ my @current_biblio_searches = map { >+ $_->{type} eq 'biblio' ? $_ : () >+ } @$current_searches; >+ >+ my @current_authority_searches = map { >+ $_->{type} eq 'authority' ? $_ : () >+ } @$current_searches; >+ >+ my $previous_searches = C4::Search::History::get({ >+ userid => $loggedinuser, >+ sessionid => $cgi->cookie("CGISESSID"), >+ previous => 1 >+ }); >+ >+ my @previous_biblio_searches = map { >+ $_->{type} eq 'biblio' ? $_ : () >+ } @$previous_searches; >+ >+ my @previous_authority_searches = map { >+ $_->{type} eq 'authority' ? $_ : () >+ } @$previous_searches; >+ >+ $template->param( >+ current_biblio_searches => \@current_biblio_searches, >+ current_authority_searches => \@current_authority_searches, >+ previous_biblio_searches => \@previous_biblio_searches, >+ previous_authority_searches => \@previous_authority_searches, >+ >+ ); >+} >+ >+ >+$template->param( >+); >+ >+output_html_with_http_headers $cgi, $cookie, $template->output; >diff --git a/catalogue/search.pl b/catalogue/search.pl >index 9e81a81..4bb8d21 100755 >--- a/catalogue/search.pl >+++ b/catalogue/search.pl >@@ -152,6 +152,7 @@ use URI::Escape; > use POSIX qw(ceil floor); > use String::Random; > use C4::Branch; # GetBranches >+use C4::Search::History; > > my $DisplayMultiPlaceHold = C4::Context->preference("DisplayMultiPlaceHold"); > # create a new CGI object >@@ -159,7 +160,6 @@ my $DisplayMultiPlaceHold = C4::Context->preference("DisplayMultiPlaceHold"); > use CGI qw('-no_undef_params'); > my $cgi = new CGI; > >-my ($template,$borrowernumber,$cookie); > my $lang = C4::Templates::getlanguage($cgi, 'intranet'); > # decide which template to use > my $template_name; >@@ -173,7 +173,7 @@ else { > $template_type = 'advsearch'; > } > # load the template >-($template, $borrowernumber, $cookie) = get_template_and_user({ >+my ($template, $borrowernumber, $cookie) = get_template_and_user({ > template_name => $template_name, > query => $cgi, > type => "intranet", >@@ -653,6 +653,29 @@ for (my $i=0;$i<@servers;$i++) { > $template->param (z3950_search_params => C4::Search::z3950_search_args($z3950par || $query_desc)); > } > >+ # Search history >+ if (C4::Context->preference('EnableSearchHistory')) { >+ unless ( $offset ) { >+ my $path_info = $cgi->url(-path_info=>1); >+ my $query_cgi_history = $cgi->url(-query=>1); >+ $query_cgi_history =~ s/^$path_info\?//; >+ $query_cgi_history =~ s/;/&/g; >+ my $query_desc_history = $query_desc; >+ $query_desc_history .= ", $limit_desc" >+ if $limit_desc; >+ >+ C4::Search::History::add({ >+ userid => $borrowernumber, >+ sessionid => $cgi->cookie("CGISESSID"), >+ query_desc => $query_desc_history, >+ query_cgi => $query_cgi_history, >+ total => $total, >+ type => "biblio", >+ }); >+ } >+ $template->param( EnableSearchHistory => 1 ); >+ } >+ > } # end of the if local > > # asynchronously search the authority server >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index e8ca401..88f2d62 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -98,6 +98,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('EasyAnalyticalRecords','0','','If on, display in the catalogue screens tools to easily setup analytical record relationships','YesNo'), > ('emailLibrarianWhenHoldIsPlaced','0',NULL,'If ON, emails the librarian whenever a hold is placed','YesNo'), > ('EnableBorrowerFiles','0',NULL,'If enabled, allows librarians to upload and attach arbitrary files to a borrower record.','YesNo'), >+('EnableSearchHistory','0','','Enable or disable search history','YesNo'), > ('EnableOpacSearchHistory','1','YesNo','Enable or disable opac search history',''), > ('EnhancedMessagingPreferences','0','','If ON, allows patrons to select to receive additional messages about items due or nearly due.','YesNo'), > ('expandedSearchOption','0',NULL,'If ON, set advanced search to be expanded by default','YesNo'), >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index cef18e3..daded51 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -7117,6 +7117,26 @@ if ( CheckVersion($DBversion) ) { > SetVersion($DBversion); > } > >+ >+ >+ >+ >+ >+ >+$DBversion = "3.13.00.XXX"; >+if ( CheckVersion($DBversion) ) { >+ $dbh->do(q| >+ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('EnableSearchHistory','1','','Enable or disable search history','YesNo') >+ |); >+ print "Upgrade to $DBversion done (MT12541: Add EnableSearchHistory syspref)\n"; >+ SetVersion($DBversion); >+} >+ >+ >+ >+ >+ >+ > =head1 FUNCTIONS > > =head2 TableExists($table) >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc >index 58f721f..666eaf5 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc >@@ -75,6 +75,11 @@ > <a class="toplinks" href="/cgi-bin/koha/circ/selectbranchprinter.pl">Set library</a> > </li> > [% END %] >+ [% IF EnableSearchHistory %] >+ <li> >+ <a class="toplinks" href="/cgi-bin/koha/catalogue/search-history.pl">Search history</a> >+ </li> >+ [% END %] > <li> > <a id="logout" class="toplinks" href="/cgi-bin/koha/mainpage.pl?logout.x=1">Log out</a> > </li> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref >index 29da64e..b430406 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref >@@ -71,6 +71,13 @@ Searching: > yes: Include > no: "Don't include" > - "<i>see from</i> (non-preferred form) headings in bibliographic searches. Please note: you will need to reindex your bibliographic database when changing this preference." >+ - >+ - pref: EnableSearchHistory >+ default: 0 >+ choices: >+ yes: Keep >+ no: "Don't keep" >+ - patron search history in the OPAC. > Search Form: > - > - Show tabs in OPAC and staff-side advanced search for limiting searches on the >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/search-history.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/search-history.tt >new file mode 100644 >index 0000000..23bda80 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/search-history.tt >@@ -0,0 +1,178 @@ >+[% USE Koha %] >+[% USE KohaDates %] >+<title>Koha › Catalog › History search</title> >+[% INCLUDE 'doc-head-close.inc' %] >+<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" /> >+<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.dataTables.min.js"></script> >+<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.dataTables.columnFilter.js"></script> >+[% INCLUDE 'datatables-strings.inc' %] >+<script type="text/javascript" src="[% themelang %]/js/datatables.js"></script> >+<script type="text/javascript"> >+//<![CDATA[ >+var MSG_CONFIRM_DELETE_HISTORY = _("Are you sure you want to delete your search history?"); >+$(document).ready(function() { >+ // We show table ordered by descending dates by default >+ // (so that the more recent query is shown first) >+ $(".historyt").dataTable($.extend(true, {}, dataTablesDefaults, { >+ "aaSorting": [[ 0, "desc" ]], >+ "aoColumns": [ >+ { "sType": "title-string" }, >+ null, >+ null >+ ] >+ })); >+ >+ $('#tabs').tabs(); >+}); >+//]]> >+ >+</script> >+</head> >+<body id="catalogue_search-history" class="catalogue"> >+ >+[% INCLUDE 'header.inc' %] >+[% INCLUDE 'cat-search.inc' %] >+ >+<div id="breadcrumbs"> >+ <a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/catalogue/search.pl">Catalog</a> › History search >+</div> >+ >+<div id="doc3" class="yui-t2"> >+ >+<div id="bd"> >+ <div id="yui-main"> >+ <div class="yui-b"> >+ <h1>Search history</h1> >+ <div id="tabs" class="toptabs"> >+ <ul> >+ <li><a href="#biblio_tab">Biblio</a></li> >+ <li><a href="#authority_tab">Authority</a></li> >+ </ul> >+ <div id="biblio_tab"> >+ [% IF ( current_biblio_searches ) %] >+ <h2>Current session</h2> >+ <form action="/cgi-bin/koha/catalogue/search-history.pl" method="get"> >+ <input type="hidden" name="action" value="delete" /> >+ <input type="hidden" name="previous" value="0" /> >+ <input type="hidden" name="type" value="biblio" /> >+ <input type="submit" class="deleteshelf" value="Delete your current biblio history" onclick="return confirm(MSG_CONFIRM_DELETE_HISTORY);" /> >+ </form> >+ <table class="historyt"> >+ <thead> >+ <tr> >+ <th>Date</th> >+ <th>Search</th> >+ <th>Results</th> >+ </tr> >+ </thead> >+ <tbody> >+ [% FOREACH s IN current_biblio_searches %] >+ <tr> >+ <td><span title="[% s.time %]">[% s.time |$KohaDates with_hours => 1 %]</span></td> >+ <td><a href="/cgi-bin/koha/catalogue/search.pl?[% s.query_cgi |html %]">[% s.query_desc |html %]</a></td> >+ <td>[% s.total %]</td> >+ </tr> >+ [% END %] >+ </tbody> >+ </table> >+ [% END %] >+ >+ [% IF ( previous_biblio_searches ) %] >+ <h2>Previous sessions</h2> >+ <form action="/cgi-bin/koha/catalogue/search-history.pl" method="get"> >+ <input type="hidden" name="action" value="delete" /> >+ <input type="hidden" name="previous" value="1" /> >+ <input type="hidden" name="type" value="biblio" /> >+ <input type="submit" class="deleteshelf" value="Delete your previous biblio search history" onclick="return confirm(MSG_CONFIRM_DELETE_HISTORY);" /> >+ </form> >+ <table class="historyt"> >+ <thead> >+ <tr> >+ <th>Date</th> >+ <th>Search</th> >+ <th>Results</th> >+ </tr> >+ </thead> >+ <tbody> >+ [% FOREACH s IN previous_biblio_searches %] >+ <tr> >+ <td><span title="[% s.time %]">[% s.time |$KohaDates with_hours => 1 %]</span></td> >+ <td><a href="/cgi-bin/koha/catalogue/search.pl?[% s.query_cgi |html %]">[% s.query_desc |html %]</a></td> >+ <td>[% s.total %]</td> >+ </tr> >+ [% END %] >+ </tbody> >+ </table> >+ [% END %] >+ >+ [% IF !current_biblio_searches && !previous_biblio_searches %] >+ <p>Your biblio search history is empty.</p> >+ [% END %] >+ </div> >+ >+ <div id="authority_tab"> >+ [% IF ( current_authority_searches ) %] >+ <h2>Current session</h2> >+ <form action="/cgi-bin/koha/catalogue/search-history.pl" method="get"> >+ <input type="hidden" name="action" value="delete" /> >+ <input type="hidden" name="previous" value="0" /> >+ <input type="hidden" name="type" value="authority" /> >+ <input type="submit" class="deleteshelf" value="Delete your current authority search history" onclick="return confirm(MSG_CONFIRM_DELETE_HISTORY);" /> >+ </form> >+ <table class="historyt"> >+ <thead> >+ <tr> >+ <th>Date</th> >+ <th>Search</th> >+ <th>Results</th> >+ </tr> >+ </thead> >+ <tbody> >+ [% FOREACH s IN current_authority_searches %] >+ <tr> >+ <td><span title="[% s.time %]">[% s.time |$KohaDates with_hours => 1 %]</span></td> >+ <td><a href="/cgi-bin/koha/authorities/authorities-home.pl?[% s.query_cgi |html %]">[% s.query_desc |html %]</a></td> >+ <td>[% s.total %]</td> >+ </tr> >+ [% END %] >+ </tbody> >+ </table> >+ [% END %] >+ >+ [% IF ( previous_authority_searches ) %] >+ <h2>Previous sessions</h2> >+ <form action="/cgi-bin/koha/catalogue/search-history.pl" method="get"> >+ <input type="hidden" name="action" value="delete" /> >+ <input type="hidden" name="previous" value="1" /> >+ <input type="hidden" name="type" value="authority" /> >+ <input type="submit" class="deleteshelf" value="Delete your previous authority search history" onclick="return confirm(MSG_CONFIRM_DELETE_HISTORY);" /> >+ </form> >+ <table class="historyt"> >+ <thead> >+ <tr> >+ <th>Date</th> >+ <th>Search</th> >+ <th>Results</th> >+ </tr> >+ </thead> >+ <tbody> >+ [% FOREACH s IN previous_authority_searches %] >+ <tr> >+ <td><span title="[% s.time %]">[% s.time |$KohaDates with_hours => 1 %]</span></td> >+ <td><a href="/cgi-bin/koha/authorities/authorities-home.pl?[% s.query_cgi |html %]">[% s.query_desc |html %]</a></td> >+ <td>[% s.total %]</td> >+ </tr> >+ [% END %] >+ </tbody> >+ </table> >+ [% END %] >+ >+ [% IF !current_authority_searches && !previous_authority_searches %] >+ <p>Your authority search history is empty.</p> >+ [% END %] >+ </div> >+ </div> >+ </div> >+ </div> >+</div> >+[% INCLUDE 'intranet-bottom.inc' %] >-- >1.7.9.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 10862
:
20953
|
20982
|
21005
|
21047
|
21048
|
21049
|
22100
|
22101
|
22102