Changeset 1737

Show
Ignore:
Timestamp:
10/04/04 08:49:45 (4 years ago)
Author:
saxmatt
Message:

Kitten's emergent registration / comment whitelisting patch.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-admin/options-discussion.php

    r1620 r1737  
    5858    <form name="form1" method="post" action="options.php">  
    5959        <input type="hidden" name="action" value="update" />  
    60         <input type="hidden" name="page_options" value="'default_pingback_flag','default_ping_status','default_comment_status','comments_notify','moderation_notify','comment_moderation','require_name_email','comment_max_links','moderation_keys'" />  
     60        <input type="hidden" name="page_options" value="'default_pingback_flag','default_ping_status','default_comment_status','comments_notify','moderation_notify','comment_moderation','require_name_email','comment_whitelist','comment_max_links','moderation_keys'" />  
    6161<fieldset class="options"> 
    6262        <legend><?php _e('Usual settings for an article: <em>(These settings may be overridden for individual articles.)</em>') ?></legend>  
     
    102102                <?php _e('An administrator must approve the comment (regardless of any matches below)') ?> </label>  
    103103            </li>  
    104             <li>  
    105                 <label for="require_name_email">  
    106                 <input type="checkbox" name="require_name_email" id="require_name_email" value="1" <?php checked('1', get_settings('require_name_email')); ?> />  
    107                 <?php _e('User must fill out name and e-mail') ?> </label>  
    108             </li>  
     104            <li><label for="require_name_email"><input type="checkbox" name="require_name_email" id="require_name_email" value="1" <?php checked('1', get_settings('require_name_email')); ?> /> <?php _e('Comment author must fill out name and e-mail') ?></label></li>  
     105            <li><label for="comment_whitelist"><input type="checkbox" name="comment_whitelist" id="comment_whitelist" value="1" <?php checked('1', get_settings('comment_whitelist')); ?> /> <?php _e('Comment author must have a previously approved comment') ?></label></li>  
    109106        </ul>  
    110107</fieldset> 
  • trunk/wp-admin/upgrade-schema.php

    r1735 r1737  
    212212    add_option('template', 'default'); 
    213213    add_option('stylesheet', 'default'); 
     214    add_option('comment_whitelist', 0); 
    214215 
    215216    // Delete unused options 
  • trunk/wp-includes/functions.php

    r1734 r1737  
    14741474 
    14751475function check_comment($author, $email, $url, $comment, $user_ip) { 
     1476    global $wpdb; 
     1477 
    14761478    if (1 == get_settings('comment_moderation')) return false; // If moderation is set to manual 
    14771479 
     
    14791481        return false; // Check # of external links 
    14801482 
    1481     if ('' == trim( get_settings('moderation_keys') ) ) return true; // If moderation keys are empty 
    1482     $words = explode("\n", get_settings('moderation_keys') ); 
     1483    // Comment whitelisting: 
     1484    if ( 1 == get_settings('comment_whitelist')) { 
     1485        $ok_to_comment = $wpdb->get_var("SELECT comment_approved FROM $wpdb->comments WHERE comment_author_email = '$email' and comment_approved = '1' "); 
     1486        if ( 1 == $ok_to_comment && false === strpos( $email, get_settings('moderation_keys')) ) 
     1487            return true 
     1488    return false; 
     1489    } 
     1490 
     1491    $mod_keys = trim( get_settings('moderation_keys') ); 
     1492    if ('' == $mod_keys ) 
     1493        return true; // If moderation keys are empty 
     1494    $words = explode("\n", $mod_keys ); 
     1495 
    14831496    foreach ($words as $word) { 
    14841497        $word = trim($word);