Bug 10589 - Override OpacHiddenItems based on Patron Branch
Summary: Override OpacHiddenItems based on Patron Branch
Status: ASSIGNED
Alias: None
Product: Koha
Classification: Unclassified
Component: OPAC (show other bugs)
Version: master
Hardware: All All
: P5 - low enhancement (vote)
Target Milestone: ---
Assignee: M. Tompsett
QA Contact: Marcel de Rooy
URL:
Whiteboard:
Keywords:
Depends on: 10900 11592 14385 15777
Blocks:
  Show dependency treegraph
 
Reported: 2013-07-15 10:57 UTC by M. Tompsett
Modified: 2019-06-11 00:39 UTC (History)
11 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Bot Control: ---
When did the bot last check this: 2013-09-24 00:00:00
Who signed the patch off:
Text to go in the release notes:
Version(s) released in:


Attachments
Provide two system preferences to flexibly override OpacHiddenItems (6.01 KB, patch)
2013-07-15 11:28 UTC, M. Tompsett
Details | Diff | Splinter Review
Based on patron category unhide items hidden with OpacHiddenItems (6.09 KB, patch)
2013-07-17 03:13 UTC, M. Tompsett
Details | Diff | Splinter Review
Uses patron category to keep visible some things hidden by OPACHiddenItems (6.37 KB, patch)
2013-07-24 18:23 UTC, M. Tompsett
Details | Diff | Splinter Review
Using list of category codes OPACHiddenItems can be overridden (6.70 KB, patch)
2013-07-25 06:01 UTC, M. Tompsett
Details | Diff | Splinter Review
Using list of category codes OPACHiddenItems can be overridden (6.73 KB, patch)
2013-07-25 06:13 UTC, M. Tompsett
Details | Diff | Splinter Review
Provide two system preferences to flexibly override OpacHiddenItems (6.73 KB, patch)
2013-07-25 18:19 UTC, M. Tompsett
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 10589 - Override OpacHiddenItems based on Patron Category (6.76 KB, patch)
2013-07-26 00:06 UTC, Srdjan Jankovic
Details | Diff | Splinter Review
Bug 10589 - Override OpacHiddenItems based on Patron Category (7.79 KB, patch)
2013-09-13 01:13 UTC, M. Tompsett
Details | Diff | Splinter Review
Bug 10589 - Override OpacHiddenItems based on Patron Category (7.84 KB, patch)
2013-09-13 02:13 UTC, Srdjan Jankovic
Details | Diff | Splinter Review
Bug 10589 - Override OpacHiddenItems based on Patron Category (7.81 KB, patch)
2013-09-19 18:04 UTC, M. Tompsett
Details | Diff | Splinter Review
Bug 10589 - Override OpacHiddenItems based on Patron Category (7.85 KB, patch)
2013-09-30 02:38 UTC, Srdjan Jankovic
Details | Diff | Splinter Review
Bug 10589 - Override OpacHiddenItems based on Patron Category (7.83 KB, patch)
2013-10-30 12:53 UTC, M. Tompsett
Details | Diff | Splinter Review
Bug 10589 - Override OpacHiddenItems based on Patron Category (7.95 KB, patch)
2013-10-31 10:28 UTC, Marcel de Rooy
Details | Diff | Splinter Review
Bug 10589 - Override OpacHiddenItems based on Patron Category (7.97 KB, patch)
2014-08-14 17:45 UTC, Marc Véron
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 10589 - Override OpacHiddenItems based on Patron Category (8.03 KB, patch)
2014-08-15 01:18 UTC, Srdjan Jankovic
Details | Diff | Splinter Review
Bug 10589: local exceptions overriding OpacHiddenItems (26.93 KB, patch)
2018-11-19 18:49 UTC, M. Tompsett
Details | Diff | Splinter Review
Bug 10589: Unit tests of changes (2.44 KB, patch)
2018-11-19 18:49 UTC, M. Tompsett
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description M. Tompsett 2013-07-15 10:57:56 UTC
This patch will:
1) Add two system preferences: PatronSingleBranch and PatronEveryBranch.
2) Items which would normally be hidden by OpacHiddenItems will be visible if:
a) The patron's category code matches the PatronSingleBranch patron category code AND the home branch of the item is the same as the home branch of the patron.
OR
b) The patron's category code matches the PatronEveryBranch patron category code.

The two system preferences default to PTSB and PTEB which are not added to the list of possible patron categories. This means OpacHiddenItems will continue to function as is normally. Having them as system preferences means the patron category code is not hard coded and can be changed.
Comment 1 M. Tompsett 2013-07-15 11:28:29 UTC Comment hidden (obsolete)
Comment 2 M. Tompsett 2013-07-17 03:13:25 UTC Comment hidden (obsolete)
Comment 3 M. Tompsett 2013-07-24 18:23:25 UTC Comment hidden (obsolete)
Comment 4 Srdjan Jankovic 2013-07-25 04:38:36 UTC Comment hidden (obsolete)
Comment 5 M. Tompsett 2013-07-25 05:55:54 UTC Comment hidden (obsolete)
Comment 6 M. Tompsett 2013-07-25 06:01:17 UTC Comment hidden (obsolete)
Comment 7 M. Tompsett 2013-07-25 06:13:51 UTC Comment hidden (obsolete)
Comment 8 Srdjan Jankovic 2013-07-25 07:24:08 UTC Comment hidden (obsolete)
Comment 9 M. Tompsett 2013-07-25 18:19:33 UTC Comment hidden (obsolete)
Comment 10 Srdjan Jankovic 2013-07-25 23:11:32 UTC Comment hidden (obsolete)
Comment 11 Srdjan Jankovic 2013-07-26 00:06:28 UTC Comment hidden (obsolete)
Comment 12 M. Tompsett 2013-07-26 03:47:26 UTC Comment hidden (obsolete)
Comment 13 M. Tompsett 2013-09-13 01:13:20 UTC Comment hidden (obsolete)
Comment 14 M. Tompsett 2013-09-13 01:14:46 UTC Comment hidden (obsolete)
Comment 15 Srdjan Jankovic 2013-09-13 02:13:15 UTC Comment hidden (obsolete)
Comment 16 M. Tompsett 2013-09-19 18:04:00 UTC Comment hidden (obsolete)
Comment 17 I'm just a bot 2013-09-24 05:44:50 UTC Comment hidden (obsolete)
Comment 18 M. Tompsett 2013-09-24 06:17:55 UTC Comment hidden (obsolete)
Comment 19 Srdjan Jankovic 2013-09-30 02:38:32 UTC Comment hidden (obsolete)
Comment 20 M. Tompsett 2013-10-30 12:53:10 UTC Comment hidden (obsolete)
Comment 21 M. Tompsett 2013-10-30 12:53:57 UTC Comment hidden (obsolete)
Comment 22 Marcel de Rooy 2013-10-31 10:28:04 UTC Comment hidden (obsolete)
Comment 23 Marcel de Rooy 2013-10-31 10:38:56 UTC Comment hidden (obsolete)
Comment 24 Marcel de Rooy 2013-10-31 10:40:28 UTC Comment hidden (obsolete)
Comment 25 Chris Cormack 2013-12-27 00:55:30 UTC Comment hidden (obsolete)
Comment 26 Galen Charlton 2014-05-05 23:07:42 UTC Comment hidden (obsolete)
Comment 27 Manny Tamayao 2014-05-07 06:20:25 UTC
This patch will work perfectly with us in terms of managing our patrons that can view hidden materials.
We are a network of linguistic libraries located in different countries in South East Asia and we have materials that would need to be hidden from one library to another and we used OpacHiddenItems to manage this. It really works well with us in restricting general public and regular patrons in viewing hidden materials from the Opac. But since we have patrons who works in multiple countries that needs access to the hidden materials, once they logged in Opac they must have a privilege to view hidden materials.
Comment 28 Jane Pattison 2014-05-08 02:26:18 UTC
I second Manny's comments. Our situation with a variety of libraries spread throughout countries and yet connected in purpose is complicated. We have so appreciated Koha as a means to serve all these libraries. The upgrades and patches -- several headed up by Mark Tompsett (thanks Mark!) -- have been huge in our ability to serve our patrons. This particular patch would really help us in this unique situation in which we work.
Comment 29 Marc Véron 2014-08-14 17:45:35 UTC Comment hidden (obsolete)
Comment 30 Srdjan Jankovic 2014-08-15 01:18:37 UTC Comment hidden (obsolete)
Comment 31 Jonathan Druart 2014-09-05 14:58:17 UTC Comment hidden (obsolete)
Comment 32 M. Tompsett 2014-09-05 15:22:22 UTC Comment hidden (obsolete)
Comment 33 Jonathan Druart 2014-09-10 15:25:17 UTC Comment hidden (obsolete)
Comment 34 M. Tompsett 2014-09-10 22:12:02 UTC Comment hidden (obsolete)
Comment 35 M. Tompsett 2014-09-17 03:22:13 UTC Comment hidden (obsolete)
Comment 36 Marc Véron 2015-12-24 14:04:53 UTC Comment hidden (obsolete)
Comment 37 M. Tompsett 2016-02-12 15:16:36 UTC Comment hidden (obsolete)
Comment 38 M. Tompsett 2016-04-22 17:05:07 UTC Comment hidden (obsolete)
Comment 39 M. Tompsett 2016-04-22 18:04:25 UTC Comment hidden (obsolete)
Comment 40 M. Tompsett 2016-08-01 11:43:51 UTC Comment hidden (obsolete)
Comment 41 M. Tompsett 2017-06-28 02:55:34 UTC
The PatronEveryBranch is duplicate of bug 14385, but the PatronSingleBranch is a granularity which that bug lacks.
Comment 42 M. Tompsett 2017-08-01 15:46:06 UTC Comment hidden (obsolete)
Comment 43 M. Tompsett 2017-08-01 15:46:47 UTC Comment hidden (obsolete)
Comment 44 M. Tompsett 2018-11-19 18:49:33 UTC
Created attachment 82521 [details] [review]
Bug 10589: local exceptions overriding OpacHiddenItems

This patch adds the functionality change to C4/Items.pm
which allows to cross check the patron branch with the
item branch in addition to the local exception patron
category list.

This patch is large because is also merely adds
patron_branch to a series of function calls which
OpacHiddenItems affects.
Comment 45 M. Tompsett 2018-11-19 18:49:38 UTC
Created attachment 82522 [details] [review]
Bug 10589: Unit tests of changes

The core changes were in C4/Items.pm with
GetHiddenItemnumbers now processing logic against
a patron branch vs. an item's home branch and
does the patron have the local exception category.

This adds 4 tests to confirm those changes.

prove -v t/db_dependent/Items.t

If you apply just this, the tests should fail.
If you apply both patches, the tests should pass.
Comment 46 M. Tompsett 2018-11-19 19:26:02 UTC
Now that bug 14385 has been pushed to master, this patch will merely need to add a patron branch code to the passed parameter hash, so that logic can be added. A fuller test plan will come shortly.
Comment 47 Tomás Cohen Arazi 2019-03-06 10:53:27 UTC
Please take a look at bug 22454 and bug 22455. The rationale is that if you have the biblio object, you can know all that is needed regarding hiding in OPAC without fetching MARC data or complex calculations. And if we were to add parameters like category and library, I would rather pass the Koha::Patron object altogether.
This check, with bug 22457 in mind could be written:

my $should_hide = ( $patron->category->overrides_opac_hidding_policy or
                    $patron->library->overrides_opac_hidding_policy )
                ? 0
                : 1;

while ( my $biblio = $biblios->next ) {
 next if $biblio->hidden_in_opac and $should_hide;
 do_your_things();
}

This check should be written on the controller script.
Comment 48 M. Tompsett 2019-06-11 00:28:11 UTC
(In reply to Tomás Cohen Arazi from comment #47)
> Please take a look at bug 22454 and bug 22455. The rationale is that if you
> have the biblio object, you can know all that is needed regarding hiding in
> OPAC without fetching MARC data or complex calculations. And if we were to
> add parameters like category and library, I would rather pass the
> Koha::Patron object altogether.
> This check, with bug 22457 in mind could be written:
> 
> my $should_hide = ( $patron->category->overrides_opac_hidding_policy or
>                     $patron->library->overrides_opac_hidding_policy )
>                 ? 0
>                 : 1;
> 
> while ( my $biblio = $biblios->next ) {
>  next if $biblio->hidden_in_opac and $should_hide;
>  do_your_things();
> }
> 
> This check should be written on the controller script.

Doesn't quite work.

The idea is:
if (! defined $patron) {
    $globally_override = 0;
} elsif (! defined $patron->category) {
    $globally_override = 0;
} else {
    $globally_override = $patron->category->globally_overrides_opac_hiding;
}
while ( my $biblio = $bilbios->next ) {
    if (! defined $patron) {
        $locally_override = 0;
    } else {
        $locally_override = ($patron->branchcode ne $biblio->homebranch)
            ? 0
            : $patron->category->overrides_opac_hiding_policy_locally;
    }
    $should_show = $globally_override || $locally_override;
    $should_hide = ! $should_show;
    next if $biblio->hidden_in_opac && $should_hide;
    do_your_things();
}
Comment 49 M. Tompsett 2019-06-11 00:39:07 UTC
Doh! That doesn't quite work, because homebranch is on item. So, you want to pass patron to hidden_in_opac on items... Okay... Hmm... thinking....