Changeset 4378
- Timestamp:
- 05/16/2011 10:22:39 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity/bp-activity-classes.php
r4372 r4378 524 524 525 525 function total_favorite_count( $user_id ) { 526 if ( !$favorite_activity_entries = get_user_meta( $user_id, bp_get_user_meta_key( ' favorite_activities' ), true ) )526 if ( !$favorite_activity_entries = get_user_meta( $user_id, bp_get_user_meta_key( 'bp_favorite_activities' ), true ) ) 527 527 return 0; 528 528 -
trunk/bp-activity/bp-activity-functions.php
r4372 r4378 191 191 192 192 // Get favorites for user 193 $favs = get_user_meta( $user_id, bp_get_user_meta_key( ' favorite_activities' ), true );193 $favs = get_user_meta( $user_id, bp_get_user_meta_key( 'bp_favorite_activities' ), true ); 194 194 195 195 return apply_filters( 'bp_activity_get_user_favorites', $favs ); … … 216 216 217 217 // Update the user's personal favorites 218 $my_favs = get_user_meta( $bp->loggedin_user->id, bp_get_user_meta_key( ' favorite_activities' ), true );218 $my_favs = get_user_meta( $bp->loggedin_user->id, bp_get_user_meta_key( 'bp_favorite_activities' ), true ); 219 219 $my_favs[] = $activity_id; 220 220 … … 224 224 225 225 // Update user meta 226 update_user_meta( $bp->loggedin_user->id, bp_get_user_meta_key( ' favorite_activities' ), $my_favs );226 update_user_meta( $bp->loggedin_user->id, bp_get_user_meta_key( 'bp_favorite_activities' ), $my_favs ); 227 227 228 228 // Update activity meta counts … … 256 256 257 257 // Remove the fav from the user's favs 258 $my_favs = get_user_meta( $user_id, bp_get_user_meta_key( ' favorite_activities' ), true );258 $my_favs = get_user_meta( $user_id, bp_get_user_meta_key( 'bp_favorite_activities' ), true ); 259 259 $my_favs = array_flip( (array) $my_favs ); 260 260 unset( $my_favs[$activity_id] ); … … 268 268 269 269 // Update users favorites 270 if ( update_user_meta( $user_id, bp_get_user_meta_key( ' favorite_activities' ), $my_favs ) ) {270 if ( update_user_meta( $user_id, bp_get_user_meta_key( 'bp_favorite_activities' ), $my_favs ) ) { 271 271 272 272 // Execute additional code … … 500 500 501 501 // Remove any usermeta 502 delete_user_meta( $user_id, bp_get_user_meta_key( ' latest_update' ) );503 delete_user_meta( $user_id, bp_get_user_meta_key( ' favorite_activities' ) );502 delete_user_meta( $user_id, bp_get_user_meta_key( 'bp_latest_update' ) ); 503 delete_user_meta( $user_id, bp_get_user_meta_key( 'bp_favorite_activities' ) ); 504 504 505 505 // Execute additional code … … 676 676 677 677 // Add this update to the "latest update" usermeta so it can be fetched anywhere. 678 update_user_meta( $bp->loggedin_user->id, bp_get_user_meta_key( ' latest_update' ), array( 'id' => $activity_id, 'content' => wp_filter_kses( $content ) ) );678 update_user_meta( $bp->loggedin_user->id, bp_get_user_meta_key( 'bp_latest_update' ), array( 'id' => $activity_id, 'content' => wp_filter_kses( $content ) ) ); 679 679 680 680 // Require the notifications code so email notifications can be set on the 'bp_activity_posted_update' action. … … 808 808 do_action( 'bp_before_activity_delete', $args ); 809 809 810 $latest_update = get_user_meta( $user_id, bp_get_user_meta_key( ' latest_update' ), true );810 $latest_update = get_user_meta( $user_id, bp_get_user_meta_key( 'bp_latest_update' ), true ); 811 811 if ( !empty( $latest_update ) ) { 812 812 if ( in_array( (int)$latest_update['id'], (array)$activity_ids_deleted ) ) 813 delete_user_meta( $user_id, bp_get_user_meta_key( ' latest_update' ) );813 delete_user_meta( $user_id, bp_get_user_meta_key( 'bp_latest_update' ) ); 814 814 } 815 815 -
trunk/bp-activity/bp-activity-loader.php
r4372 r4378 68 68 'table_name_meta' => $bp->table_prefix . 'bp_activity_meta', 69 69 ); 70 71 // User meta keys72 $user_meta_keys = array(73 'new_mention_count' => 'bp_new_mention_count',74 'new_mentions' => 'bp_new_mentions',75 'favorite_activities' => 'bp_favorite_activities',76 'latest_update' => 'bp_latest_update',77 'notification_activity_new_mention' => 'notification_activity_new_mention',78 'notification_activity_new_reply' => 'notification_activity_new_reply'79 );80 70 81 71 // All globals for activity component. … … 86 76 'root_slug' => isset( $bp->pages->activity->slug ) ? $bp->pages->activity->slug : BP_ACTIVITY_SLUG, 87 77 'search_string' => __( 'Search Activity...', 'buddypress' ), 88 'global_tables' => $global_tables, 89 'user_meta_keys' => $user_meta_keys 78 'global_tables' => $global_tables 90 79 ); 91 80 -
trunk/bp-activity/bp-activity-template.php
r4376 r4378 94 94 95 95 // Get an array of the logged in user's favorite activities 96 $this->my_favs = maybe_unserialize( get_user_meta( $bp->loggedin_user->id, bp_get_user_meta_key( ' favorite_activities' ), true ) );96 $this->my_favs = maybe_unserialize( get_user_meta( $bp->loggedin_user->id, bp_get_user_meta_key( 'bp_favorite_activities' ), true ) ); 97 97 98 98 // Fetch specific activity items based on ID's … … 1026 1026 $user_id = $bp->displayed_user->id; 1027 1027 1028 if ( !$update = get_user_meta( $user_id, bp_get_user_meta_key( ' latest_update' ), true ) )1028 if ( !$update = get_user_meta( $user_id, bp_get_user_meta_key( 'bp_latest_update' ), true ) ) 1029 1029 return false; 1030 1030 … … 1144 1144 global $bp; 1145 1145 1146 return apply_filters( 'bp_get_total_mention_count_for_user', get_user_meta( $user_id, bp_get_user_meta_key( ' new_mention_count' ), true ) );1146 return apply_filters( 'bp_get_total_mention_count_for_user', get_user_meta( $user_id, bp_get_user_meta_key( 'bp_new_mention_count' ), true ) ); 1147 1147 } 1148 1148 -
trunk/bp-core/bp-core-classes.php
r4372 r4378 432 432 433 433 // Fetch the user's latest update 434 $user_update = $wpdb->get_results( "SELECT user_id as id, meta_value as latest_update FROM " . CUSTOM_USER_META_TABLE . " WHERE meta_key = ' bp_latest_update' AND user_id IN ( {$user_ids} )" );434 $user_update = $wpdb->get_results( "SELECT user_id as id, meta_value as latest_update FROM " . CUSTOM_USER_META_TABLE . " WHERE meta_key = '" . bp_get_user_meta_key( 'bp_latest_update' ) . "' AND user_id IN ( {$user_ids} )" ); 435 435 for ( $i = 0; $i < count( $paged_users ); $i++ ) { 436 436 foreach ( (array)$user_update as $update ) { -
trunk/bp-core/bp-core-component.php
r4372 r4378 95 95 * @uses apply_filters() Calls 'bp_{@link bp_Component::name}_id' 96 96 * @uses apply_filters() Calls 'bp_{@link bp_Component::name}_slug' 97 * @uses apply_filters() Calls 'bp_user_meta_keys_$key_name'98 97 * 99 98 * @param arr $args Used to … … 109 108 'notification_callback' => '', 110 109 'search_string' => '', 111 'global_tables' => '', 112 'user_meta_keys' => array() 110 'global_tables' => '' 113 111 ); 114 112 $r = wp_parse_args( $args, $defaults ); … … 130 128 foreach ( $r['global_tables'] as $global_name => $table_name ) 131 129 $this->$global_name = $table_name; 132 133 // User meta keys134 if ( !empty( $r['user_meta_keys'] ) ) {135 foreach ( $r['user_meta_keys'] as $key_name => $key_value )136 $bp->user_meta_keys->$key_name = apply_filters( "bp_user_meta_keys_$key_name", $key_value );137 }138 130 139 131 /** BuddyPress ********************************************************/ -
trunk/bp-core/bp-core-functions.php
r4372 r4378 28 28 29 29 $page_blog_id = $is_enable_multiblog ? get_current_blog_id() : BP_ROOT_BLOG; 30 30 31 31 // Upgrading from an earlier version of BP pre-1.3 32 32 if ( empty( $page_ids ) || isset( $page_ids['members'] ) ) { … … 1001 1001 * BuddyPress stores a number of pieces of userdata in the WordPress central usermeta table. In 1002 1002 * order to allow plugins to enable multiple instances of BuddyPress on a single WP installation, 1003 * BP's usermeta keys are abstracted and stored in the $bp global, at $bp->user_meta_keys.1003 * BP's usermeta keys are filtered with this function, so that they can be altered on the fly. 1004 1004 * 1005 1005 * Plugin authors who access or modify metadata created by BuddyPress should use … … 1009 1009 * 1010 1010 * If your plugin introduces custom user metadata that might change between multiple BP instances 1011 * on a single WP installation, you are strongly recommended to register your meta keys in the $bp 1012 * global (see BP_Core_Component::setup_globals()), and use this function when storing and 1011 * on a single WP installation, you are strongly recommended to use this function when storing and 1013 1012 * retrieving metadata. 1014 1013 * 1015 1014 * @package BuddyPress 1016 1015 * @since 1.3 1017 * @see BP_Core_Component::_setup_globals()1018 1016 * 1019 1017 * @uses apply_filters() Filter bp_get_user_meta_key to modify keys individually 1020 * @param str $ name1018 * @param str $key 1021 1019 * @return str $key 1022 1020 */ 1023 function bp_get_user_meta_key( $name = false ) { 1024 global $bp; 1025 1026 if ( !$name ) 1027 return false; 1028 1029 $key = isset( $bp->user_meta_keys->$name ) ? $bp->user_meta_keys->$name : false; 1030 1031 return apply_filters( 'bp_get_user_meta_key', $key, $name ); 1021 function bp_get_user_meta_key( $key = false ) { 1022 return apply_filters( 'bp_get_user_meta_key', $key ); 1032 1023 } 1033 1024 -
trunk/bp-core/bp-core-loader.php
r4372 r4378 150 150 // The user ID of the user who is currently logged in. 151 151 $bp->loggedin_user->id = $current_user->ID; 152 153 // Keys for BP user_meta154 $bp->user_meta_keys->last_activity = apply_filters( 'bp_user_meta_key_last_activity', 'last_activity' );155 $bp->user_meta_keys->closed_notices = apply_filters( 'bp_user_meta_key_closed_notices', 'closed_notices' );156 152 157 153 /** Avatars ***********************************************************/ -
trunk/bp-friends/bp-friends-loader.php
r4372 r4378 71 71 'table_name_meta' => $bp->table_prefix . 'bp_friends_meta', 72 72 ); 73 74 // User meta keys75 $user_meta_keys = array(76 'total_friend_count' => 'total_friend_count',77 'notification_friends_friendship_request' => 'notification_friends_friendship_request',78 'notification_friends_friendship_accepted' => 'notification_friends_friendship_accepted'79 );80 73 81 74 // All globals for the friends component. … … 86 79 'search_string' => __( 'Search Friends...', 'buddypress' ), 87 80 'notification_callback' => 'friends_format_notifications', 88 'global_tables' => $global_tables, 89 'user_meta_keys' => $user_meta_keys 81 'global_tables' => $global_tables 90 82 ); 91 83 -
trunk/bp-groups/bp-groups-functions.php
r4372 r4378 249 249 250 250 // Modify user's group memberhip count 251 update_user_meta( $user_id, $bp->user_meta_keys->total_group_count, (int) get_user_meta( $user_id, bp_get_user_meta_key( 'total_group_count' ), true ) - 1 );251 update_user_meta( $user_id, bp_get_user_meta_key( 'total_group_count' ), (int) get_user_meta( $user_id, bp_get_user_meta_key( 'total_group_count' ), true ) - 1 ); 252 252 253 253 /** -
trunk/bp-groups/bp-groups-loader.php
r4372 r4378 74 74 'table_name_groupmeta' => $bp->table_prefix . 'bp_groups_groupmeta' 75 75 ); 76 77 // User meta_keys78 $user_meta_keys = array(79 'total_group_count' => 'total_group_count',80 'notification_groups_group_updated' => 'notification_groups_group_updated',81 'notification_groups_membership_request' => 'notification_groups_membership_request',82 'notification_membership_request_completed' => 'notification_membership_request_completed',83 'notification_groups_invite' => 'notification_groups_invite',84 'notification_groups_admin_promotion' => 'notification_groups_admin_promotion'85 );86 76 87 77 // All globals for messaging component. … … 92 82 'notification_callback' => 'groups_format_notifications', 93 83 'search_string' => __( 'Search Groups...', 'buddypress' ), 94 'global_tables' => $global_tables, 95 'user_meta_keys' => $user_meta_keys 84 'global_tables' => $global_tables 96 85 ); 97 86 -
trunk/bp-messages/bp-messages-loader.php
r4372 r4378 71 71 ); 72 72 73 $user_meta_keys = array(74 'notification_messages_new_message' => 'notification_messages_new_message',75 'notification_messages_new_notice' => 'notification_messages_new_notice'76 );77 78 73 // All globals for messaging component. 79 74 // Note that global_tables is included in this array. … … 82 77 'notification_callback' => 'messages_format_notifications', 83 78 'search_string' => __( 'Search Messages...', 'buddypress' ), 84 'global_tables' => $global_tables, 85 'user_meta_keys' => $user_meta_keys 79 'global_tables' => $global_tables 86 80 ); 87 81 -
trunk/bp-xprofile/bp-xprofile-loader.php
r4372 r4378 93 93 ); 94 94 95 $user_meta_keys = array(96 'profile_last_updated' => 'profile_last_updated'97 );98 99 95 $globals = array( 100 96 'slug' => BP_XPROFILE_SLUG, 101 97 'root_slug' => isset( $bp->pages->xprofile->slug ) ? $bp->pages->xprofile->slug : BP_XPROFILE_SLUG, 102 98 'notification_callback' => 'xprofile_format_notifications', 103 'global_tables' => $global_tables, 104 'user_meta_keys' => $user_meta_keys 99 'global_tables' => $global_tables 105 100 ); 106 101
Note: See TracChangeset
for help on using the changeset viewer.