Changeset 5827 for trunk/src/includes/users/functions.php
- Timestamp:
- 07/14/2015 12:31:42 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/users/functions.php
r5805 r5827 188 188 } 189 189 190 global $wpdb; 191 192 $key = $wpdb->prefix . '_bbp_favorites'; 193 $users = wp_cache_get( 'bbp_get_topic_favoriters_' . $topic_id, 'bbpress_users' ); 190 $bbp_db = bbp_db(); 191 $key = $bbp_db->prefix . '_bbp_favorites'; 192 $users = wp_cache_get( 'bbp_get_topic_favoriters_' . $topic_id, 'bbpress_users' ); 194 193 if ( false === $users ) { 195 $users = $ wpdb->get_col( "SELECT user_id FROM {$wpdb->usermeta} WHERE meta_key = '{$key}' and FIND_IN_SET('{$topic_id}', meta_value) > 0" );194 $users = $bbp_db->get_col( "SELECT user_id FROM {$bbp_db->usermeta} WHERE meta_key = '{$key}' and FIND_IN_SET('{$topic_id}', meta_value) > 0" ); 196 195 wp_cache_set( 'bbp_get_topic_favoriters_' . $topic_id, $users, 'bbpress_users' ); 197 196 } … … 499 498 } 500 499 501 global $wpdb; 502 503 $key = $wpdb->prefix . '_bbp_forum_subscriptions'; 504 $users = wp_cache_get( 'bbp_get_forum_subscribers_' . $forum_id, 'bbpress_users' ); 500 $bbp_db = bbp_db(); 501 $key = $bbp_db->prefix . '_bbp_forum_subscriptions'; 502 $users = wp_cache_get( 'bbp_get_forum_subscribers_' . $forum_id, 'bbpress_users' ); 505 503 if ( false === $users ) { 506 $users = $ wpdb->get_col( "SELECT user_id FROM {$wpdb->usermeta} WHERE meta_key = '{$key}' and FIND_IN_SET('{$forum_id}', meta_value) > 0" );504 $users = $bbp_db->get_col( "SELECT user_id FROM {$bbp_db->usermeta} WHERE meta_key = '{$key}' and FIND_IN_SET('{$forum_id}', meta_value) > 0" ); 507 505 wp_cache_set( 'bbp_get_forum_subscribers_' . $forum_id, $users, 'bbpress_users' ); 508 506 } … … 527 525 } 528 526 529 global $wpdb; 530 531 $key = $wpdb->prefix . '_bbp_subscriptions'; 532 $users = wp_cache_get( 'bbp_get_topic_subscribers_' . $topic_id, 'bbpress_users' ); 527 $bbp_db = bbp_db(); 528 $key = $bbp_db->prefix . '_bbp_subscriptions'; 529 $users = wp_cache_get( 'bbp_get_topic_subscribers_' . $topic_id, 'bbpress_users' ); 533 530 if ( false === $users ) { 534 $users = $ wpdb->get_col( "SELECT user_id FROM {$wpdb->usermeta} WHERE meta_key = '{$key}' and FIND_IN_SET('{$topic_id}', meta_value) > 0" );531 $users = $bbp_db->get_col( "SELECT user_id FROM {$bbp_db->usermeta} WHERE meta_key = '{$key}' and FIND_IN_SET('{$topic_id}', meta_value) > 0" ); 535 532 wp_cache_set( 'bbp_get_topic_subscribers_' . $topic_id, $users, 'bbpress_users' ); 536 533 } … … 1316 1313 * is the one of the logged in user) 1317 1314 * @uses get_option() To get the displayed user's new email id option 1318 * @uses wpdb::prepare() To sanitize our sql query1319 * @uses wpdb::get_var() To execute our query and get back the variable1320 * @uses wpdb::query() To execute our query1321 1315 * @uses wp_update_user() To update the user 1322 1316 * @uses delete_option() To delete the displayed user's email id option … … 1331 1325 * @uses get_userdata() To get the user data 1332 1326 * @uses is_email() To check if the string is an email id or not 1333 * @uses wpdb::get_blog_prefix() To get the blog prefix1334 1327 * @uses is_network_admin() To check if the user is the network admin 1335 1328 * @uses revoke_super_admin() To revoke super admin priviledges … … 1449 1442 * @since bbPress (r5660) 1450 1443 * 1451 * @global object $wpdb 1452 * @param string $action 1444 * @param string $action 1453 1445 * 1454 1446 * @uses bbp_is_user_home_edit() To check if on the current users profile edit page … … 1531 1523 // Update signups table, if signups table & entry exists 1532 1524 // For Multisite & BuddyPress compatibility 1533 global $wpdb;1534 if ( ! empty( $ wpdb->signups ) && $wpdb->get_var( $wpdb->prepare( "SELECT user_login FROM {$wpdb->signups} WHERE user_login = %s", bbp_get_displayed_user_field( 'user_login', 'raw' ) ) ) ) {1535 $ wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->signups} SET user_email = %s WHERE user_login = %s", $user->user_email, bbp_get_displayed_user_field( 'user_login', 'raw' ) ) );1525 $bbp_db = bbp_db(); 1526 if ( ! empty( $bbp_db->signups ) && $bbp_db->get_var( $bbp_db->prepare( "SELECT user_login FROM {$bbp_db->signups} WHERE user_login = %s", bbp_get_displayed_user_field( 'user_login', 'raw' ) ) ) ) { 1527 $bbp_db->query( $bbp_db->prepare( "UPDATE {$bbp_db->signups} SET user_email = %s WHERE user_login = %s", $user->user_email, bbp_get_displayed_user_field( 'user_login', 'raw' ) ) ); 1536 1528 } 1537 1529 … … 1727 1719 * 1728 1720 * @since bbPress (r3633) 1721 * 1729 1722 * @param int $user_id User ID to get count for 1730 * @global WPDB $wpdb1723 * 1731 1724 * @uses bbp_get_user_id() 1732 1725 * @uses get_posts_by_author_sql() 1733 1726 * @uses bbp_get_topic_post_type() 1734 1727 * @uses apply_filters() 1728 * 1735 1729 * @return int Raw DB count of topics 1736 1730 */ … … 1741 1735 } 1742 1736 1743 global $wpdb; 1744 1745 $where = get_posts_by_author_sql( bbp_get_topic_post_type(), true, $user_id ); 1746 $count = (int) $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->posts} {$where}" ); 1737 $bbp_db = bbp_db(); 1738 $where = get_posts_by_author_sql( bbp_get_topic_post_type(), true, $user_id ); 1739 $count = (int) $bbp_db->get_var( "SELECT COUNT(*) FROM {$bbp_db->posts} {$where}" ); 1747 1740 1748 1741 return (int) apply_filters( 'bbp_get_user_topic_count_raw', $count, $user_id ); … … 1753 1746 * 1754 1747 * @since bbPress (r3633) 1748 * 1755 1749 * @param int $user_id User ID to get count for 1756 * @global WPDB $wpdb1750 * 1757 1751 * @uses bbp_get_user_id() 1758 1752 * @uses get_posts_by_author_sql() 1759 1753 * @uses bbp_get_reply_post_type() 1760 1754 * @uses apply_filters() 1755 * 1761 1756 * @return int Raw DB count of replies 1762 1757 */ … … 1767 1762 } 1768 1763 1769 global $wpdb; 1770 1771 $where = get_posts_by_author_sql( bbp_get_reply_post_type(), true, $user_id ); 1772 $count = (int) $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->posts} {$where}" ); 1764 $bbp_db = bbp_db(); 1765 $where = get_posts_by_author_sql( bbp_get_reply_post_type(), true, $user_id ); 1766 $count = (int) $bbp_db->get_var( "SELECT COUNT(*) FROM {$bbp_db->posts} {$where}" ); 1773 1767 1774 1768 return (int) apply_filters( 'bbp_get_user_reply_count_raw', $count, $user_id ); … … 1846 1840 1847 1841 // Add them up and filter them 1848 $new_count = apply_filters( 'bbp_bump_user_reply_count', ( (int) $count + (int) $difference ), $user_id, $difference, $count );1842 $new_count = apply_filters( 'bbp_bump_user_reply_count', $user_reply_count, $user_id, $difference, $count ); 1849 1843 1850 1844 return bbp_update_user_reply_count( $user_id, $new_count ); … … 2069 2063 * 2070 2064 * @since bbPress (r3813) 2071 * @global WPDB $wpdb2072 2065 */ 2073 2066 function bbp_user_maybe_convert_pass() { … … 2083 2076 } 2084 2077 2085 global $wpdb;2086 2087 2078 // Bail if no user password to convert 2088 $row = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->users} INNER JOIN {$wpdb->usermeta} ON user_id = ID WHERE meta_key = '_bbp_class' AND user_login = '%s' LIMIT 1", $username ) ); 2079 $bbp_db = bbp_db(); 2080 $query = $bbp_db->prepare( "SELECT * FROM {$bbp_db->users} INNER JOIN {$bbp_db->usermeta} ON user_id = ID WHERE meta_key = '_bbp_class' AND user_login = '%s' LIMIT 1", $username ); 2081 $row = $bbp_db->get_row( $query ); 2089 2082 if ( empty( $row ) || is_wp_error( $row ) ) { 2090 2083 return;
Note: See TracChangeset
for help on using the changeset viewer.