[Bps-public-commit] r15357 - in RT-Extension-Captcha: . html/Callbacks/RT-Extension-Captcha/Ticket/Create.html html/Callbacks/RT-Extension-Captcha/Ticket/Update.html html/Elements lib/RT/Extension

ruz at bestpractical.com ruz at bestpractical.com
Fri Aug 22 04:34:50 EDT 2008


Author: ruz
Date: Fri Aug 22 04:34:50 2008
New Revision: 15357

Added:
   RT-Extension-Captcha/html/Callbacks/RT-Extension-Captcha/Ticket/Update.html/
   RT-Extension-Captcha/html/Callbacks/RT-Extension-Captcha/Ticket/Update.html/FormStart
   RT-Extension-Captcha/html/Callbacks/RT-Extension-Captcha/Ticket/Update.html/Initial
   RT-Extension-Captcha/html/Elements/
   RT-Extension-Captcha/html/Elements/Captcha
Modified:
   RT-Extension-Captcha/MANIFEST
   RT-Extension-Captcha/html/Callbacks/RT-Extension-Captcha/Ticket/Create.html/FormStart
   RT-Extension-Captcha/html/Callbacks/RT-Extension-Captcha/Ticket/Display.html/Initial
   RT-Extension-Captcha/lib/RT/Extension/Captcha.pm

Log:
* captcha on update(reply/comment)

Modified: RT-Extension-Captcha/MANIFEST
==============================================================================
--- RT-Extension-Captcha/MANIFEST	(original)
+++ RT-Extension-Captcha/MANIFEST	Fri Aug 22 04:34:50 2008
@@ -1,6 +1,10 @@
+html/Callbacks/RT-Extension-Captcha/index.html/Initial
 html/Callbacks/RT-Extension-Captcha/Ticket/Create.html/BeforeCreate
 html/Callbacks/RT-Extension-Captcha/Ticket/Create.html/FormStart
 html/Callbacks/RT-Extension-Captcha/Ticket/Display.html/Initial
+html/Callbacks/RT-Extension-Captcha/Ticket/Update.html/FormStart
+html/Callbacks/RT-Extension-Captcha/Ticket/Update.html/Initial
+html/Elements/Captcha
 html/Helpers/Captcha
 inc/Module/Install.pm
 inc/Module/Install/Base.pm

Modified: RT-Extension-Captcha/html/Callbacks/RT-Extension-Captcha/Ticket/Create.html/FormStart
==============================================================================
--- RT-Extension-Captcha/html/Callbacks/RT-Extension-Captcha/Ticket/Create.html/FormStart	(original)
+++ RT-Extension-Captcha/html/Callbacks/RT-Extension-Captcha/Ticket/Create.html/FormStart	Fri Aug 22 04:34:50 2008
@@ -1,14 +1,4 @@
-<div id="Ticket-Create-captcha">
-<a name="captcha"></a>
-
-<&| /Widgets/TitleBox, title => loc("You must solve a CAPTACHA to create a new ticket") &>
-
-<table border="0" cellpadding="0" cellspacing="0">
-<tr><td><img src="<% RT->Config->Get('WebURL') %>Helpers/Captcha" /></td>
-<td><input type="text" name="CaptchaString" /></td></tr>
-</table>
-
-</&>
+<div id="Ticket-Create-captcha"><a name="captcha"></a><& /Elements/Captcha &></div>
 <%ARGS>
 $ARGSRef => {}
 </%ARGS>

Modified: RT-Extension-Captcha/html/Callbacks/RT-Extension-Captcha/Ticket/Display.html/Initial
==============================================================================
--- RT-Extension-Captcha/html/Callbacks/RT-Extension-Captcha/Ticket/Display.html/Initial	(original)
+++ RT-Extension-Captcha/html/Callbacks/RT-Extension-Captcha/Ticket/Display.html/Initial	Fri Aug 22 04:34:50 2008
@@ -2,27 +2,50 @@
 $ARGSRef => {}
 </%ARGS>
 <%INIT>
-return unless ($ARGSRef->{'id'}||'') eq 'new';
+my ($is_create, $is_update);
+if ( ($ARGSRef->{'id'}||'') eq 'new' ) {
+    my $queue = RT::Queue->new( $session{'CurrentUser'} );
+    $queue->Load( $ARGSRef->{'Queue'} );
+    return unless $queue->id;
 
-my $queue = RT::Queue->new( $session{'CurrentUser'} );
-$queue->Load( $ARGSRef->{'Queue'} );
-return unless $queue->id;
-
-return if $queue->CurrentUserHasRight('NoCaptchaOnCreate');
+    return if $queue->CurrentUserHasRight('NoCaptchaOnCreate');
+    $is_create = 1;
+}
+elsif ( $ARGSRef->{'UpdateContent'} ) {
+    my $ticket = LoadTicket( $ARGSRef->{'id'} );
+    return if $ticket->CurrentUserHasRight('NoCaptchaOnUpdate');
+    $is_update = 1;
+}
+else {
+    return;
+}
 
 my ($captcha) = ($ARGSRef->{'CaptchaString'});
-
 if ( !$captcha || lc($captcha) ne lc($session{'Captcha'}{'String'}||'') ) {
     my $key = Digest::MD5::md5_hex( rand(1024) );
     push @{ $session{"Actions"}->{ $key } ||= [] },
         loc("You have to solve CAPTCHA");
     $session{'i'}++;
-    RT::Interface::Web::Redirect(
-        RT->Config->Get('WebURL')
-        ."Ticket/Create.html"
-        ."?Queue=". $m->interp->apply_escapes( $ARGSRef->{'Queue'}, 'u' )
-        ."&results=". $key
-    );
+
+    if ( $is_create ) {
+        RT::Interface::Web::Redirect(
+            RT->Config->Get('WebURL')
+            ."Ticket/Create.html"
+            ."?Queue=". $m->interp->apply_escapes( $ARGSRef->{'Queue'}, 'u' )
+            ."&results=". $key
+        );
+    }
+    elsif ( $is_update ) {
+        RT::Interface::Web::Redirect(
+            RT->Config->Get('WebURL')
+            ."Ticket/Update.html"
+            ."?id=". $m->interp->apply_escapes( $ARGSRef->{'id'}, 'u' )
+            ."&results=". $key
+        );
+    } else {
+        $RT::Logger->crit("Something wrong in captcha code");
+        return;
+    }
     return $m->abort;
 }
 

Added: RT-Extension-Captcha/html/Callbacks/RT-Extension-Captcha/Ticket/Update.html/FormStart
==============================================================================
--- (empty file)
+++ RT-Extension-Captcha/html/Callbacks/RT-Extension-Captcha/Ticket/Update.html/FormStart	Fri Aug 22 04:34:50 2008
@@ -0,0 +1,14 @@
+<div id="Ticket-Update-captcha"><a name="captcha"></a><& /Elements/Captcha &></div>
+<%ARGS>
+$ARGSRef => {}
+$Ticket  => undef
+</%ARGS>
+<%INIT>
+
+unless ( $Ticket ) {
+    $Ticket = LoadTicket( $ARGSRef->{'id'} );
+}
+return if $Ticket->CurrentUserHasRight('NoCaptchaOnUpdate');
+
+</%INIT>
+

Added: RT-Extension-Captcha/html/Callbacks/RT-Extension-Captcha/Ticket/Update.html/Initial
==============================================================================
--- (empty file)
+++ RT-Extension-Captcha/html/Callbacks/RT-Extension-Captcha/Ticket/Update.html/Initial	Fri Aug 22 04:34:50 2008
@@ -0,0 +1,28 @@
+<%ARGS>
+$ARGSRef => {}
+$Ticket
+$results => undef
+</%ARGS>
+<%INIT>
+return if $Ticket->CurrentUserHasRight('NoCaptchaOnUpdate');
+
+unless ( $results ) {
+    $results = $session{"Actions"}->{''} ||= [];
+}
+
+my ($captcha) = ($ARGSRef->{'CaptchaString'});
+unless ( $captcha ) {
+    push @$results, loc("You have to solve CAPTCHA");
+    delete $ARGSRef->{'SubmitTicket'};
+}
+elsif ( !$session{'Captcha'}{'String'} ) {
+    push @$results, loc("Don't play with me. You must solve CAPTCHA");
+    delete $ARGSRef->{'SubmitTicket'};
+}
+elsif ( lc($captcha) ne lc $session{'Captcha'}{'String'} ) {
+    delete $session{'Captcha'};
+    push @$results, loc("Not equal. Give you another CAPTCHA");
+    delete $ARGSRef->{'SubmitTicket'};
+}
+return;
+</%INIT>

Added: RT-Extension-Captcha/html/Elements/Captcha
==============================================================================
--- (empty file)
+++ RT-Extension-Captcha/html/Elements/Captcha	Fri Aug 22 04:34:50 2008
@@ -0,0 +1,12 @@
+
+<&| /Widgets/TitleBox, title => loc("You must solve a CAPTACHA to proceed") &>
+
+<table border="0" cellpadding="0" cellspacing="0">
+<tr><td><img src="<% RT->Config->Get('WebURL') %>Helpers/Captcha" /></td>
+<td><input type="text" name="CaptchaString" /></td></tr>
+</table>
+
+</&>
+
+<%ARGS>
+</%ARGS>

Modified: RT-Extension-Captcha/lib/RT/Extension/Captcha.pm
==============================================================================
--- RT-Extension-Captcha/lib/RT/Extension/Captcha.pm	(original)
+++ RT-Extension-Captcha/lib/RT/Extension/Captcha.pm	Fri Aug 22 04:34:50 2008
@@ -37,6 +37,7 @@
 
 use RT::Queue;
 $RT::Queue::RIGHTS->{'NoCaptchaOnCreate'} = "Don't ask user to solve a CAPTCHA on ticket create"; #loc_pair
+$RT::Queue::RIGHTS->{'NoCaptchaOnUpdate'} = "Don't ask user to solve a CAPTCHA on ticket reply or comment"; #loc_pair
 
 =head1 LICENSE
 



More information about the Bps-public-commit mailing list