b0VIM 6.2Kx}@`Azjhiverfrogette.webarchitects.co.uk~jhiver/01_mkdoc_modules/MKDoc-Forum/lib/MKDoc/Forum/IMAP/Query.pm3210#"! Utpado~kjiIHljih,+ v X ! p k -  I   z v p k > < ; : + )  y I  oiV60+vpk(zqk< lecbaA@xRQUuon } $condition .= "OR UID $uid "; my $uid = shift (@{$uids}); { while (@{$uids} != 2) my $condition = ''; if (scalar @{$uids} == 2) { return select_threaded_messages ("OR UID $uids->[0] UID $uids->[1]") } if (scalar @{$uids} == 1) { return select_threaded_messages ("UID $uids->[0]") } return new MKDoc::Forum::Message ( children => [] ) unless (scalar @{$uids}); return new MKDoc::Forum::Message ( children => [] ) unless (defined $uids); my $uids = [ @{$slice->{uids}} ]; my $slice = shift;{sub slice_threaded=cutmessages.corresponding messages and threads them properly. Returns the top threadUsing the UIDs defined whitin this particular slice, loads all the=head2 slice_threaded ($slice);} }; uids => \@slice, thickness => $thickness, number => $slice_num, return { my @slice = @{$uid_array}[$lower_bound .. $upper_bound]; } $upper_bound = $slice_num * $thickness - 1; $lower_bound = ($slice_num - 1) * $thickness; { else # we're somewhere in the middle } $upper_bound = $#{$uid_array}; $lower_bound = ($slice_num - 1) * $thickness; { elsif ($slice_num == $last_slice_num) # if there is more than one slice, but we're on the last slice } $upper_bound = $slice_num * $thickness - 1; $lower_bound = 0; { elsif ($slice_num == $first_slice_num) # if there is more than one slice, but we're on the first slice } $upper_bound = $#{$uid_array}; $lower_bound = 0; { if ($first_slice_num == $last_slice_num) # if there is only one slice, then things are easy enough my $upper_bound; my $lower_bound; unless ($last_slice_num == int ($last_slice_num)); $last_slice_num = int ($last_slice_num) + 1 my $last_slice_num = scalar @{$uid_array} / $thickness; my $first_slice_num = 1; my $uid_array = shift; my $slice_num = shift; my $thickness = shift;{sub slice_info} return (wantarray) ? @struct : \@struct; } }; uids => [], thickness => $thickness, number => 1, push @struct, { { unless (scalar @struct) } push @struct, $slice; $slice->{current} = ($slice_num == $_) ? 1 : 0; my $slice = slice_info ($thickness, $_, $uid_array); { for (1..$number_of_slices) my @struct = (); if (int ($number_of_slices) != $number_of_slices); $number_of_slices = int ($number_of_slices) + 1 my $number_of_slices = scalar @{$uid_array} / $thickness; my $uid_array = shift; my $slice_num = shift; my $thickness = shift;{sub slicing_structure=cut } current => uids => thickness => $per_page, number => , {Each element of the resulting array looks like this:Splits $uid_array into a list of 'slices' containing $per_page message each.=head2 slicing_structure ($per_page, $current, $uid_array);} return (wantarray) ? @res : \@res; my @res = $::MKD_IMAP->sort ('REVERSE DATE', 'US-ASCII', 'ALL');{sub uid_most_recent_first=cutmost recent first.Returns all the UIDs from the current $::MKD_IMAP object,=head2 uid_most_recent_first();our @Stack = ();our $Current = undef;our %Threads = ();use warnings;use strict;use MKDoc::Forum::Message;package MKDoc::Forum::IMAP::Query;adrpLG r o O J 9 7 6 5 " Q O N M 6 4  v 3   y @   V 5 trqpRP8cMGEDC?rm1wuB   __END__1;} __END__1;} return $::MKD_IMAP->parse_headers ($uid, 'ALL') my $uid = shift || die "\$uid not specified";{sub message_header=cutReturns the parsed headers for the message $uid.=head2 message_header ($uid);} foreach (@{$message->{children}}) { _messages_parentify ($_, $message) } if (defined $parent) { $message->{parent} = "$parent" } my $parent = shift; my $message = shift;{sub _messages_parentify} (defined $thread->{uid}) ? return ($thread) : return @{$thread->{children}}; $thread->{children} = \@new_children; push @new_children, _messages_threaded_collapse_empty_threads ($_) for (@{$thread->{children}}); my @new_children = (); return ($thread) unless (defined $thread->{children}); my $thread = shift;{sub _messages_threaded_collapse_empty_threads} } $Current = $message; push @{$Current->{children}}, $message; $Current->{children} ||= []; my $message = new MKDoc::Forum::Message ($number); { else } $Current->{uid} = $number; { if (not defined $Current->uid) my $number = shift;{sub _messages_threaded_number} $Current = $Stack[$#Stack]; pop (@Stack);{sub _messages_threaded_close_parenthesis} push @Stack, $message; $Current = $message; push @{$Current->{children}}, $message; $Current->{children} ||= []; my $message = new MKDoc::Forum::Message;{sub _messages_threaded_open_parenthesis} return $first; _messages_threaded_collapse_empty_threads ($first); } else { _messages_threaded_number ($_) } elsif (/\)/) { _messages_threaded_close_parenthesis() } if (/\(/) { _messages_threaded_open_parenthesis() } { foreach (@tokens) my $first = $Current; # builds the tree using the tokens local @Stack = ($Current); local $Current = new MKDoc::Forum::Message ( children => [] ); local %Threads = (); # a bit of initialization... my @tokens = map { (defined $_) ? $_ : () } $thread_info_string =~ /(\()|(\))|(\d+)/g; my $thread_info_string = shift;{sub _messages_threaded} return $::MKD_IMAP->parse_headers (scalar ($::MKD_IMAP->search ($condition)) , @headers) @headers = ('ALL') unless (scalar @headers); my @headers = @_; my $condition = shift || 'ALL';{sub select_headers} return $res; _messages_parentify ($res); my $res = _messages_threaded ($res_string); my ($res_string) = grep /\*\s+THREAD/, $::MKD_IMAP->tag_and_run ("UID THREAD REFERENCES US-ASCII $condition"); ); qw/Message-ID From To Date Subject In-Reply-To References Content-Language/ $condition, $::MKD_MESSAGES_HEADERS_TEMP = select_headers ( # performance greatly. # one later on. It's a bit of a kludge but it increases # bulk-load message headers to avoid loading them one by my $condition = shift || 'ALL';{sub select_threaded_messages} return select_threaded_messages ($condition); $condition .= "OR UID $uids->[0] UID $uids->[1]";