Changeset 6534
- Timestamp:
- 06/12/2017 09:23:32 PM (8 years ago)
- Location:
- trunk/src/includes
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/admin/tools/upgrade.php
r6525 r6534 178 178 $tpt = bbp_get_topic_post_type(); 179 179 $rpt = bbp_get_reply_post_type(); 180 $pps = bbp_get_public_status_id(); 181 $cps = bbp_get_closed_status_id(); 180 182 $sql = "INSERT INTO {$bbp_db->postmeta} (post_id, meta_key, meta_value) ( 181 183 SELECT postmeta.meta_value, '_bbp_engagement', posts.post_author … … 185 187 AND postmeta.meta_key = '_bbp_topic_id' 186 188 WHERE posts.post_type IN (%s, %s) 189 AND posts.post_status IN (%s, %s) 187 190 GROUP BY postmeta.meta_value, posts.post_author)"; 188 191 189 192 // Run the big query 190 $prepare = $bbp_db->prepare( $sql, $tpt, $rpt );193 $prepare = $bbp_db->prepare( $sql, $tpt, $rpt, $pps, $cps ); 191 194 $engagements = $bbp_db->query( $prepare ); 192 195 -
trunk/src/includes/core/actions.php
r6530 r6534 258 258 add_action( 'bbp_trashed_reply', 'bbp_decrease_forum_reply_count' ); 259 259 add_action( 'bbp_trashed_topic', 'bbp_decrease_forum_topic_count' ); 260 add_action( 'bbp_trashed_topic', 'bbp_increase_forum_topic_count_hidden' );261 260 add_action( 'bbp_untrashed_reply', 'bbp_increase_forum_reply_count' ); 262 261 add_action( 'bbp_untrashed_topic', 'bbp_increase_forum_topic_count' ); 263 add_action( 'bbp_untrashed_topic', 'bbp_decrease_forum_topic_count_hidden' );264 262 add_action( 'bbp_spammed_reply', 'bbp_decrease_forum_reply_count' ); 265 263 add_action( 'bbp_spammed_topic', 'bbp_decrease_forum_topic_count' ); 266 add_action( 'bbp_spammed_topic', 'bbp_increase_forum_topic_count_hidden' );267 264 add_action( 'bbp_unspammed_reply', 'bbp_increase_forum_reply_count' ); 268 265 add_action( 'bbp_unspammed_topic', 'bbp_increase_forum_topic_count' ); 269 add_action( 'bbp_unspammed_topic', 'bbp_decrease_forum_topic_count_hidden' );270 266 add_action( 'bbp_approved_reply', 'bbp_increase_forum_reply_count' ); 271 267 add_action( 'bbp_approved_topic', 'bbp_increase_forum_topic_count' ); 272 add_action( 'bbp_approved_topic', 'bbp_decrease_forum_topic_count_hidden' );273 268 add_action( 'bbp_unapproved_reply', 'bbp_decrease_forum_reply_count' ); 274 269 add_action( 'bbp_unapproved_topic', 'bbp_decrease_forum_topic_count' ); 270 add_action( 'bbp_trashed_topic', 'bbp_increase_forum_topic_count_hidden' ); 271 add_action( 'bbp_untrashed_topic', 'bbp_decrease_forum_topic_count_hidden' ); 272 add_action( 'bbp_spammed_topic', 'bbp_increase_forum_topic_count_hidden' ); 273 add_action( 'bbp_unspammed_topic', 'bbp_decrease_forum_topic_count_hidden' ); 274 add_action( 'bbp_approved_topic', 'bbp_decrease_forum_topic_count_hidden' ); 275 275 add_action( 'bbp_unapproved_topic', 'bbp_increase_forum_topic_count_hidden' ); 276 276 … … 282 282 add_action( 'bbp_new_reply', 'bbp_increase_topic_reply_count' ); 283 283 add_action( 'bbp_trashed_reply', 'bbp_decrease_topic_reply_count' ); 284 add_action( 'bbp_untrashed_reply', 'bbp_increase_topic_reply_count' ); 285 add_action( 'bbp_spammed_reply', 'bbp_decrease_topic_reply_count' ); 286 add_action( 'bbp_unspammed_reply', 'bbp_increase_topic_reply_count' ); 287 add_action( 'bbp_approved_reply', 'bbp_increase_topic_reply_count' ); 288 add_action( 'bbp_unapproved_reply', 'bbp_decrease_topic_reply_count' ); 284 289 add_action( 'bbp_trashed_reply', 'bbp_increase_topic_reply_count_hidden' ); 285 add_action( 'bbp_untrashed_reply', 'bbp_increase_topic_reply_count' );286 290 add_action( 'bbp_untrashed_reply', 'bbp_decrease_topic_reply_count_hidden' ); 287 add_action( 'bbp_spammed_reply', 'bbp_decrease_topic_reply_count' );288 291 add_action( 'bbp_spammed_reply', 'bbp_increase_topic_reply_count_hidden' ); 289 add_action( 'bbp_unspammed_reply', 'bbp_increase_topic_reply_count' );290 292 add_action( 'bbp_unspammed_reply', 'bbp_decrease_topic_reply_count_hidden' ); 291 add_action( 'bbp_approved_reply', 'bbp_increase_topic_reply_count' );292 293 add_action( 'bbp_approved_reply', 'bbp_decrease_topic_reply_count_hidden' ); 293 add_action( 'bbp_unapproved_reply', 'bbp_decrease_topic_reply_count' );294 294 add_action( 'bbp_unapproved_reply', 'bbp_increase_topic_reply_count_hidden' ); 295 295 add_action( 'bbp_deleted_reply', 'bbp_decrease_topic_reply_count_hidden' ); … … 307 307 add_action( 'bbp_spam_reply', 'bbp_decrease_user_reply_count' ); 308 308 309 // Insert topic/reply engagements.310 add_action( 'bbp_insert_topic', 'bbp_update_topic_engagements' );311 add_action( 'bbp_insert_reply', 'bbp_update_topic_engagements' );312 313 // Insert topic/reply counts.314 add_action( 'bbp_insert_topic', 'bbp_insert_topic_update_counts', 10, 2 );315 add_action( 'bbp_insert_reply', 'bbp_insert_reply_update_counts', 10, 3 );316 317 // Update engagements.318 add_action( 'bbp_new_topic', 'bbp_update_topic_engagements' );319 add_action( 'bbp_new_reply', 'bbp_update_topic_engagements' );320 321 // Recalculate engagements.322 add_action( 'bbp_deleted_topic', 'bbp_recalculate_topic_engagements' );323 add_action( 'bbp_deleted_reply', 'bbp_recalculate_topic_engagements' );324 325 // Update engagement counts.326 add_action( 'bbp_new_reply', 'bbp_update_topic_voice_count' );327 add_action( 'bbp_trashed_reply', 'bbp_update_topic_voice_count' );328 add_action( 'bbp_untrashed_reply', 'bbp_update_topic_voice_count' );329 add_action( 'bbp_spammed_reply', 'bbp_update_topic_voice_count' );330 add_action( 'bbp_unspammed_reply', 'bbp_update_topic_voice_count' );331 add_action( 'bbp_approved_reply', 'bbp_update_topic_voice_count' );332 add_action( 'bbp_unapproved_reply', 'bbp_update_topic_voice_count' );333 add_action( 'bbp_deleted_reply', 'bbp_update_topic_voice_count' );334 335 // Insert reply voice counts.336 add_action( 'bbp_insert_reply', 'bbp_update_topic_voice_count' );337 338 309 // Topic status transition helpers for replies 339 310 add_action( 'bbp_trash_topic', 'bbp_trash_topic_replies' ); … … 342 313 add_action( 'bbp_spam_topic', 'bbp_spam_topic_replies' ); 343 314 add_action( 'bbp_unspam_topic', 'bbp_unspam_topic_replies' ); 315 316 // Topic engagements on user creation. 317 add_action( 'bbp_new_topic', 'bbp_update_topic_engagements', 20 ); 318 add_action( 'bbp_new_reply', 'bbp_update_topic_engagements', 20 ); 319 320 add_action( 'bbp_new_reply', 'bbp_update_topic_voice_count', 30 ); 321 add_action( 'bbp_new_topic', 'bbp_update_topic_voice_count', 30 ); 322 323 // Topic/reply counts on code insert (unit tests) 324 add_action( 'bbp_insert_topic', 'bbp_insert_topic_update_counts', 10, 2 ); 325 add_action( 'bbp_insert_reply', 'bbp_insert_reply_update_counts', 10, 3 ); 326 327 // Topic engagements on code insert (unit tests) 328 add_action( 'bbp_insert_topic', 'bbp_update_topic_engagements', 20 ); 329 add_action( 'bbp_insert_reply', 'bbp_update_topic_engagements', 20 ); 330 331 // Topic engagement counts on code insert (unit tests) 332 add_action( 'bbp_insert_topic', 'bbp_update_topic_voice_count', 30 ); 333 add_action( 'bbp_insert_reply', 'bbp_update_topic_voice_count', 30 ); 334 335 // Recalculate engagements. 336 add_action( 'bbp_trashed_reply', 'bbp_recalculate_topic_engagements' ); 337 add_action( 'bbp_untrashed_reply', 'bbp_recalculate_topic_engagements' ); 338 add_action( 'bbp_spammed_reply', 'bbp_recalculate_topic_engagements' ); 339 add_action( 'bbp_unspammed_reply', 'bbp_recalculate_topic_engagements' ); 340 add_action( 'bbp_approved_reply', 'bbp_recalculate_topic_engagements' ); 341 add_action( 'bbp_unapproved_reply', 'bbp_recalculate_topic_engagements' ); 342 add_action( 'bbp_deleted_reply', 'bbp_recalculate_topic_engagements' ); 343 add_action( 'bbp_trashed_topic', 'bbp_recalculate_topic_engagements' ); 344 add_action( 'bbp_untrashed_topic', 'bbp_recalculate_topic_engagements' ); 345 add_action( 'bbp_spammed_topic', 'bbp_recalculate_topic_engagements' ); 346 add_action( 'bbp_unspammed_topic', 'bbp_recalculate_topic_engagements' ); 347 add_action( 'bbp_approved_topic', 'bbp_recalculate_topic_engagements' ); 348 add_action( 'bbp_unapproved_topic', 'bbp_recalculate_topic_engagements' ); 349 add_action( 'bbp_deleted_topic', 'bbp_recalculate_topic_engagements' ); 350 351 // Update engagement counts. 352 add_action( 'bbp_trashed_reply', 'bbp_update_topic_voice_count', 30 ); 353 add_action( 'bbp_untrashed_reply', 'bbp_update_topic_voice_count', 30 ); 354 add_action( 'bbp_spammed_reply', 'bbp_update_topic_voice_count', 30 ); 355 add_action( 'bbp_unspammed_reply', 'bbp_update_topic_voice_count', 30 ); 356 add_action( 'bbp_approved_reply', 'bbp_update_topic_voice_count', 30 ); 357 add_action( 'bbp_unapproved_reply', 'bbp_update_topic_voice_count', 30 ); 358 add_action( 'bbp_deleted_reply', 'bbp_update_topic_voice_count', 30 ); 359 add_action( 'bbp_trashed_topic', 'bbp_update_topic_voice_count', 30 ); 360 add_action( 'bbp_untrashed_topic', 'bbp_update_topic_voice_count', 30 ); 361 add_action( 'bbp_spammed_topic', 'bbp_update_topic_voice_count', 30 ); 362 add_action( 'bbp_unspammed_topic', 'bbp_update_topic_voice_count', 30 ); 363 add_action( 'bbp_approved_topic', 'bbp_update_topic_voice_count', 30 ); 364 add_action( 'bbp_unapproved_topic', 'bbp_update_topic_voice_count', 30 ); 365 add_action( 'bbp_deleted_topic', 'bbp_update_topic_voice_count', 30 ); 344 366 345 367 // User status -
trunk/src/includes/forums/functions.php
r6529 r6534 1205 1205 $forum_id = bbp_get_topic_forum_id( $topic_id ); 1206 1206 1207 // If this is a new, unpublished, topic, increase hidden count and bail.1208 if ( 'bbp_new_topic' === current_filter() && ( ! bbp_is_topic_published( $topic_id ) && ! bbp_is_topic_closed( $topic_id )) ) {1207 // Bail if not public. 1208 if ( ! bbp_is_topic_public( $topic_id ) ) { 1209 1209 bbp_increase_forum_topic_count_hidden( $forum_id ); 1210 1210 return; … … 1419 1419 // If it's a reply, get the forum id. 1420 1420 if ( bbp_is_reply( $forum_id ) ) { 1421 $reply_id = $forum_id; 1422 $forum_id = bbp_get_reply_forum_id( $reply_id ); 1423 1424 // Don't update if this is a new, unpublished, reply. 1425 if ( 'bbp_new_reply' === current_filter() && ! bbp_is_reply_published( $reply_id ) ) { 1426 return; 1427 } 1421 $forum_id = bbp_get_reply_forum_id( $forum_id ); 1428 1422 } 1429 1423 -
trunk/src/includes/replies/functions.php
r6529 r6534 109 109 110 110 // If the reply is public, update the forum/topic reply counts. 111 if ( bbp_ get_reply_status( $reply_id ) === bbp_get_public_status_id() ) {111 if ( bbp_is_reply_published( $reply_id ) ) { 112 112 bbp_increase_topic_reply_count( $topic_id ); 113 bbp_increase_forum_reply_count( $ forum_id );113 bbp_increase_forum_reply_count( $reply_id ); 114 114 115 115 // If the reply isn't public only update the topic reply hidden count. -
trunk/src/includes/topics/functions.php
r6529 r6534 2518 2518 2519 2519 // If this is a new, unpublished, reply, update hidden count and bail. 2520 if ( 'bbp_new_reply' === current_filter() &&! bbp_is_reply_published( $reply_id ) ) {2520 if ( ! bbp_is_reply_published( $reply_id ) ) { 2521 2521 bbp_increase_topic_reply_count_hidden( $topic_id ); 2522 2522 return; … … 2664 2664 2665 2665 // If the topic is public, update the forum topic counts. 2666 if ( bbp_ get_topic_status( $topic_id ) === bbp_get_public_status_id() ) {2666 if ( bbp_is_topic_public( $topic_id ) ) { 2667 2667 bbp_increase_forum_topic_count( $forum_id ); 2668 2668 … … 2695 2695 2696 2696 // If it's a reply, then get the parent (topic id) 2697 if ( bbp_is_reply( $topic_id ) ) { 2698 $topic_id = bbp_get_reply_topic_id( $topic_id ); 2699 } else { 2700 $topic_id = bbp_get_topic_id( $topic_id ); 2701 } 2702 2697 $topic_id = bbp_is_reply( $topic_id ) 2698 ? bbp_get_reply_topic_id( $topic_id ) 2699 : bbp_get_topic_id( $topic_id ); 2700 2701 // Forum ID fallback 2703 2702 if ( empty( $forum_id ) ) { 2704 2703 $forum_id = get_post_field( 'post_parent', $topic_id ); … … 2753 2752 2754 2753 // If it's a reply, then get the parent (topic id) 2755 if ( bbp_is_reply( $topic_id ) ) { 2756 $topic_id = bbp_get_reply_topic_id( $topic_id ); 2757 } else { 2758 $topic_id = bbp_get_topic_id( $topic_id ); 2759 } 2754 $topic_id = bbp_is_reply( $topic_id ) 2755 ? bbp_get_reply_topic_id( $topic_id ) 2756 : bbp_get_topic_id( $topic_id ); 2760 2757 2761 2758 // Get replies of topic if not passed … … 2797 2794 2798 2795 // If it's a reply, then get the parent (topic id) 2799 if ( bbp_is_reply( $topic_id ) ) { 2800 $topic_id = bbp_get_reply_topic_id( $topic_id ); 2801 } else { 2802 $topic_id = bbp_get_topic_id( $topic_id ); 2803 } 2796 $topic_id = bbp_is_reply( $topic_id ) 2797 ? bbp_get_reply_topic_id( $topic_id ) 2798 : bbp_get_topic_id( $topic_id ); 2804 2799 2805 2800 // Get replies of topic … … 2841 2836 2842 2837 // If it's a reply, then get the parent (topic id) 2843 if ( bbp_is_reply( $topic_id ) ) { 2844 $topic_id = bbp_get_reply_topic_id( $topic_id ); 2845 } else { 2846 $topic_id = bbp_get_topic_id( $topic_id ); 2847 } 2848 2838 $topic_id = bbp_is_reply( $topic_id ) 2839 ? bbp_get_reply_topic_id( $topic_id ) 2840 : bbp_get_topic_id( $topic_id ); 2841 2842 // Get last public active id if not passed 2849 2843 if ( empty( $active_id ) ) { 2850 2844 $active_id = bbp_get_public_child_last_id( $topic_id, bbp_get_reply_post_type() ); … … 2886 2880 2887 2881 // If it's a reply, then get the parent (topic id) 2888 if ( bbp_is_reply( $topic_id ) ) { 2889 $topic_id = bbp_get_reply_topic_id( $topic_id ); 2890 } else { 2891 $topic_id = bbp_get_topic_id( $topic_id ); 2892 } 2882 $topic_id = bbp_is_reply( $topic_id ) 2883 ? bbp_get_reply_topic_id( $topic_id ) 2884 : bbp_get_topic_id( $topic_id ); 2893 2885 2894 2886 // Check time and use current if empty … … 3019 3011 3020 3012 // If it's a reply, then get the parent (topic id) 3021 if ( bbp_is_reply( $topic_id ) ) { 3022 $topic_id = bbp_get_reply_topic_id( $topic_id ); 3023 } elseif ( bbp_is_topic( $topic_id ) ) { 3024 $topic_id = bbp_get_topic_id( $topic_id ); 3025 } else { 3026 return; 3027 } 3013 $topic_id = bbp_is_reply( $topic_id ) 3014 ? bbp_get_reply_topic_id( $topic_id ) 3015 : bbp_get_topic_id( $topic_id ); 3028 3016 3029 3017 // Query the DB to get anonymous replies in this topic … … 3452 3440 3453 3441 /** 3454 * Retr eive tags to a topic from post meta before it's unmarked as spam so they.3442 * Retrieve tags to a topic from post meta before it's unmarked as spam so they. 3455 3443 * 3456 3444 * Usually you'll want to do this before the topic itself is unmarked as spam. -
trunk/src/includes/users/engagements.php
r6529 r6534 196 196 $topic_id = bbp_get_topic_id( $topic_id ); 197 197 $bbp_db = bbp_db(); 198 $statii = "'" . implode( "', '", bbp_get_public_topic_statuses() ) . "'"; 198 199 199 200 // A cool UNION query! … … 201 202 SELECT DISTINCT( post_author ) FROM ( 202 203 SELECT post_author FROM {$bbp_db->posts} 203 WHERE ( ID = %d AND post_ type = %s )204 WHERE ( ID = %d AND post_status IN ({$statii}) AND post_type = %s ) 204 205 UNION 205 206 SELECT post_author FROM {$bbp_db->posts} 206 WHERE ( post_parent = %d AND post_ type = %s )207 WHERE ( post_parent = %d AND post_status = %s AND post_type = %s ) 207 208 ) as u1"; 208 209 209 210 // Prepare & get results 210 $query = $bbp_db->prepare( $sql, $topic_id, bbp_get_topic_post_type(), $topic_id, bbp_get_ reply_post_type() );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() ); 211 212 $results = $bbp_db->get_col( $query ); 212 213 … … 439 440 function bbp_update_topic_engagements( $topic_id = 0 ) { 440 441 441 // Check post type442 // Is a reply 442 443 if ( bbp_is_reply( $topic_id ) ) { 444 445 // Bail if reply isn't published 446 if ( ! bbp_is_reply_published( $topic_id ) ) { 447 return; 448 } 449 443 450 $author_id = bbp_get_reply_author_id( $topic_id ); 444 451 $topic_id = bbp_get_reply_topic_id( $topic_id ); 452 453 // Is a topic 445 454 } elseif ( bbp_is_topic( $topic_id ) ) { 446 455 $author_id = bbp_get_topic_author_id( $topic_id ); 447 456 $topic_id = bbp_get_topic_id( $topic_id ); 457 458 // Is unknown 448 459 } else { 460 return; 461 } 462 463 // Bail if topic is not public 464 if ( ! bbp_is_topic_public( $topic_id ) ) { 449 465 return; 450 466 }
Note: See TracChangeset
for help on using the changeset viewer.