Changeset 43791

Show
Ignore:
Timestamp:
05/01/08 09:15:21 (2 months ago)
Author:
ear1grey
Message:

Tow imprvements, one bug fix:

i1: Added a "Delete selected" button to the top of the list.

i2: Added a "Select all" checkbox.

b1: Found a fix for the "clipping" problem where the matching comment ID list was getting concatenated at 1024 characters. It's now set to be 8192 chars, which is plenty for proving the issue, but it should either be configurable, or preferably, the client should notice if the max-length is reached and adjust the max-length to accommodate the result.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • worst-offenders/trunk/classes/domain_litmus.php

    r39125 r43791  
    2222 
    2323            public static function getMatches() { 
    24                   global $keys
     24                  global $keys, $wpdb
    2525                  $lower_limit = get_option( $keys['ui_vis'] );  
     26                  $wpdb->get_results("SET SESSION group_concat_max_len = 8192"); 
    2627                  return self::runCachedMatchesQuery( 
    2728                        self::getName(), 
     
    3233            function content() {     
    3334                  if (DomainLitmus::isActive() || AllLitmus::isActive() ) { 
     35                        echo("<table>"); 
    3436                        $comments = DomainLitmus::getMatches(); 
    35                         echo("<table>"); 
     37                        if (self::isActive()) { 
     38                              self::wo3_include_select_all($comments); 
     39                        } 
    3640                        foreach($comments as $comment) { 
    37                               Litmus::wo3_show_row($comment->num, "comments from ".$comment->comment_author_url_simplified, $comment->comment_id_list); 
     41                              self::wo3_show_row($comment->num, "comments from ".$comment->comment_author_url_simplified, $comment->comment_id_list); 
    3842                        } 
    3943                        echo("</table>"); 
  • worst-offenders/trunk/classes/email_litmus.php

    r39125 r43791  
    3131 
    3232            function content() {     
    33                   if ( EmailLitmus::isActive() || AllLitmus::isActive() ) { 
     33                  if ( self::isActive() || AllLitmus::isActive() ) { 
     34                        echo("<table>"); 
    3435                        $comments = EmailLitmus::getMatches(); 
    35                         echo("<table>"); 
     36                         
     37                        if (self::isActive()) { 
     38                              self::wo3_include_select_all($comments); 
     39                        } 
     40 
    3641                        foreach($comments as $comment) { 
    3742                              Litmus::wo3_show_row($comment->num, "comments from ".$comment->comment_author_email, $comment->comment_id_list); 
     
    4651 
    4752            //============================================ 
    48             // common class methods for litmus tests   
     53            // common class methods for litmus tests:   
    4954            // (there's got to be a better way to do this! 
     55            // somebody please tell me what it is, because 
     56            // include doesn't work in objects and moving 
     57            // these to the superclass results in getName() 
     58            // (etc) not referencing the subclass. 
    5059            //============================================ 
    51              
     60 
    5261            function getCount() { 
    5362                  global $wo3_title; 
     
    5564                  return wp_cache_get(self::getName()."_count", $wo3_title); 
    5665            } 
    57              
     66 
    5867            public static function tab() {       
    5968                  parent::tab(self::getName(), self::getCount(), self::isActive()); 
    6069            } 
    61              
     70 
    6271            function isActive() { 
    6372                  return ($_GET['tab'] == self::getName() ) && parent::isActive(); 
  • worst-offenders/trunk/classes/ip_litmus.php

    r39125 r43791  
    2222             
    2323            public static function getMatches() { 
    24                   global $keys
     24                  global $keys, $wpdb
    2525                  $lower_limit = get_option( $keys['ui_vis'] );  
     26                  $wpdb->get_results("SET SESSION group_concat_max_len = 8192"); 
    2627                  return self::runCachedMatchesQuery( 
    2728                        self::getName(), 
    28                         "select comment_author_ip, count(comment_id) as num, group_concat(comment_ID separator ',') as comment_id_list from wp_comments where comment_approved='spam' group by comment_author_ip having num >= $lower_limit order by num;"                   
     29                        "select comment_author_ip, count(comment_id) as num, group_concat(comment_ID separator ',') as comment_id_list from wp_comments where comment_approved='spam' group by comment_author_ip having num >= $lower_limit order by num desc;"              
    2930                  ); 
    3031            } 
     
    3233            function content() {     
    3334                  if (IPLitmus::isActive() || AllLitmus::isActive()) { 
    34                         $comments = IPLitmus::getMatches(); 
     35                        $comments = self::getMatches(); 
    3536                        echo("<table>"); 
     37 
     38                        if (self::isActive()) { 
     39                              self::wo3_include_select_all($comments); 
     40                        } 
     41 
    3642                        foreach($comments as $comment) { 
    3743                              Litmus::wo3_show_row($comment->num, "messages from ".$comment->comment_author_ip, $comment->comment_id_list); 
  • worst-offenders/trunk/classes/litmus.php

    r39125 r43791  
    8585      } 
    8686 
     87 
     88      public static function wo3_show_rows($num, $comments) { 
     89            foreach($comments as $comment) { 
     90                  self::wo3_show_row(1, $comment->comment_author, $comment->comment_id); 
     91            } 
     92      } 
     93 
     94 
     95      public static function wo3_include_select_all($comments) { 
     96            if (sizeof($comments) > 0) { 
     97                  echo("<tr><td><input id='all' type='checkbox' onclick='toggleCheck(this)' name='' value='' /></td><td></td><td>Select all</td></tr>"); 
     98            } 
     99      } 
     100 
    87101      function link_to_comments($comma_separated_list) { 
    88102            foreach( explode( ",", $comma_separated_list ) as $id ) { 
  • worst-offenders/trunk/classes/md5_litmus.php

    r39125 r43791  
    3232            function content() {     
    3333                  if (self::isActive() || AllLitmus::isActive()) { 
     34                        echo("<table>"); 
    3435                        $comments = self::getMatches(); 
    35                         echo("<table>"); 
    36                         if (!AllLitmus::isActive()) echo("<tr><th></th><th>Links</th><th>Message ID</th></tr>"); 
     36                        if (self::isActive()) { 
     37                              self::wo3_include_select_all($comments); 
     38                        } 
    3739                        foreach($comments as $comment) { 
    3840                              Litmus::wo3_show_row($comment->num, "messages match MD5(".$comment->comment_content_md5.")", $comment->comment_id_list); 
  • worst-offenders/trunk/classes/multilink_litmus.php

    r39125 r43791  
    2222 
    2323            public static function getMatches() { 
    24                   global $keys
     24                  global $keys, $wpdb
    2525                  $lower_limit = get_option( $keys['ui_vis'] );  
     26                  $wpdb->get_results("SET SESSION group_concat_max_len = 8192"); 
    2627                  return self::runCachedMatchesQuery( 
    2728                        self::getName(), 
     
    3132            function content() {     
    3233                  if (self::isActive() || AllLitmus::isActive()) { 
     34                        echo("<table>"); 
    3335                        $comments = MultiLinkLitmus::getMatches(); 
    34                         echo("<table>"); 
     36                        if (self::isActive()) { 
     37                              self::wo3_include_select_all($comments); 
     38                        } 
    3539                        foreach($comments as $comment) { 
    36                                    Litmus::wo3_show_row($comment->num, "links found in", $comment->comment_id_list ); 
     40                              self::wo3_show_row($comment->num, "links found in", $comment->comment_id_list ); 
    3741                        } 
    3842                        echo("</table>"); 
  • worst-offenders/trunk/classes/name_length_litmus.php

    r35682 r43791  
    3333                        $comments = self::getMatches(); 
    3434                        echo("<table>"); 
    35                         foreach($comments as $comment) { 
    36                                     self::wo3_show_row(1, $comment->comment_author, $comment->comment_id); 
     35 
     36                        if (self::isActive()) { 
     37                              self::wo3_include_select_all($comments); 
    3738                        } 
     39 
     40                        self::wo3_show_rows(1, $comments); 
    3841                        echo("</table>"); 
    3942                  } 
  • worst-offenders/trunk/classes/obvious_name_litmus.php

    r39125 r43791  
    3434            function content() {     
    3535                  if (self::isActive() || AllLitmus::isActive()) { 
     36                        echo("<table>"); 
    3637                        $comments = self::getMatches(); 
    37                         echo("<table>"); 
    38                         foreach($comments as $comment) { 
    39                                     self::wo3_show_row(1, $comment->comment_author, $comment->comment_id); 
     38                        if (self::isActive()) { 
     39                              self::wo3_include_select_all($comments); 
    4040                        } 
     41                        self::wo3_show_rows(1, $comments); 
    4142                        echo("</table>"); 
    4243                  } 
  • worst-offenders/trunk/functions.php

    r39125 r43791  
    251251function do_delete($comma_separated_id_list) { 
    252252      global $wpdb, $keys; 
    253        
    254       $query = "delete from   wp_comments where comment_ID in     ($comma_separated_id_list)"; 
     253      $query = "delete from wp_comments where   comment_ID in ($comma_separated_id_list)"; 
    255254      $result = $wpdb->query($query); 
    256255      return $result; 
     
    264263<ul   class="wo3_tabs"> 
    265264      <?php 
    266       do_action( "wo3_tabs"  ); 
     265      do_action( "wo3_tabs" ); 
    267266      ?> 
    268267</ul> 
    269268 
     269<script type="text/javascript"> 
     270      function toggleCheck(me) { 
     271            var new_value = me.checked; 
     272            for(i=0; i<me.form.length;i++){ 
     273         if(me.form[i].type == 'checkbox') { 
     274                        me.form[i].checked = new_value; 
     275                  } 
     276            } 
     277      } 
     278</script> 
    270279 
    271280<form method="post"     action=""> 
     281      <input type="submit" class="button delete" name="submit" value="<?php   _e('Delete selected'); ?>" /> 
    272282      <?php do_action( "wo3_content" );   ?> 
    273283      <input type="hidden" name="act"     value="delete" /> 
     
    282292            if (!empty($_POST['worst'])) { 
    283293                  $deletionList     =     implode(",", $_POST['worst']); 
     294//                $wo3_feedback[] = "<div class='updated'>$deletionList</div>"; 
    284295                  $deleted = do_delete($deletionList); 
    285296                  if ($deleted === false) { 
    286297                        $wo3_feedback[] = "<div class='updated'>DB      Error -     Failed to   delete - Boo!      Perhaps the DB   log   can   help!</div>"; 
    287298                  }     else { 
    288                         $wo3_feedback[] = "<div class='updated'>Congratulations, you just deleted <strong>$deleted</strong> spam comments!</div>"; 
     299                        $wo3_feedback[] = "<div class='updated'>Congratulations!  You just ignored <strong>$deleted</strong> servings of spam!</div>"; 
    289300                        update_option( $keys['counter'], $deleted + get_option( $keys['counter'] ) ); 
    290301                        reset_current_count();