Changeset 2858 for branches/plugin/bbp-includes/bbp-reply-functions.php
- Timestamp:
- 02/07/2011 01:51:29 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/plugin/bbp-includes/bbp-reply-functions.php
r2818 r2858 7 7 * @subpackage Functions 8 8 */ 9 10 /** 11 * Update the reply with its forum ID it is in 12 * 13 * @since bbPress (r2855) 14 * 15 * @param int $reply_id Optional. Reply id to update 16 * @param int $forum_id Optional. Forum id 17 * @uses bbp_get_reply_id() To get the reply id 18 * @uses bbp_get_forum_id() To get the forum id 19 * @uses update_post_meta() To update the reply forum id meta 20 * @return bool True on success, false on failure 21 */ 22 function bbp_update_reply_forum_id( $reply_id = 0, $forum_id = 0 ) { 23 $reply_id = bbp_get_reply_id( $reply_id ); 24 $forum_id = bbp_get_forum_id( $forum_id ); 25 26 // Update the last reply ID 27 if ( !empty( $reply_id ) ) 28 return update_post_meta( $reply_id, '_bbp_reply_forum_id', $forum_id ); 29 30 return false; 31 } 32 33 /** 34 * Update the reply with its topic ID it is in 35 * 36 * @since bbPress (r2855) 37 * 38 * @param int $reply_id Optional. Reply id to update 39 * @param int $topic_id Optional. Topic id 40 * @uses bbp_get_reply_id() To get the reply id 41 * @uses bbp_get_topic_id() To get the topic id 42 * @uses update_post_meta() To update the reply topic id meta 43 * @return bool True on success, false on failure 44 */ 45 function bbp_update_reply_topic_id( $reply_id = 0, $topic_id = 0 ) { 46 $reply_id = bbp_get_reply_id( $reply_id ); 47 $topic_id = bbp_get_topic_id( $topic_id ); 48 49 // Update the last reply ID 50 if ( !empty( $reply_id ) ) 51 return update_post_meta( $reply_id, '_bbp_reply_topic_id', $topic_id ); 52 53 return false; 54 } 9 55 10 56 /** Post Form Handlers ********************************************************/ … … 98 144 99 145 // Check for duplicate 100 if ( !bbp_check_for_duplicate( array( 'post_type' => $bbp->reply_id, 'post_author' => $reply_author, 'post_content' => $reply_content, 'post_parent' => $topic_id, 'anonymous_data' => $anonymous_data ) ) )146 if ( !bbp_check_for_duplicate( array( 'post_type' => bbp_get_reply_post_type(), 'post_author' => $reply_author, 'post_content' => $reply_content, 'post_parent' => $topic_id, 'anonymous_data' => $anonymous_data ) ) ) 101 147 $bbp->errors->add( 'bbp_reply_duplicate', __( '<strong>ERROR</strong>: Duplicate reply detected; it looks as though you’ve already said that!', 'bbpress' ) ); 102 148 … … 119 165 'post_parent' => $topic_id, 120 166 'post_status' => 'publish', 121 'post_type' => $bbp->reply_id167 'post_type' => bbp_get_reply_post_type() 122 168 ); 123 169 … … 286 332 * @uses bbp_update_forum_last_reply_id() To update the last reply id forum meta 287 333 */ 288 function bbp_new_reply_update_reply( $reply_id = 0, $topic_id = 0, $forum_id = 0, $anonymous_data = false, $author_id = 0, $is_edit = false ) { 289 global $bbp; 290 334 function bbp_reply_updater( $reply_id = 0, $topic_id = 0, $forum_id = 0, $anonymous_data = false, $author_id = 0, $is_edit = false ) { 291 335 // Validate the ID's passed from 'bbp_new_reply' action 292 336 $reply_id = bbp_get_reply_id( $reply_id ); … … 296 340 $author_id = bbp_get_current_user_id(); 297 341 298 // If anonymous post, store name, email, website and ip in post_meta. It expects anonymous_data to be sanitized. Check bbp_filter_anonymous_post_data() for sanitization. 342 // If anonymous post, store name, email, website and ip in post_meta. 343 // It expects anonymous_data to be sanitized. 344 // Check bbp_filter_anonymous_post_data() for sanitization. 299 345 if ( !empty( $anonymous_data ) && is_array( $anonymous_data ) ) { 300 346 extract( $anonymous_data ); … … 303 349 update_post_meta( $reply_id, '_bbp_anonymous_email', $bbp_anonymous_email, false ); 304 350 305 // Set transient for throttle check and update ip address meta (only when the reply is not being edited) 351 // Set transient for throttle check and update ip address meta 352 // (only when the reply is not being edited) 306 353 if ( empty( $is_edit ) ) { 307 354 update_post_meta( $reply_id, '_bbp_anonymous_ip', $bbp_anonymous_ip, false ); … … 319 366 // Handle Subscription Checkbox 320 367 if ( bbp_is_subscriptions_active() && !empty( $author_id ) ) { 321 $subscribed = bbp_is_user_subscribed( $author_id, $topic_id ) ? true : false;368 $subscribed = bbp_is_user_subscribed( $author_id, $topic_id ); 322 369 $subscheck = ( !empty( $_POST['bbp_topic_subscription'] ) && 'bbp_subscribe' == $_POST['bbp_topic_subscription'] ) ? true : false; 323 370 … … 331 378 } 332 379 380 // Update associated topic values if this is a new reply 333 381 if ( empty( $is_edit ) ) { 334 // Topic meta relating to most recent reply 335 bbp_update_topic_last_reply_id( $topic_id, $reply_id ); 336 bbp_update_topic_last_active ( $topic_id ); 337 338 // Forum meta relating to most recent topic 339 bbp_update_forum_last_topic_id( $forum_id, $topic_id ); 340 bbp_update_forum_last_reply_id( $forum_id, $reply_id ); 341 bbp_update_forum_last_active ( $forum_id ); 382 // Last active time 383 $last_active = current_time( 'mysql' ); 384 385 // Reply meta relating to reply position in tree 386 bbp_update_reply_forum_id ( $reply_id, $forum_id ); 387 bbp_update_reply_topic_id ( $reply_id, $topic_id ); 388 389 global $bbp; 390 391 foreach ( get_post_ancestors( $reply_id ) as $ancestor ) { 392 // Topic meta relating to most recent reply 393 if ( bbp_get_topic_post_type() == get_post_field( 'post_type', $ancestor ) ) { 394 bbp_update_topic_last_reply_id( $ancestor, $reply_id ); 395 bbp_update_topic_last_active ( $ancestor, $last_active ); 396 bbp_update_topic_reply_count ( $ancestor ); 397 bbp_update_topic_voice_count ( $ancestor ); 398 399 // Forum meta relating to most recent topic 400 } elseif ( bbp_get_forum_post_type() == get_post_field( 'post_type', $ancestor ) ) { 401 bbp_update_forum_last_topic_id( $ancestor, $topic_id ); 402 bbp_update_forum_last_reply_id( $ancestor, $reply_id ); 403 bbp_update_forum_last_active ( $ancestor, $last_active ); 404 bbp_update_forum_reply_count ( $ancestor ); 405 bbp_update_forum_voice_count ( $ancestor ); 406 } 407 } 342 408 } 343 409 } … … 409 475 switch ( $sub_action ) { 410 476 case 'trash': 411 check_ajax_referer( 'trash-' . $bbp->reply_id. '_' . $reply_id );477 check_ajax_referer( 'trash-' . bbp_get_reply_post_type() . '_' . $reply_id ); 412 478 413 479 $success = wp_trash_post( $reply_id ); … … 417 483 418 484 case 'untrash': 419 check_ajax_referer( 'untrash-' . $bbp->reply_id. '_' . $reply_id );485 check_ajax_referer( 'untrash-' . bbp_get_reply_post_type() . '_' . $reply_id ); 420 486 421 487 $success = wp_untrash_post( $reply_id ); … … 425 491 426 492 case 'delete': 427 check_ajax_referer( 'delete-' . $bbp->reply_id. '_' . $reply_id );493 check_ajax_referer( 'delete-' . bbp_get_reply_post_type() . '_' . $reply_id ); 428 494 429 495 $success = wp_delete_post( $reply_id );
Note: See TracChangeset
for help on using the changeset viewer.