Changeset 3911
- Timestamp:
- 05/22/2012 08:00:55 AM (13 years ago)
- Location:
- branches/plugin
- Files:
-
- 1 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/plugin/bbp-admin/bbp-tools.php
r3890 r3911 385 385 return array( 1, sprintf( $statement, $result ) ); 386 386 387 $key = $wpdb->prefix . '_bbp_topic_count'; 387 388 $insert_values = array(); 388 389 foreach ( $insert_rows as $insert_row ) 389 $insert_values[] = "('{$insert_row->post_author}', ' _bbp_topic_count', '{$insert_row->_count}')";390 $insert_values[] = "('{$insert_row->post_author}', '{$key}', '{$insert_row->_count}')"; 390 391 391 392 if ( !count( $insert_values ) ) 392 393 return array( 2, sprintf( $statement, $result ) ); 393 394 394 $sql_delete = "DELETE FROM `{$wpdb->usermeta}` WHERE `meta_key` = ' _bbp_topic_count';";395 $sql_delete = "DELETE FROM `{$wpdb->usermeta}` WHERE `meta_key` = '{$key}';"; 395 396 if ( is_wp_error( $wpdb->query( $sql_delete ) ) ) 396 397 return array( 3, sprintf( $statement, $result ) ); … … 431 432 return array( 1, sprintf( $statement, $result ) ); 432 433 434 $key = $wpdb->prefix . '_bbp_reply_count'; 433 435 $insert_values = array(); 434 436 foreach ( $insert_rows as $insert_row ) 435 $insert_values[] = "('{$insert_row->post_author}', ' _bbp_reply_count', '{$insert_row->_count}')";437 $insert_values[] = "('{$insert_row->post_author}', '{$key}', '{$insert_row->_count}')"; 436 438 437 439 if ( !count( $insert_values ) ) 438 440 return array( 2, sprintf( $statement, $result ) ); 439 441 440 $sql_delete = "DELETE FROM `{$wpdb->usermeta}` WHERE `meta_key` = ' _bbp_reply_count';";442 $sql_delete = "DELETE FROM `{$wpdb->usermeta}` WHERE `meta_key` = '{$key}';"; 441 443 if ( is_wp_error( $wpdb->query( $sql_delete ) ) ) 442 444 return array( 3, sprintf( $statement, $result ) ); … … 471 473 $statement = __( 'Removing trashed topics from user favorites… %s', 'bbpress' ); 472 474 $result = __( 'Failed!', 'bbpress' ); 473 $key = bbp_get_favorites_key();475 $key = $wpdb->prefix . '_bbp_favorites'; 474 476 $users = $wpdb->get_results( "SELECT `user_id`, `meta_value` AS `favorites` FROM `{$wpdb->usermeta}` WHERE `meta_key` = '{$key}';" ); 475 477 … … 531 533 $statement = __( 'Removing trashed topics from user subscriptions… %s', 'bbpress' ); 532 534 $result = __( 'Failed!', 'bbpress' ); 533 $key = bbp_get_subscriptions_key();535 $key = $wpdb->prefix . '_bbp_subscriptions'; 534 536 $users = $wpdb->get_results( "SELECT `user_id`, `meta_value` AS `subscriptions` FROM `{$wpdb->usermeta}` WHERE `meta_key` = '{$key}';" ); 535 537 -
branches/plugin/bbp-includes/bbp-common-functions.php
r3902 r3911 693 693 * @uses get_option() To get the throttle time 694 694 * @uses get_transient() To get the last posted transient of the ip 695 * @uses get_user_meta() To get the last posted metaof the user695 * @uses bbp_get_user_last_posted() To get the last posted time of the user 696 696 * @uses current_user_can() To check if the current user can throttle 697 697 * @return bool True if there is no flooding, false if there is … … 715 715 } elseif ( !empty( $author_id ) ) { 716 716 $author_id = (int) $author_id; 717 $last_posted = get_user_meta( $author_id, '_bbp_last_posted', true);717 $last_posted = bbp_get_user_last_posted( $author_id ); 718 718 719 719 if ( isset( $last_posted ) && time() < $last_posted + $throttle_time && !current_user_can( 'throttle' ) ) { -
branches/plugin/bbp-includes/bbp-core-actions.php
r3830 r3911 59 59 * Attach various loader actions to the bbp_loaded action. 60 60 * The load order helps to execute code at the correct time. 61 * v---Load order 62 */ 63 add_action( 'bbp_loaded', 'bbp_constants', 2 ); 64 add_action( 'bbp_loaded', 'bbp_boot_strap_globals', 4 ); 65 add_action( 'bbp_loaded', 'bbp_includes', 6 ); 66 add_action( 'bbp_loaded', 'bbp_setup_globals', 8 ); 67 add_action( 'bbp_loaded', 'bbp_register_theme_directory', 10 ); 68 add_action( 'bbp_loaded', 'bbp_register_theme_packages', 12 ); 61 * v---Load order 62 */ 63 add_action( 'bbp_loaded', 'bbp_constants', 2 ); 64 add_action( 'bbp_loaded', 'bbp_boot_strap_globals', 4 ); 65 add_action( 'bbp_loaded', 'bbp_includes', 6 ); 66 add_action( 'bbp_loaded', 'bbp_setup_globals', 8 ); 67 add_action( 'bbp_loaded', 'bbp_setup_option_filters', 10 ); 68 add_action( 'bbp_loaded', 'bbp_setup_user_option_filters', 12 ); 69 add_action( 'bbp_loaded', 'bbp_register_theme_directory', 14 ); 70 add_action( 'bbp_loaded', 'bbp_register_theme_packages', 16 ); 69 71 70 72 /** … … 76 78 */ 77 79 add_action( 'bbp_init', 'bbp_load_textdomain', 2 ); 78 add_action( 'bbp_init', 'bbp_setup_option_filters', 4 );79 80 add_action( 'bbp_init', 'bbp_register_post_types', 10 ); 80 81 add_action( 'bbp_init', 'bbp_register_post_statuses', 12 ); -
branches/plugin/bbp-includes/bbp-reply-functions.php
r3840 r3911 593 593 * @uses update_post_meta() To update the reply metas 594 594 * @uses set_transient() To update the flood check transient for the ip 595 * @uses update_user_meta() To update the last posted meta for the user595 * @uses bbp_update_user_last_posted() To update the users last posted time 596 596 * @uses bbp_is_subscriptions_active() To check if the subscriptions feature is 597 597 * activated or not … … 651 651 } else { 652 652 if ( empty( $is_edit ) && !current_user_can( 'throttle' ) ) { 653 update_user_meta( $author_id, '_bbp_last_posted', time());653 bbp_update_user_last_posted( $author_id ); 654 654 } 655 655 } -
branches/plugin/bbp-includes/bbp-topic-functions.php
r3840 r3911 695 695 * @uses update_post_meta() To update the topic metas 696 696 * @uses set_transient() To update the flood check transient for the ip 697 * @uses update_user_meta() To update the last posted meta for the user697 * @uses bbp_update_user_last_posted() To update the users last posted time 698 698 * @uses bbp_is_subscriptions_active() To check if the subscriptions feature is 699 699 * activated or not … … 754 754 } else { 755 755 if ( empty( $is_edit ) && !current_user_can( 'throttle' ) ) { 756 update_user_meta( $author_id, '_bbp_last_posted', time());756 bbp_update_user_last_posted( $author_id ); 757 757 } 758 758 } -
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 -
branches/plugin/bbp-includes/bbp-user-template.php
r3860 r3911 1530 1530 } 1531 1531 1532 /** Post Counts ***************************************************************/1533 1534 /**1535 * Output a users topic count1536 *1537 * @since bbPress (r3632)1538 *1539 * @param int $user_id1540 * @uses bbp_get_user_topic_count()1541 * @return string1542 */1543 function bbp_user_topic_count( $user_id = 0 ) {1544 echo bbp_get_user_topic_count( $user_id );1545 }1546 /**1547 * Return a users reply count1548 *1549 * @since bbPress (r3632)1550 *1551 * @param int $user_id1552 * @uses bbp_get_user_id()1553 * @uses get_user_meta()1554 * @uses apply_filters()1555 * @return string1556 */1557 function bbp_get_user_topic_count( $user_id = 0 ) {1558 1559 // Validate user id1560 $user_id = bbp_get_user_id( $user_id );1561 if ( empty( $user_id ) )1562 return false;1563 1564 $count = get_user_meta( $user_id, '_bbp_topic_count', true );1565 1566 return apply_filters( 'bbp_get_user_topic_count', (int) $count, $user_id );1567 }1568 1569 /**1570 * Output a users reply count1571 *1572 * @since bbPress (r3632)1573 *1574 * @param int $user_id1575 * @uses bbp_get_user_reply_count()1576 * @return string1577 */1578 function bbp_user_reply_count( $user_id = 0 ) {1579 echo bbp_get_user_reply_count( $user_id );1580 }1581 /**1582 * Return a users reply count1583 *1584 * @since bbPress (r3632)1585 *1586 * @param int $user_id1587 * @uses bbp_get_user_id()1588 * @uses get_user_meta()1589 * @uses apply_filters()1590 * @return string1591 */1592 function bbp_get_user_reply_count( $user_id = 0 ) {1593 1594 // Validate user id1595 $user_id = bbp_get_user_id( $user_id );1596 if ( empty( $user_id ) )1597 return false;1598 1599 $count = get_user_meta( $user_id, '_bbp_reply_count', true );1600 1601 return apply_filters( 'bbp_get_user_reply_count', (int) $count, $user_id );1602 }1603 1604 /**1605 * Output a users total post count1606 *1607 * @since bbPress (r3632)1608 *1609 * @param int $user_id1610 * @uses bbp_get_user_post_count()1611 * @return string1612 */1613 function bbp_user_post_count( $user_id = 0 ) {1614 echo bbp_get_user_post_count( $user_id );1615 }1616 /**1617 * Return a users total post count1618 *1619 * @since bbPress (r3632)1620 *1621 * @param int $user_id1622 * @uses bbp_get_user_id()1623 * @uses get_user_meta()1624 * @uses apply_filters()1625 * @return string1626 */1627 function bbp_get_user_post_count( $user_id = 0 ) {1628 1629 // Validate user id1630 $user_id = bbp_get_user_id( $user_id );1631 if ( empty( $user_id ) )1632 return false;1633 1634 $topics = get_user_meta( $user_id, '_bbp_topic_count', true );1635 $replies = get_user_meta( $user_id, '_bbp_reply_count', true );1636 $count = (int) $topics + (int) $replies;1637 1638 return apply_filters( 'bbp_get_user_post_count', (int) $count, $user_id );1639 }1640 1641 1532 ?> -
branches/plugin/bbpress.php
r3907 r3911 262 262 263 263 /** 264 * @var array Optional Overloads default options retrieved from get_option() 264 * Overloads default options retrieved from get_option() 265 * 266 * @var array Optional array( $key => $value ); 265 267 */ 266 268 public $options = array(); 267 269 268 /** Function Overload *****************************************************/269 270 /**271 * @var array Optional Overloads WordPress functions with new functions.272 */ 273 public $ functions = array();270 /** 271 * Overloads default user options retrieved from get_user_option() 272 * 273 * @var array Optional array( $user_id => array( $key => $value ) ); 274 */ 275 public $user_options = array(); 274 276 275 277 /** Singleton *************************************************************/ … … 462 464 require( $this->plugin_dir . 'bbp-includes/bbp-user-functions.php' ); // User functions 463 465 require( $this->plugin_dir . 'bbp-includes/bbp-user-template.php' ); // User template tags 466 require( $this->plugin_dir . 'bbp-includes/bbp-user-options.php' ); // User options 464 467 465 468 /** Admin *************************************************************/
Note: See TracChangeset
for help on using the changeset viewer.