Bugzilla – Attachment 139113 Details for
Bug 31333
Add the ability to limit purchase suggestions by patron category
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31333: Add ability to make purchase suggestions by borrower type
Bug-31333-Add-ability-to-make-purchase-suggestions.patch (text/plain), 9.07 KB, created by
Alex Buckley
on 2022-08-15 07:28:23 UTC
(
hide
)
Description:
Bug 31333: Add ability to make purchase suggestions by borrower type
Filename:
MIME Type:
Creator:
Alex Buckley
Created:
2022-08-15 07:28:23 UTC
Size:
9.07 KB
patch
obsolete
>From 946c236eb37d3fe3ce457641896c2dd0527c05dc Mon Sep 17 00:00:00 2001 >From: Alex Buckley <alexbuckley@catalyst.net.nz> >Date: Tue, 9 Aug 2022 14:43:33 +0000 >Subject: [PATCH] Bug 31333: Add ability to make purchase suggestions by > borrower type > >Introduce a suggestionPatronCategoryExceptions system preference. > >If the suggestion syspref is enabled then libraries can stop specific >borrower types from making suggestions by ticking the type in the >suggestionPatronCategoryExceptions syspref. > >Test plan: >1. Apply patches, update database, re-start services > >2. Set 'suggestion' syspref = 'Allow' > >3. Confirm you can view the purchase suggestion links on OPAC biblio detail >page & 'your summary' page. As well as successfully submit a suggestion. > >4. Select the patron category you're logged in as in >suggestionPatronCategoryExceptions syspref > >5. Confirm the purchase suggestion links are hidden in the OPAC biblio >detail page & 'your summary' page > >6. In your browser enter the link: <OPAC base URL>/cgi-bin/koha/opac-suggestions.pl >e.g. http://localhost:8080/cgi-bin/koha/opac-suggestions.pl > >7. Confirm a 404 page loads > >8. Confirm you can view/moderate suggestions in the staff >client - even though your patron is selected in the >suggestionPatronCategoryExceptions syspref > >9. Untick your patron category in the suggestionPatronCategoryExceptions syspref > >10. Confirm you can view the purchase suggestion links on the OPAC, as >well as successfully submit a suggestion. > >11. Set 'suggestion' syspref = "Don't allow" > >12. Confirm the purchase suggestion links are hidden in the OPAC > >13. Select all patron categories in suggestPatronCategoryExceptions >syspref. View the OPAC without logging in and confirm you can perform >searches and view OPAC biblio detail pages. > >Sponsored-by: Catalyst IT, New Zealand >--- > C4/Auth.pm | 10 ++++++-- > Koha/Patron/Category.pm | 25 +++++++++++++++++++ > .../en/modules/admin/preferences/opac.pref | 7 +++++- > .../en/includes/opac-detail-sidebar.inc | 2 +- > .../bootstrap/en/includes/usermenu.inc | 2 +- > opac/opac-suggestions.pl | 12 ++++----- > 6 files changed, 47 insertions(+), 11 deletions(-) > >diff --git a/C4/Auth.pm b/C4/Auth.pm >index 7cf4c9dbc8d..277bd6b4460 100644 >--- a/C4/Auth.pm >+++ b/C4/Auth.pm >@@ -500,6 +500,12 @@ sub get_template_and_user { > > # these template parameters are set the same regardless of $in->{'type'} > >+ # Decide if the patron can make suggestions in the OPAC >+ my $can_make_suggestions; >+ if ( C4::Context->userenv && C4::Context->userenv->{'number'} ) { >+ $can_make_suggestions = Koha::Patrons->find(C4::Context->userenv->{'number'})->category->can_make_suggestions; >+ } >+ > my $minPasswordLength = C4::Context->preference('minPasswordLength'); > $minPasswordLength = 3 if not $minPasswordLength or $minPasswordLength < 3; > $template->param( >@@ -538,7 +544,7 @@ sub get_template_and_user { > intranetstylesheet => C4::Context->preference("intranetstylesheet"), > IntranetUserCSS => C4::Context->preference("IntranetUserCSS"), > IntranetUserJS => C4::Context->preference("IntranetUserJS"), >- suggestion => C4::Context->preference("suggestion"), >+ suggestion => $can_make_suggestions, > virtualshelves => C4::Context->preference("virtualshelves"), > StaffSerialIssueDisplayCount => C4::Context->preference("StaffSerialIssueDisplayCount"), > EasyAnalyticalRecords => C4::Context->preference('EasyAnalyticalRecords'), >@@ -628,7 +634,7 @@ sub get_template_and_user { > OpenLibrarySearch => C4::Context->preference("OpenLibrarySearch"), > ShowReviewer => C4::Context->preference("ShowReviewer"), > ShowReviewerPhoto => C4::Context->preference("ShowReviewerPhoto"), >- suggestion => "" . C4::Context->preference("suggestion"), >+ suggestion => $can_make_suggestions, > virtualshelves => "" . C4::Context->preference("virtualshelves"), > OPACSerialIssueDisplayCount => C4::Context->preference("OPACSerialIssueDisplayCount"), > SyndeticsClientCode => C4::Context->preference("SyndeticsClientCode"), >diff --git a/Koha/Patron/Category.pm b/Koha/Patron/Category.pm >index c6837ca00f2..39c56be14a7 100644 >--- a/Koha/Patron/Category.pm >+++ b/Koha/Patron/Category.pm >@@ -205,6 +205,31 @@ sub override_hidden_items { > split( /\|/, C4::Context->preference('OpacHiddenItemsExceptions') ); > } > >+=head3 can_make_suggestions >+ >+ >+ if ( $patron->category->can_make_suggestions ) { >+ ... >+ } >+ >+Returns if the OPAC logged-in user is allowed to make OPAC purchase suggestions. >+ >+=cut >+ >+sub can_make_suggestions { >+ my ( $self ) = @_; >+ >+ if ( C4::Context->preference('suggestion') ) { >+ my @patron_categories = split ',', C4::Context->preference('suggestionPatronCategoryExceptions'); >+ if ( @patron_categories ) { >+ my $categorycode = $self->categorycode; >+ return if grep {$_ eq $categorycode } @patron_categories; >+ } >+ return 1; >+ } >+ return; >+} >+ > =head2 Internal methods > > =head3 _library_limits >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >index c74d5c9d497..258a819458d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >@@ -427,7 +427,12 @@ OPAC: > choices: > 1: Allow > 0: "Don't allow" >- - patrons to make purchase suggestions on the OPAC. >+ - 'Patron categories allowed to make purchase suggestions on the OPAC:' >+ - >+ - 'Patron categories not affected by <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=suggestion">suggestion</a>:' >+ - pref: suggestionPatronCategoryExceptions >+ choices: patron-categories >+ class: multiple > - > - pref: OPACComments > choices: >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc >index a3cbb23590a..2602ad7502a 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc >@@ -38,7 +38,7 @@ > [% END %] > [% END %] > >- [% IF Koha.Preference('suggestion') %] >+ [% IF ( suggestion ) %] > <li><a class="suggest_for_purchase btn btn-link btn-lg" href="/cgi-bin/koha/opac-suggestions.pl?op=add&biblionumber=[% biblio.biblionumber | url %]"><i class="fa fa-fw fa-gift" aria-hidden="true"></i> Suggest for purchase</a></li> > [% END %] > >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/usermenu.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/usermenu.inc >index d172132cb74..1c23e011819 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/usermenu.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/usermenu.inc >@@ -83,7 +83,7 @@ > <a href="/cgi-bin/koha/opac-holdshistory.pl">your holds history</a></li> > [% END %] > >- [% IF Koha.Preference( 'suggestion' ) == 1 %] >+ [% IF ( suggestion ) %] > [% IF ( suggestionsview ) %] > <li class="active"> > [% ELSE %] >diff --git a/opac/opac-suggestions.pl b/opac/opac-suggestions.pl >index b2ab7609bc4..a9e2f2208c0 100755 >--- a/opac/opac-suggestions.pl >+++ b/opac/opac-suggestions.pl >@@ -69,12 +69,6 @@ if ($negcaptcha ) { > exit; > } > >-#If suggestions are turned off we redirect to 404 error. This will also redirect guest suggestions >-if ( ! C4::Context->preference('suggestion') ) { >- print $input->redirect("/cgi-bin/koha/errors/404.pl"); >- exit; >-} >- > my ( $template, $borrowernumber, $cookie, @messages ); > my $deleted = $input->param('deleted'); > my $submitted = $input->param('submitted'); >@@ -99,6 +93,12 @@ else { > ); > } > >+# If suggestions are turned off, or this patron belongs to a category not allowed to make suggestions (suggestionPatronCategoryExceptions syspref) we redirect to 404 error. This will also redirect guest suggestions >+if ( !Koha::Patrons->find( $borrowernumber )->category->can_make_suggestions ) { >+ print $input->redirect("/cgi-bin/koha/errors/404.pl"); >+ exit; >+} >+ > my $suggested_by; > if ( $op eq 'else' ) { > if ( C4::Context->preference("OPACViewOthersSuggestions") ) { >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 31333
:
139112
|
139113
|
139114
|
139165
|
139897
|
139898
|
139935
|
139936
|
140169
|
140170
|
140171
|
140172
|
140173
|
140174
|
140270
|
140271
|
140272
|
140273
|
140274
|
140275
|
140276
|
141392
|
141393