DSPAM Web UI quarantine patch

Kenneth Marshall <[email protected]> Wed, 4 Jan 2017 13:01:01 -0600
Newsgroups gmane.mail.spam.dspam.user
Message-ID <[email protected]>
--CUfgB8w4ZwR/yMy5
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hi DSPAM users,

We have finished our DSPAM upgrade to 3.10.2. I noticed that the DSPAM
UI for the Quarantine has a 'Select 200' button but it is not very
useful because the available sort orders for the quarantine a by
rating - leastlike to mostlike SPAM, date - newest to to oldest, and
then from and subject alphabetically. In particular, using the reverse
order to rating and date would allow for easy pruning of the quarantine
by way of the 'Select 200' option. Please find attached the changes
needed for the file dspam.cgi to allow the sort direction to be toggled.

Regards,
Ken

--CUfgB8w4ZwR/yMy5
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="dspam-sort-toggle.patch"

--- dspam.cgi	2017-01-04 12:45:31.727532258 -0600
+++ dspam2.cgi	2017-01-04 12:47:52.877877754 -0600
@@ -1064,6 +1064,9 @@
 sub by_rating { $a->{'rating'} <=> $b->{'rating'} }
 sub by_subject { lc($a->{'Subject'}) cmp lc($b->{'Subject'}) }
 sub by_from { lc($a->{'From'}) cmp lc($b->{'From'}) }
+sub by_revrating { $b->{'rating'} <=> $a->{'rating'} }
+sub by_revsubject { lc($b->{'Subject'}) cmp lc($a->{'Subject'}) }
+sub by_revfrom { lc($b->{'From'}) cmp lc($a->{'From'}) }
 
 sub DisplayQuarantine {
   my(@alerts);
@@ -1183,36 +1186,54 @@
   if ($sortBy eq "Rating") {
     @headings = sort by_rating @headings;
   }
+  if ($sortBy eq "RevRating") {
+    @headings = sort by_revrating @headings;
+  }
   if ($sortBy eq "Subject") {
     @headings = sort by_subject @headings;
   }
+  if ($sortBy eq "RevSubject") {
+    @headings = sort by_revsubject @headings;
+  }
   if ($sortBy eq "From") {
     @headings = sort by_from @headings;
   }
+  if ($sortBy eq "RevFrom") {
+    @headings = sort by_revfrom @headings;
+  }
   if ($sortBy eq "Date") {
     @headings = reverse @headings;
   }
+  if ($sortBy eq "RevDate") {
+    @headings = @headings;
+  }
 
-  $DATA{'SORTBY'} = $sortBy;
-  $DATA{'SORT_QUARANTINE'} .=  "<th><a href=\"$CONFIG{'ME'}?user=$FORM{'user'}&amp;template=quarantine&amp;language=$LANGUAGE&amp;sortby=Rating&amp;user=$FORM{'user'}\">";
+  #
+  # Toggle the sort direction to make the 'Select 200' useful.
+  if ($sortBy =~ /^Rev([A-Za-z]*)/) {
+    $DATA{'SORTBY'} = '';
+  } else {
+    $DATA{'SORTBY'} = 'Rev';
+  }
+  $DATA{'SORT_QUARANTINE'} .=  "<th><a href=\"$CONFIG{'ME'}?user=$FORM{'user'}&amp;template=quarantine&amp;language=$LANGUAGE&amp;sortby=$DATA{'SORTBY'}Rating&amp;user=$FORM{'user'}\">";
   if ($sortBy eq "Rating") {
     $DATA{'SORT_QUARANTINE'} .= "<strong>$CONFIG{'LANG'}->{$LANGUAGE}->{'quarantine_rating'}</strong>";
   } else {
     $DATA{'SORT_QUARANTINE'} .= "$CONFIG{'LANG'}->{$LANGUAGE}->{'quarantine_rating'}";
   }
-  $DATA{'SORT_QUARANTINE'} .=  "</a></th>\n\t<th><a href=\"$CONFIG{'ME'}?user=$FORM{'user'}&amp;template=quarantine&amp;language=$LANGUAGE&amp;sortby=Date&amp;user=$FORM{'user'}\">";
+  $DATA{'SORT_QUARANTINE'} .=  "</a></th>\n\t<th><a href=\"$CONFIG{'ME'}?user=$FORM{'user'}&amp;template=quarantine&amp;language=$LANGUAGE&amp;sortby=$DATA{'SORTBY'}Date&amp;user=$FORM{'user'}\">";
   if ($sortBy eq "Date") {
     $DATA{'SORT_QUARANTINE'} .= "<strong>$CONFIG{'LANG'}->{$LANGUAGE}->{'quarantine_date'}</strong>";
   } else {
     $DATA{'SORT_QUARANTINE'} .= "$CONFIG{'LANG'}->{$LANGUAGE}->{'quarantine_date'}";
   }
-  $DATA{'SORT_QUARANTINE'} .=  "</a></th>\n\t<th><a href=\"$CONFIG{'ME'}?user=$FORM{'user'}&amp;template=quarantine&amp;language=$LANGUAGE&amp;sortby=From&amp;user=$FORM{'user'}\">";
+  $DATA{'SORT_QUARANTINE'} .=  "</a></th>\n\t<th><a href=\"$CONFIG{'ME'}?user=$FORM{'user'}&amp;template=quarantine&amp;language=$LANGUAGE&amp;sortby=$DATA{'SORTBY'}From&amp;user=$FORM{'user'}\">";
   if ($sortBy eq "From") {
     $DATA{'SORT_QUARANTINE'} .= "<strong>$CONFIG{'LANG'}->{$LANGUAGE}->{'quarantine_from'}</strong>";
   } else {
     $DATA{'SORT_QUARANTINE'} .= "$CONFIG{'LANG'}->{$LANGUAGE}->{'quarantine_from'}";
   }
-  $DATA{'SORT_QUARANTINE'} .=  "</a></th>\n\t<th><a href=\"$CONFIG{'ME'}?user=$FORM{'user'}&amp;template=quarantine&amp;language=$LANGUAGE&amp;sortby=Subject&amp;user=$FORM{'user'}\">";
+  $DATA{'SORT_QUARANTINE'} .=  "</a></th>\n\t<th><a href=\"$CONFIG{'ME'}?user=$FORM{'user'}&amp;template=quarantine&amp;language=$LANGUAGE&amp;sortby=$DATA{'SORTBY'}Subject&amp;user=$FORM{'user'}\">";
   if ($sortBy eq "Subject") {
     $DATA{'SORT_QUARANTINE'} .= "<strong>$CONFIG{'LANG'}->{$LANGUAGE}->{'quarantine_subject'}</strong>";
   } else {

--CUfgB8w4ZwR/yMy5
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
--CUfgB8w4ZwR/yMy5
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Dspam-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dspam-user

--CUfgB8w4ZwR/yMy5--