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

(-)a/opac/opac-suggestions.pl (-9 / +18 lines)
Lines 43-54 use Koha::DateUtils qw( dt_from_string output_pref ); Link Here
43
my $input           = CGI->new;
43
my $input           = CGI->new;
44
my $op              = $input->param('op') || 'else';
44
my $op              = $input->param('op') || 'else';
45
my $biblionumber    = $input->param('biblionumber');
45
my $biblionumber    = $input->param('biblionumber');
46
my $suggestion      = $input->Vars;
47
my $negcaptcha      = $input->param('negcap');
46
my $negcaptcha      = $input->param('negcap');
48
my $suggested_by_anyone = $input->param('suggested_by_anyone') || 0;
47
my $suggested_by_anyone = $input->param('suggested_by_anyone') || 0;
49
my $title_filter    = $input->param('title_filter');
48
my $title_filter    = $input->param('title_filter');
50
my $need_confirm    = 0;
49
my $need_confirm    = 0;
51
50
51
my $suggestion = {
52
    title           => scalar $input->param('title'),
53
    author          => scalar $input->param('author'),
54
    copyrightdate   => scalar $input->param('copyrightdate'),
55
    isbn            => scalar $input->param('isbn'),
56
    publishercode   => scalar $input->param('publishercode'),
57
    collectiontitle => scalar $input->param('collectiontitle'),
58
    place           => scalar $input->param('place'),
59
    quantity        => scalar $input->param('quantity'),
60
    itemtype        => scalar $input->param('itemtype'),
61
    branchcode      => scalar $input->param('branchcode'),
62
    patronreason    => scalar $input->param('patronreason'),
63
    note            => scalar $input->param('note'),
64
};
65
52
# If a spambot accidentally populates the 'negcap' field in the sugesstions form, then silently skip and return.
66
# If a spambot accidentally populates the 'negcap' field in the sugesstions form, then silently skip and return.
53
if ($negcaptcha ) {
67
if ($negcaptcha ) {
54
    print $input->redirect("/cgi-bin/koha/opac-suggestions.pl");
68
    print $input->redirect("/cgi-bin/koha/opac-suggestions.pl");
Lines 85-95 else { Link Here
85
    );
99
    );
86
}
100
}
87
101
88
# don't pass 'negcap' column to DB, else DBI::Class will error
89
# DBIx::Class::Row::store_column(): No such column 'negcap' on Koha::Schema::Result::Suggestion at  Koha/C4/Suggestions.pm
90
delete $suggestion->{negcap};
91
delete $suggestion->{$_} foreach qw<op suggested_by_anyone confirm>;
92
93
if ( $op eq 'else' ) {
102
if ( $op eq 'else' ) {
94
    if ( C4::Context->preference("OPACViewOthersSuggestions") ) {
103
    if ( C4::Context->preference("OPACViewOthersSuggestions") ) {
95
        if ( $borrowernumber ) {
104
        if ( $borrowernumber ) {
Lines 157-168 if ( $op eq "add_confirm" ) { Link Here
157
    elsif ( @$suggestions_loop >= 1 ) {
166
    elsif ( @$suggestions_loop >= 1 ) {
158
167
159
        #some suggestion are answering the request Donot Add
168
        #some suggestion are answering the request Donot Add
160
        for my $suggestion (@$suggestions_loop) {
169
        for my $s (@$suggestions_loop) {
161
            push @messages,
170
            push @messages,
162
              {
171
              {
163
                type => 'error',
172
                type => 'error',
164
                code => 'already_exists',
173
                code => 'already_exists',
165
                id   => $suggestion->{suggestionid}
174
                id   => $s->{suggestionid}
166
              };
175
              };
167
            last;
176
            last;
168
        }
177
        }
Lines 177-182 if ( $op eq "add_confirm" ) { Link Here
177
        }
186
        }
178
        $suggestion->{suggesteddate} = dt_from_string;
187
        $suggestion->{suggesteddate} = dt_from_string;
179
        $suggestion->{branchcode} = $input->param('branchcode') || C4::Context->userenv->{"branch"};
188
        $suggestion->{branchcode} = $input->param('branchcode') || C4::Context->userenv->{"branch"};
189
        $suggestion->{STATUS} = 'ASKED';
180
190
181
        &NewSuggestion($suggestion);
191
        &NewSuggestion($suggestion);
182
        $patrons_pending_suggestions_count++;
192
        $patrons_pending_suggestions_count++;
183
- 

Return to bug 28941