Ticket #1823: 1823.3.patch
File 1823.3.patch, 13.5 KB (added by , 12 years ago) |
---|
-
bbp-includes/bbp-common-functions.php
689 689 * Do not supply if supplying $anonymous_data. 690 690 * @uses get_option() To get the throttle time 691 691 * @uses get_transient() To get the last posted transient of the ip 692 * @uses get_user_meta() To get the last posted meta of the user692 * @uses bbp_get_user_meta() To get the last posted meta of the user 693 693 * @uses current_user_can() To check if the current user can throttle 694 694 * @return bool True if there is no flooding, false if there is 695 695 */ … … 711 711 // User is logged in, so check their last posted time 712 712 } elseif ( !empty( $author_id ) ) { 713 713 $author_id = (int) $author_id; 714 $last_posted = get_user_meta( $author_id, '_bbp_last_posted', true );714 $last_posted = bbp_get_user_meta( $author_id, '_bbp_last_posted', true ); 715 715 716 716 if ( isset( $last_posted ) && time() < $last_posted + $throttle_time && !current_user_can( 'throttle' ) ) { 717 717 return false; -
bbp-includes/bbp-reply-functions.php
592 592 * @uses bbp_get_topic_forum_id() To get the topic forum id 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_meta() To update the last posted meta for the user 596 596 * @uses bbp_is_subscriptions_active() To check if the subscriptions feature is 597 597 * activated or not 598 598 * @uses bbp_is_user_subscribed() To check if the user is subscribed … … 650 650 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_meta( $author_id, '_bbp_last_posted', time() ); 654 654 } 655 655 } 656 656 -
bbp-includes/bbp-topic-functions.php
694 694 * @yses bbp_get_topic_forum_id() To get the topic forum id 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_meta() To update the last posted meta for the user 698 698 * @uses bbp_is_subscriptions_active() To check if the subscriptions feature is 699 699 * activated or not 700 700 * @uses bbp_is_user_subscribed() To check if the user is subscribed … … 753 753 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_meta( $author_id, '_bbp_last_posted', time() ); 757 757 } 758 758 } 759 759 -
bbp-includes/bbp-user-functions.php
10 10 // Exit if accessed directly 11 11 if ( !defined( 'ABSPATH' ) ) exit; 12 12 13 /** Meta **********************************************************************/ 14 13 15 /** 16 * Add meta data field to a user. 17 * 18 * Post meta data is called "Custom Fields" on the Administration Screens. 19 * 20 * @since bbPress (r3900) 21 * @uses add_meta_data() 22 * @param int $user_id Post ID. 23 * @param string $meta_key Metadata name. 24 * @param mixed $meta_value Metadata value. 25 * @param bool $unique Optional, default is false. Whether the same key should not be added. 26 * @return bool False for failure. True for success. 27 */ 28 function bbp_add_user_meta( $user_id, $meta_key, $meta_value, $unique = false ) { 29 $function = apply_filters( 'bbp_add_user_meta_function', 'add_user_meta' ); 30 return $function( $user_id, $meta_key, $meta_value, $unique ); 31 } 32 33 /** 34 * Remove metadata matching criteria from a user. 35 * 36 * You can match based on the key, or key and value. Removing based on key and 37 * value, will keep from removing duplicate metadata with the same key. It also 38 * allows removing all metadata matching key, if needed. 39 * 40 * @since bbPress (r3900) 41 * @uses bbp_delete_user_meta() 42 * @param int $user_id user ID 43 * @param string $meta_key Metadata name. 44 * @param mixed $meta_value Optional. Metadata value. 45 * @return bool False for failure. True for success. 46 */ 47 function bbp_delete_user_meta( $user_id, $meta_key, $meta_value = '' ) { 48 $function = apply_filters( 'bbp_delete_user_meta_function', 'delete_user_meta' ); 49 return $function( $user_id, $meta_key, $meta_value ); 50 } 51 52 /** 53 * Retrieve user meta field for a user. 54 * 55 * @since bbPress (r3900) 56 * @uses bbp_get_user_meta() 57 * @param int $user_id Post ID. 58 * @param string $meta_key Optional. The meta key to retrieve. By default, returns data for all keys. 59 * @param bool $single Whether to return a single value. 60 * @return mixed Will be an array if $single is false. Will be value of meta data field if $single 61 * is true. 62 */ 63 function bbp_get_user_meta( $user_id, $meta_key = '', $single = false ) { 64 $function = apply_filters( 'bbp_get_user_meta_function', 'get_user_meta', $meta_key ); 65 return $function( $user_id, $meta_key, $single ); 66 } 67 68 /** 69 * Update user meta field based on user ID. 70 * 71 * Use the $prev_value parameter to differentiate between meta fields with the 72 * same key and user ID. 73 * 74 * If the meta field for the user does not exist, it will be added. 75 * 76 * @since bbPress (r3900) 77 * @uses update_user_meta 78 * @param int $user_id Post ID. 79 * @param string $meta_key Metadata key. 80 * @param mixed $meta_value Metadata value. 81 * @param mixed $prev_value Optional. Previous value to check before removing. 82 * @return bool False on failure, true if success. 83 */ 84 function bbp_update_user_meta( $user_id, $meta_key, $meta_value, $prev_value = '' ) { 85 $function = apply_filters( 'bbp_update_user_meta_function', 'update_user_meta', $meta_key ); 86 return $function( $user_id, $meta_key, $meta_value, $prev_value ); 87 } 88 89 /** Other *********************************************************************/ 90 91 /** 14 92 * Redirect back to $url when attempting to use the login page 15 93 * 16 94 * @since bbPress (r2815) … … 304 382 * 305 383 * @param int $user_id Optional. User id 306 384 * @uses bbp_get_user_id() To get the user id 307 * @uses get_user_meta() To get the user favorites385 * @uses bbp_get_user_meta() To get the user favorites 308 386 * @uses apply_filters() Calls 'bbp_get_user_favorites_topic_ids' with 309 387 * the favorites and user id 310 388 * @return array|bool Results if user has favorites, otherwise false … … 314 392 if ( empty( $user_id ) ) 315 393 return false; 316 394 317 $favorites = (string) get_user_meta( $user_id, bbp_get_favorites_key(), true );395 $favorites = (string) bbp_get_user_meta( $user_id, bbp_get_favorites_key(), true ); 318 396 $favorites = (array) explode( ',', $favorites ); 319 397 $favorites = array_filter( $favorites ); 320 398 … … 378 456 * @param int $user_id Optional. User id 379 457 * @param int $topic_id Optional. Topic id 380 458 * @uses bbp_get_user_favorites_topic_ids() To get the user favorites 381 * @uses update_user_meta() To update the user favorites459 * @uses bbp_update_user_meta() To update the user favorites 382 460 * @uses do_action() Calls 'bbp_add_user_favorite' with the user id and topic id 383 461 * @return bool Always true 384 462 */ … … 395 473 $favorites[] = $topic_id; 396 474 $favorites = array_filter( $favorites ); 397 475 $favorites = (string) implode( ',', $favorites ); 398 update_user_meta( $user_id, bbp_get_favorites_key(), $favorites );476 bbp_update_user_meta( $user_id, bbp_get_favorites_key(), $favorites ); 399 477 } 400 478 401 479 do_action( 'bbp_add_user_favorite', $user_id, $topic_id ); … … 411 489 * @param int $user_id Optional. User id 412 490 * @param int $topic_id Optional. Topic id 413 491 * @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 meta492 * @uses bbp_update_user_meta() To update the user favorites 493 * @uses bbp_delete_user_meta() To delete the user favorites meta 416 494 * @uses do_action() Calls 'bbp_remove_user_favorite' with the user & topic id 417 495 * @return bool True if the topic was removed from user's favorites, otherwise 418 496 * false … … 432 510 433 511 if ( !empty( $favorites ) ) { 434 512 $favorites = implode( ',', $favorites ); 435 update_user_meta( $user_id, bbp_get_favorites_key(), $favorites );513 bbp_update_user_meta( $user_id, bbp_get_favorites_key(), $favorites ); 436 514 } else { 437 delete_user_meta( $user_id, bbp_get_favorites_key() );515 bbp_delete_user_meta( $user_id, bbp_get_favorites_key() ); 438 516 } 439 517 } 440 518 … … 634 712 * 635 713 * @param int $user_id Optional. User id 636 714 * @uses bbp_get_user_id() To get the user id 637 * @uses get_user_meta() To get the user's subscriptions715 * @uses bbp_get_user_meta() To get the user's subscriptions 638 716 * @uses apply_filters() Calls 'bbp_get_user_subscribed_topic_ids' with 639 717 * the subscriptions and user id 640 718 * @return array|bool Results if user has subscriptions, otherwise false … … 644 722 if ( empty( $user_id ) ) 645 723 return false; 646 724 647 $subscriptions = (string) get_user_meta( $user_id, bbp_get_subscriptions_key(), true );725 $subscriptions = (string) bbp_get_user_meta( $user_id, bbp_get_subscriptions_key(), true ); 648 726 $subscriptions = (array) explode( ',', $subscriptions ); 649 727 $subscriptions = array_filter( $subscriptions ); 650 728 … … 710 788 * @param int $topic_id Optional. Topic id 711 789 * @uses bbp_get_user_subscribed_topic_ids() To get the user's subscriptions 712 790 * @uses bbp_get_topic() To get the topic 713 * @uses update_user_meta() To update the user's subscriptions791 * @uses bbp_update_user_meta() To update the user's subscriptions 714 792 * @uses do_action() Calls 'bbp_add_user_subscription' with the user & topic id 715 793 * @return bool Always true 716 794 */ … … 728 806 $subscriptions[] = $topic_id; 729 807 $subscriptions = array_filter( $subscriptions ); 730 808 $subscriptions = (string) implode( ',', $subscriptions ); 731 update_user_meta( $user_id, bbp_get_subscriptions_key(), $subscriptions );809 bbp_update_user_meta( $user_id, bbp_get_subscriptions_key(), $subscriptions ); 732 810 733 811 wp_cache_delete( 'bbp_get_topic_subscribers_' . $topic_id, 'bbpress' ); 734 812 } … … 746 824 * @param int $user_id Optional. User id 747 825 * @param int $topic_id Optional. Topic id 748 826 * @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 meta827 * @uses bbp_update_user_meta() To update the user's subscriptions 828 * @uses bbp_delete_user_meta() To delete the user's subscriptions meta 751 829 * @uses do_action() Calls 'bbp_remove_user_subscription' with the user id and 752 830 * topic id 753 831 * @return bool True if the topic was removed from user's subscriptions, … … 769 847 770 848 if ( !empty( $subscriptions ) ) { 771 849 $subscriptions = implode( ',', $subscriptions ); 772 update_user_meta( $user_id, bbp_get_subscriptions_key(), $subscriptions );850 bbp_update_user_meta( $user_id, bbp_get_subscriptions_key(), $subscriptions ); 773 851 } else { 774 delete_user_meta( $user_id, bbp_get_subscriptions_key() );852 bbp_delete_user_meta( $user_id, bbp_get_subscriptions_key() ); 775 853 } 776 854 777 855 wp_cache_delete( 'bbp_get_topic_subscribers_' . $topic_id, 'bbpress' ); … … 994 1072 995 1073 // stops users being added to current blog when they are edited 996 1074 if ( $delete_role ) { 997 delete_user_meta( $user_id, $blog_prefix . 'capabilities' );1075 bbp_delete_user_meta( $user_id, $blog_prefix . 'capabilities' ); 998 1076 } 999 1077 1000 1078 if ( is_multisite() && is_network_admin() & !bbp_is_user_home() && current_user_can( 'manage_network_options' ) && !isset( $super_admins ) && empty( $_POST['super_admin'] ) == is_super_admin( $user_id ) ) { -
bbp-includes/bbp-user-template.php
1550 1550 * 1551 1551 * @param int $user_id 1552 1552 * @uses bbp_get_user_id() 1553 * @uses get_user_meta()1553 * @uses bbp_get_user_meta() 1554 1554 * @uses apply_filters() 1555 1555 * @return string 1556 1556 */ … … 1561 1561 if ( empty( $user_id ) ) 1562 1562 return false; 1563 1563 1564 $count = get_user_meta( $user_id, '_bbp_topic_count', true );1564 $count = bbp_get_user_meta( $user_id, '_bbp_topic_count', true ); 1565 1565 1566 1566 return apply_filters( 'bbp_get_user_topic_count', (int) $count, $user_id ); 1567 1567 } … … 1585 1585 * 1586 1586 * @param int $user_id 1587 1587 * @uses bbp_get_user_id() 1588 * @uses get_user_meta()1588 * @uses bbp_get_user_meta() 1589 1589 * @uses apply_filters() 1590 1590 * @return string 1591 1591 */ … … 1596 1596 if ( empty( $user_id ) ) 1597 1597 return false; 1598 1598 1599 $count = get_user_meta( $user_id, '_bbp_reply_count', true );1599 $count = bbp_get_user_meta( $user_id, '_bbp_reply_count', true ); 1600 1600 1601 1601 return apply_filters( 'bbp_get_user_reply_count', (int) $count, $user_id ); 1602 1602 } … … 1620 1620 * 1621 1621 * @param int $user_id 1622 1622 * @uses bbp_get_user_id() 1623 * @uses get_user_meta()1623 * @uses bbp_get_user_meta() 1624 1624 * @uses apply_filters() 1625 1625 * @return string 1626 1626 */ … … 1631 1631 if ( empty( $user_id ) ) 1632 1632 return false; 1633 1633 1634 $topics = get_user_meta( $user_id, '_bbp_topic_count', true );1635 $replies = get_user_meta( $user_id, '_bbp_reply_count', true );1634 $topics = bbp_get_user_meta( $user_id, '_bbp_topic_count', true ); 1635 $replies = bbp_get_user_meta( $user_id, '_bbp_reply_count', true ); 1636 1636 $count = (int) $topics + (int) $replies; 1637 1637 1638 1638 return apply_filters( 'bbp_get_user_post_count', (int) $count, $user_id );