Skip to:
Content

bbPress.org

Ticket #2863: 2863.02.patch

File 2863.02.patch, 4.7 KB (added by thebrandonallen, 9 years ago)
  • src/includes/common/functions.php

    diff --git src/includes/common/functions.php src/includes/common/functions.php
    index da33568..0c89a45 100644
    function bbp_notify_topic_subscribers( $reply_id = 0, $topic_id = 0, $forum_id = 
    11011101        // Poster name
    11021102        $reply_author_name = bbp_get_reply_author_display_name( $reply_id );
    11031103
     1104        /** Users *****************************************************************/
     1105
     1106        // Get topic subscribers and bail if empty
     1107        $user_ids = bbp_get_topic_subscribers( $topic_id, true );
     1108
     1109        // Dedicated filter to manipulate user ID's to send emails to
     1110        $user_ids = (array) apply_filters( 'bbp_topic_subscription_user_ids', $user_ids );
     1111        $user_ids = array_filter( array_map( 'intval', $user_ids ) );
     1112        if ( empty( $user_ids ) ) {
     1113                return false;
     1114        }
     1115
     1116        // Remove the reply author from the list.
     1117        $reply_author_key = array_search( (int) $reply_author, $user_ids, true );
     1118        if ( false !== $reply_author_key ) {
     1119                unset( $user_ids[ $reply_author_key ] );
     1120        }
     1121
     1122        // Bail of the reply author was the only one subscribed.
     1123        if ( empty( $user_ids ) ) {
     1124                return false;
     1125        }
     1126
    11041127        /** Mail ******************************************************************/
    11051128
    11061129        // Remove filters from reply content and topic title to prevent content
    Login and visit the topic to unsubscribe from these emails.', 'bbpress' ), 
    11431166                return;
    11441167        }
    11451168
    1146         /** Users *****************************************************************/
     1169        /** Headers ***************************************************************/
    11471170
    11481171        // Get the noreply@ address
    11491172        $no_reply   = bbp_get_do_not_reply_address();
    Login and visit the topic to unsubscribe from these emails.', 'bbpress' ), 
    11541177        // Setup the From header
    11551178        $headers = array( 'From: ' . get_bloginfo( 'name' ) . ' <' . $from_email . '>' );
    11561179
    1157         // Get topic subscribers and bail if empty
    1158         $user_ids = bbp_get_topic_subscribers( $topic_id, true );
    1159 
    1160         // Dedicated filter to manipulate user ID's to send emails to
    1161         $user_ids = apply_filters( 'bbp_topic_subscription_user_ids', $user_ids );
    1162         if ( empty( $user_ids ) ) {
    1163                 return false;
    1164         }
    1165 
    11661180        // Loop through users
    11671181        foreach ( (array) $user_ids as $user_id ) {
    11681182
    1169                 // Don't send notifications to the person who made the post
    1170                 if ( ! empty( $reply_author ) && (int) $user_id === (int) $reply_author ) {
    1171                         continue;
    1172                 }
    1173 
    11741183                // Get email address of subscribed user
    11751184                $headers[] = 'Bcc: ' . get_userdata( $user_id )->user_email;
    11761185        }
    function bbp_notify_forum_subscribers( $topic_id = 0, $forum_id = 0, $anonymous_ 
    12581267        // Poster name
    12591268        $topic_author_name = bbp_get_topic_author_display_name( $topic_id );
    12601269
     1270        /** Users *****************************************************************/
     1271
     1272        // Get topic subscribers and bail if empty
     1273        $user_ids = bbp_get_forum_subscribers( $forum_id, true );
     1274
     1275        // Dedicated filter to manipulate user ID's to send emails to
     1276        $user_ids = (array) apply_filters( 'bbp_forum_subscription_user_ids', $user_ids );
     1277        $user_ids = array_filter( array_map( 'intval', $user_ids ) );
     1278        if ( empty( $user_ids ) ) {
     1279                return false;
     1280        }
     1281
     1282        // Remove the topic author from the list.
     1283        $topic_author_key = array_search( (int) $topic_author, $user_ids, true );
     1284        if ( false !== $topic_author_key ) {
     1285                unset( $user_ids[ $topic_author_key ] );
     1286        }
     1287
     1288        // Bail of the topic author was the only one subscribed.
     1289        if ( empty( $user_ids ) ) {
     1290                return false;
     1291        }
     1292
    12611293        /** Mail ******************************************************************/
    12621294
    12631295        // Remove filters from reply content and topic title to prevent content
    Login and visit the topic to unsubscribe from these emails.', 'bbpress' ), 
    13001332                return;
    13011333        }
    13021334
    1303         /** User ******************************************************************/
     1335        /** Headers ***************************************************************/
    13041336
    13051337        // Get the noreply@ address
    13061338        $no_reply   = bbp_get_do_not_reply_address();
    Login and visit the topic to unsubscribe from these emails.', 'bbpress' ), 
    13111343        // Setup the From header
    13121344        $headers = array( 'From: ' . get_bloginfo( 'name' ) . ' <' . $from_email . '>' );
    13131345
    1314         // Get topic subscribers and bail if empty
    1315         $user_ids = bbp_get_forum_subscribers( $forum_id, true );
    1316 
    1317         // Dedicated filter to manipulate user ID's to send emails to
    1318         $user_ids = apply_filters( 'bbp_forum_subscription_user_ids', $user_ids );
    1319         if ( empty( $user_ids ) ) {
    1320                 return false;
    1321         }
    1322 
    13231346        // Loop through users
    13241347        foreach ( (array) $user_ids as $user_id ) {
    13251348
    1326                 // Don't send notifications to the person who made the post
    1327                 if ( ! empty( $topic_author ) && (int) $user_id === (int) $topic_author ) {
    1328                         continue;
    1329                 }
    1330 
    13311349                // Get email address of subscribed user
    13321350                $headers[] = 'Bcc: ' . get_userdata( $user_id )->user_email;
    13331351        }