X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;f=maps%2Fbin%2Fdetail.cgi;h=ee2d2f4352ec04d190e7583b355fe1d84fbad480;hb=8d6e59ba7728e19d42da1533b9f24d0216867899;hp=857bb40c8e429e1489c51af8247e8539af7b3bcf;hpb=ae9e57b169de143d2b8a7c761c3bf7394385e0d0;p=clearscm.git diff --git a/maps/bin/detail.cgi b/maps/bin/detail.cgi index 857bb40..ee2d2f4 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; @@ -25,6 +25,7 @@ use FindBin; local $0 = $FindBin::Script; use lib "$FindBin::Bin/../lib"; +use lib "$FindBin::Bin/../../lib"; use MAPS; use MAPSLog; @@ -136,7 +137,12 @@ sub MakeButtons($) { -onClick => 'return ClearAll (document.detail);'}); } # if - return $buttons . $next_button; + print div { + -align => 'center', + -class => 'toolbar', + }, $buttons . $next_button; + + return; } # MakeButtons sub Body($) { @@ -151,6 +157,9 @@ sub Body($) { -action => 'processaction.cgi', -name => 'detail' }; + + MakeButtons $type; + print start_table({-align => 'center', -id => $table_name, -border => 0, @@ -158,34 +167,52 @@ sub Body($) { -cellpadding => 0, -width => '100%'}) . "\n"; - my $buttons = MakeButtons $type; - - print start_div {-class => 'toolbar'}; print Tr [ - td {-class => 'tablebordertopleft', - -valign => 'middle'}, - td {-class => 'tablebordertopright', - -valign => 'middle', - -align => 'center'}, $buttons, + td {-class => 'tablebordertopleft'}, ' ', + th {-class => 'tableborder'}, 'Sender', + th {-class => 'tableborder'}, 'List', + th {-class => 'tableborder'}, 'Hit Count', + th {-class => 'tableborder'}, 'Rule', + th {-class => 'tablebordertopright'}, 'Comment', ]; - print end_div; - 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 @@ -213,57 +240,96 @@ sub Body($) { } # unless } # unless - if ($rule) { - if ($rule =~ /\((\w+):(\d+)\)\s+"(.*)"/) { - my $list = $1; - my $sequence = $2; - my $next = $sequence - 1; - $rule = $3; + $hit_count //= ''; - $rule =~ s/\\@/\@/; + my $list = ''; + my $sequence = 0; + my $comment = ''; - $rule = "$list:$sequence/$hit_count $rule"; + # 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 + $sequence //= 0; $next++; - print - start_Tr {-valign => 'middle'}; - print - td {-class => 'tableborder'}, small ($next, - checkbox {-name => "action$next", - -label => ''}), - hidden ({-name => "email$next", - -default => $sender}); - print - start_td {-align => 'left'}; - print - start_table {-class => 'tablerightdata', - -cellpadding => 2, - -callspacing => 0, - -border => 0, - -width => '100%', - -bgcolor => '#d4d0c8'}; + + # Start Sender line + my $rowspan = @$msgs + 1; + + print start_Tr {-valign => 'middle'}; + print td { + -class => $leftclass, + -align => 'right', + -valign => 'middle', + -rowspan => $rowspan, + }, $next, + checkbox { + -name => "action$next", + -label => '', + -valign => 'middle', + }; + + print hidden({ + -name => "email$next", + -default => $sender, + }); # Get subject line $heading = "?subject=$heading" if $heading; - print - td {-class => 'tablelabel', - -valign => 'middle', - -width => '40'}, 'Sender:', - td {-class => 'sender', - -valign => 'middle', - -width => '40%'}, - a {-href => "mailto:$sender$heading"}, $sender, - td { - -valign => 'middle'}, - $rule; - print - end_table; - - my $messages = 1; + + print td { + -class => $senderclass, + }, a { + -href => "mailto:$sender$heading", + }, " $sender"; + + my $listlink = ($list and $sequence) ? "$list:$sequence" : ' '; + + print td { + -class => $dataclass, + -align => 'right', + }, a { + href => "/maps/php/list.php?type=$list&next=" . ($sequence - 1), + }, $listlink, + td { + -class => $dataclass, + -align => 'right', + }, "$hit_count ", + td { + -class => $dataclass, + }, $rule, + td { + -class => $rightclass, + }, $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 { @@ -275,48 +341,26 @@ sub Body($) { $rec->{subject} =~ s/\>/>/g; $rec->{subject} =~ s/\ 'tablerightdata', - -cellpadding => 2, - -cellspacing => 2, - -border => 0, - -width => '100%'}; print Tr [ - td {-class => 'msgnbr', - -valign => 'middle', - -rowspan => 2, - -width => '2%'}, $messages++, - td {-class => 'tablelabel', - -valign => 'middle', - -width => '45'}, 'Subject:', - td {-class => 'subject', - -valign => 'middle', - -bgcolor => '#ffffff'}, - a {-href => "display.cgi?sender=$sender;msg_date=$rec->{timestamp}"}, $rec->{subject}, - td {-class => 'date', - -width => '150', - -valign => 'middle'}, $rec->{date}, + td { + -class => $subjectclass, + -colspan => 4, + }, a { + -href => "display.cgi?sender=$sender;msg_date=$rec->{timestamp}", + }, '    ' . $rec->{subject}, + td {-class => $rightclass, + -width => '150', + -align => 'right'}, span {-class => 'date'}, $rec->{date} . ' ', ]; - print end_table; } # for - print end_td; - print end_Tr; } # for - print start_div {-class => 'toolbar'}; - print - Tr [ - td {-class => 'tableborderbottomleft', - -valign => 'middle'}, - td {-class => 'tableborderbottomright', - -valign => 'middle'}, - $buttons - ]; - print end_div; print end_table; print end_form; + MakeButtons $type; + return; } # Body @@ -355,8 +399,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, );