X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;f=maps%2Fbin%2Fdetail.cgi;h=857bb40c8e429e1489c51af8247e8539af7b3bcf;hb=ae9e57b169de143d2b8a7c761c3bf7394385e0d0;hp=2da6965042e8f06df7bce646446b2658d51ccd71;hpb=54fdcfd0cdc71457e3fae07fa28854546cf46e70;p=clearscm.git diff --git a/maps/bin/detail.cgi b/maps/bin/detail.cgi index 2da6965..857bb40 100755 --- a/maps/bin/detail.cgi +++ b/maps/bin/detail.cgi @@ -1,5 +1,5 @@ #!/usr/bin/perl -################################################################################# +################################################################################ # # File: $RCSfile: detail.cgi,v $ # Revision: $Revision: 1.1 $ @@ -16,30 +16,30 @@ use strict; use warnings; use MIME::Words qw(:all); + +use CGI qw(:standard *table start_td end_td start_Tr end_Tr start_div end_div); +use CGI::Carp 'fatalsToBrowser'; + use FindBin; -$0 = $FindBin::Script; -use lib $FindBin::Bin; +local $0 = $FindBin::Script; + +use lib "$FindBin::Bin/../lib"; use MAPS; use MAPSLog; -use MAPSUtil; use MAPSWeb; -use CGI qw (:standard *table start_td end_td start_Tr end_Tr start_div end_div); -use CGI::Carp 'fatalsToBrowser'; +use DateUtils; -my $type = param ('type'); -my $next = param ('next'); -my $lines = param ('lines'); -my $date = param ('date'); +my $type = param 'type'; +my $next = param 'next'; +my $lines = param 'lines'; +my $date = param 'date'; $date ||= ''; -my $userid; -my $current; -my $last; -my $prev; -my $total; +my ($userid, $current, $last, $prev, $total); + my $table_name = 'detail'; my %types = ( @@ -73,8 +73,8 @@ my %types = ( ] ); -sub MakeButtons { - my $type = shift; +sub MakeButtons($) { + my ($type) = @_; my $prev_button = $prev >= 0 ? a ({-href => "detail.cgi?type=$type;date=$date;next=$prev", @@ -90,56 +90,56 @@ sub MakeButtons { if ($type eq 'whitelist') { $buttons = $buttons . submit ({-name => 'action', - -value => 'Blacklist Marked', - -onClick => 'return CheckAtLeast1Checked (document.detail);'}) . + -value => 'Blacklist', + -onClick => 'return CheckAtLeast1Checked (document.detail);'}) . ' ' . submit ({-name => 'action', - -value => 'Nulllist Marked', - -onClick => 'return CheckAtLeast1Checked (document.detail);'}) . + -value => 'Nulllist', + -onClick => 'return CheckAtLeast1Checked (document.detail);'}) . ' ' . submit ({-name => 'action', - -value => 'Reset Marks', + -value => 'Reset', -onClick => 'return ClearAll (document.detail);'}); } elsif ($type eq 'blacklist') { $buttons = $buttons . submit ({-name => 'action', - -value => 'Whitelist Marked', - -onClick => 'return CheckAtLeast1Checked (document.detail);'}) . + -value => 'Whitelist', + -onClick => 'return CheckAtLeast1Checked (document.detail);'}) . ' ' . submit ({-name => 'action', - -value => 'Nulllist Marked', - -onClick => 'return CheckAtLeast1Checked (document.detail);'}) . + -value => 'Nulllist', + -onClick => 'return CheckAtLeast1Checked (document.detail);'}) . ' ' . submit ({-name => 'action', - -value => 'Reset Marks', + -value => 'Reset', -onClick => 'return ClearAll (document.detail);'}); } elsif ($type eq 'nulllist') { $buttons = $buttons . submit ({-name => 'action', - -value => 'Whitelist Marked', - -onClick => 'return CheckAtLeast1Checked (document.detail);'}) . + -value => 'Whitelist', + -onClick => 'return CheckAtLeast1Checked (document.detail);'}) . ' ' . submit ({-name => 'action', - -value => 'Blacklist Marked', - -onClick => 'return CheckAtLeast1Checked (document.detail);'}) . + -value => 'Blacklist', + -onClick => 'return CheckAtLeast1Checked (document.detail);'}) . ' ' . submit ({-name => 'action', - -value => 'Reset Marks', + -value => 'Reset', -onClick => 'return ClearAll (document.detail);'}); } else { $buttons = $buttons . submit ({-name => 'action', - -value => 'Whitelist Marked', - -onClick => 'return CheckAtLeast1Checked (document.detail);'}) . + -value => 'Whitelist', + -onClick => 'return CheckAtLeast1Checked (document.detail);'}) . ' ' . submit ({-name => 'action', - -value => 'Blacklist Marked', - -onClick => 'return CheckAtLeast1Checked (document.detail);'}) . + -value => 'Blacklist', + -onClick => 'return CheckAtLeast1Checked (document.detail);'}) . ' ' . submit ({-name => 'action', - -value => 'Nulllist Marked', - -onClick => 'return CheckAtLeast1Checked (document.detail);'}) . + -value => 'Nulllist', + -onClick => 'return CheckAtLeast1Checked (document.detail);'}) . ' ' . submit ({-name => 'action', - -value => 'Reset Marks', + -value => 'Reset', -onClick => 'return ClearAll (document.detail);'}); } # if return $buttons . $next_button; } # MakeButtons -sub PrintTable { +sub Body($) { my ($type) = @_; my $current = $next + 1; @@ -151,12 +151,12 @@ sub PrintTable { -action => 'processaction.cgi', -name => 'detail' }; - print start_table ({-align => 'center', - -id => $table_name, - -border => 0, - -cellspacing => 0, - -cellpadding => 0, - -width => '100%'}) . "\n"; + print start_table({-align => 'center', + -id => $table_name, + -border => 0, + -cellspacing => 0, + -cellpadding => 0, + -width => '100%'}) . "\n"; my $buttons = MakeButtons $type; @@ -171,33 +171,58 @@ sub PrintTable { ]; print end_div; - foreach my $sender (ReturnSenders $userid, $type, $next, $lines, $date) { - my @msgs = ReturnMessages $userid, $sender; - my @msgs2 = @msgs; + for my $sender (ReturnSenders( + userid => $userid, + type => $type, + start_at => $next, + lines => $lines, + date => $date + )) { + my $msgs = ReturnMessages( + userid => $userid, + sender => $sender, + ); + + # 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 + my ($onlist, $seq); + my $rule = 'none'; my $hit_count = 0; - ($onlist, $rule, $seq, $hit_count) = OnWhitelist $sender, $userid, 0; + ($onlist, $rule, $seq, $hit_count) = OnWhitelist($sender, $userid, 0); unless ($onlist) { - ($onlist, $rule, $seq, $hit_count) = OnBlacklist $sender, 0; + ($onlist, $rule, $seq, $hit_count) = OnBlacklist($sender, 0); unless ($onlist) { - ($onlist, $rule, $seq, $hit_count) = OnNulllist $sender, 0; + ($onlist, $rule, $seq, $hit_count) = OnNulllist($sender, 0); } # unless } # unless if ($rule) { - $rule =~ s/Matching rule: \(//; - $rule =~ s/\)//; - - if ($rule =~ /(\w+):(\d+)/) { + if ($rule =~ /\((\w+):(\d+)\)\s+"(.*)"/) { my $list = $1; - my $sequence = $2 - 1; - my $link = "$list:$2/$hit_count"; + my $sequence = $2; + my $next = $sequence - 1; + $rule = $3; + + $rule =~ s/\\@/\@/; - $rule =~ s/\w+:\d+/$link/; + $rule = "$list:$sequence/$hit_count $rule"; } # if } # if @@ -219,6 +244,9 @@ sub PrintTable { -border => 0, -width => '100%', -bgcolor => '#d4d0c8'}; + + # Get subject line + $heading = "?subject=$heading" if $heading; print td {-class => 'tablelabel', -valign => 'middle', @@ -226,7 +254,7 @@ sub PrintTable { td {-class => 'sender', -valign => 'middle', -width => '40%'}, - a {-href => "mailto:$sender?subject=$msgs2[0][0]"}, $sender, + a {-href => "mailto:$sender$heading"}, $sender, td { -valign => 'middle'}, $rule; @@ -235,20 +263,17 @@ sub PrintTable { my $messages = 1; - foreach (@msgs) { - my $msg_date = pop @{$_}; - my $subject = pop @{$_}; - - if ($date eq substr ($msg_date, 0, 10)) { - $msg_date = b font {-color => 'green'}, SQLDatetime2UnixDatetime $msg_date; + for my $rec (@$msgs) { + if ($date eq substr ($rec->{timestamp}, 0, 10)) { + $rec->{date} = b font {-color => 'green'}, SQLDatetime2UnixDatetime $rec->{timestamp}; } else { - $msg_date = SQLDatetime2UnixDatetime $msg_date; + $rec->{date} = SQLDatetime2UnixDatetime $rec->{timestamp}; } # if - $subject = $subject eq '' ? '<Unspecified>' : $subject; - $subject = decode_mimewords ($subject); - $subject =~ s/\>/>/g; - $subject =~ s/\{subject} //= '<Unspecified>'; + $rec->{subject} = decode_mimewords ($rec->{subject}); + $rec->{subject} =~ s/\>/>/g; + $rec->{subject} =~ s/\ 'tablerightdata', @@ -256,7 +281,6 @@ sub PrintTable { -cellspacing => 2, -border => 0, -width => '100%'}; - my $msg_nbr = $messages; print Tr [ td {-class => 'msgnbr', @@ -269,16 +293,16 @@ sub PrintTable { td {-class => 'subject', -valign => 'middle', -bgcolor => '#ffffff'}, - a {-href => "display.cgi?sender=$sender;msg_nbr=$msg_nbr"}, $subject, + a {-href => "display.cgi?sender=$sender;msg_date=$rec->{timestamp}"}, $rec->{subject}, td {-class => 'date', -width => '150', - -valign => 'middle'}, $msg_date + -valign => 'middle'}, $rec->{date}, ]; print end_table; - } # foreach + } # for print end_td; print end_Tr; - } # foreach + } # for print start_div {-class => 'toolbar'}; print @@ -292,45 +316,49 @@ sub PrintTable { print end_div; print end_table; print end_form; -} # PrintTable + + return; +} # Body # Main my $condition; my @scripts = ('ListActions.js'); -my $heading_date =$date ne '' ? ' on ' . FormatDate ($date) : ''; +my $heading_date =$date ne '' ? ' on ' . FormatDate ($date, 1) : ''; -$userid = Heading ( +$userid = Heading( 'getcookie', '', (ucfirst ($type) . ' Report'), - $types {$type} [0], - $types {$type} [1] . $heading_date, + $types{$type} [0], + $types{$type} [1] . $heading_date, $table_name, @scripts ); $userid ||= $ENV{USER}; -SetContext $userid; -NavigationBar $userid; +SetContext($userid); +NavigationBar($userid); unless ($lines) { - my %options = GetUserOptions $userid; + my %options = GetUserOptions($userid); $lines = $options{'Page'}; } # unless if ($date eq '') { - $condition .= "userid = '$userid' and type = '$type'"; + $condition .= "type = '$type'"; } else { my $sod = $date . ' 00:00:00'; my $eod = $date . ' 23:59:59'; - $condition .= "userid = '$userid' and type = '$type' " - . "and timestamp > '$sod' and timestamp < '$eod' "; + $condition .= "type = '$type' and timestamp > '$sod' and timestamp < '$eod'"; } # if -$total = MAPSDB::count_distinct ('log', 'sender', $condition); +$total = CountLog( + userid => $userid, + additional => $condition, +); $next ||= 0; @@ -339,11 +367,11 @@ $last = $next + $lines < $total ? $next + $lines : $total; if (($next - $lines) > 0) { $prev = $next - $lines; } else { - $prev = $next eq 0 ? -1 : 0; + $prev = $next == 0 ? -1 : 0; } # if -PrintTable $type; +Body($type); -Footing $table_name; +Footing($table_name); exit;