From 6be1d2f76e1cdb3d6a2b4602165ffbf142747f66 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Fri, 5 May 2006 20:20:15 +0000 Subject: [PATCH] fixed captcha to work even in not htmlform environments added captch field to contact the maintainer form in matrix added default label to captcha --- docs/changelog/6.x.x.txt | 1 + lib/WebGUI/Asset/Wobject/Matrix.pm | 5 ++++- lib/WebGUI/Form/Captcha.pm | 10 ++++++++-- lib/WebGUI/i18n/English/Form_Captcha.pm | 5 +++++ 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/docs/changelog/6.x.x.txt b/docs/changelog/6.x.x.txt index 5aa98b764..e57632a96 100644 --- a/docs/changelog/6.x.x.txt +++ b/docs/changelog/6.x.x.txt @@ -54,6 +54,7 @@ template. (thanks to Jukka Raimovaara / Axxion Oy) - Added a screenshot feature to the matrix. - Added an option to delete Matrix fields. + - Added a captcha challenge to the contact the maintainer form in the matrix. - Added an API for retrieving email from POP3 servers. - The rebuildLineage.pl script now finds and fixes orphans, and tries to locate circular relationships as well. diff --git a/lib/WebGUI/Asset/Wobject/Matrix.pm b/lib/WebGUI/Asset/Wobject/Matrix.pm index f8c50911e..c07a343ee 100644 --- a/lib/WebGUI/Asset/Wobject/Matrix.pm +++ b/lib/WebGUI/Asset/Wobject/Matrix.pm @@ -1104,7 +1104,7 @@ sub www_viewDetail { } $var{"discussion"} = $forum->view; $var{'isLoggedIn'} = ($self->session->user->userId ne "1"); - if ($self->session->form->process("do") eq "sendEmail") { + if ($self->session->form->process("do") eq "sendEmail" && $self->session->form->process("verify","captcha")) { if ($self->session->form->process("body") ne "") { my $u = WebGUI::User->new($self->session, $listing->{maintainerId}); my $mail = WebGUI::Mail::Send->create($self->session, {to=>$u->profileField("email"),subject=>$listing->{productName}." - ".$self->session->form->process("subject"),from=>$self->session->form->process("from")}); @@ -1149,6 +1149,9 @@ sub www_viewDetail { -name=>"listingId", -value=>$listingId ); + $f->captcha( + -name=>"verify" + ); $f->email( -extras=>'class="content"', -name=>"from", diff --git a/lib/WebGUI/Form/Captcha.pm b/lib/WebGUI/Form/Captcha.pm index 2d3073378..7b17a299d 100644 --- a/lib/WebGUI/Form/Captcha.pm +++ b/lib/WebGUI/Form/Captcha.pm @@ -47,6 +47,10 @@ See the super class for additional details. The following additional parameters have been added via this sub class. +=head3 label + +Defaults to "Verify Your Humanity" + =head4 profileEnabled Flag that tells the User Profile system that this is a valid form element in a User Profile @@ -62,6 +66,9 @@ sub definition { formName=>{ defaultValue=>$i18n->get("topicName") }, + label => { + defaultValue=>$i18n->get("verify your humanity") + }, profileEnabled=>{ defaultValue=>0 }, @@ -100,8 +107,7 @@ sub toHtml { $self->set("size", 6); $self->set("maxlength", 6); $self->session->scratch->set("captcha_".$self->get("name"), $challenge); - $self->set("subtext", '

captcha

'.$self->get("subtext")); - return $self->SUPER::toHtml; + return $self->SUPER::toHtml.'

captcha

'; } 1; diff --git a/lib/WebGUI/i18n/English/Form_Captcha.pm b/lib/WebGUI/i18n/English/Form_Captcha.pm index 92b87cfb9..43b3e4b45 100644 --- a/lib/WebGUI/i18n/English/Form_Captcha.pm +++ b/lib/WebGUI/i18n/English/Form_Captcha.pm @@ -1,6 +1,11 @@ package WebGUI::i18n::English::Form_Captcha; our $I18N = { + 'verify your humanity' => { + message => q|Verify Your Humanity|, + lastUpdated => 1078852836 + }, + 'topicName' => { message => q|Captcha|, context => q|Captcha is an acronym, it cannot be translated.|,