|
From: <ssc...@us...> - 2003-04-30 05:46:50
|
Update of /cvsroot/popfile/engine/UI
In directory sc8-pr-cvs1:/tmp/cvs-serv8285
Modified Files:
HTML.pm
Log Message:
Fixes deletion bug by redirecting to a safe URL from any non-idempotent pages.
Also adds a method for printing multiple form fields (correctly omits them if they have no value)
[ 699073 ] prevent repeated message deletion
Index: HTML.pm
===================================================================
RCS file: /cvsroot/popfile/engine/UI/HTML.pm,v
retrieving revision 1.146
retrieving revision 1.147
diff -C2 -d -r1.146 -r1.147
*** HTML.pm 27 Apr 2003 01:08:13 -0000 1.146
--- HTML.pm 30 Apr 2003 05:46:46 -0000 1.147
***************
*** 2302,2306 ****
$body .= "[<a href=\"/history?start_message=";
$body .= $start_message - $self->config_( 'page_size' );
! $body .= "&session=$self->{session_key__}&sort=$self->{form_}{sort}&search=$self->{form_}{search}&filter=$self->{form_}{filter}\">< $self->{language__}{Previous}</a>] ";
}
my $i = 0;
--- 2302,2306 ----
$body .= "[<a href=\"/history?start_message=";
$body .= $start_message - $self->config_( 'page_size' );
! $body .= $self->print_form_fields_(0,1,('session','filter','search','sort')) . "\">< $self->{language__}{Previous}</a>] ";
}
my $i = 0;
***************
*** 2310,2314 ****
$body .= $i+1 . "</b>";
} else {
! $body .= "[<a href=\"/history?start_message=$i&session=$self->{session_key__}&search=$self->{form_}{search}&sort=$self->{form_}{sort}&filter=$self->{form_}{filter}\">";
$body .= $i+1 . "</a>]";
}
--- 2310,2314 ----
$body .= $i+1 . "</b>";
} else {
! $body .= "[<a href=\"/history?start_message=$i" . $self->print_form_fields_(0,1,('session','filter','search','sort')). "\">";
$body .= $i+1 . "</a>]";
}
***************
*** 2320,2324 ****
$body .= "[<a href=\"/history?start_message=";
$body .= $start_message + $self->config_( 'page_size' );
! $body .= "&session=$self->{session_key__}&sort=$self->{form_}{sort}&search=$self->{form_}{search}&filter=$self->{form_}{filter}\">$self->{language__}{Next} ></a>]";
}
--- 2320,2324 ----
$body .= "[<a href=\"/history?start_message=";
$body .= $start_message + $self->config_( 'page_size' );
! $body .= $self->print_form_fields_(0,1,('session','filter','search','sort')) . "\">$self->{language__}{Next} ></a>]";
}
***************
*** 2716,2719 ****
--- 2716,2729 ----
( defined( $self->{form_}{clearall} ) ) ||
( defined( $self->{form_}{clearpage} ) ) );
+
+ # Redirect somewhere safe if non-idempotent action has been taken
+
+ if ( defined( $self->{form_}{deletemessage} ) ||
+ defined( $self->{form_}{clearpage} ) ||
+ defined( $self->{form_}{undo} ) ||
+ defined( $self->{form_}{reclassify} ) ) {
+ return $self->http_redirect_( $client, "/history?" . $self->print_form_fields_(1,0,('start_message','filter','search','sort','session') ) );
+ }
+
my $body = '';
***************
*** 2723,2726 ****
--- 2733,2737 ----
$start_message = $self->{form_}{start_message} if ( ( defined($self->{form_}{start_message}) ) && ($self->{form_}{start_message} > 0 ) );
+ $self->{form_}{start_message} = $start_message;
my $stop_message = $start_message + $self->config_( 'page_size' ) - 1;
$stop_message = $self->history_size() - 1 if ( $stop_message >= $self->history_size() );
***************
*** 2773,2777 ****
foreach my $header ('', 'from', 'subject', 'bucket') {
$body .= "<th class=\"historyLabel\" scope=\"col\">\n";
! $body .= "<a href=\"/history?session=$self->{session_key__}&filter=$self->{form_}{filter}&setsort=" . ($self->{form_}{sort} eq "$header"?"-":"");
$body .= "$header\">";
--- 2784,2788 ----
foreach my $header ('', 'from', 'subject', 'bucket') {
$body .= "<th class=\"historyLabel\" scope=\"col\">\n";
! $body .= "<a href=\"/history?" . $self->print_form_fields_(1,1,('filter','session','search')) . "&setsort=" . ($self->{form_}{sort} eq "$header"?"-":"");
$body .= "$header\">";
***************
*** 2822,2826 ****
$mail_file =~ /popfile\d+=(\d+)\.msg$/;
$body .= "<a title=\"$from\">$short_from</a></td>\n";
! $body .= "<td><a class=\"messageLink\" title=\"$subject\" href=\"/view?view=$mail_file&start_message=$start_message&session=$self->{session_key__}&sort=$self->{form_}{sort}&filter=$self->{form_}{filter}&search=$self->{form_}{search}\">";
$body .= "$short_subject</a></td>\n<td>";
if ( $reclassified ) {
--- 2833,2837 ----
$mail_file =~ /popfile\d+=(\d+)\.msg$/;
$body .= "<a title=\"$from\">$short_from</a></td>\n";
! $body .= "<td><a class=\"messageLink\" title=\"$subject\" href=\"/view?view=$mail_file" . $self->print_form_fields_(0,1,('start_message','session','filter','search','sort')) . "\">";
$body .= "$short_subject</a></td>\n<td>";
if ( $reclassified ) {
***************
*** 2933,2937 ****
$body .= "<a href=\"/view?view=" . $self->{history_keys__}[ $index - 1 ];
$body .= "&start_message=". ((( $index - 1 ) >= $start_message )?$start_message:($start_message - $self->config_( 'page_size' )));
! $body .= "&session=$self->{session_key__}&sort=$self->{form_}{sort}&filter=$self->{form_}{filter}&search=$self->{form_}{search}\"><<";
$body .= $self->{language__}{Previous};
$body .= "</a> ";
--- 2944,2948 ----
$body .= "<a href=\"/view?view=" . $self->{history_keys__}[ $index - 1 ];
$body .= "&start_message=". ((( $index - 1 ) >= $start_message )?$start_message:($start_message - $self->config_( 'page_size' )));
! $body .= $self->print_form_fields_(0,1,('filter','session','search','sort')) . "\"><<";
$body .= $self->{language__}{Previous};
$body .= "</a> ";
***************
*** 2941,2945 ****
$body .= "<a href=\"/view?view=" . $self->{history_keys__}[ $index + 1 ];
$body .= "&start_message=". ((( $index + 1 ) < ( $start_message + $self->config_( 'page_size' ) ) )?$start_message:($start_message + $self->config_( 'page_size' )));
! $body .= "&session=$self->{session_key__}&sort=$self->{form_}{sort}&filter=$self->{form_}{filter}&search=$self->{form_}{search}\"> ";
$body .= $self->{language__}{Next};
$body .= ">></a>";
--- 2952,2956 ----
$body .= "<a href=\"/view?view=" . $self->{history_keys__}[ $index + 1 ];
$body .= "&start_message=". ((( $index + 1 ) < ( $start_message + $self->config_( 'page_size' ) ) )?$start_message:($start_message + $self->config_( 'page_size' )));
! $body .= $self->print_form_fields_(0,1,('filter','session','search','sort')) . "\"> ";
$body .= $self->{language__}{Next};
$body .= ">></a>";
***************
*** 2949,2953 ****
$body .= "<td class=\"openMessageCloser\">";
! $body .= "<a class=\"messageLink\" href=\"/history?start_message=$start_message&session=$self->{session_key__}&sort=$self->{form_}{sort}&search=$self->{form_}{search}&filter=$self->{form_}{filter}\">\n";
$body .= "<span class=\"historyLabel\">$self->{language__}{Close}</span>\n</a>\n";
$body .= "</td>\n</tr>\n</table>\n";
--- 2960,2964 ----
$body .= "<td class=\"openMessageCloser\">";
! $body .= "<a class=\"messageLink\" href=\"/history?" . $self->print_form_fields_(1,1,('start_message','filter','session','search','sort')) . "\">\n";
$body .= "<span class=\"historyLabel\">$self->{language__}{Close}</span>\n</a>\n";
$body .= "</td>\n</tr>\n</table>\n";
***************
*** 3068,3072 ****
$body .= "<tr>\n<td class=\"openMessageCloser\">";
! $body .= "<a class=\"messageLink\" href=\"/history?start_message=$start_message&session=$self->{session_key__}&sort=$self->{form_}{sort}&search=$self->{form_}{search}&filter=$self->{form_}{filter}\">\n";
$body .= "<span class=\"historyLabel\">$self->{language__}{Close}</span>\n</a>\n";
$body .= "</td>\n</tr>\n";
--- 3079,3083 ----
$body .= "<tr>\n<td class=\"openMessageCloser\">";
! $body .= "<a class=\"messageLink\" href=\"/history?" . $self->print_form_fields_(1,1,('start_message','filter','session','search','sort')). "\">\n";
$body .= "<span class=\"historyLabel\">$self->{language__}{Close}</span>\n</a>\n";
$body .= "</td>\n</tr>\n";
***************
*** 3328,3331 ****
--- 3339,3384 ----
}
}
+
+ # ---------------------------------------------------------------------------------------------
+ #
+ # print_form_fields_ - Returns a form string containing any presently defined form fields
+ #
+ # $first - 1 if the form field is at the beginning of a query, 0 otherwise
+ # $in_href - 1 if the form field is printing in a href, 0 otherwise (eg, for a 302 redirect)
+ # $include - a list of fields to return
+ #
+ # ---------------------------------------------------------------------------------------------
+ sub print_form_fields_
+ {
+ my ($self, $first, $in_href, @include) = @_;
+
+ my $amp;
+ if ($in_href) {
+ $amp = '&';
+ } else {
+ $amp = '&';
+ }
+
+ my $count = 0;
+ my $formstring = '';
+
+ $formstring = "$amp" if (!$first);
+
+ foreach my $field ( @include ) {
+ unless ( !defined($self->{form_}{$field}) || ( $self->{form_}{$field} eq '' ) ) {
+ $formstring .= "$amp" if ($count > 0);
+ if ($field eq 'session') {
+ $formstring .= "session=$self->{session_key__}";
+ } else {
+ $formstring .= "$field=$self->{form_}{$field}";
+ }
+ $count++;
+ }
+ }
+
+ return $formstring if ($count > 0);
+ return '';
+ }
+
# ---------------------------------------------------------------------------------------------
|