Skip to:
Content

bbPress.org

Changeset 2328


Ignore:
Timestamp:
07/28/2009 03:41:57 PM (15 years ago)
Author:
sambauers
Message:

Update voice count when changing the status of posts. Fixes #1153

Location:
trunk/bb-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/bb-includes/functions.bb-posts.php

    r2279 r2328  
    347347                bb_update_usermeta( $poster_id, $bbdb->prefix . 'topics_replied', $user->topics_replied + 1 );
    348348
    349             if ( $voices = $bbdb->get_col( $bbdb->prepare( "SELECT DISTINCT poster_id FROM $bbdb->posts WHERE topic_id = %s AND post_status = '0';", $topic_id ) ) ) {
    350                 $voices = count( $voices );
    351                 bb_update_topicmeta( $topic_id, 'voices_count', $voices );
    352             }
    353349        } else {
    354350            bb_update_topicmeta( $topic->topic_id, 'deleted_posts', isset($topic->deleted_posts) ? $topic->deleted_posts + 1 : 1 );
    355351        }
    356352    }
     353    bb_update_topic_voices( $topic_id );
    357354   
    358355    if ( $throttle && !bb_current_user_can( 'throttle' ) )
     
    446443            bb_topic_set_last_post( $topic_id );
    447444            bb_update_post_positions( $topic_id );
    448         }
     445            bb_update_topic_voices( $topic_id );
     446        }
     447
    449448        $user = bb_get_user( $uid );
    450449
  • trunk/bb-includes/functions.bb-topics.php

    r2279 r2328  
    409409}
    410410
     411function bb_update_topic_voices( $topic_id )
     412{
     413    if ( !$topic_id ) {
     414        return;
     415    }
     416
     417    $topic_id = abs( (int) $topic_id );
     418
     419    global $bbdb;
     420    if ( $voices = $bbdb->get_col( $bbdb->prepare( "SELECT DISTINCT poster_id FROM $bbdb->posts WHERE topic_id = %s AND post_status = '0';", $topic_id ) ) ) {
     421        $voices = count( $voices );
     422        bb_update_topicmeta( $topic_id, 'voices_count', $voices );
     423    }
     424}
     425
    411426/* Thread */
    412427
Note: See TracChangeset for help on using the changeset viewer.