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

(-)a/C4/Auth.pm (-2 / +8 lines)
Lines 500-505 sub get_template_and_user { Link Here
500
500
501
    # these template parameters are set the same regardless of $in->{'type'}
501
    # these template parameters are set the same regardless of $in->{'type'}
502
502
503
    # Decide if the patron can make suggestions in the OPAC
504
    my $can_make_suggestions;
505
    if ( C4::Context->userenv && C4::Context->userenv->{'number'} ) {
506
        $can_make_suggestions = Koha::Patrons->find(C4::Context->userenv->{'number'})->category->can_make_suggestions;
507
    }
508
503
    my $minPasswordLength = C4::Context->preference('minPasswordLength');
509
    my $minPasswordLength = C4::Context->preference('minPasswordLength');
504
    $minPasswordLength = 3 if not $minPasswordLength or $minPasswordLength < 3;
510
    $minPasswordLength = 3 if not $minPasswordLength or $minPasswordLength < 3;
505
    $template->param(
511
    $template->param(
Lines 538-544 sub get_template_and_user { Link Here
538
            intranetstylesheet                                                         => C4::Context->preference("intranetstylesheet"),
544
            intranetstylesheet                                                         => C4::Context->preference("intranetstylesheet"),
539
            IntranetUserCSS                                                            => C4::Context->preference("IntranetUserCSS"),
545
            IntranetUserCSS                                                            => C4::Context->preference("IntranetUserCSS"),
540
            IntranetUserJS                                                             => C4::Context->preference("IntranetUserJS"),
546
            IntranetUserJS                                                             => C4::Context->preference("IntranetUserJS"),
541
            suggestion                                                                 => C4::Context->preference("suggestion"),
547
            suggestion                                                                 => $can_make_suggestions,
542
            virtualshelves                                                             => C4::Context->preference("virtualshelves"),
548
            virtualshelves                                                             => C4::Context->preference("virtualshelves"),
543
            StaffSerialIssueDisplayCount                                               => C4::Context->preference("StaffSerialIssueDisplayCount"),
549
            StaffSerialIssueDisplayCount                                               => C4::Context->preference("StaffSerialIssueDisplayCount"),
544
            EasyAnalyticalRecords                                                      => C4::Context->preference('EasyAnalyticalRecords'),
550
            EasyAnalyticalRecords                                                      => C4::Context->preference('EasyAnalyticalRecords'),
Lines 628-634 sub get_template_and_user { Link Here
628
            OpenLibrarySearch                     => C4::Context->preference("OpenLibrarySearch"),
634
            OpenLibrarySearch                     => C4::Context->preference("OpenLibrarySearch"),
629
            ShowReviewer                          => C4::Context->preference("ShowReviewer"),
635
            ShowReviewer                          => C4::Context->preference("ShowReviewer"),
630
            ShowReviewerPhoto                     => C4::Context->preference("ShowReviewerPhoto"),
636
            ShowReviewerPhoto                     => C4::Context->preference("ShowReviewerPhoto"),
631
            suggestion                            => "" . C4::Context->preference("suggestion"),
637
            suggestion                            => $can_make_suggestions,
632
            virtualshelves                        => "" . C4::Context->preference("virtualshelves"),
638
            virtualshelves                        => "" . C4::Context->preference("virtualshelves"),
633
            OPACSerialIssueDisplayCount           => C4::Context->preference("OPACSerialIssueDisplayCount"),
639
            OPACSerialIssueDisplayCount           => C4::Context->preference("OPACSerialIssueDisplayCount"),
634
            SyndeticsClientCode                   => C4::Context->preference("SyndeticsClientCode"),
640
            SyndeticsClientCode                   => C4::Context->preference("SyndeticsClientCode"),
(-)a/Koha/Patron/Category.pm (+25 lines)
Lines 205-210 sub override_hidden_items { Link Here
205
    split( /\|/, C4::Context->preference('OpacHiddenItemsExceptions') );
205
    split( /\|/, C4::Context->preference('OpacHiddenItemsExceptions') );
206
}
206
}
207
207
208
=head3 can_make_suggestions
209
210
211
    if ( $patron->category->can_make_suggestions ) {
212
        ...
213
    }
214
215
Returns if the OPAC logged-in user is allowed to make OPAC purchase suggestions.
216
217
=cut
218
219
sub can_make_suggestions {
220
    my ( $self ) = @_;
221
222
    if ( C4::Context->preference('suggestion') ) {
223
        my @patron_categories = split ',', C4::Context->preference('suggestionPatronCategoryExceptions');
224
        if ( @patron_categories ) {
225
            my $categorycode = $self->categorycode;
226
            return if grep {$_ eq $categorycode } @patron_categories;
227
        }
228
        return 1;
229
    }
230
    return;
231
}
232
208
=head2 Internal methods
233
=head2 Internal methods
209
234
210
=head3 _library_limits
235
=head3 _library_limits
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref (-1 / +6 lines)
Lines 427-433 OPAC: Link Here
427
              choices:
427
              choices:
428
                  1: Allow
428
                  1: Allow
429
                  0: "Don't allow"
429
                  0: "Don't allow"
430
            - patrons to make purchase suggestions on the OPAC.
430
            - 'Patron categories allowed to make purchase suggestions on the OPAC:'
431
        -
432
            - 'Patron categories not affected by <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=suggestion">suggestion</a>:'
433
            - pref: suggestionPatronCategoryExceptions
434
              choices: patron-categories
435
              class: multiple
431
        -
436
        -
432
            - pref: OPACComments
437
            - pref: OPACComments
433
              choices:
438
              choices:
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc (-1 / +1 lines)
Lines 38-44 Link Here
38
        [% END %]
38
        [% END %]
39
    [% END %]
39
    [% END %]
40
40
41
    [% IF Koha.Preference('suggestion') %]
41
    [% IF ( suggestion ) %]
42
        <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>
42
        <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>
43
    [% END %]
43
    [% END %]
44
44
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/usermenu.inc (-1 / +1 lines)
Lines 83-89 Link Here
83
                <a href="/cgi-bin/koha/opac-holdshistory.pl">your holds history</a></li>
83
                <a href="/cgi-bin/koha/opac-holdshistory.pl">your holds history</a></li>
84
            [% END %]
84
            [% END %]
85
85
86
            [% IF Koha.Preference( 'suggestion' ) == 1 %]
86
            [% IF ( suggestion ) %]
87
                [% IF ( suggestionsview ) %]
87
                [% IF ( suggestionsview ) %]
88
                    <li class="active">
88
                    <li class="active">
89
                [% ELSE %]
89
                [% ELSE %]
(-)a/opac/opac-suggestions.pl (-7 / +6 lines)
Lines 69-80 if ($negcaptcha ) { Link Here
69
    exit;
69
    exit;
70
}
70
}
71
71
72
#If suggestions are turned off we redirect to 404 error. This will also redirect guest suggestions
73
if ( ! C4::Context->preference('suggestion') ) {
74
    print $input->redirect("/cgi-bin/koha/errors/404.pl");
75
    exit;
76
}
77
78
my ( $template, $borrowernumber, $cookie, @messages );
72
my ( $template, $borrowernumber, $cookie, @messages );
79
my $deleted = $input->param('deleted');
73
my $deleted = $input->param('deleted');
80
my $submitted = $input->param('submitted');
74
my $submitted = $input->param('submitted');
Lines 99-104 else { Link Here
99
    );
93
    );
100
}
94
}
101
95
96
# 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
97
if ( !Koha::Patrons->find( $borrowernumber )->category->can_make_suggestions ) {
98
    print $input->redirect("/cgi-bin/koha/errors/404.pl");
99
    exit;
100
}
101
102
my $suggested_by;
102
my $suggested_by;
103
if ( $op eq 'else' ) {
103
if ( $op eq 'else' ) {
104
    if ( C4::Context->preference("OPACViewOthersSuggestions") ) {
104
    if ( C4::Context->preference("OPACViewOthersSuggestions") ) {
105
- 

Return to bug 31333