Ticket #6286: individual notifications.2.diff
File individual notifications.2.diff, 10.9 KB (added by , 15 years ago) |
---|
-
Users/simon/Projects/WordPress-Bleeding/site/wp-includes/comment.php
1350 1350 1351 1351 $post = &get_post($commentdata['comment_post_ID']); // Don't notify if it's your own comment 1352 1352 1353 if ( get_ option('comments_notify') && $commentdata['comment_approved'] && ( ! isset( $commentdata['user_id'] ) || $post->post_author != $commentdata['user_id'] ) )1353 if ( get_user_option('comments_notify', $post->post_author) && $commentdata['comment_approved'] && ( ! isset( $commentdata['user_id'] ) || $post->post_author != $commentdata['user_id'] ) ) 1354 1354 wp_notify_postauthor($comment_ID, isset( $commentdata['comment_type'] ) ? $commentdata['comment_type'] : '' ); 1355 1355 } 1356 1356 … … 1386 1386 case 'approve': 1387 1387 case '1': 1388 1388 $status = '1'; 1389 if ( get_option('comments_notify') ) { 1390 $comment = get_comment($comment_id); 1389 $comment = get_comment($comment_id); 1390 $post = get_post($comment->comment_post_ID); 1391 if ( get_user_option('comments_notify', $post->post_author) ) 1391 1392 wp_notify_postauthor($comment_id, $comment->comment_type); 1392 }1393 1393 break; 1394 1394 case 'spam': 1395 1395 $status = 'spam'; … … 1575 1575 return true; 1576 1576 } 1577 1577 1578 /** 1579 * Gets the User IDs of the users who should be emailed if a 1580 * particular comment is held for moderation. 1581 * 1582 * @param int $comment_id The ID of the comment we want moderation recipients for 1583 * @return array An array of WP_User objects 1584 **/ 1585 function wp_get_moderation_recipients( $comment_id ) { 1586 global $wpdb; 1587 1588 $comment = get_comment( $comment_id ); 1589 $post = get_post( $comment->comment_post_ID ); 1590 1591 // Find the IDs of the users who have requested moderation notifications in 1592 // one way or another. 1593 $sql = " SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s OR ( user_id = %d AND meta_key = %s ) "; 1594 $moderation_notify = $wpdb->prefix . 'moderation_notify'; 1595 $moderation_notify_all = $wpdb->prefix . 'moderation_notify_all'; 1596 $user_ids = $wpdb->get_col( $wpdb->prepare( $sql, $comments_notify, $post->post_author, $comments_notify_all ) ); 1597 1598 $user_ids = array_unique( $user_ids ); 1599 1600 $users = array(); 1601 foreach ( $user_ids as $user_id ) 1602 $users[] = new WP_User( $user_id ); 1603 1604 return $users; 1605 } 1606 1578 1607 // 1579 1608 // Ping and trackback functions. 1580 1609 // -
Users/simon/Projects/WordPress-Bleeding/site/wp-includes/pluggable.php
1102 1102 function wp_notify_moderator($comment_id) { 1103 1103 global $wpdb; 1104 1104 1105 if ( 0 == get_option( 'moderation_notify') )1105 if ( ! $recipients = wp_get_moderation_recipients( $comment_id ) ) 1106 1106 return true; 1107 1107 1108 $email_to = array(); 1109 foreach ( $recipients as $recipient ) 1110 $email_to[] = $recipient->user_email; 1111 1108 1112 $comment = get_comment($comment_id); 1109 1113 $post = get_post($comment->comment_post_ID); 1110 $user = get_userdata( $post->post_author );1111 // Send to the administation and to the post author if the author can modify the comment.1112 $email_to = array( get_option('admin_email') );1113 if ( user_can($user->ID, 'edit_comment', $comment_id) && !empty($user->user_email) && ( get_option('admin_email') != $user->user_email) )1114 $email_to[] = $user->user_email;1115 1114 1116 1115 $comment_author_domain = @gethostbyaddr($comment->comment_author_IP); 1117 1116 $comments_waiting = $wpdb->get_var("SELECT count(comment_ID) FROM $wpdb->comments WHERE comment_approved = '0'"); -
Users/simon/Projects/WordPress-Bleeding/site/wp-admin/includes/schema.php
206 206 'use_balanceTags' => 0, 207 207 'use_smilies' => 1, 208 208 'require_name_email' => 1, 209 'comments_notify' => 1,210 209 'posts_per_rss' => 10, 211 210 'rss_use_excerpt' => 0, 212 211 'mailserver_url' => 'mail.example.com', … … 229 228 'links_recently_updated_append' => '</em>', 230 229 'links_recently_updated_time' => 120, 231 230 'comment_moderation' => 0, 232 'moderation_notify' => 1,233 231 'permalink_structure' => '', 234 232 'gzipcompression' => 0, 235 233 'hack_file' => 0, -
Users/simon/Projects/WordPress-Bleeding/site/wp-admin/includes/user.php
185 185 $user_id = wp_insert_user( get_object_vars( $user ) ); 186 186 wp_new_user_notification( $user_id, isset($_POST['send_password']) ? $pass1 : '' ); 187 187 } 188 189 // Per site email notification settings 190 // Only change these if the user can moderate comments 191 if ( user_can( $user_id, 'moderate_comments' ) ) { 192 // @TODO: Some of these options probably need to be defaulted on when the first user in a site is created 193 $comments_notify = (bool) @ $_POST['comments_notify']; 194 $moderation_notify = (bool) @ $_POST['moderation_notify']; 195 $moderation_notify_all = (bool) @ $_POST['moderation_notify_all']; 196 update_user_option( $user_id, 'comments_notify', $comments_notify ); 197 update_user_option( $user_id, 'moderation_notify', $moderation_notify ); 198 update_user_option( $user_id, 'moderation_notify_all', $moderation_notify_all ); 199 } 200 188 201 return $user_id; 189 202 } 190 203 -
Users/simon/Projects/WordPress-Bleeding/site/wp-admin/options-discussion.php
113 113 </fieldset></td> 114 114 </tr> 115 115 <tr valign="top"> 116 <th scope="row"><?php _e('E-mail me whenever') ?></th>117 <td><fieldset><legend class="screen-reader-text"><span><?php _e('E-mail me whenever') ?></span></legend>118 <label for="comments_notify">119 <input name="comments_notify" type="checkbox" id="comments_notify" value="1" <?php checked('1', get_option('comments_notify')); ?> />120 <?php _e('Anyone posts a comment') ?> </label>121 <br />122 <label for="moderation_notify">123 <input name="moderation_notify" type="checkbox" id="moderation_notify" value="1" <?php checked('1', get_option('moderation_notify')); ?> />124 <?php _e('A comment is held for moderation') ?> </label>125 </fieldset></td>126 </tr>127 <tr valign="top">128 116 <th scope="row"><?php _e('Before a comment appears') ?></th> 129 117 <td><fieldset><legend class="screen-reader-text"><span><?php _e('Before a comment appears') ?></span></legend> 130 118 <label for="comment_moderation"> -
Users/simon/Projects/WordPress-Bleeding/site/wp-admin/options.php
56 56 57 57 $whitelist_options = array( 58 58 'general' => array( 'blogname', 'blogdescription', 'gmt_offset', 'date_format', 'time_format', 'start_of_week', 'timezone_string' ), 59 'discussion' => array( 'default_pingback_flag', 'default_ping_status', 'default_comment_status', 'comment s_notify', 'moderation_notify', 'comment_moderation', 'require_name_email', 'comment_whitelist', 'comment_max_links', 'moderation_keys', 'blacklist_keys', 'show_avatars', 'avatar_rating', 'avatar_default', 'close_comments_for_old_posts', 'close_comments_days_old', 'thread_comments', 'thread_comments_depth', 'page_comments', 'comments_per_page', 'default_comments_page', 'comment_order', 'comment_registration' ),59 'discussion' => array( 'default_pingback_flag', 'default_ping_status', 'default_comment_status', 'comment_moderation', 'require_name_email', 'comment_whitelist', 'comment_max_links', 'moderation_keys', 'blacklist_keys', 'show_avatars', 'avatar_rating', 'avatar_default', 'close_comments_for_old_posts', 'close_comments_days_old', 'thread_comments', 'thread_comments_depth', 'page_comments', 'comments_per_page', 'default_comments_page', 'comment_order', 'comment_registration' ), 60 60 'media' => array( 'thumbnail_size_w', 'thumbnail_size_h', 'thumbnail_crop', 'medium_size_w', 'medium_size_h', 'large_size_w', 'large_size_h', 'image_default_size', 'image_default_align', 'image_default_link_type', 'embed_autourls', 'embed_size_w', 'embed_size_h' ), 61 61 'privacy' => array( 'blog_public' ), 62 62 'reading' => array( 'posts_per_page', 'posts_per_rss', 'rss_use_excerpt', 'blog_charset', 'show_on_front', 'page_on_front', 'page_for_posts' ), -
Users/simon/Projects/WordPress-Bleeding/site/wp-admin/user-edit.php
211 211 <th scope="row"><?php _e( 'Keyboard Shortcuts' ); ?></th> 212 212 <td><label for="comment_shortcuts"><input type="checkbox" name="comment_shortcuts" id="comment_shortcuts" value="true" <?php if ( !empty($profileuser->comment_shortcuts) ) checked('true', $profileuser->comment_shortcuts); ?> /> <?php _e('Enable keyboard shortcuts for comment moderation.'); ?></label> <?php _e('<a href="http://codex.wordpress.org/Keyboard_Shortcuts" target="_blank">More information</a>'); ?></td> 213 213 </tr> 214 <?php if ( user_can( $profileuser->ID, 'moderate_comments' ) ) : ?> 215 <input type="hidden" name="email_notifications" value="1" /> 216 <tr valign="top"> 217 <th scope="row"><?php _e('E-mail me whenever') ?></th> 218 <td><fieldset><legend class="screen-reader-text"><span><?php _e('E-mail me whenever') ?></span></legend> 219 <label for="comments_notify"> 220 <input name="comments_notify" type="checkbox" id="comments_notify" value="1" <?php checked('1', get_user_option('comments_notify', $profileuser->ID)); ?> /> 221 <?php _e('A comment is posted on one of my posts') ?> 222 </label> 223 <br /> 224 <br /> 225 <label for="moderation_notify"> 226 <input name="moderation_notify" type="checkbox" id="moderation_notify" value="1" <?php checked('1', get_user_option('moderation_notify', $profileuser->ID)); ?> /> 227 <?php _e('A comment on one of my posts is held for moderation') ?> </label> 228 <br /> 229 <label for="moderation_notify_all"> 230 <input name="moderation_notify_all" type="checkbox" id="moderation_notify_all" value="1" <?php checked('1', get_user_option('moderation_notify_all', $profileuser->ID)); ?> /> 231 <?php _e('Any comment is held for moderation') ?> </label> 232 </fieldset></td> 233 </tr> 234 <?php endif; // current_user_can moderate_comments ?> 214 235 <?php 215 236 endif; 216 237 do_action('personal_options', $profileuser);