Changeset 9471 for trunk/src/bp-core/bp-core-classes.php
- Timestamp:
- 02/10/2015 02:49:16 AM (11 years ago)
- File:
-
- 1 edited
-
trunk/src/bp-core/bp-core-classes.php (modified) (23 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-classes.php
r9404 r9471 222 222 */ 223 223 public function prepare_user_ids_query() { 224 global $wpdb, $bp; 224 global $wpdb; 225 226 $bp = buddypress(); 225 227 226 228 // Default query variables used here … … 953 955 */ 954 956 public static function get_users( $type, $limit = 0, $page = 1, $user_id = 0, $include = false, $search_terms = false, $populate_extras = true, $exclude = false, $meta_key = false, $meta_value = false ) { 955 global $wpdb , $bp;957 global $wpdb; 956 958 957 959 _deprecated_function( __METHOD__, '1.7', 'BP_User_Query' ); 960 961 $bp = buddypress(); 958 962 959 963 $sql = array(); … … 1129 1133 * Fetch the details for all users whose usernames start with the given letter. 1130 1134 * 1131 * @global BuddyPress $bp The one true BuddyPress instance.1132 1135 * @global wpdb $wpdb WordPress database object. 1133 1136 * … … 1143 1146 */ 1144 1147 public static function get_users_by_letter( $letter, $limit = null, $page = 1, $populate_extras = true, $exclude = '' ) { 1145 global $ bp, $wpdb;1148 global $wpdb; 1146 1149 1147 1150 $pag_sql = ''; … … 1160 1163 } 1161 1164 } 1165 1166 $bp = buddypress(); 1162 1167 1163 1168 $letter_like = bp_esc_like( $letter ) . '%'; … … 1244 1249 * Find users who match on the value of an xprofile data. 1245 1250 * 1246 * @global BuddyPress $bp The one true BuddyPress instance.1247 1251 * @global wpdb $wpdb WordPress database object. 1248 1252 * … … 1255 1259 */ 1256 1260 public static function search_users( $search_terms, $limit = null, $page = 1, $populate_extras = true ) { 1257 global $bp, $wpdb; 1261 global $wpdb; 1262 1263 $bp = buddypress(); 1258 1264 1259 1265 $user_ids = array(); … … 1288 1294 * Accepts multiple user IDs to fetch data for. 1289 1295 * 1290 * @global BuddyPress $bp The one true BuddyPress instance.1291 1296 * @global wpdb $wpdb WordPress database object. 1292 1297 * … … 1297 1302 */ 1298 1303 public static function get_user_extras( &$paged_users, &$user_ids, $type = false ) { 1299 global $bp, $wpdb; 1304 global $wpdb; 1305 1306 $bp = buddypress(); 1300 1307 1301 1308 if ( empty( $user_ids ) ) … … 1699 1706 * Update or insert notification details into the database. 1700 1707 * 1701 * @global BuddyPress $bp The one true BuddyPress instance1702 1708 * @global wpdb $wpdb WordPress database object 1703 1709 * @return bool Success or failure 1704 1710 */ 1705 1711 public function save() { 1706 global $bp, $wpdb; 1712 global $wpdb; 1713 1714 $bp = buddypress(); 1707 1715 1708 1716 // Update … … 1728 1736 * Fetches the notification data from the database. 1729 1737 * 1730 * @global BuddyPress $bp The one true BuddyPress instance1731 1738 * @global wpdb $wpdb WordPress database object 1732 1739 */ 1733 1740 public function populate() { 1734 global $bp, $wpdb; 1741 global $wpdb; 1742 1743 $bp = buddypress(); 1735 1744 1736 1745 if ( $notification = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->core->table_name_notifications} WHERE id = %d", $this->id ) ) ) { … … 1748 1757 1749 1758 public static function check_access( $user_id, $notification_id ) { 1750 global $wpdb, $bp; 1759 global $wpdb; 1760 1761 $bp = buddypress(); 1751 1762 1752 1763 return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->core->table_name_notifications} WHERE id = %d AND user_id = %d", $notification_id, $user_id ) ); … … 1756 1767 * Fetches all the notifications in the database for a specific user. 1757 1768 * 1758 * @global BuddyPress $bp The one true BuddyPress instance1759 1769 * @global wpdb $wpdb WordPress database object 1760 1770 * @param integer $user_id User ID … … 1764 1774 */ 1765 1775 public static function get_all_for_user( $user_id, $status = 'is_new' ) { 1766 global $bp, $wpdb; 1767 1768 $is_new = ( 'is_new' == $status ) ? ' AND is_new = 1 ' : ''; 1776 global $wpdb; 1777 1778 $bp = buddypress(); 1779 1780 $is_new = ( 'is_new' === $status ) 1781 ? ' AND is_new = 1 ' 1782 : ''; 1769 1783 1770 1784 return $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->core->table_name_notifications} WHERE user_id = %d {$is_new}", $user_id ) ); … … 1774 1788 * Delete all the notifications for a user based on the component name and action. 1775 1789 * 1776 * @global BuddyPress $bp The one true BuddyPress instance1777 1790 * @global wpdb $wpdb WordPress database object 1778 1791 * @param integer $user_id … … 1782 1795 */ 1783 1796 public static function delete_for_user_by_type( $user_id, $component_name, $component_action ) { 1784 global $bp, $wpdb; 1797 global $wpdb; 1798 1799 $bp = buddypress(); 1785 1800 1786 1801 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->core->table_name_notifications} WHERE user_id = %d AND component_name = %s AND component_action = %s", $user_id, $component_name, $component_action ) ); … … 1790 1805 * Delete all the notifications that have a specific item id, component name and action. 1791 1806 * 1792 * @global BuddyPress $bp The one true BuddyPress instance1793 1807 * @global wpdb $wpdb WordPress database object 1794 1808 * @param integer $user_id The ID of the user who the notifications are for. … … 1800 1814 */ 1801 1815 public static function delete_for_user_by_item_id( $user_id, $item_id, $component_name, $component_action, $secondary_item_id = false ) { 1802 global $bp, $wpdb; 1803 1804 $secondary_item_sql = !empty( $secondary_item_id ) ? $wpdb->prepare( " AND secondary_item_id = %d", $secondary_item_id ) : ''; 1816 global $wpdb; 1817 1818 $bp = buddypress(); 1819 1820 $secondary_item_sql = !empty( $secondary_item_id ) 1821 ? $wpdb->prepare( " AND secondary_item_id = %d", $secondary_item_id ) 1822 : ''; 1805 1823 1806 1824 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->core->table_name_notifications} WHERE user_id = %d AND item_id = %d AND component_name = %s AND component_action = %s{$secondary_item_sql}", $user_id, $item_id, $component_name, $component_action ) ); … … 1810 1828 * Deletes all the notifications sent by a specific user, by component and action. 1811 1829 * 1812 * @global BuddyPress $bp The one true BuddyPress instance1813 1830 * @global wpdb $wpdb WordPress database object 1814 1831 * @param integer $user_id The ID of the user whose sent notifications we wish to delete. … … 1818 1835 */ 1819 1836 public static function delete_from_user_by_type( $user_id, $component_name, $component_action ) { 1820 global $bp, $wpdb; 1837 global $wpdb; 1838 1839 $bp = buddypress(); 1821 1840 1822 1841 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->core->table_name_notifications} WHERE item_id = %d AND component_name = %s AND component_action = %s", $user_id, $component_name, $component_action ) ); … … 1826 1845 * Deletes all the notifications for all users by item id, and optional secondary item id, and component name and action. 1827 1846 * 1828 * @global BuddyPress $bp The one true BuddyPress instance1829 1847 * @global wpdb $wpdb WordPress database object 1830 1848 * @param string $item_id The item id that they notifications are to be for. … … 1835 1853 */ 1836 1854 public static function delete_all_by_type( $item_id, $component_name, $component_action, $secondary_item_id ) { 1837 global $ bp, $wpdb;1855 global $wpdb; 1838 1856 1839 1857 if ( $component_action ) … … 1846 1864 else 1847 1865 $secondary_item_sql = ''; 1866 1867 $bp = buddypress(); 1848 1868 1849 1869 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->core->table_name_notifications} WHERE item_id = %d AND component_name = %s {$component_action_sql} {$secondary_item_sql}", $item_id, $component_name ) );
Note: See TracChangeset
for help on using the changeset viewer.