Changeset 3911 for branches/plugin/bbp-includes/bbp-user-functions.php
- Timestamp:
- 05/22/2012 08:00:55 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/plugin/bbp-includes/bbp-user-functions.php
r3910 r3911 216 216 217 217 /** 218 * Get the meta key for favorites, based on blog prefix219 *220 * @since bbPress (r3856)221 * @param int $blog_id Optional blog id to switch to222 * @global WPDB $wpdb223 * @return string224 */225 function bbp_get_favorites_key( $blog_id = 0 ) {226 global $wpdb;227 228 // If blog ID is passed, switch to that blog229 if ( !empty( $blog_id ) ) {230 switch_to_blog( $blog_id );231 $prefix = $wpdb->prefix;232 restore_current_blog();233 234 // Use current blog235 } else {236 $prefix = $wpdb->prefix;237 }238 239 return apply_filters( 'bbp_get_favorites_key', '_bbp_' . $prefix . 'favorites', $blog_id, $prefix );240 }241 242 /**243 218 * Get the users who have made the topic favorite 244 219 * … … 258 233 259 234 // Get the users who have favorited the topic 260 $key = bbp_get_favorites_key();235 $key = $wpdb->prefix . '_bbp_favorites'; 261 236 $users = $wpdb->get_col( "SELECT user_id FROM {$wpdb->usermeta} WHERE meta_key = '{$key}' and FIND_IN_SET('{$topic_id}', meta_value) > 0" ); 262 237 $users = apply_filters( 'bbp_get_topic_favoriters', $users, $topic_id ); … … 305 280 * @param int $user_id Optional. User id 306 281 * @uses bbp_get_user_id() To get the user id 307 * @uses get_user_ meta() To get the user favorites282 * @uses get_user_option() To get the user favorites 308 283 * @uses apply_filters() Calls 'bbp_get_user_favorites_topic_ids' with 309 284 * the favorites and user id … … 315 290 return false; 316 291 317 $favorites = (string) get_user_ meta( $user_id, bbp_get_favorites_key(), true);292 $favorites = (string) get_user_option( '_bbp_favorites', $user_id ); 318 293 $favorites = (array) explode( ',', $favorites ); 319 294 $favorites = array_filter( $favorites ); … … 379 354 * @param int $topic_id Optional. Topic id 380 355 * @uses bbp_get_user_favorites_topic_ids() To get the user favorites 381 * @uses update_user_ meta() To update the user favorites356 * @uses update_user_option() To update the user favorites 382 357 * @uses do_action() Calls 'bbp_add_user_favorite' with the user id and topic id 383 358 * @return bool Always true … … 396 371 $favorites = array_filter( $favorites ); 397 372 $favorites = (string) implode( ',', $favorites ); 398 update_user_ meta( $user_id, bbp_get_favorites_key(), $favorites );373 update_user_option( $user_id, '_bbp_favorites', $favorites ); 399 374 } 400 375 … … 412 387 * @param int $topic_id Optional. Topic id 413 388 * @uses bbp_get_user_favorites_topic_ids() To get the user favorites 414 * @uses update_user_ meta() To update the user favorites415 * @uses delete_user_ meta() To delete the user favorites meta389 * @uses update_user_option() To update the user favorites 390 * @uses delete_user_option() To delete the user favorites meta 416 391 * @uses do_action() Calls 'bbp_remove_user_favorite' with the user & topic id 417 392 * @return bool True if the topic was removed from user's favorites, otherwise … … 433 408 if ( !empty( $favorites ) ) { 434 409 $favorites = implode( ',', $favorites ); 435 update_user_ meta( $user_id, bbp_get_favorites_key(), $favorites );410 update_user_option( $user_id, '_bbp_favorites', $favorites ); 436 411 } else { 437 delete_user_ meta( $user_id, bbp_get_favorites_key());412 delete_user_option( $user_id, '_bbp_favorites' ); 438 413 } 439 414 } … … 546 521 547 522 /** 548 * Get the meta key for subscriptions, based on blog prefix549 *550 * @since bbPress (r3856)551 * @global WPDB $wpdb552 * @return string553 */554 function bbp_get_subscriptions_key( $blog_id = 0 ) {555 global $wpdb;556 557 // If blog ID is passed, switch to that blog558 if ( !empty( $blog_id ) ) {559 switch_to_blog( $blog_id );560 $prefix = $wpdb->prefix;561 restore_current_blog();562 563 // Use current blog564 } else {565 $prefix = $wpdb->prefix;566 }567 568 return apply_filters( 'bbp_get_subscriptions_key', '_bbp_' . $prefix . 'subscriptions', $blog_id, $prefix );569 }570 571 /**572 523 * Get the users who have subscribed to the topic 573 524 * … … 584 535 global $wpdb; 585 536 586 $key = bbp_get_subscriptions_key();537 $key = $wpdb->prefix . '_bbp_subscriptions'; 587 538 $users = wp_cache_get( 'bbp_get_topic_subscribers_' . $topic_id, 'bbpress' ); 588 539 if ( empty( $users ) ) { … … 635 586 * @param int $user_id Optional. User id 636 587 * @uses bbp_get_user_id() To get the user id 637 * @uses get_user_ meta() To get the user's subscriptions588 * @uses get_user_option() To get the user's subscriptions 638 589 * @uses apply_filters() Calls 'bbp_get_user_subscribed_topic_ids' with 639 590 * the subscriptions and user id … … 645 596 return false; 646 597 647 $subscriptions = (string) get_user_ meta( $user_id, bbp_get_subscriptions_key(), true);598 $subscriptions = (string) get_user_option( '_bbp_subscriptions', $user_id ); 648 599 $subscriptions = (array) explode( ',', $subscriptions ); 649 600 $subscriptions = array_filter( $subscriptions ); … … 711 662 * @uses bbp_get_user_subscribed_topic_ids() To get the user's subscriptions 712 663 * @uses bbp_get_topic() To get the topic 713 * @uses update_user_ meta() To update the user's subscriptions664 * @uses update_user_option() To update the user's subscriptions 714 665 * @uses do_action() Calls 'bbp_add_user_subscription' with the user & topic id 715 666 * @return bool Always true … … 729 680 $subscriptions = array_filter( $subscriptions ); 730 681 $subscriptions = (string) implode( ',', $subscriptions ); 731 update_user_ meta( $user_id, bbp_get_subscriptions_key(), $subscriptions );682 update_user_option( $user_id, '_bbp_subscriptions', $subscriptions ); 732 683 733 684 wp_cache_delete( 'bbp_get_topic_subscribers_' . $topic_id, 'bbpress' ); … … 747 698 * @param int $topic_id Optional. Topic id 748 699 * @uses bbp_get_user_subscribed_topic_ids() To get the user's subscriptions 749 * @uses update_user_ meta() To update the user's subscriptions750 * @uses delete_user_ meta() To delete the user's subscriptions meta700 * @uses update_user_option() To update the user's subscriptions 701 * @uses delete_user_option() To delete the user's subscriptions meta 751 702 * @uses do_action() Calls 'bbp_remove_user_subscription' with the user id and 752 703 * topic id … … 770 721 if ( !empty( $subscriptions ) ) { 771 722 $subscriptions = implode( ',', $subscriptions ); 772 update_user_ meta( $user_id, bbp_get_subscriptions_key(), $subscriptions );723 update_user_option( $user_id, '_bbp_subscriptions', $subscriptions ); 773 724 } else { 774 delete_user_ meta( $user_id, bbp_get_subscriptions_key());725 delete_user_option( $user_id, '_bbp_subscriptions' ); 775 726 } 776 727 … … 994 945 995 946 // stops users being added to current blog when they are edited 996 if ( $delete_role ) {947 if ( true === $delete_role ) { 997 948 delete_user_meta( $user_id, $blog_prefix . 'capabilities' ); 998 949 } … … 1070 1021 wp_cache_set( 'bbp_total_users', $bbp_total_users, 'bbpress' ); 1071 1022 1072 return (int)apply_filters( 'bbp_get_total_users', (int) $bbp_total_users );1023 return apply_filters( 'bbp_get_total_users', (int) $bbp_total_users ); 1073 1024 } 1074 1025
Note: See TracChangeset
for help on using the changeset viewer.