@@ -, +, @@ --- installer/data/mysql/en/mandatory/sysprefs.sql | 4 ++ installer/data/mysql/updatedatabase.pl | 9 +++++ .../prog/en/modules/opac-suggestions.tmpl | 1 + opac/opac-suggestions.pl | 33 ++++++++++++++++++-- 4 files changed, 44 insertions(+), 3 deletions(-) --- a/installer/data/mysql/en/mandatory/sysprefs.sql +++ a/installer/data/mysql/en/mandatory/sysprefs.sql @@ -215,3 +215,7 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES(' INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('MergeAuthoritiesOnUpdate', '1', 'if ON, Updating authorities will automatically updates biblios',NULL,'YesNo'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AllowNotForLoanOverride', '0', 'if ON, enables the librarian to choose when they want to check out a notForLoan regular item',NULL,'YesNo'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('RenewalPeriodBase', 'date_due', 'Set whether the renewal date should be counted from the date_due or from the moment the Patron asks for renewal ','date_due|now','Choice'); + +INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('Mollom',0,'Turn ON Mollom antispam for anonimous suggestions - You MUST set MollomPublicKey and MollomPrivateKey if enabled','','YesNo'); +INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('MollomPublicKey','','See: http://mollom.com','','free'); +INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('MollomPrivateKey','','See: http://mollom.com','','free'); --- a/installer/data/mysql/updatedatabase.pl +++ a/installer/data/mysql/updatedatabase.pl @@ -1965,6 +1965,15 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('ILS-DI','0','if ON, ILS-DI server is enabled',NULL,'YesNo');"); SetVersion ($DBversion); } + +$DBversion = "3.01.00.039"; +if (C4::Context->preference("Version") < TransformToNum($DBversion)) { + $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('Mollom',0,'Turn ON Mollom antispam for anonimous suggestions - You MUST set MollomPublicKey and MollomPrivateKey if enabled','','YesNo');"); + $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('MollomPublicKey','','See: http://mollom.com','','free');"); + $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('MollomPrivateKey','','See: http://mollom.com','','free');"); + SetVersion ($DBversion); +} + if (C4::Context->preference("Version") =~/3\.00/) { warn "inside 3.00"; my $perllibdir=C4::Context->config('intranetdir'); --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-suggestions.tmpl +++ a/koha-tmpl/opac-tmpl/prog/en/modules/opac-suggestions.tmpl @@ -73,6 +73,7 @@ $.tablesorter.addParser({

My Purchase Suggestions

+ Sorry, your suggestion has been considered as spam. Please login to your account and try again.
--- a/opac/opac-suggestions.pl +++ a/opac/opac-suggestions.pl @@ -23,6 +23,7 @@ use C4::Auth; # get_template_and_user use C4::Branch; use C4::Output; use C4::Suggestions; +use Net::Mollom; my $input = new CGI; my $title = $input->param('title'); @@ -67,13 +68,12 @@ else { ); } -if ( $op eq "add_confirm" ) { +sub create_suggestion { &NewSuggestion( $borrowernumber, $title, $author, $publishercode, $note, $copyrightdate, $volumedesc, $publicationyear, $place, $isbn, '' ); - # empty fields, to avoid filter in "SearchSuggestion" $title = ''; $author = ''; @@ -86,6 +86,33 @@ if ( $op eq "add_confirm" ) { $op = 'else'; } +if ( $op eq "add_confirm" ) { + # If antispam is enabled and user not logged + if (C4::Context->preference('Mollom') + and $borrowernumber == C4::Context->preference("AnonSuggestions")) { + # Instanciates Mollom Antispam + my $mollom = Net::Mollom->new( + 'public_key' => C4::Context->preference("MollomPublicKey"), + 'private_key' => C4::Context->preference("MollomPrivateKey"), + ); + # Checks the suggestion content + my $check = $mollom->check_content( + post_title => $title, + post_body => $author . ' ' . $publishercode . ' ' . $note + ); + # You can add a $check->is_unsure case to display a captcha + if ($check->is_ham) { + create_suggestion; + } else { + $template->param(spam => 1); + $op = 'else'; + } + # If the user is logged or antispam is turned off, create the suggestion + } else { + create_suggestion; + } +} + if ( $op eq "delete_confirm" ) { my @delete_field = $input->param("delete_field"); foreach my $delete_field (@delete_field) { @@ -106,7 +133,7 @@ $template->param( status => $status, suggestedbyme => $suggestedbyme, "op_$op" => 1, - suggestionsview => 1 + suggestionsview => 1 ); output_html_with_http_headers $input, $cookie, $template->output; --