Lines 33-43
use C4::Scrubber;
Link Here
|
33 |
use Koha::DateUtils qw( dt_from_string ); |
33 |
use Koha::DateUtils qw( dt_from_string ); |
34 |
|
34 |
|
35 |
my $input = new CGI; |
35 |
my $input = new CGI; |
36 |
my $allsuggestions = $input->param('showall'); |
|
|
37 |
my $op = $input->param('op'); |
36 |
my $op = $input->param('op'); |
38 |
my $suggestion = $input->Vars; |
37 |
my $suggestion = $input->Vars; |
39 |
delete $suggestion->{negcap}; |
38 |
delete $suggestion->{negcap}; |
40 |
my $negcaptcha = $input->param('negcap'); |
39 |
my $negcaptcha = $input->param('negcap'); |
|
|
40 |
my $suggested_by_anyone = $input->param('suggested_by_anyone') || 0; |
41 |
|
41 |
|
42 |
# If a spambot accidentally populates the 'negcap' field in the sugesstions form, then silently skip and return. |
42 |
# If a spambot accidentally populates the 'negcap' field in the sugesstions form, then silently skip and return. |
43 |
if ($negcaptcha ) { |
43 |
if ($negcaptcha ) { |
Lines 51-64
if ( ! C4::Context->preference('suggestion') ) {
Link Here
|
51 |
exit; |
51 |
exit; |
52 |
} |
52 |
} |
53 |
|
53 |
|
54 |
delete $$suggestion{$_} foreach qw<op suggestedbyme>; |
54 |
delete $suggestion->{$_} foreach qw<op suggested_by_anyone>; |
55 |
$op = 'else' unless $op; |
55 |
$op = 'else' unless $op; |
56 |
|
56 |
|
57 |
my ( $template, $borrowernumber, $cookie ); |
57 |
my ( $template, $borrowernumber, $cookie ); |
58 |
my $deleted = $input->param('deleted'); |
58 |
my $deleted = $input->param('deleted'); |
59 |
my $submitted = $input->param('submitted'); |
59 |
my $submitted = $input->param('submitted'); |
60 |
|
60 |
|
61 |
if ( C4::Context->preference("AnonSuggestions") ) { |
61 |
if ( C4::Context->preference("AnonSuggestions") or ( C4::Context->preference("OPACViewOthersSuggestions") and $op eq 'else' ) ) { |
62 |
( $template, $borrowernumber, $cookie ) = get_template_and_user( |
62 |
( $template, $borrowernumber, $cookie ) = get_template_and_user( |
63 |
{ |
63 |
{ |
64 |
template_name => "opac-suggestions.tt", |
64 |
template_name => "opac-suggestions.tt", |
Lines 67-75
if ( C4::Context->preference("AnonSuggestions") ) {
Link Here
|
67 |
authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ), |
67 |
authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ), |
68 |
} |
68 |
} |
69 |
); |
69 |
); |
70 |
if ( !$$suggestion{suggestedby} ) { |
|
|
71 |
$$suggestion{suggestedby} = C4::Context->preference("AnonymousPatron"); |
72 |
} |
73 |
} |
70 |
} |
74 |
else { |
71 |
else { |
75 |
( $template, $borrowernumber, $cookie ) = get_template_and_user( |
72 |
( $template, $borrowernumber, $cookie ) = get_template_and_user( |
Lines 81-93
else {
Link Here
|
81 |
} |
78 |
} |
82 |
); |
79 |
); |
83 |
} |
80 |
} |
84 |
if ($allsuggestions){ |
81 |
|
85 |
delete $$suggestion{suggestedby}; |
82 |
if ( $op eq 'else' ) { |
86 |
} |
83 |
if ( C4::Context->preference("OPACViewOthersSuggestions") ) { |
87 |
else { |
84 |
if ( $borrowernumber ) { |
88 |
$$suggestion{suggestedby} ||= $borrowernumber unless ($allsuggestions); |
85 |
# A logged in user is able to see suggestions from others |
|
|
86 |
$suggestion->{suggestedby} = $suggested_by_anyone |
87 |
? undef |
88 |
: $borrowernumber; |
89 |
} |
90 |
else { |
91 |
# Non logged in user is able to see all suggestions |
92 |
$suggestion->{suggestedby} = undef; |
93 |
} |
94 |
} |
95 |
else { |
96 |
if ( $borrowernumber ) { |
97 |
$suggestion->{suggestedby} = $borrowernumber; |
98 |
} |
99 |
else { |
100 |
$suggestion->{suggestedby} = -1; |
101 |
} |
102 |
} |
103 |
} else { |
104 |
if ( $borrowernumber ) { |
105 |
$suggestion->{suggestedby} = $borrowernumber; |
106 |
} |
107 |
else { |
108 |
$suggestion->{suggestedby} = C4::Context->preference("AnonymousPatron"); |
109 |
} |
89 |
} |
110 |
} |
90 |
# warn "bornum:",$borrowernumber; |
|
|
91 |
|
111 |
|
92 |
my $suggestions_loop = |
112 |
my $suggestions_loop = |
93 |
&SearchSuggestion( $suggestion); |
113 |
&SearchSuggestion( $suggestion); |
Lines 169-177
$template->param(
Link Here
|
169 |
itemtypeloop=> $supportlist, |
189 |
itemtypeloop=> $supportlist, |
170 |
suggestions_loop => $suggestions_loop, |
190 |
suggestions_loop => $suggestions_loop, |
171 |
patron_reason_loop => $patron_reason_loop, |
191 |
patron_reason_loop => $patron_reason_loop, |
172 |
showall => $allsuggestions, |
|
|
173 |
"op_$op" => 1, |
192 |
"op_$op" => 1, |
174 |
suggestionsview => 1, |
193 |
suggestionsview => 1, |
|
|
194 |
suggested_by_anyone => $suggested_by_anyone, |
175 |
); |
195 |
); |
176 |
|
196 |
|
177 |
output_html_with_http_headers $input, $cookie, $template->output; |
197 |
output_html_with_http_headers $input, $cookie, $template->output; |
178 |
- |
|
|