X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;f=maps%2Fbin%2Fdetail.cgi;h=0ecf224ea97f96842d33414fcb7d8d9e4f41f40f;hb=HEAD;hp=53fc47e2e24ace7d0336f7b66ded9ce27048c75e;hpb=24352d115ade3e1f4916df9c0102b1edb804f0c6;p=clearscm.git diff --git a/maps/bin/detail.cgi b/maps/bin/detail.cgi index 53fc47e..0ecf224 100755 --- a/maps/bin/detail.cgi +++ b/maps/bin/detail.cgi @@ -9,7 +9,7 @@ # Modified: $Date: 2013/06/12 14:05:47 $ # Language: perl # -# (c) Copyright 2000-2006, Andrew@DeFaria.com, all rights reserved. +# (c) Copyright 2000-2021, Andrew@DeFaria.com, all rights reserved. # ################################################################################ use strict; @@ -32,10 +32,11 @@ use MAPSLog; use MAPSWeb; use DateUtils; -my $type = param 'type'; -my $next = param 'next'; -my $lines = param 'lines'; -my $date = param 'date'; +my $type = param 'type'; +my $list = substr $type, 0, -4 if $type =~ /list$/; +my $next = param 'next'; +my $lines = param 'lines'; +my $date = param 'date'; $date ||= ''; @@ -74,6 +75,17 @@ my %types = ( ] ); +sub formatRule($) { + my ($rec) = @_; + + return '' unless $rec->{pattern} or $rec->{domain}; + + $rec->{pattern} //= ''; + $rec->{domain} //= ''; + + return "$rec->{pattern}\@$rec->{domain}"; +} # formatRule + sub MakeButtons($) { my ($type) = @_; @@ -150,6 +162,8 @@ sub Body($) { my $current = $next + 1; + my ($onlist, $rec); + print div {-align => 'center'}, b ( '(' . $current . '-' . $last . ' of ' . $total . ')'); print start_form { @@ -160,6 +174,8 @@ sub Body($) { MakeButtons $type; + print start_div {-id => 'highlightrow'}; + print start_table({-align => 'center', -id => $table_name, -border => 0, @@ -169,29 +185,51 @@ sub Body($) { print Tr [ - td {-class => 'tablebordertopleft'}, ' ', - th {-class => 'tableborder'}, 'Sender', - th {-class => 'tableborder'}, 'List', - th {-class => 'tableborder'}, 'Hit Count', - th {-class => 'tableborder'}, 'Rule', - th {-class => 'tablebordertopright'}, 'Comment', + th {-class => 'tablebordertopleft'}, '', + th {-class => 'tableborder'}, 'Sender', + th {-class => 'tableborder'}, 'List', + th {-class => 'tableborder'}, 'Hit Count', + th {-class => 'tableborder'}, 'Rule', + th {-class => 'tableborder'}, 'Retention', + th {-class => 'tablebordertopright'}, 'Comment/Date', ]; - for my $sender (ReturnSenders( + 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. + # 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 @@ -204,40 +242,16 @@ sub Body($) { $heading = $msgs->[0]{subject} if $msgs->[0]{subject}; } # if - my ($onlist, $seq); - - my $rule = 'none'; - my $hit_count = 0; - - ($onlist, $rule, $seq, $hit_count) = OnWhitelist($sender, $userid, 0); + ($onlist, $rec) = OnWhitelist($sender, $userid, 0); unless ($onlist) { - ($onlist, $rule, $seq, $hit_count) = OnBlacklist($sender, 0); + ($onlist, $rec) = OnBlacklist($sender, 0); unless ($onlist) { - ($onlist, $rule, $seq, $hit_count) = OnNulllist($sender, 0); + ($onlist, $rec) = OnNulllist($sender, 0); } # unless } # unless - my ($list, $sequence, $comment); - - # Parse rule - if ($rule) { - if ($rule =~ /\((\w+):(\d+)\)\s+"(\S*)"/) { - $list = $1; - $sequence = $2; - $rule = $3; - $comment = ''; - } elsif ($rule =~ /\((\w+):(\d+)\)\s+"(\S*) - (.*)"/) { - $list = $1; - $sequence = $2; - $rule = $3; - $comment = $4; - } # if - - $rule =~ s/\\@/\@/; - } # if - $next++; # Start Sender line @@ -245,47 +259,82 @@ sub Body($) { print start_Tr {-valign => 'middle'}; print td { - -class => 'tableborder', + -class => $leftclass, + -align => 'right', + -valign => 'middle', -rowspan => $rowspan, - }, small ($next, + }, $next, checkbox { - -name => "action$next", - -label => '' - }), hidden({ + -name => "action$next", + -label => '', + -valign => 'middle', + }; + + print hidden({ -name => "email$next", - -default => $sender + -default => $sender, }); # Get subject line $heading = "?subject=$heading" if $heading; print td { - -class => 'sender', + -class => $senderclass, }, a { -href => "mailto:$sender$heading", - }, " $sender"; - - my $listlink = ($list and $sequence) ? "$list:$sequence" : ' '; + }, " $sender"; + + if ($rec) { + my $listlink = ($rec->{type} and $rec->{sequence}) ? "$rec->{type}:$rec->{sequence}" : ''; + + $rec->{comment} //= ''; + $rec->{retention} //= ''; + + print td { + -class => $dataclass, + -align => 'right', + }, a { + href => "/maps/php/list.php?type=$rec->{type}&next=" . ($rec->{sequence} - 1), + }, $listlink, + td { + -class => $dataclass, + -align => 'right', + }, "$rec->{hit_count} ", + td { + -class => $dataclass, + }, formatRule($rec), + td { + -class => $dataclass, + -align => 'right', + }, "$rec->{retention} ", + td { + -class => $rightclass, + }, $rec->{comment}; + } else { + # $rec will be undefined if this message will be returned + print td {-class => $dataclass}, + td {-class => $dataclass}, + td {-class => $dataclass}, + td {-class => $dataclass}, + td {-class => $rightclass}; + } # if - print td { - -class => 'tabledata', - -align => 'right', - }, a { - href => "/maps/php/list.php?type=$list&next=" . ($sequence - 1), - }, $listlink, - td { - -class => 'tabledata', - -align => 'right', - }, "$hit_count ", - td { - -class => 'tabledata', - }, $rule, - td { - -class => 'tablerightdata', - }, $comment; print end_Tr; + my $msgnbr = 0; + for my $rec (@$msgs) { + $msgnbr++; + + # We increased $next earlier so do not add 1 here + if (($next % $lines) == (@senders % $lines)) { + $dataclass = 'tablebottomdata'; + $rightclass = 'tablebottomright' if $msgnbr == @$msgs; + + # Only subjectbottom the last message + $subjectclass = 'subjectbottom' if $msgnbr == @$msgs; + } # if + if ($date eq substr ($rec->{timestamp}, 0, 10)) { $rec->{date} = b font {-color => 'green'}, SQLDatetime2UnixDatetime $rec->{timestamp}; } else { @@ -300,34 +349,25 @@ sub Body($) { print Tr [ td { - -class => 'subject', - -valign => 'middle', - -bgcolor => '#ffffff', - -colspan => 4, - }, a {-href => "display.cgi?sender=$sender;msg_date=$rec->{timestamp}" + -class => $subjectclass, + -colspan => 5, + }, a { + -href => "display.cgi?sender=$sender;msg_date=$rec->{timestamp}", }, '    ' . $rec->{subject}, - td {-class => 'tablerightdata', - -width => '150', - -valign => 'middle', - -align => 'right'}, span {-class => 'date'}, $rec->{date}, + td {-class => $rightclass, + -width => '150', + -align => 'right'}, span {-class => 'date'}, $rec->{date} . ' ', ]; } # for } # for - print - Tr [ - td {-class => 'tableborderbottomleft'}, ' ', - th {-class => 'tableborder'}, ' ', - th {-class => 'tableborder'}, ' ', - th {-class => 'tableborder'}, ' ', - th {-class => 'tableborder'}, ' ', - th {-class => 'tableborderbottomright'}, ' ' - ]; print end_table; - print end_form; + print end_div; MakeButtons $type; + print end_form; + return; } # Body @@ -366,8 +406,10 @@ if ($date eq '') { $condition .= "type = '$type' and timestamp > '$sod' and timestamp < '$eod'"; } # if -$total = CountLog( +# Need to count distinct on sender +$total = CountLogDistinct( userid => $userid, + column => 'sender', additional => $condition, );