@@ -, +, @@ --- 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='