@@ -, +, @@ added --- opac/opac-suggestions.pl | 78 +++++++++++++++++++++++++++--------------------- 1 file changed, 44 insertions(+), 34 deletions(-) --- a/opac/opac-suggestions.pl +++ a/opac/opac-suggestions.pl @@ -112,36 +112,46 @@ if ( $op eq 'else' ) { } } -my $suggestions_loop = - &SearchSuggestion( $suggestion); +my $suggestions_loop = &SearchSuggestion($suggestion); if ( $op eq "add_confirm" ) { - my $count_own_suggestions = $borrowernumber ? &SearchSuggestion( { suggestedby => $borrowernumber}) : 0; - if( @$count_own_suggestions >= C4::Context->preference("MaxOpenSuggestions") ){ - push @messages, { type => 'error', code => 'too_many'}; + my $count_own_suggestions = $borrowernumber ? &SearchSuggestion( { suggestedby => $borrowernumber } ) : 0; + if ( @$count_own_suggestions >= C4::Context->preference("MaxOpenSuggestions") ) + { + push @messages, { type => 'error', code => 'too_many' }; } - elsif (@$suggestions_loop>=1){ - #some suggestion are answering the request Donot Add - for my $suggestion ( @$suggestions_loop ) { - push @messages, { type => 'error', code => 'already_exists', id => $suggestion->{suggestionid} }; + elsif ( @$suggestions_loop >= 1 ) { + + #some suggestion are answering the request Donot Add + for my $suggestion (@$suggestions_loop) { + push @messages, + { + type => 'error', + code => 'already_exists', + id => $suggestion->{suggestionid} + }; last; } - } - else { - my $scrubber = C4::Scrubber->new(); - foreach my $suggest (keys %$suggestion){ + } + else { + my $scrubber = C4::Scrubber->new(); + foreach my $suggest ( keys %$suggestion ) { + # Don't know why the encode is needed for Perl v5.10 here - $suggestion->{$suggest} = Encode::encode("utf8", $scrubber->scrub($suggestion->{$suggest}) ); - } + $suggestion->{$suggest} = Encode::encode( "utf8", + $scrubber->scrub( $suggestion->{$suggest} ) ); + } $suggestion->{suggesteddate} = dt_from_string; $suggestion->{branchcode} = $input->param('branchcode') || C4::Context->userenv->{"branch"}; - &NewSuggestion($suggestion); - # empty fields, to avoid filter in "SearchSuggestion" - $$suggestion{$_}='' foreach qw