(bug #2040) This prevent users to post empty suggestions, and post the same suggestio...
authorJean-André Santoni <jeanandre.santoni@biblibre.com>
Tue, 7 Jul 2009 08:46:24 +0000 (10:46 +0200)
committerHenri-Damien LAURENT <henridamien.laurent@biblibre.com>
Mon, 13 Jul 2009 10:43:39 +0000 (12:43 +0200)
This make the title field mandatory. And forces redirection to clear POST data.

C4/Suggestions.pm
opac/opac-suggestions.pl

index 1732540..1f9daef 100644 (file)
@@ -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
index b739817..bef3e9f 100755 (executable)
@@ -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" ) {