@@ -, +, @@ borrower type --- 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(-) --- a/C4/Auth.pm +++ a/C4/Auth.pm @@ -499,6 +499,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( @@ -537,7 +543,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'), @@ -627,7 +633,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"), --- a/Koha/Patron/Category.pm +++ a/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 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref +++ a/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 suggestion:' + - pref: suggestionPatronCategoryExceptions + choices: patron-categories + class: multiple - - pref: OPACComments choices: --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc +++ a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc @@ -38,7 +38,7 @@ [% END %] [% END %] - [% IF Koha.Preference('suggestion') %] + [% IF ( suggestion ) %]