Skip to:
Content

bbPress.org

Changeset 6525


Ignore:
Timestamp:
06/12/2017 02:10:58 PM (8 years ago)
Author:
johnjamesjacoby
Message:

Engagements: Tracking is not just for public or closed topics.

This commit updates the engagement upgrade tool and recalculation helper functions to not be limited to public & closed post statuses. Engagements can happen on private or hidden topics also, including trash, spam, and so on.

The non-visible topics that a user is engaged in should be filtered out as needed when queried based on post_status or other various meta-data.

See #3068.

Location:
trunk/src/includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/admin/tools/upgrade.php

    r6523 r6525  
    178178    $tpt = bbp_get_topic_post_type();
    179179    $rpt = bbp_get_reply_post_type();
    180     $pps = bbp_get_public_status_id();
    181     $cps = bbp_get_closed_status_id();
    182     $sql = $bbp_db->prepare( "INSERT INTO {$bbp_db->postmeta} (post_id, meta_key, meta_value) (
     180    $sql = "INSERT INTO {$bbp_db->postmeta} (post_id, meta_key, meta_value) (
    183181            SELECT postmeta.meta_value, '_bbp_engagement', posts.post_author
    184182                FROM {$bbp_db->posts} AS posts
     
    187185                    AND postmeta.meta_key = '_bbp_topic_id'
    188186                WHERE posts.post_type IN (%s, %s)
    189                     AND posts.post_status IN (%s, %s)
    190                 GROUP BY postmeta.meta_value, posts.post_author)", $tpt, $rpt, $pps, $cps );
     187                GROUP BY postmeta.meta_value, posts.post_author)";
    191188
    192189    // Run the big query
    193     $prepare     = $bbp_db->prepare( $sql, $tpt, $rpt, $pps, $cps );
     190    $prepare     = $bbp_db->prepare( $sql, $tpt, $rpt );
    194191    $engagements = $bbp_db->query( $prepare );
    195192
  • trunk/src/includes/users/engagements.php

    r6522 r6525  
    196196    $topic_id = bbp_get_topic_id( $topic_id );
    197197    $bbp_db   = bbp_db();
    198     $statii   = "'" . implode( "', '", bbp_get_public_topic_statuses() ) . "'";
    199198
    200199    // A cool UNION query!
     
    202201SELECT DISTINCT( post_author ) FROM (
    203202    SELECT post_author FROM {$bbp_db->posts}
    204         WHERE ( ID = %d AND post_status IN ({$statii}) AND post_type = %s )
     203        WHERE ( ID = %d AND post_type = %s )
    205204UNION
    206205    SELECT post_author FROM {$bbp_db->posts}
    207         WHERE ( post_parent = %d AND post_status = %s AND post_type = %s )
     206        WHERE ( post_parent = %d AND post_type = %s )
    208207) as u1";
    209208
    210209    // Prepare & get results
    211     $query   = $bbp_db->prepare( $sql, $topic_id, bbp_get_topic_post_type(), $topic_id, bbp_get_public_status_id(), bbp_get_reply_post_type() );
     210    $query   = $bbp_db->prepare( $sql, $topic_id, bbp_get_topic_post_type(), $topic_id, bbp_get_reply_post_type() );
    212211    $results = $bbp_db->get_col( $query );
    213212
Note: See TracChangeset for help on using the changeset viewer.