@@ -, +, @@
---
C4/Auth.pm | 4 +-
C4/Branch.pm | 24 +-
C4/Koha.pm | 4 +-
C4/Members/Attributes.pm | 14 +-
.../prog/en/modules/admin/preferences/opac.pref | 12 +-
.../prog/en/modules/admin/preferences/patrons.pref | 6 +
.../en/modules/admin/preferences/searching.pref | 7 +
.../opac-tmpl/prog/en/css/jquery.multiSelect.css | 85 +++
.../opac-tmpl/prog/en/js/jquery.bgiframe.min.js | 7 +
.../opac-tmpl/prog/en/js/jquery.multiSelect.js | 554 ++++++++++++++++++++
.../opac-tmpl/prog/en/modules/opac-advsearch.tt | 12 +
.../opac-tmpl/prog/images/dropdown.blue.active.png | Bin 0 -> 390 bytes
.../opac-tmpl/prog/images/dropdown.blue.hover.png | Bin 0 -> 389 bytes
koha-tmpl/opac-tmpl/prog/images/dropdown.blue.png | Bin 0 -> 298 bytes
koha-tmpl/opac-tmpl/prog/images/dropdown.gif | Bin 0 -> 61 bytes
.../opac-tmpl/prog/images/dropdown_active.gif | Bin 0 -> 61 bytes
koha-tmpl/opac-tmpl/prog/images/dropdown_hover.gif | Bin 0 -> 61 bytes
opac/opac-search.pl | 60 ++-
18 files changed, 771 insertions(+), 18 deletions(-)
create mode 100644 koha-tmpl/opac-tmpl/prog/en/css/jquery.multiSelect.css
create mode 100644 koha-tmpl/opac-tmpl/prog/en/js/jquery.bgiframe.min.js
create mode 100644 koha-tmpl/opac-tmpl/prog/en/js/jquery.multiSelect.js
create mode 100644 koha-tmpl/opac-tmpl/prog/images/dropdown.blue.active.png
create mode 100644 koha-tmpl/opac-tmpl/prog/images/dropdown.blue.hover.png
create mode 100644 koha-tmpl/opac-tmpl/prog/images/dropdown.blue.png
create mode 100644 koha-tmpl/opac-tmpl/prog/images/dropdown.gif
create mode 100644 koha-tmpl/opac-tmpl/prog/images/dropdown_active.gif
create mode 100644 koha-tmpl/opac-tmpl/prog/images/dropdown_hover.gif
--- a/C4/Auth.pm
+++ a/C4/Auth.pm
@@ -383,7 +383,7 @@ 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 (C4::Context->preference("SearchMyLibraryFirst") && C4::Context->userenv && C4::Context->userenv->{'branch'}) {
+ } elsif (C4::Context->preference("SearchableBranches") ne "all" && C4::Context->userenv && C4::Context->userenv->{'branch'}) {
$opac_name = C4::Context->userenv->{'branch'};
}
$template->param(
@@ -429,7 +429,7 @@ sub get_template_and_user {
RequestOnOpac => C4::Context->preference("RequestOnOpac"),
'Version' => C4::Context->preference('Version'),
hidelostitems => C4::Context->preference("hidelostitems"),
- mylibraryfirst => (C4::Context->preference("SearchMyLibraryFirst") && C4::Context->userenv) ? C4::Context->userenv->{'branch'} : '',
+ mylibraryfirst => (C4::Context->preference("SearchableBranches") ne 'all' && C4::Context->userenv) ? C4::Context->userenv->{'branch'} : '',
opaclayoutstylesheet => "" . C4::Context->preference("opaclayoutstylesheet"),
opacbookbag => "" . C4::Context->preference("opacbookbag"),
opaccredits => "" . C4::Context->preference("opaccredits"),
--- a/C4/Branch.pm
+++ a/C4/Branch.pm
@@ -20,6 +20,8 @@ use strict;
#use warnings; FIXME - Bug 2505
require Exporter;
use C4::Context;
+use C4::Members::Attributes;
+use C4::Members;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
@@ -109,11 +111,31 @@ sub GetBranches {
my $sth;
my $query="SELECT * FROM branches";
my @bind_parameters;
+ my $borrowernumber;
+ if(C4::Context->userenv){$borrowernumber = C4::Context->userenv->{number}};
+
if ($onlymine && C4::Context->userenv && C4::Context->userenv->{branch}){
$query .= ' WHERE branchcode = ? ';
push @bind_parameters, C4::Context->userenv->{branch};
+ } elsif(C4::Context->preference("SearchableBranches") eq 'securehome' && C4::Context->userenv && $borrowernumber !=0) { # Preference is set to search only the branches specified in patron record.
+ my $value = C4::Members::Attributes::GetBorrowerAttributeValue($borrowernumber, "branchcode",1); #calling for an arrayref with all values.
+ my %borrower_branches;
+ foreach my $branchcode (@{$value}) {
+ $borrower_branches{$$branchcode[0]} = 1;
+ }
+ my $members = GetMember( 'borrowernumber' => $borrowernumber );
+ my $homebranch = $members->{'branchcode'};
+ $borrower_branches{$homebranch} = 1 if $homebranch;
+ if($ENV{'OPAC_SEARCH_LIMIT'} =~ m/^branch:(.*)/){
+ $borrower_branches{$1} = 1;
+ }
+ my @allowedbranches;
+ foreach my $branch (keys %borrower_branches) {
+ push @allowedbranches, $branch;
+ }
+ $query .= ' WHERE branchcode in (\''.join('\',\'',@allowedbranches).'\')';;
}
- $query.=" ORDER BY branchname";
+ $query.=" ORDER BY branchname";
$sth = $dbh->prepare($query);
$sth->execute( @bind_parameters );
--- a/C4/Koha.pm
+++ a/C4/Koha.pm
@@ -717,7 +717,7 @@ sub getFacets {
];
my $library_facet;
- unless ( C4::Context->preference("singleBranchMode") || GetBranchesCount() == 1 ) {
+ unless ( C4::Context->preference("singleBranchMode") || C4::Branch::GetBranchesCount() == 1 ) {
$library_facet = {
idx => 'branch',
label => 'Libraries',
@@ -779,7 +779,7 @@ sub getFacets {
];
my $library_facet;
- unless ( C4::Context->preference("singleBranchMode") || GetBranchesCount() == 1 ) {
+ unless ( C4::Context->preference("singleBranchMode") || C4::Branch::GetBranchesCount() == 1 ) {
$library_facet = {
idx => 'branch',
label => 'Libraries',
--- a/C4/Members/Attributes.pm
+++ a/C4/Members/Attributes.pm
@@ -118,24 +118,28 @@ sub GetAttributes {
=head2 GetBorrowerAttributeValue
- my $value = C4::Members::Attributes::GetBorrowerAttributeValue($borrowernumber, $attribute_code);
+ my $value = C4::Members::Attributes::GetBorrowerAttributeValue($borrowernumber, $attribute_code, $as_array);
Retrieve the value of an extended attribute C<$attribute_code> associated with the
-patron specified by C<$borrowernumber>.
+patron specified by C<$borrowernumber>. If $as_array is true, gets all available values, and returns it as an arrayref.
=cut
sub GetBorrowerAttributeValue {
my $borrowernumber = shift;
my $code = shift;
-
+ my $as_array = shift;
my $dbh = C4::Context->dbh();
my $query = "SELECT attribute
FROM borrower_attributes
WHERE borrowernumber = ?
AND code = ?";
- my $value = $dbh->selectrow_array($query, undef, $borrowernumber, $code);
- return $value;
+ if ($as_array){
+ return $dbh->selectall_arrayref($query,undef, $borrowernumber, $code);
+ } else {
+ my $value = $dbh->selectrow_array($query, undef, $borrowernumber, $code);
+ return $value;
+ }
}
=head2 SearchIdMatchingAttribute
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref
@@ -389,11 +389,13 @@ OPAC:
no: Allow
- patrons to select their branch on the OPAC or show branch names with callnumbers.
-
- - pref: SearchMyLibraryFirst
- choices:
- yes: Limit
- no: "Don't limit"
- - "patrons' searches to the library they are registered at."
+ - Search
+ - pref: SearchableBranches
+ choices:
+ all: All libraries
+ preferhome: Prefers patrons' home library (others may be searched)
+ securehome: Only patrons' home library and other assigned libraries (if any) can be searched
+ - Note, Other assigned libraries are only accessable by logged-in users. Otherwise, in Only mode, Home library is set via virtualhost option, and no other libraries are available. Multiple libraries can only be assigned when Multibranch is enabled, found in the Patron syspref page.
# -
# This system preference does not actually affect anything
# - pref: OpacBrowser
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref
@@ -91,6 +91,12 @@ Patrons:
class: integer
- characters long.
-
+ - pref: multibranch
+ choices:
+ yes: Enable
+ no: Disable
+ - assigning multiple branches to a patron.
+ -
- Show a notice that a patron is about to expire
- pref: NotifyBorrowerDeparture
class: integer
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref
@@ -78,6 +78,13 @@ Searching:
- "fields (separate values with |). Tabs appear in the order listed.
"
- "Currently supported values: Item types (itemtypes), Collection Codes (ccode) and Shelving Location (loc)."
-
+ - pref: MultiBranchSelect
+ type: boolean
+ choices:
+ yes: Show
+ no: "Don't show"
+ - 'a multibranch dropdown instead of single branch.'
+ -
- By default,
- pref: expandedSearchOption
type: boolean
--- a/koha-tmpl/opac-tmpl/prog/en/css/jquery.multiSelect.css
+++ a/koha-tmpl/opac-tmpl/prog/en/css/jquery.multiSelect.css
@@ -0,0 +1,85 @@
+a.multiSelect {
+ background: #FFF url(../../images/dropdown.blue.png) right center no-repeat;
+ border: solid 1px #BBB;
+ padding-right: 20px;
+ position: relative;
+ cursor: default;
+ text-decoration: none;
+ color: black;
+ display: -moz-inline-stack;
+ display: inline-block;
+ vertical-align: top;
+}
+
+a.multiSelect:link, a.multiSelect:visited, a.multiSelect:hover, a.multiSelect:active {
+ color: black;
+ text-decoration: none;
+}
+
+a.multiSelect span
+{
+ margin: 1px 0px 1px 3px;
+ overflow: hidden;
+ display: -moz-inline-stack;
+ display: inline-block;
+ white-space: nowrap;
+}
+
+a.multiSelect.hover {
+ background-image: url(../../images/dropdown.blue.hover.png);
+}
+
+a.multiSelect.active,
+a.multiSelect.focus {
+ border: inset 1px #000;
+}
+
+a.multiSelect.active {
+ background-image: url(../../images/dropdown.blue.active.png);
+}
+
+.multiSelectOptions {
+ margin-top: -1px;
+ overflow-y: auto;
+ overflow-x: hidden;
+ border: solid 1px #B2B2B2;
+ background: #FFF;
+}
+
+.multiSelectOptions LABEL {
+ padding: 0px 2px;
+ display: block;
+ white-space: nowrap;
+}
+
+.multiSelectOptions LABEL.optGroup
+{
+ font-weight: bold;
+}
+
+.multiSelectOptions .optGroupContainer LABEL
+{
+ padding-left: 10px;
+}
+
+.multiSelectOptions.optGroupHasCheckboxes .optGroupContainer LABEL
+{
+ padding-left: 18px;
+}
+
+.multiSelectOptions input{
+ vertical-align: middle;
+}
+
+.multiSelectOptions LABEL.checked {
+ background-color: #dce5f8;
+}
+
+.multiSelectOptions LABEL.selectAll {
+ border-bottom: dotted 1px #CCC;
+}
+
+.multiSelectOptions LABEL.hover {
+ background-color: #3399ff;
+ color: white;
+}
--- a/koha-tmpl/opac-tmpl/prog/en/js/jquery.bgiframe.min.js
+++ a/koha-tmpl/opac-tmpl/prog/en/js/jquery.bgiframe.min.js
@@ -0,0 +1,7 @@
+/*! Copyright (c) 2010 Brandon Aaron (http://brandonaaron.net)
+ * Licensed under the MIT License (LICENSE.txt).
+ *
+ * Version 2.1.3-pre
+ */
+
+(function($){$.fn.bgiframe=($.browser.msie&&/msie 6\.0/i.test(navigator.userAgent)?function(s){s=$.extend({top:'auto',left:'auto',width:'auto',height:'auto',opacity:true,src:'javascript:false;'},s);var html='';return this.each(function(){if($(this).children('iframe.bgiframe').length===0)this.insertBefore(document.createElement(html),this.firstChild)})}:function(){return this});$.fn.bgIframe=$.fn.bgiframe;function prop(n){return n&&n.constructor===Number?n+'px':n}})(jQuery);
--- a/koha-tmpl/opac-tmpl/prog/en/js/jquery.multiSelect.js
+++ a/koha-tmpl/opac-tmpl/prog/en/js/jquery.multiSelect.js
@@ -0,0 +1,554 @@
+/*
+// jQuery multiSelect
+//
+// Version 1.2.2 beta
+//
+// Cory S.N. LaViska
+// A Beautiful Site (http://abeautifulsite.net/)
+// 09 September 2009
+//
+// Visit http://abeautifulsite.net/notebook/62 for more information
+//
+// (Amended by Andy Richmond, Letters & Science Deans' Office, University of California, Davis)
+//
+// Usage: $('#control_id').multiSelect( options, callback )
+//
+// Options: selectAll - whether or not to display the Select All option; true/false, default = true
+// selectAllText - text to display for selecting/unselecting all options simultaneously
+// noneSelected - text to display when there are no selected items in the list
+// oneOrMoreSelected - text to display when there are one or more selected items in the list
+// (note: you can use % as a placeholder for the number of items selected).
+// Use * to show a comma separated list of all selected; default = '% selected'
+// optGroupSelectable - whether or not optgroups are selectable if you use them; true/false, default = false
+// listHeight - the max height of the droptdown options
+//
+// Dependencies: jQuery 1.2.6 or higher (http://jquery.com/)
+//
+// Change Log:
+//
+// 1.0.1 - Updated to work with jQuery 1.2.6+ (no longer requires the dimensions plugin)
+// - Changed $(this).offset() to $(this).position(), per James' and Jono's suggestions
+//
+// 1.0.2 - Fixed issue where dropdown doesn't scroll up/down with keyboard shortcuts
+// - Changed '$' in setTimeout to use 'jQuery' to support jQuery.noConflict
+// - Renamed from jqueryMultiSelect.* to jquery.multiSelect.* per the standard recommended at
+// http://docs.jquery.com/Plugins/Authoring (does not affect API methods)
+//
+// 1.0.3 - Now uses the bgiframe plugin (if it exists) to fix the IE6 layering bug.
+// - Forces IE6 to use a min-height of 200px (this needs to be added to the options)
+//
+// 1.1.0 - Added the ability to update the options dynamically via javascript: multiSelectOptionsUpdate(JSON)
+// - Added a title that displays the whole comma delimited list when using oneOrMoreSelected = *
+// - Moved some of the functions to be closured to make them private
+// - Changed the way the keyboard navigation worked to more closely match how a standard dropdown works
+// - ** by Andy Richmond **
+//
+// 1.2.0 - Added support for optgroups
+// - Added the ability for selectable optgroups (i.e. select all for an optgroup)
+// - ** by Andy Richmond **
+//
+// 1.2.1 - Fixed bug where input text overlapped dropdown arrow in IE (i.e. when using oneOrMoreSelected = *)
+// - Added option "listHeight" for min-height of the dropdown
+// - Fixed bug where bgiframe was causing a horizontal scrollbar and on short lists extra whitespace below the options
+// - ** by Andy Richmond **
+//
+// 1.2.2 - Fixed bug where the keypress stopped showing the dropdown because in jQuery 1.3.2 they changed the way ':visible' works
+// - Fixed some other bugs in the way the keyboard interface worked
+// - Changed the main textbox to an tag (with 'display: inline-block') to prevent the display text from being selected/highlighted
+// - Added the ability to jump to an option by typing the first character of that option (simular to a normal drop down)
+// - ** by Andy Richmond **
+// - Added [] to make each control submit an HTML array so $.serialize() works properly
+//
+// Licensing & Terms of Use
+//
+// This plugin is dual-licensed under the GNU General Public License and the MIT License and
+// is copyright 2008 A Beautiful Site, LLC.
+//
+*/
+if(jQuery) (function($){
+
+ // render the html for a single option
+ function renderOption(id, option)
+ {
+ var html = '';
+
+ return html;
+ }
+
+ // render the html for the options/optgroups
+ function renderOptions(id, options, o)
+ {
+ var html = "";
+
+ for(var i = 0; i < options.length; i++) {
+ if(options[i].optgroup) {
+ html += '