From 2142f539e05230e9ab3385be38510b16e4e20484 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Andr=C3=A9=20Santoni?= Date: Tue, 7 Jul 2009 10:46:24 +0200 Subject: [PATCH] (bug #2040) This prevent users to post empty suggestions, and post the same suggestion twice. This make the title field mandatory. And forces redirection to clear POST data. --- C4/Suggestions.pm | 20 +++++++++++--------- opac/opac-suggestions.pl | 2 ++ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/C4/Suggestions.pm b/C4/Suggestions.pm index 17325401ea..1f9daef177 100644 --- a/C4/Suggestions.pm +++ b/C4/Suggestions.pm @@ -331,15 +331,17 @@ Insert a new suggestion on database with value given on input arg. sub NewSuggestion { my ($borrowernumber,$title,$author,$publishercode,$note,$copyrightdate,$volumedesc,$publicationyear,$place,$isbn,$biblionumber,$reason) = @_; - my $dbh = C4::Context->dbh; - my $query = qq | - INSERT INTO suggestions - (status,suggestedby,title,author,publishercode,note,copyrightdate, - volumedesc,publicationyear,place,isbn,biblionumber,reason) - VALUES ('ASKED',?,?,?,?,?,?,?,?,?,?,?,?) - |; - my $sth = $dbh->prepare($query); - $sth->execute($borrowernumber,$title,$author,$publishercode,$note,$copyrightdate,$volumedesc,$publicationyear,$place,$isbn,$biblionumber,$reason); + if ($title) { + my $dbh = C4::Context->dbh; + my $query = qq | + INSERT INTO suggestions + (status,suggestedby,title,author,publishercode,note,copyrightdate, + volumedesc,publicationyear,place,isbn,biblionumber,reason) + VALUES ('ASKED',?,?,?,?,?,?,?,?,?,?,?,?) + |; + my $sth = $dbh->prepare($query); + $sth->execute($borrowernumber,$title,$author,$publishercode,$note,$copyrightdate,$volumedesc,$publicationyear,$place,$isbn,$biblionumber,$reason); + } } =head2 ModStatus diff --git a/opac/opac-suggestions.pl b/opac/opac-suggestions.pl index b739817c95..bef3e9f0a9 100755 --- a/opac/opac-suggestions.pl +++ b/opac/opac-suggestions.pl @@ -84,6 +84,8 @@ if ( $op eq "add_confirm" ) { $place = ''; $isbn = ''; $op = 'else'; + + print $input->redirect('/cgi-bin/koha/opac-suggestions.pl'); } if ( $op eq "delete_confirm" ) { -- 2.20.1