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

(-)a/C4/Items.pm (-2 / +22 lines)
Lines 1635-1640 sub GetHiddenItemnumbers { Link Here
1635
        return ();
1635
        return ();
1636
    }
1636
    }
1637
    my $dbh = C4::Context->dbh;
1637
    my $dbh = C4::Context->dbh;
1638
    my $userid = q{};
1639
    my $homebranch = q{};
1640
    if (C4::Context->userenv) {
1641
        $userid = C4::Context->userenv->{'id'} || q{};
1642
        $homebranch = C4::Context->userenv->{'branch'} || q{};
1643
    }
1644
    my $categorycode = q{};
1645
    if ($userid) {
1646
        my $sth = $dbh->prepare("SELECT categorycode FROM borrowers WHERE userid=?;");
1647
        $sth->execute($userid);
1648
        $categorycode = $sth->fetchrow;
1649
    }
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
                      $categorycode eq C4::Context->preference('PatronSingleBranch') ) ||
1672
                     $categorycode eq C4::Context->preference('PatronEveryBranch') ) {
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 428-430 INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) V Link Here
428
INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacHoldNotes',0,'Show hold notes on OPAC','','YesNo');
428
INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacHoldNotes',0,'Show hold notes on OPAC','','YesNo');
429
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('CalculateFinesOnReturn','1','Switch to control if overdue fines are calculated on return or not', '', 'YesNo');
429
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 ('AcqWarnOnDuplicateInvoice','0','Warn librarians when they try to create a duplicate invoice', '', 'YesNo');
430
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 ('PatronEveryBranch','PTEB','The patron category code which allows viewing hidden items for every branch','','');
432
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('PatronSingleBranch','PTSB',"The patron category code which allows viewing hidden items for only the patron's home branch",'','');
(-)a/installer/data/mysql/updatedatabase.pl (+16 lines)
Lines 7044-7049 if ( CheckVersion($DBversion) ) { Link Here
7044
    SetVersion($DBversion);
7044
    SetVersion($DBversion);
7045
}
7045
}
7046
7046
7047
$DBversion = "3.13.00.XXX";
7048
if ( CheckVersion($DBversion) ) {
7049
    $dbh->do(
7050
        q{
7051
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('PatronEveryBranch','PTEB',"The patron category code which allows viewing hidden items for every branch",'','');
7052
}
7053
    );
7054
    $dbh->do(
7055
        q{
7056
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('PatronSingleBranch','PTSB',"The patron category code which allows viewing hidden items for only the patron's home branch",'','');
7057
}
7058
    );
7059
    print "Upgrade to $DBversion done (Bug filtering: Patron Category to override OPACHiddenItems)\n";
7060
    SetVersion($DBversion);
7061
}
7062
7047
=head1 FUNCTIONS
7063
=head1 FUNCTIONS
7048
7064
7049
=head2 TableExists($table)
7065
=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 this patron category overrides OpacHiddenItems for their home branch only.
503
        -
504
            - pref: PatronEveryBranch
505
              class: short
506
            - Patrons matching this patron category overrides OpacHiddenItems for their every branch.
507
        -
500
            - pref: OpacAllowPublicListCreation
508
            - pref: OpacAllowPublicListCreation
501
              default: 1
509
              default: 1
502
              choices:
510
              choices:
503
- 

Return to bug 10589