Skip to content

Commit

Permalink
Fix selection of folder when they are in an unexpected order
Browse files Browse the repository at this point in the history
  • Loading branch information
jcameron committed Nov 2, 2024
1 parent acb0771 commit 23ae9cb
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 13 deletions.
5 changes: 3 additions & 2 deletions mailbox/delete_mail.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ our (%text, %in, %userconfig, %gconfig);
require './mailbox-lib.pl';
&ReadParse();
my @ids = sort { $a <=> $b } split(/\0/, $in{'d'});
my @folders = &list_folders();
my $folder = $folders[$in{'folder'}];
my @folders = &list_folders_sorted();
my ($folder) = grep { $_->{'index'} == $in{'folder'} } @folders;
$folder || &error($text{'view_efolder'});
my $r = time().$$;

my @delmail;
Expand Down
5 changes: 3 additions & 2 deletions mailbox/detach.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ use Socket;
require './mailbox-lib.pl';

&ReadParse();
my @folders = &list_folders();
my $folder = $folders[$in{'folder'}];
my @folders = &list_folders_sorted();
my ($folder) = grep { $_->{'index'} == $in{'folder'} } @folders;
$folder || &error($text{'view_efolder'});
my $mail = &mailbox_get_mail($folder, $in{'id'}, 0);
$mail || &error($text{'view_egone'});
&parse_mail($mail);
Expand Down
5 changes: 3 additions & 2 deletions mailbox/detachall.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ require './mailbox-lib.pl';
&error_setup($text{'detachall_err'});

&ReadParse();
my @folders = &list_folders();
my $folder = $folders[$in{'folder'}];
my @folders = &list_folders_sorted();
my ($folder) = grep { $_->{'index'} == $in{'folder'} } @folders;
$folder || &error($text{'view_efolder'});
my $mail = &mailbox_get_mail($folder, $in{'id'}, 0);
$mail || &error($text{'view_egone'});
&parse_mail($mail);
Expand Down
3 changes: 2 additions & 1 deletion mailbox/search_form.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ our $search_folder_id;

require './mailbox-lib.pl';
&ReadParse();
my @folders = &list_folders_sorted();
my @folders = &list_folders_sorted();
my ($folder) = grep { $_->{'index'} == $in{'folder'} } @folders;
$folder || &error($text{'view_efolder'});
&set_module_index($in{'folder'});
&ui_print_header(undef, $text{'sform_title'}, "");

Expand Down
5 changes: 3 additions & 2 deletions mailbox/send_mail.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ foreach my $k (keys %in) {
$in{$k} = join("\0", @{$in{$k}}) if ($k !~ /^attach\d+/);
}
&set_module_index($in{'folder'});
my @folders = &list_folders();
my $folder = $folders[$in{'folder'}];
my @folders = &list_folders_sorted();
my ($folder) = grep { $_->{'index'} == $in{'folder'} } @folders;
$folder || &error($text{'view_efolder'});
&error_setup($text{'send_err'});
if (!$in{'subject'}) {
if ($userconfig{'force_subject'} eq 'error') {
Expand Down
5 changes: 3 additions & 2 deletions mailbox/slideshow.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ require './mailbox-lib.pl';

# Get the mail
&ReadParse();
my @folders = &list_folders();
my $folder = $folders[$in{'folder'}];
my @folders = &list_folders_sorted();
my ($folder) = grep { $_->{'index'} == $in{'folder'} } @folders;
$folder || &error($text{'view_efolder'});
my $mail = &mailbox_get_mail($folder, $in{'id'}, 0);
$mail || &error($text{'view_egone'});
&parse_mail($mail);
Expand Down
3 changes: 2 additions & 1 deletion mailbox/sort.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ our %in;

require './mailbox-lib.pl';
&ReadParse();
my @folders = &list_folders();
my @folders = &list_folders_sorted();
my ($folder) = grep { $_->{'index'} == $in{'folder'} } @folders;
$folder || &error($text{'view_efolder'});
&save_sort_field($folder, $in{'field'}, $in{'dir'});

#Return in JSON format if needed
Expand Down
4 changes: 3 additions & 1 deletion mailbox/virtualize.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ my $folder = { 'type' => 6,
foreach my $k (keys %in) {
if ($k =~ /^idx_(\d+)$/) {
my ($idx, $fidx) = split(/\s+/, $in{$k}, 2);
$folder->{'members'}->[$1] = [ $folders[$fidx], $idx ];
my ($folder) = grep { $_->{'index'} == $fidx } @folders;
$folder || &error($text{'view_efolder'});
$folder->{'members'}->[$1] = [ $folder, $idx ];
}
}
&save_folder($folder);
Expand Down

0 comments on commit 23ae9cb

Please sign in to comment.