|
Lines 36-41
use URI::Escape;
Link Here
|
| 36 |
use Business::ISBN; |
36 |
use Business::ISBN; |
| 37 |
use MARC::Record; |
37 |
use MARC::Record; |
| 38 |
use MARC::Field; |
38 |
use MARC::Field; |
|
|
39 |
use List::MoreUtils qw(none); |
| 39 |
use utf8; |
40 |
use utf8; |
| 40 |
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $DEBUG); |
41 |
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $DEBUG); |
| 41 |
|
42 |
|
|
Lines 301-306
sub SimpleSearch {
Link Here
|
| 301 |
$zoom_query->destroy(); |
302 |
$zoom_query->destroy(); |
| 302 |
} |
303 |
} |
| 303 |
|
304 |
|
|
|
305 |
if ( C4::Context->preference('IndependentBranchesRecordsAndItems') ) { |
| 306 |
my @new_results; |
| 307 |
my $dbh = C4::Context->dbh(); |
| 308 |
foreach my $result ( @{$results} ) { |
| 309 |
my $marc_record = MARC::Record->new_from_usmarc($result); |
| 310 |
my $koha_record = TransformMarcToKoha( $dbh, $marc_record ); |
| 311 |
my $is_allowed = $koha_record->{branchcode} ? GetIndependentGroupModificationRights( { for => $koha_record->{branchcode} } ) : 1; |
| 312 |
|
| 313 |
push( @new_results, $result ) if ( $is_allowed ); |
| 314 |
} |
| 315 |
$results = \@new_results; |
| 316 |
$total_hits = scalar( @new_results ); |
| 317 |
} |
| 318 |
|
| 304 |
return ( undef, $results, $total_hits ); |
319 |
return ( undef, $results, $total_hits ); |
| 305 |
} |
320 |
} |
| 306 |
|
321 |
|
|
Lines 1574-1579
sub buildQuery {
Link Here
|
| 1574 |
$limit .= "($availability_limit)"; |
1589 |
$limit .= "($availability_limit)"; |
| 1575 |
} |
1590 |
} |
| 1576 |
|
1591 |
|
|
|
1592 |
if ( C4::Context->preference('IndependentBranchesRecordsAndItems') ) { |
| 1593 |
my $search_context = C4::Context->userenv->{type}; |
| 1594 |
my $IndependentBranchesRecordsAndItems; |
| 1595 |
if ( $search_context eq 'opac' ) { |
| 1596 |
# For the OPAC, if IndependentBranchesRecordsAndItems is enabled, |
| 1597 |
# and BRANCHCODE has been set in the httpd conf, |
| 1598 |
# we need to filter the items |
| 1599 |
$IndependentBranchesRecordsAndItems = $ENV{BRANCHCODE}; |
| 1600 |
} |
| 1601 |
else { |
| 1602 |
# For the intranet, if IndependentBranchesRecordsAndItems is enabled, |
| 1603 |
# and the user is not a superlibrarian, |
| 1604 |
# we need to filter the items |
| 1605 |
$IndependentBranchesRecordsAndItems = !C4::Context->IsSuperLibrarian(); |
| 1606 |
} |
| 1607 |
my @allowed_branches = $IndependentBranchesRecordsAndItems ? GetIndependentGroupModificationRights() : (); |
| 1608 |
|
| 1609 |
if ( @allowed_branches ) { |
| 1610 |
$limit .= " and " if ( $query || $limit ); |
| 1611 |
$limit .= "(" . join( " or ", map { "branch:$_" } @allowed_branches ) . ")"; |
| 1612 |
} |
| 1613 |
} |
| 1614 |
|
| 1577 |
# Normalize the query and limit strings |
1615 |
# Normalize the query and limit strings |
| 1578 |
# This is flawed , means we can't search anything with : in it |
1616 |
# This is flawed , means we can't search anything with : in it |
| 1579 |
# if user wants to do ccl or cql, start the query with that |
1617 |
# if user wants to do ccl or cql, start the query with that |
|
Lines 1828-1841
sub searchResults {
Link Here
|
| 1828 |
my $maxitems = $maxitems_pref ? $maxitems_pref - 1 : 1; |
1866 |
my $maxitems = $maxitems_pref ? $maxitems_pref - 1 : 1; |
| 1829 |
my @hiddenitems; # hidden itemnumbers based on OpacHiddenItems syspref |
1867 |
my @hiddenitems; # hidden itemnumbers based on OpacHiddenItems syspref |
| 1830 |
|
1868 |
|
|
|
1869 |
my $IndependentBranchesRecordsAndItems; |
| 1870 |
if ( $search_context eq 'opac' ) { |
| 1871 |
# For the OPAC, if IndependentBranchesRecordsAndItems is enabled, |
| 1872 |
# and BRANCHCODE has been set in the httpd conf, |
| 1873 |
# we need to filter the items |
| 1874 |
$IndependentBranchesRecordsAndItems = |
| 1875 |
C4::Context->preference('IndependentBranchesRecordsAndItems') |
| 1876 |
&& $ENV{BRANCHCODE}; |
| 1877 |
} |
| 1878 |
else { |
| 1879 |
# For the intranet, if IndependentBranchesRecordsAndItems is enabled, |
| 1880 |
# and the user is not a superlibrarian, |
| 1881 |
# we need to filter the items |
| 1882 |
$IndependentBranchesRecordsAndItems = |
| 1883 |
C4::Context->preference('IndependentBranchesRecordsAndItems') |
| 1884 |
&& !C4::Context->IsSuperLibrarian(); |
| 1885 |
} |
| 1886 |
my @allowed_branches = $IndependentBranchesRecordsAndItems ? GetIndependentGroupModificationRights() : undef; |
| 1887 |
|
| 1831 |
# loop through every item |
1888 |
# loop through every item |
|
|
1889 |
my $index = -1; |
| 1832 |
foreach my $field (@fields) { |
1890 |
foreach my $field (@fields) { |
|
|
1891 |
$index++; |
| 1833 |
my $item; |
1892 |
my $item; |
| 1834 |
|
1893 |
|
| 1835 |
# populate the items hash |
1894 |
# populate the items hash |
| 1836 |
foreach my $code ( keys %subfieldstosearch ) { |
1895 |
foreach my $code ( keys %subfieldstosearch ) { |
| 1837 |
$item->{$code} = $field->subfield( $subfieldstosearch{$code} ); |
1896 |
$item->{$code} = $field->subfield( $subfieldstosearch{$code} ); |
| 1838 |
} |
1897 |
} |
|
|
1898 |
|
| 1899 |
# if IndependentBranchesRecordsAndItems is enabled, and this record |
| 1900 |
# isn't allowed to be viewed, remove it from the items list and go |
| 1901 |
# right to the next item. |
| 1902 |
if ( $IndependentBranchesRecordsAndItems ) { |
| 1903 |
if ( none { $_ eq $item->{homebranch} } @allowed_branches ) { |
| 1904 |
splice(@fields, $index, 1); |
| 1905 |
$items_count--; |
| 1906 |
next; |
| 1907 |
} |
| 1908 |
} |
| 1909 |
|
| 1839 |
$item->{description} = $itemtypes{ $item->{itype} }{description}; |
1910 |
$item->{description} = $itemtypes{ $item->{itype} }{description}; |
| 1840 |
|
1911 |
|
| 1841 |
# OPAC hidden items |
1912 |
# OPAC hidden items |