Bugzilla – Attachment 16745 Details for
Bug 9257
Add "groups" to normal search pulldown
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[PASSED QA] Bug 9257 - Add "groups" to normal search pulldown
PASSED-QA-Bug-9257---Add-groups-to-normal-search-p.patch (text/plain), 17.28 KB, created by
Paul Poulain
on 2013-03-22 10:03:42 UTC
(
hide
)
Description:
[PASSED QA] Bug 9257 - Add "groups" to normal search pulldown
Filename:
MIME Type:
Creator:
Paul Poulain
Created:
2013-03-22 10:03:42 UTC
Size:
17.28 KB
patch
obsolete
>From 50a511dbc45fd99345d5be2d050c6c7b20e01aa5 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Mon, 10 Dec 2012 13:58:16 -0500 >Subject: [PATCH] [PASSED QA] Bug 9257 - Add "groups" to normal search > pulldown >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >This patch adds the ability to add groups to the library select >pulldown on the opac, if it is enabled. > >Test Plan: >1) Apply patch >2) Run updatedatabase.pl >3) Go to Administration ΓΆΒΊ Libraries and groups >4) Create a new group, or edit an existing one >5) Ensure the 'Show in search pulldown' checkbox is checked >6) Save the group >7) Enable OpacAddMastheadLibraryPulldown if it is not already enabled >8) Load the OPAC, try the group search from the libraries pulldown menu > >Signed-off-by: Liz Rea <liz@catalyst.net.nz> >Yes! Now this works, and well. > >Signed-off-by: Paul Poulain <paul.poulain@biblibre.com> >--- > C4/Auth.pm | 11 ++-- > C4/Branch.pm | 68 ++++++++++++-------- > admin/branches.pl | 3 + > installer/data/mysql/kohastructure.sql | 4 +- > installer/data/mysql/updatedatabase.pl | 10 +++ > .../prog/en/modules/admin/branches.tt | 8 +++ > koha-tmpl/opac-tmpl/ccsr/en/includes/masthead.inc | 29 +++++++-- > koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc | 21 ++++-- > opac/opac-search.pl | 16 +++++ > 9 files changed, 128 insertions(+), 42 deletions(-) > >diff --git a/C4/Auth.pm b/C4/Auth.pm >index 2984570..ca061b5 100644 >--- a/C4/Auth.pm >+++ b/C4/Auth.pm >@@ -387,6 +387,8 @@ sub get_template_and_user { > my $opac_name = ''; > if (($opac_search_limit && $opac_search_limit =~ /branch:(\w+)/ && $opac_limit_override) || ($in->{'query'}->param('limit') && $in->{'query'}->param('limit') =~ /branch:(\w+)/)){ > $opac_name = $1; # opac_search_limit is a branch, so we use it. >+ } elsif ( $in->{'query'}->param('multibranchlimit') ) { >+ $opac_name = $in->{'query'}->param('multibranchlimit'); > } elsif (C4::Context->preference("SearchMyLibraryFirst") && C4::Context->userenv && C4::Context->userenv->{'branch'}) { > $opac_name = C4::Context->userenv->{'branch'}; > } >@@ -395,13 +397,14 @@ sub get_template_and_user { > AnonSuggestions => "" . C4::Context->preference("AnonSuggestions"), > AuthorisedValueImages => C4::Context->preference("AuthorisedValueImages"), > BranchesLoop => GetBranchesLoop($opac_name), >- CalendarFirstDayOfWeek => (C4::Context->preference("CalendarFirstDayOfWeek") eq "Sunday")?0:1, >+ BranchCategoriesLoop => GetBranchCategories( undef, undef, 1, $opac_name ), >+ CalendarFirstDayOfWeek => (C4::Context->preference("CalendarFirstDayOfWeek") eq "Sunday")?0:1, > LibraryName => "" . C4::Context->preference("LibraryName"), > LibraryNameTitle => "" . $LibraryNameTitle, > LoginBranchname => C4::Context->userenv?C4::Context->userenv->{"branchname"}:"", > OPACAmazonCoverImages => C4::Context->preference("OPACAmazonCoverImages"), > OPACFRBRizeEditions => C4::Context->preference("OPACFRBRizeEditions"), >- OpacHighlightedWords => C4::Context->preference("OpacHighlightedWords"), >+ OpacHighlightedWords => C4::Context->preference("OpacHighlightedWords"), > OPACItemHolds => C4::Context->preference("OPACItemHolds"), > OPACShelfBrowser => "". C4::Context->preference("OPACShelfBrowser"), > OpacShowRecentComments => C4::Context->preference("OpacShowRecentComments"), >@@ -412,7 +415,7 @@ sub get_template_and_user { > OpacAuthorities => C4::Context->preference("OpacAuthorities"), > OPACBaseURL => ($in->{'query'}->https() ? "https://" : "http://") . $ENV{'SERVER_NAME'} . > ($ENV{'SERVER_PORT'} eq ($in->{'query'}->https() ? "443" : "80") ? '' : ":$ENV{'SERVER_PORT'}"), >- opac_css_override => $ENV{'OPAC_CSS_OVERRIDE'}, >+ opac_css_override => $ENV{'OPAC_CSS_OVERRIDE'}, > opac_search_limit => $opac_search_limit, > opac_limit_override => $opac_limit_override, > OpacBrowser => C4::Context->preference("OpacBrowser"), >@@ -426,7 +429,7 @@ sub get_template_and_user { > OpacNavRight => "" . C4::Context->preference("OpacNavRight"), > OpacNavBottom => "" . C4::Context->preference("OpacNavBottom"), > OpacPasswordChange => C4::Context->preference("OpacPasswordChange"), >- OPACPatronDetails => C4::Context->preference("OPACPatronDetails"), >+ OPACPatronDetails => C4::Context->preference("OPACPatronDetails"), > OPACPrivacy => C4::Context->preference("OPACPrivacy"), > OPACFinesTab => C4::Context->preference("OPACFinesTab"), > OpacTopissue => C4::Context->preference("OpacTopissue"), >diff --git a/C4/Branch.pm b/C4/Branch.pm >index fe67e0c..1509c13 100644 >--- a/C4/Branch.pm >+++ b/C4/Branch.pm >@@ -328,7 +328,7 @@ sub GetBranchCategory { > > =head2 GetBranchCategories > >- my $categories = GetBranchCategories($branchcode,$categorytype); >+ my $categories = GetBranchCategories($branchcode,$categorytype,$show_in_pulldown,$selected_in_pulldown); > > Returns a list ref of anon hashrefs with keys eq columns of branchcategories table, > i.e. categorycode, categorydescription, categorytype, categoryname. >@@ -338,27 +338,43 @@ $branchcode is a member of , and to $categorytype. > =cut > > sub GetBranchCategories { >- my ($branchcode,$categorytype) = @_; >- my $dbh = C4::Context->dbh(); >- my $query = "SELECT c.* FROM branchcategories c"; >- my (@where, @bind); >- if($branchcode) { >- $query .= ",branchrelations r, branches b "; >- push @where, "c.categorycode=r.categorycode and r.branchcode=? "; >- push @bind , $branchcode; >- } >- if ($categorytype) { >- push @where, " c.categorytype=? "; >- push @bind, $categorytype; >- } >- $query .= " where " . join(" and ", @where) if(@where); >- $query .= " order by categorytype,c.categorycode"; >- my $sth=$dbh->prepare( $query); >- $sth->execute(@bind); >- >- my $branchcats = $sth->fetchall_arrayref({}); >- $sth->finish(); >- return( $branchcats ); >+ my ( $branchcode, $categorytype, $show_in_pulldown, $selected_in_pulldown ) = @_; >+ my $dbh = C4::Context->dbh(); >+ >+ my $query = "SELECT c.* FROM branchcategories c"; >+ my ( @where, @bind ); >+ >+ if( $branchcode ) { >+ $query .= ",branchrelations r, branches b "; >+ push @where, "c.categorycode = r.categorycode AND r.branchcode = ? "; >+ push @bind , $branchcode; >+ } >+ >+ if ( $categorytype ) { >+ push @where, " c.categorytype = ? "; >+ push @bind, $categorytype; >+ } >+ >+ if ( defined( $show_in_pulldown ) ) { >+ push( @where, " c.show_in_pulldown = ? " ); >+ push( @bind, $show_in_pulldown ); >+ } >+ >+ $query .= " WHERE " . join(" AND ", @where) if(@where); >+ $query .= " ORDER BY categorytype,c.categorycode"; >+ my $sth=$dbh->prepare( $query); >+ $sth->execute(@bind); >+ >+ my $branchcats = $sth->fetchall_arrayref({}); >+ $sth->finish(); >+ >+ if ( $selected_in_pulldown ) { >+ foreach my $bc ( @$branchcats ) { >+ $bc->{'selected'} = 1 if ( $bc->{'categorycode'} eq $selected_in_pulldown ); >+ } >+ } >+ >+ return( $branchcats ); > } > > =head2 GetCategoryTypes >@@ -506,14 +522,14 @@ sub ModBranchCategoryInfo { > my $dbh = C4::Context->dbh; > if ($data->{'add'}){ > # we are doing an insert >- my $sth = $dbh->prepare("INSERT INTO branchcategories (categorycode,categoryname,codedescription,categorytype) VALUES (?,?,?,?)"); >- $sth->execute(uc( $data->{'categorycode'} ),$data->{'categoryname'}, $data->{'codedescription'},$data->{'categorytype'} ); >+ my $sth = $dbh->prepare("INSERT INTO branchcategories (categorycode,categoryname,codedescription,categorytype,show_in_pulldown) VALUES (?,?,?,?,?)"); >+ $sth->execute(uc( $data->{'categorycode'} ),$data->{'categoryname'}, $data->{'codedescription'},$data->{'categorytype'},$data->{'show_in_pulldown'} ); > $sth->finish(); > } > else { > # modifying >- my $sth = $dbh->prepare("UPDATE branchcategories SET categoryname=?,codedescription=?,categorytype=? WHERE categorycode=?"); >- $sth->execute($data->{'categoryname'}, $data->{'codedescription'},$data->{'categorytype'},uc( $data->{'categorycode'} ) ); >+ my $sth = $dbh->prepare("UPDATE branchcategories SET categoryname=?,codedescription=?,categorytype=?,show_in_pulldown=? WHERE categorycode=?"); >+ $sth->execute($data->{'categoryname'}, $data->{'codedescription'},$data->{'categorytype'},$data->{'show_in_pulldown'},uc( $data->{'categorycode'} ) ); > $sth->finish(); > } > } >diff --git a/admin/branches.pl b/admin/branches.pl >index d172ea6..026d983 100755 >--- a/admin/branches.pl >+++ b/admin/branches.pl >@@ -168,6 +168,8 @@ elsif ( $op eq 'addcategory_validate' ) { > $template->param( else => 1 ); > # confirm settings change... > my $params = $input->Vars; >+ $params->{'show_in_pulldown'} = ( $params->{'show_in_pulldown'} eq 'on' ) ? 1 : 0; >+ > unless ( $params->{'categorycode'} && $params->{'categoryname'} ) { > default("MESSAGE4",$template); > } >@@ -294,6 +296,7 @@ sub editcatform { > categorycode => $data->{'categorycode'}, > categoryname => $data->{'categoryname'}, > codedescription => $data->{'codedescription'}, >+ show_in_pulldown => $data->{'show_in_pulldown'}, > ); > } > for my $ctype (GetCategoryTypes()) { >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index 15eb4d7..0fd7db1 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -340,7 +340,9 @@ CREATE TABLE `branchcategories` ( -- information related to library/branch group > `categoryname` varchar(32), -- name of the library/branch group > `codedescription` mediumtext, -- longer description of the library/branch group > `categorytype` varchar(16), -- says whether this is a search group or a properties group >- PRIMARY KEY (`categorycode`) >+ `show_in_pulldown` tinyint(1) NOT NULL DEFAULT '0', -- says this group should be in the opac libararies pulldown if it is enabled >+ PRIMARY KEY (`categorycode`), >+ KEY `show_in_pulldown` (`show_in_pulldown`) > ) ENGINE=InnoDB DEFAULT CHARSET=utf8; > > -- >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 5c7b323..ed4a581 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -6700,6 +6700,16 @@ if ( CheckVersion($DBversion) ) { > SetVersion ($DBversion); > } > >+$DBversion = "3.11.00.XXX"; >+if (C4::Context->preference("Version") < TransformToNum($DBversion)) { >+ $dbh->do(q{ >+ ALTER TABLE branchcategories ADD show_in_pulldown BOOLEAN NOT NULL DEFAULT '0', >+ ADD INDEX ( show_in_pulldown ) >+ }); >+ print "Upgrade to $DBversion done (Bug 9257 - Add groups to normal search pulldown)\n"; >+ SetVersion ($DBversion); >+} >+ > =head1 FUNCTIONS > > =head2 TableExists($table) >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt >index 4404e28..f9e5b99 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt >@@ -335,6 +335,14 @@ tinyMCE.init({ > [% END %] > </select> > </li> >+ <li> >+ <label for="show_in_pulldown">Show in search pulldown: </label> >+ [% IF ( show_in_pulldown ) %] >+ <input type="checkbox" name="show_in_pulldown" id="show_in_pulldown" checked="checked"/> >+ [% ELSE %] >+ <input type="checkbox" name="show_in_pulldown" id="show_in_pulldown" /> >+ [% END %] >+ </li> > </ol> > </fieldset> > <fieldset class="action"><input type="submit" value="Update" /></fieldset> >diff --git a/koha-tmpl/opac-tmpl/ccsr/en/includes/masthead.inc b/koha-tmpl/opac-tmpl/ccsr/en/includes/masthead.inc >index 1d8538e..5275bc8 100644 >--- a/koha-tmpl/opac-tmpl/ccsr/en/includes/masthead.inc >+++ b/koha-tmpl/opac-tmpl/ccsr/en/includes/masthead.inc >@@ -168,13 +168,28 @@ > [% ELSE %] > <div id="libraries" class="mobile-hidden"> > [% END %] >- <select name="limit" id="select_library" class="left"> >- <option value="">All libraries</option> >- [% FOREACH BranchesLoo IN BranchesLoop %] >- [% IF ( BranchesLoo.selected ) %]<option selected="selected" value="branch:[% BranchesLoo.value %]">[% BranchesLoo.branchname %]</option> >- [% ELSE %]<option value="branch:[% BranchesLoo.value %]">[% BranchesLoo.branchname %]</option>[% END %] >- [% END %] >- </select> >+ >+ <select name="branch_group_limit" id="select_library" class="left"> >+ <option value="">All libraries</option> >+ <optgroup label="Libraries"> >+ [% FOREACH BranchesLoo IN BranchesLoop %] >+ [% IF ( BranchesLoo.selected ) %]<option selected="selected" value="branch:[% BranchesLoo.value %]">[% BranchesLoo.branchname %]</option> >+ [% ELSE %]<option value="branch:[% BranchesLoo.value %]">[% BranchesLoo.branchname %]</option>[% END %] >+ [% END %] >+ </optgroup> >+ [% IF BranchCategoriesLoop %] >+ <optgroup label="Groups"> >+ [% FOREACH bc IN BranchCategoriesLoop %] >+ [% IF ( bc.selected ) %] >+ <option selected="selected" value="multibranchlimit-[% bc.categorycode %]">[% bc.categoryname %]</option> >+ [% ELSE %] >+ <option value="multibranchlimit-[% bc.categorycode %]">[% bc.categoryname %]</option> >+ [% END %] >+ [% END %] >+ </optgroup> >+ [% END %] >+ </select> >+ > </div> > [% ELSE %] > [% IF ( opac_limit_override ) %] >diff --git a/koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc b/koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc >index aa8c281..ac815bc 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc >+++ b/koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc >@@ -85,11 +85,24 @@ > <input type="text" title="Type search term" id = "transl1" name="q" class="left" style="width: 35%; font-size: 111%;"/><div id="translControl"></div> > [% END %] > [% IF ( OpacAddMastheadLibraryPulldown ) %] >- <select name="limit" id="select_library" class="left"> >+ <select name="branch_group_limit" id="select_library" class="left"> > <option value="">All libraries</option> >- [% FOREACH BranchesLoo IN BranchesLoop %] >- [% IF ( BranchesLoo.selected ) %]<option selected="selected" value="branch:[% BranchesLoo.value %]">[% BranchesLoo.branchname %]</option> >- [% ELSE %]<option value="branch:[% BranchesLoo.value %]">[% BranchesLoo.branchname %]</option>[% END %] >+ <optgroup label="Libraries"> >+ [% FOREACH BranchesLoo IN BranchesLoop %] >+ [% IF ( BranchesLoo.selected ) %]<option selected="selected" value="branch:[% BranchesLoo.value %]">[% BranchesLoo.branchname %]</option> >+ [% ELSE %]<option value="branch:[% BranchesLoo.value %]">[% BranchesLoo.branchname %]</option>[% END %] >+ [% END %] >+ </optgroup> >+ [% IF BranchCategoriesLoop %] >+ <optgroup label="Groups"> >+ [% FOREACH bc IN BranchCategoriesLoop %] >+ [% IF ( bc.selected ) %] >+ <option selected="selected" value="multibranchlimit-[% bc.categorycode %]">[% bc.categoryname %]</option> >+ [% ELSE %] >+ <option value="multibranchlimit-[% bc.categorycode %]">[% bc.categoryname %]</option> >+ [% END %] >+ [% END %] >+ </optgroup> > [% END %] > </select> > [% ELSE %] >diff --git a/opac/opac-search.pl b/opac/opac-search.pl >index a0ba296..4b202b2 100755 >--- a/opac/opac-search.pl >+++ b/opac/opac-search.pl >@@ -63,6 +63,21 @@ my $DisplayMultiPlaceHold = C4::Context->preference("DisplayMultiPlaceHold"); > use CGI qw('-no_undef_params'); > my $cgi = new CGI; > >+my $branch_group_limit = $cgi->param("branch_group_limit"); >+if ( $branch_group_limit ) { >+ if ( $branch_group_limit =~ /^multibranchlimit/ ) { >+ $cgi->param( >+ -name => 'multibranchlimit', >+ -values => [ ( split( 'multibranchlimit-', $branch_group_limit ) )[1] ] >+ ); >+ } else { >+ $cgi->append( >+ -name => 'limit', >+ -values => [ $branch_group_limit ] >+ ); >+ } >+} >+ > BEGIN { > if (C4::Context->preference('BakerTaylorEnabled')) { > require C4::External::BakerTaylor; >@@ -77,6 +92,7 @@ my $template_name; > my $template_type = 'basic'; > my @params = $cgi->param("limit"); > >+ > my $format = $cgi->param("format") || ''; > my $build_grouped_results = C4::Context->preference('OPACGroupResults'); > if ($format =~ /(rss|atom|opensearchdescription)/) { >-- >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 9257
:
13980
|
14364
|
14365
|
15279
|
16074
|
16077
| 16745