- foreach my $sender (ReturnSenders $userid, $type, $next, $lines, $date) {
- my @msgs = ReturnMessages $userid, $sender;
- my @msgs2 = @msgs;
- my ($onlist, $seq);
- my $rule = 'none';
- my $hit_count = 0;
+ my @senders = ReturnSenders(
+ userid => $userid,
+ type => $type,
+ start_at => $next,
+ lines => $lines,
+ date => $date
+ );
+
+ for my $sender (@senders) {
+ my $msgs = ReturnMessages(
+ userid => $userid,
+ sender => $sender,
+ );
+
+ my $leftclass = 'tableleftdata';
+ my $dataclass = 'tabledata';
+ my $rightclass = 'tablerightdata';
+ my $senderclass = 'sender';
+ my $subjectclass = 'subject';
+
+ # Check to see if this is the last line
+ if ((($next + 1) % $lines) == (@senders % $lines)) {
+ # We always "bottom" the first column
+ $leftclass = 'tablebottomleft';
+
+ # Check to see if there any message lines to display
+ unless (@$msgs) {
+ $dataclass = 'tablebottomdata';
+ $rightclass = 'tablebottomright';
+ $senderclass = 'senderbottom';
+ } # unless
+ } # if
+
+ # This is for the purposes of supplying a subject line if the mailto address
+ # is clicked on. It's kludgy because we are simply grabbing the subject line
+ # of the first email sent where there may be many emails from this sender
+ # Still it is often the right subject (or a good enough one)
+ #
+ # A little tricky here because of transliteration. If I test for
+ # $msg->[0]{subject} when $msg->[0] is essentially empty I create the hash
+ # making it non empty. Therefore I need to first test if $msgs->[0] exists
+ # first.
+ my $heading = '';
+
+ if ($msgs->[0]) {
+ $heading = $msgs->[0]{subject} if $msgs->[0]{subject};
+ } # if