View | Details | Raw Unified | Return to bug 10589
Collapse All | Expand All

(-)a/C4/Items.pm (-2 / +22 lines)
Lines 32-37 use C4::Log; Link Here
32
use List::MoreUtils qw/any/;
32
use List::MoreUtils qw/any/;
33
use Data::Dumper; # used as part of logging item record changes, not just for
33
use Data::Dumper; # used as part of logging item record changes, not just for
34
                  # debugging; so please don't remove this
34
                  # debugging; so please don't remove this
35
use C4::Members qw/GetBorrowerCategorycode/;
35
36
36
use vars qw($VERSION @ISA @EXPORT);
37
use vars qw($VERSION @ISA @EXPORT);
37
38
Lines 1635-1640 sub GetHiddenItemnumbers { Link Here
1635
        return ();
1636
        return ();
1636
    }
1637
    }
1637
    my $dbh = C4::Context->dbh;
1638
    my $dbh = C4::Context->dbh;
1639
    my $borrowernumber = 0;
1640
    my $homebranch = q{};
1641
    if (C4::Context->userenv) {
1642
        $borrowernumber = C4::Context->userenv->{'number'} || 0;
1643
        $homebranch = C4::Context->userenv->{'branch'} || q{};
1644
    }
1645
    if ($borrowernumber) {
1646
        my $categorycode = C4::Members::GetBorrowerCategorycode($borrowernumber) || q{};
1647
    }
1648
    my @SingleBranchCodes = split /\|/,C4::Context->preference('PatronSingleBranch');
1649
    my @EveryBranchCodes = split /\|/,C4::Context->preference('PatronEveryBranch');
1638
1650
1639
    # For each item
1651
    # For each item
1640
    foreach my $item (@items) {
1652
    foreach my $item (@items) {
Lines 1654-1661 sub GetHiddenItemnumbers { Link Here
1654
            # If the results matches the values in the yaml file
1666
            # If the results matches the values in the yaml file
1655
            if (any { $val eq $_ } @{$hidingrules->{$field}}) {
1667
            if (any { $val eq $_ } @{$hidingrules->{$field}}) {
1656
1668
1657
                # We add the itemnumber to the list
1669
                my $override = 0;
1658
                push @resultitems, $item->{'itemnumber'};
1670
                if ( ($homebranch eq $item->{'homebranch'} &&
1671
                      grep( /^$categorycode$/, @SingleBranchCodes ) ) ||
1672
                     grep( /^$categorycode$/, @EveryBranchCodes ) ) {
1673
                    $override = 1;
1674
                }
1675
                if ($override==0) {
1676
                    # We add the itemnumber to the hidden list
1677
                    push @resultitems, $item->{'itemnumber'};
1678
                }
1659
1679
1660
                # If at least one rule matched for an item, no need to test the others
1680
                # If at least one rule matched for an item, no need to test the others
1661
                last;
1681
                last;
(-)a/installer/data/mysql/sysprefs.sql (+2 lines)
Lines 430-432 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) V Link Here
430
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('CalculateFinesOnReturn','1','Switch to control if overdue fines are calculated on return or not', '', 'YesNo');
430
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('CalculateFinesOnReturn','1','Switch to control if overdue fines are calculated on return or not', '', 'YesNo');
431
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('AcqWarnOnDuplicateInvoice','0','Warn librarians when they try to create a duplicate invoice', '', 'YesNo');
431
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('AcqWarnOnDuplicateInvoice','0','Warn librarians when they try to create a duplicate invoice', '', 'YesNo');
432
INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('AllowTooManyOverride', '1', 'If on, allow staff to override and check out items when the patron has reached the maximum number of allowed checkouts', '', 'YesNo');
432
INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('AllowTooManyOverride', '1', 'If on, allow staff to override and check out items when the patron has reached the maximum number of allowed checkouts', '', 'YesNo');
433
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('PatronEveryBranch','PTEB','Pipe delimited patron category codes which allow viewing hidden items for every branch','','');
434
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('PatronSingleBranch','PTSB',"Pipe delimited patron category codes which allow viewing hidden items for only the patron's home branch",'','');
(-)a/installer/data/mysql/updatedatabase.pl (+16 lines)
Lines 7067-7072 if ( CheckVersion($DBversion) ) { Link Here
7067
    SetVersion($DBversion);
7067
    SetVersion($DBversion);
7068
}
7068
}
7069
7069
7070
$DBversion = "3.13.00.XXX";
7071
if ( CheckVersion($DBversion) ) {
7072
    $dbh->do(
7073
        q{
7074
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('PatronEveryBranch','PTEB',"Pipe delimited patron category codes which allow viewing hidden items for every branch",'','');
7075
}
7076
    );
7077
    $dbh->do(
7078
        q{
7079
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('PatronSingleBranch','PTSB',"Pipe delimited patron category codes which allow viewing hidden items for only the patron's home branch",'','');
7080
}
7081
    );
7082
    print "Upgrade to $DBversion done (Bug filtering: Patron Category to override OPACHiddenItems)\n";
7083
    SetVersion($DBversion);
7084
}
7085
7070
=head1 FUNCTIONS
7086
=head1 FUNCTIONS
7071
7087
7072
=head2 TableExists($table)
7088
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref (-1 / +8 lines)
Lines 497-502 OPAC: Link Here
497
              class: code
497
              class: code
498
            - Allows to define custom rules for hiding specific items at opac. See docs/opac/OpacHiddenItems.txt for more informations
498
            - Allows to define custom rules for hiding specific items at opac. See docs/opac/OpacHiddenItems.txt for more informations
499
        -
499
        -
500
            - pref: PatronSingleBranch
501
              class: short
502
            - Patrons matching one of these pipe delimited patron category codes override OpacHiddenItems for their home branch only.
503
        -
504
            - pref: PatronEveryBranch
505
              class: short
506
            - Patrons matching one of these pipe delimited patron category codes override OpacHiddenItems for every branch.
507
        -
500
            - pref: OpacAllowPublicListCreation
508
            - pref: OpacAllowPublicListCreation
501
              default: 1
509
              default: 1
502
              choices:
510
              choices:
503
- 

Return to bug 10589