Changeset 394
- Timestamp:
- 10/23/2008 12:56:37 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 7 added
- 4 deleted
- 19 edited
-
bp-activity.php (modified) (4 diffs)
-
bp-activity/bp-activity-classes.php (modified) (1 diff)
-
bp-blogs.php (modified) (10 diffs)
-
bp-core.php (modified) (19 diffs)
-
bp-core/admin-mods (deleted)
-
bp-core/bp-core-adminbar.php (modified) (2 diffs)
-
bp-core/bp-core-ajax-handler.php (modified) (1 diff)
-
bp-core/bp-core-ajax.php (modified) (2 diffs)
-
bp-core/bp-core-avatars.php (modified) (10 diffs)
-
bp-core/bp-core-catchuri.php (modified) (7 diffs)
-
bp-core/bp-core-classes.php (modified) (3 diffs)
-
bp-core/bp-core-cssjs.php (modified) (2 diffs)
-
bp-core/bp-core-templatetags.php (modified) (3 diffs)
-
bp-core/bp-core-widgets.php (modified) (2 diffs)
-
bp-core/css/directory-members.css (added)
-
bp-core/directories (added)
-
bp-core/directories/bp-core-directory-members.php (added)
-
bp-core/homebase-creation (deleted)
-
bp-core/js/directory-members.js (added)
-
bp-friends.php (modified) (2 diffs)
-
bp-groups.php (modified) (5 diffs)
-
bp-groups/bp-groups-classes.php (modified) (3 diffs)
-
bp-xprofile.php (modified) (4 diffs)
-
bp-xprofile/admin-mods (added)
-
bp-xprofile/admin-mods/bp-xprofile-account-tab.php (added)
-
bp-xprofile/admin-mods/bp-xprofile-admin-mods.php (added)
-
bp-xprofile/bp-xprofile-signup.php (modified) (5 diffs)
-
bp-xprofile/bp-xprofile-templatetags.php (modified) (3 diffs)
-
buddypress-theme/buddypress (deleted)
-
buddypress-theme/home (deleted)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity.php
r391 r394 96 96 97 97 $bp['activity'] = array( 98 'table_name_loggedin_user' => $wpdb->base_prefix . $bp['loggedin_homebase_id'] . '_activity',99 'table_name_loggedin_user_cached' => $wpdb->base_prefix . $bp['loggedin_homebase_id'] . '_activity_cached',100 101 'table_name_current_user' => $wpdb->base_prefix . $bp['current_homebase_id'] . '_activity',102 'table_name_current_user_cached' => $wpdb->base_prefix . $bp['current_homebase_id'] . '_activity_cached',103 104 'table_name_loggedin_user_friends_cached' => $wpdb->base_prefix . $bp['loggedin_homebase_id'] . '_friends_activity_cached',98 'table_name_loggedin_user' => $wpdb->base_prefix . 'user_' . $bp['loggedin_userid'] . '_activity', 99 'table_name_loggedin_user_cached' => $wpdb->base_prefix . 'user_' . $bp['loggedin_userid'] . '_activity_cached', 100 101 'table_name_current_user' => $wpdb->base_prefix . 'user_' . $bp['current_userid'] . '_activity', 102 'table_name_current_user_cached' => $wpdb->base_prefix . 'user_' . $bp['current_userid'] . '_activity_cached', 103 104 'table_name_loggedin_user_friends_cached' => $wpdb->base_prefix . 'user_' . $bp['loggedin_userid'] . '_friends_activity_cached', 105 105 'table_name_sitewide' => $wpdb->base_prefix . 'bp_activity_sitewide', 106 106 … … 115 115 } 116 116 } 117 add_action( 'wp', 'bp_activity_setup_globals', 1 ); 117 add_action( 'wp', 'bp_activity_setup_globals', 1 ); 118 118 add_action( '_admin_menu', 'bp_activity_setup_globals', 1 ); 119 119 … … 180 180 /***** Actions **********/ 181 181 182 function bp_activity_record( $item_id, $component_name, $component_action, $is_private, $dual_record = false , $secondary_user_homebase_id = false) {182 function bp_activity_record( $item_id, $component_name, $component_action, $is_private, $dual_record = false ) { 183 183 global $bp, $wpdb; 184 184 … … 196 196 /* Save an activity entry for both logged in and secondary user. For example for a new friend connection 197 197 you would want to show "X and Y are now friends" on both users activity stream */ 198 if ( $dual_record && $secondary_user_homebase_id) {198 if ( $dual_record ) { 199 199 $table_name = $wpdb->base_prefix . $secondary_user_homebase_id . '_activity'; 200 200 $table_name_cached = $wpdb->base_prefix . $secondary_user_homebase_id . '_activity_cached'; -
trunk/bp-activity/bp-activity-classes.php
r378 r394 186 186 187 187 for ( $i = 0; $i < count($friend_ids); $i++ ) { 188 $homebase_id = get_usermeta( $friend_ids[$i], 'home_base' ); 189 $table_name = $wpdb->base_prefix . $homebase_id . '_activity_cached'; 188 $table_name = $wpdb->base_prefix . $field_ids[$i] . '_activity_cached'; 190 189 191 190 $activities[$i]['activity'] = $wpdb->get_results( $wpdb->prepare( "SELECT content, date_recorded, component_name FROM " . $table_name . " WHERE is_private = 0 ORDER BY date_recorded LIMIT 5" ) ); -
trunk/bp-blogs.php
r391 r394 250 250 251 251 252 function bp_blogs_record_blog( $blog_id = '', $user_id = '') {252 function bp_blogs_record_blog( $blog_id, $user_id ) { 253 253 global $bp; 254 254 … … 261 261 $user_id = $bp['loggedin_userid']; 262 262 263 if ( !get_usermeta( $user_id, 'home_base' ) ) 264 return false; 265 266 if ( (int)$blog_id != (int)get_usermeta( $user_id, 'home_base' ) ) { 267 $recorded_blog = new BP_Blogs_Blog; 268 $recorded_blog->user_id = $user_id; 269 $recorded_blog->blog_id = $blog_id; 270 271 $recorded_blog_id = $recorded_blog->save(); 272 273 do_action( 'bp_blogs_new_blog', array( 'item_id' => $recorded_blog_id, 'component_name' => 'blogs', 'component_action' => 'new_blog', 'is_private' => 0 ) ); 274 } 275 } 276 add_action( 'wpmu_new_blog', 'bp_blogs_record_blog', 10 ); 277 278 function bp_blogs_record_post($post_id = '') { 263 $recorded_blog = new BP_Blogs_Blog; 264 $recorded_blog->user_id = $user_id; 265 $recorded_blog->blog_id = $blog_id; 266 267 $recorded_blog_id = $recorded_blog->save(); 268 269 do_action( 'bp_blogs_new_blog', array( 'item_id' => $recorded_blog_id, 'component_name' => 'blogs', 'component_action' => 'new_blog', 'is_private' => 0 ) ); 270 } 271 add_action( 'wpmu_new_blog', 'bp_blogs_record_blog', 10, 2 ); 272 273 274 function bp_blogs_record_post($post_id) { 279 275 global $bp, $current_blog; 280 276 … … 325 321 add_action( 'publish_post', 'bp_blogs_record_post' ); 326 322 327 function bp_blogs_record_comment( $comment_id = '', $from_ajax = false ) {323 function bp_blogs_record_comment( $comment_id, $from_ajax = false ) { 328 324 global $bp, $current_blog, $current_user; 329 325 … … 376 372 } 377 373 } 378 add_action( 'comment_post', 'bp_blogs_record_comment' );379 add_action( 'edit_comment', 'bp_blogs_record_comment' );380 381 382 function bp_blogs_modify_comment( $comment_id = '', $comment_status = '') {374 add_action( 'comment_post', 'bp_blogs_record_comment', 10, 2 ); 375 add_action( 'edit_comment', 'bp_blogs_record_comment', 10, 2 ); 376 377 378 function bp_blogs_modify_comment( $comment_id, $comment_status ) { 383 379 global $bp; 384 380 … … 397 393 } 398 394 } 399 add_action( 'wp_set_comment_status', 'bp_blogs_modify_comment' );400 401 function bp_blogs_remove_blog( $blog_id = '') {395 add_action( 'wp_set_comment_status', 'bp_blogs_modify_comment', 10, 2 ); 396 397 function bp_blogs_remove_blog( $blog_id ) { 402 398 $blog_id = (int)$blog_id; 403 399 … … 406 402 add_action( 'delete_blog', 'bp_blogs_remove_blog' ); 407 403 408 function bp_blogs_remove_blog_for_user( $user_id = '', $blog_id = '') {404 function bp_blogs_remove_blog_for_user( $user_id, $blog_id ) { 409 405 $blog_id = (int)$blog_id; 410 406 $user_id = (int)$user_id; … … 412 408 BP_Blogs_Blog::delete_blog_for_user( $blog_id, $user_id ); 413 409 } 414 add_action( 'remove_user_from_blog', 'bp_blogs_remove_blog' );415 416 function bp_blogs_remove_post( $post_id = '') {410 add_action( 'remove_user_from_blog', 'bp_blogs_remove_blog', 10, 2 ); 411 412 function bp_blogs_remove_post( $post_id ) { 417 413 global $current_blog, $bp; 418 414 … … 429 425 add_action( 'delete_post', 'bp_blogs_remove_post' ); 430 426 431 function bp_blogs_remove_comment( $comment_id = '') {427 function bp_blogs_remove_comment( $comment_id ) { 432 428 global $current_blog, $bp; 433 429 … … 445 441 446 442 function bp_blogs_remove_data( $blog_id ) { 447 448 if ( $user_id = bp_core_get_homebase_userid( $blog_id ) ) { 449 /* If this is a home base, delete everything for that user. */ 450 BP_Blogs_Blog::delete_blogs_for_user( $user_id ); 451 BP_Blogs_Post::delete_posts_for_user( $user_id ); 452 BP_Blogs_Comment::delete_comments_for_user( $user_id ); 453 } else { 454 /* If this is regular blog, delete all data for that blog. */ 455 BP_Blogs_Blog::delete_blog_for_all( $blog_id ); 456 BP_Blogs_Post::delete_posts_for_blog( $blog_id ); 457 BP_Blogs_Comment::delete_comments_for_blog( $blog_id ); 458 } 459 443 /* If this is regular blog, delete all data for that blog. */ 444 BP_Blogs_Blog::delete_blog_for_all( $blog_id ); 445 BP_Blogs_Post::delete_posts_for_blog( $blog_id ); 446 BP_Blogs_Comment::delete_comments_for_blog( $blog_id ); 460 447 } 461 448 add_action( 'delete_blog', 'bp_blogs_remove_data', 1 ); … … 474 461 if ( is_array($blogs) ) { 475 462 foreach ( $blogs as $blog ) { 476 if ( (int)$blog->userblog_id != (int)get_usermeta( $user_id, 'home_base' ) ) { 477 bp_blogs_record_blog( (int)$blog->userblog_id, (int)$user_id ); 478 479 switch_to_blog( $blog->userblog_id ); 480 $posts_for_blog = bp_core_get_all_posts_for_user( $user_id ); 481 482 for ( $i = 0; $i < count($posts); $i++ ) { 483 bp_blogs_record_post( $posts[$i] ); 484 } 463 bp_blogs_record_blog( (int)$blog->userblog_id, (int)$user_id ); 464 465 switch_to_blog( $blog->userblog_id ); 466 $posts_for_blog = bp_core_get_all_posts_for_user( $user_id ); 467 468 for ( $i = 0; $i < count($posts); $i++ ) { 469 bp_blogs_record_post( $posts[$i] ); 485 470 } 486 471 } -
trunk/bp-core.php
r392 r394 5 5 /* These components are accessed via the root, and not under a blog name or home base. 6 6 e.g Groups is accessed via: http://domain.com/groups/group-name NOT http://domain.com.andy/groups/group-name */ 7 define( 'BP_CORE_ROOT_COMPONENTS', 'groups ' );8 9 /* Require all needed files */7 define( 'BP_CORE_ROOT_COMPONENTS', 'groups,members' ); 8 9 /* Functions to handle pretty URLs and breaking them down into usable variables */ 10 10 require_once( 'bp-core/bp-core-catchuri.php' ); 11 12 /* Database access classes */ 11 13 require_once( 'bp-core/bp-core-classes.php' ); 14 15 /* Functions to control the inclusion of CSS and JS files */ 12 16 require_once( 'bp-core/bp-core-cssjs.php' ); 17 18 /* Functions that handle the uploading, cropping, validation and storing of avatars */ 13 19 require_once( 'bp-core/bp-core-avatars.php' ); 20 21 /* Template functions/tags that can be used in template files */ 14 22 require_once( 'bp-core/bp-core-templatetags.php' ); 23 24 /* Functions to enable the site wide administration bar */ 15 25 require_once( 'bp-core/bp-core-adminbar.php' ); 26 27 /* Bundled core widgets that can be dropped into themes */ 16 28 require_once( 'bp-core/bp-core-widgets.php' ); 29 30 /* AJAX functionality */ 17 31 require_once( 'bp-core/bp-core-ajax.php' ); 18 require_once( 'bp-core/admin-mods/bp-core-remove-blogtabs.php' ); 19 require_once( 'bp-core/admin-mods/bp-core-admin-styles.php' ); 20 require_once( 'bp-core/homebase-creation/bp-core-homebase-functions.php' ); 32 33 /* Functions to handle and display the member and blog directory pages */ 34 require_once( 'bp-core/directories/bp-core-directory-members.php' ); 35 36 37 /* "And now for something completely different" .... */ 21 38 22 39 … … 40 57 function bp_core_setup_globals() { 41 58 global $bp; 42 global $current_user, $current_component, $current_action; 59 global $current_user, $current_component, $current_action, $current_blog; 60 global $current_userid; 43 61 global $action_variables; 62 63 /* The domain for the root of the site where the main blog resides */ 64 $bp['root_domain'] = bp_core_get_root_domain(); 44 65 45 66 /* The user ID of the user who is currently logged in. */ 46 67 $bp['loggedin_userid'] = $current_user->ID; 47 68 48 /* The domain for the user currently logged in. eg: http://andy.domain.com/ */ 49 $bp['loggedin_domain'] = bp_core_get_loggedin_domain(); 69 /* The user id of the user currently being viewed */ 70 $bp['current_userid'] = $current_userid; 71 72 /* The domain for the user currently logged in. eg: http://domain.com/members/andy */ 73 $bp['loggedin_domain'] = bp_core_get_user_domain($current_user->ID); 50 74 51 75 /* The domain for the user currently being viewed */ 52 $bp['current_domain'] = bp_core_get_current_domain(); 53 54 /* The user id of the user currently being viewed */ 55 $bp['current_userid'] = bp_core_get_current_userid(); 76 $bp['current_domain'] = bp_core_get_user_domain($current_userid); 56 77 57 78 /* The component being used eg: http://andy.domain.com/ [profile] */ … … 90 111 /* Sets up container for callback message type rendered by bp_core_render_notice() */ 91 112 $bp['message_type'] = ''; // error/success 92 93 /* Fetch the home base blog id for the logged in and current user */ 94 $bp['loggedin_homebase_id'] = get_usermeta( $bp['loggedin_userid'], 'home_base' ); 95 $bp['current_homebase_id'] = get_usermeta( $bp['current_userid'], 'home_base' ); 96 113 97 114 /* Fetch the full name for the logged in and current user */ 98 115 $bp['loggedin_fullname'] = bp_core_global_user_fullname( $bp['loggedin_userid'] ); … … 115 132 add_action( '_admin_menu', 'bp_core_setup_globals', 1 ); // must be _admin_menu hook. 116 133 117 /** 118 * bp_core_component_exists() 119 * 120 * Check to see if a component with the given name actually exists. 121 * If not, redirect to the 404. 122 * 123 * @package BuddyPress Core 124 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() 125 * @return false if no, or true if yes. 126 */ 127 function bp_core_component_exists() { 128 global $bp, $wpdb; 129 130 if ( $wpdb->blogid == $bp['current_homebase_id'] ) { 131 $component_check = $bp['current_component']; 132 133 if ( strpos( $component_check, 'activate.php' ) ) 134 return true; 135 136 if ( empty($bp[$component_check]) ) { 137 status_header('404'); 138 load_template( TEMPLATEPATH . '/header.php'); 139 load_template( TEMPLATEPATH . '/404.php'); 140 load_template( TEMPLATEPATH . '/footer.php'); 141 die; 134 function bp_core_setup_nav() { 135 global $bp; 136 137 if ( !function_exists('xprofile_install') ) { 138 /* Add 'Profile' to the main navigation */ 139 bp_core_add_nav_item( __('Profile', 'buddypress'), 'profile' ); 140 bp_core_add_nav_default( 'profile', 'bp_core_catch_profile_uri', 'public' ); 141 142 $profile_link = $bp['loggedin_domain'] . '/profile/'; 143 144 /* Add the subnav items to the profile */ 145 bp_core_add_subnav_item( 'profile', 'public', __('Public', 'buddypress'), $profile_link, 'xprofile_screen_display_profile' ); 146 147 if ( $bp['current_component'] == 'profile' ) { 148 if ( bp_is_home() ) { 149 $bp['bp_options_title'] = __('My Profile', 'buddypress'); 150 } else { 151 $bp['bp_options_avatar'] = bp_core_get_avatar( $bp['current_userid'], 1 ); 152 $bp['bp_options_title'] = $bp['current_fullname']; 153 } 142 154 } 143 155 } 144 156 } 145 add_action( 'wp', 'bp_core_component_exists', 10 ); 146 147 148 /** 149 * bp_core_add_settings_tab() 150 * 151 * Adds a custom settings tab to the home base for the user 152 * in the admin area. 153 * 154 * @package BuddyPress Core 155 * @global $menu The global WordPress admin navigation menu. 156 */ 157 function bp_core_add_settings_tab() { 158 global $menu; 159 160 $account_settings_tab = add_menu_page( __('Account', 'buddypress'), __('Account', 'buddypress'), 10, 'bp-core/admin-mods/bp-core-account-tab.php' ); 161 } 162 add_action( 'admin_menu', 'bp_core_add_settings_tab' ); 163 164 /** 165 * bp_core_get_loggedin_domain() 166 * 167 * Returns the domain for the user that is currently logged in. 168 * eg: http://andy.domain.com/ or http://domain.com/andy/ 157 add_action( 'wp', 'bp_core_setup_nav', 2 ); 158 159 /** 160 * bp_core_get_user_domain() 161 * 162 * Returns the domain for the passed user: 163 * e.g. http://domain.com/members/andy/ 169 164 * 170 165 * @package BuddyPress Core 171 166 * @global $current_user WordPress global variable containing current logged in user information 172 * @param optional user_id 173 * @uses get_usermeta() WordPress function to get the usermeta for a current user. 174 */ 175 function bp_core_get_loggedin_domain( $user_id = null ) { 176 global $current_user; 177 178 if ( !$user_id ) 179 $user_id = $current_user->ID; 180 181 /* Get the ID of the home base blog */ 182 if ( $home_base_id = get_usermeta( $user_id, 'home_base' ) ) 183 return get_blog_option( $home_base_id, 'siteurl' ) . '/'; 184 else 185 return false; 186 } 187 188 /** 189 * bp_core_get_current_domain() 190 * 191 * Returns the domain for the user that is currently being viewed. 192 * eg: http://andy.domain.com/ or http://domain.com/andy/ 167 * @param user_id The ID of the user. 168 * @uses get_usermeta() WordPress function to get the usermeta for a user. 169 */ 170 function bp_core_get_user_domain( $user_id ) { 171 global $bp; 172 173 if ( !$user_id ) return; 174 175 $ud = get_userdata($user_id); 176 177 return $bp['root_domain'] . '/members/' . $ud->user_login . '/'; 178 } 179 180 /** 181 * bp_core_get_root_domain() 182 * 183 * Returns the domain for the root blog. 184 * eg: http://domain.com/ OR https://domain.com 193 185 * 194 186 * @package BuddyPress Core 195 187 * @global $current_blog WordPress global variable containing information for the current blog being viewed. 196 * @uses get_bloginfo() WordPress function to return the value of a blog setting based on param passed 197 * @return $current_domain The domain for the user that is currently being viewed. 198 */ 199 function bp_core_get_current_domain() { 188 * @uses switch_to_blog() WordPress function to switch to a blog of the given ID. 189 * @uses site_url() WordPress function to return the current site url. 190 * @return $domain The domain URL for the blog. 191 */ 192 function bp_core_get_root_domain() { 200 193 global $current_blog; 201 194 202 return get_blog_option( $current_blog->blog_id, 'siteurl' ) . '/'; 195 switch_to_blog(1); 196 $domain = site_url(); 197 switch_to_blog($current_blog->blog_id); 198 199 return $domain; 203 200 } 204 201 … … 214 211 * @return $current_userid The user id for the user that is currently being viewed, return zero if this is not a user home and just a normal blog. 215 212 */ 216 function bp_core_get_current_userid() { 217 global $current_blog, $current_user; 218 219 if ( $current_blog->blog_id == 1 ) 220 return $current_user->ID; 221 222 /* Check to see if this is a user home, and if it is, get the user id */ 223 if ( !$current_userid = bp_core_get_homebase_userid( $current_blog->blog_id ) ) 224 return false; // return false if this is a normal blog, and not a user home. 225 226 return $current_userid; 227 } 228 229 /** 230 * bp_core_get_user_home_userid() 231 * 232 * Checks to see if there is user_home usermeta set for the current_blog. 233 * If it is set, return the user_id, if not, return false. 234 * 235 * @package BuddyPress Core 236 * @param $blog_id The ID of the blog to check user_home metadata for. 237 * @global $wpdb WordPress DB access object. 238 * @return $current_userid The user id for the home base. 239 */ 240 function bp_core_get_homebase_userid( $blog_id ) { 241 global $wpdb; 242 243 return $wpdb->get_var( $wpdb->prepare( "SELECT user_id FROM " . $wpdb->base_prefix . "usermeta WHERE meta_key = 'home_base' AND meta_value = %d", $blog_id ) ); 244 } 245 246 /** 247 * bp_core_is_home_base() 248 * 249 * Checks a blog id to see if it is a home base or not. 250 * 251 * @package BuddyPress Core 252 * @param $blog_id The ID of the blog to check user_home metadata for. 253 * @global $wpdb WordPress DB access object. 254 * @return $current_userid The user id for the home base. 255 */ 256 function bp_core_is_home_base( $blog_id ) { 257 global $wpdb; 258 259 if ( $wpdb->get_var( $wpdb->prepare( "SELECT umeta_id FROM " . $wpdb->base_prefix . "usermeta WHERE meta_key = 'home_base' AND meta_value = %d", $blog_id ) ) ) 260 return true; 261 262 return false; 263 } 264 265 /** 266 * bp_core_user_has_home() 267 * 268 * Checks to see if a user has assigned a blog as their user_home. 269 * 270 * @package BuddyPress Core 271 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() 272 * @uses get_usermeta() WordPress function to get the usermeta for a current user. 273 * @return false if no, or true if yes. 274 */ 275 function bp_core_user_has_home( $user_id = false ) { 276 global $bp; 277 278 if ( !$user_id ) { 279 if ( $bp['loggedin_homebase_id'] == '' ) 280 return false; 281 282 return $bp['loggedin_homebase_id']; 283 } else { 284 return get_usermeta( $user_id, 'home_base' ); 285 } 286 } 287 288 /** 289 * bp_core_get_primary_username() 290 * 291 * Returns the username based on http:// [username] .site.com OR http://site.com/ [username] 292 * 293 * @package BuddyPress Core 294 * @global $current_blog WordPress global containing information and settings for the current blog 295 * @return $siteuser Username for current blog or user home. 296 */ 297 function bp_core_get_primary_username() { 298 global $current_blog; 299 300 if ( VHOST == 'yes' ) { 301 $siteuser = explode('.', $current_blog->domain); 302 $siteuser = $siteuser[0]; 303 } else { 304 $siteuser = str_replace('/', '', $current_blog->path); 305 } 306 307 return $siteuser; 308 } 309 310 /** 311 * bp_core_start_buffer() 312 * 313 * Start the output buffer to replace content not easily accessible. 314 * 315 * @package BuddyPress Core 316 */ 317 function bp_core_start_buffer() { 318 ob_start(); 319 add_action( 'dashmenu', 'bp_core_stop_buffer' ); 320 } 321 add_action( 'admin_menu', 'bp_core_start_buffer' ); 322 323 /** 324 * bp_core_stop_buffer() 325 * 326 * Stop the output buffer to replace content not easily accessible. 327 * 328 * @package BuddyPress Core 329 */ 330 function bp_core_stop_buffer() { 331 $contents = ob_get_contents(); 332 ob_end_clean(); 333 bp_core_blog_switcher( $contents ); 334 } 335 336 /** 337 * bp_core_blog_switcher() 338 * 339 * Replaces the standard blog switcher included in the WordPress core so that 340 * BuddyPress specific icons can be used in tabs and the order can be changed. 341 * An output buffer is used, as the function cannot be overridden or replaced 342 * any other way. 343 * 344 * @package BuddyPress Core 345 * @param $contents str The contents of the buffer. 346 * @global $current_user obj WordPress global containing information and settings for the current user 347 * @global $blog_id int WordPress global containing the current blog id 348 * @return $siteuser Username for current blog or user home. 349 */ 350 function bp_core_blog_switcher( $contents ) { 351 global $current_user, $blog_id; // current blog 352 353 /* Code duplicated from wp-admin/includes/mu.php */ 354 /* function blogswitch_markup() */ 355 356 $filter = preg_split( '/\<ul id=\"dashmenu\"\>[\S\s]/', $contents ); 357 echo $filter[0]; 358 359 $list = array(); 360 $options = array(); 361 362 $home_base = get_usermeta( $current_user->ID, 'home_base' ); 363 364 foreach ( $blogs = get_blogs_of_user( $current_user->ID ) as $blog ) { 365 if ( !$blog->blogname ) 366 continue; 367 368 // Use siteurl for this in case of mapping 369 $parsed = parse_url( $blog->siteurl ); 370 $domain = $parsed['host']; 371 372 if ( $blog->userblog_id == $home_base ) { 373 $current = ' id="primary_blog"'; 374 $image = ' style="background-image: url(' . get_option('home') . '/wp-content/mu-plugins/bp-core/images/member.png); 375 background-position: 2px 4px; 376 background-repeat: no-repeat; 377 padding-left: 22px;"'; 378 } else { 379 $current = ''; 380 $image = ' style="background-image: url(' . get_option('home') . '/wp-content/mu-plugins/bp-core/images/blog.png); 381 background-position: 3px 3px; 382 background-repeat: no-repeat; 383 padding-left: 22px;"';; 384 } 385 386 if ( VHOST == 'yes' ) { 387 if ( $_SERVER['HTTP_HOST'] === $domain ) { 388 $current .= ' class="current"'; 389 $selected = ' selected="selected"'; 390 } else { 391 $current .= ''; 392 $selected = ''; 393 } 394 } else { 395 $path = explode( '/', str_replace( '/wp-admin', '', $_SERVER['REQUEST_URI'] ) ); 396 397 if ( $path[1] == str_replace( '/', '', $blog->path ) ) { 398 $current .= ' class="current"'; 399 $selected = ' selected="selected"'; 400 } else { 401 $current .= ''; 402 $selected = ''; 403 } 404 } 405 406 $url = clean_url( $blog->siteurl ) . '/wp-admin/'; 407 $name = wp_specialchars( strip_tags( $blog->blogname ) ); 408 409 $list_item = "<li><a$image href='$url'$current>$name</a></li>"; 410 $option_item = "<option value='$url'$selected>$name</option>"; 411 412 $list[] = $list_item; 413 $options[] = $option_item; // [sic] don't reorder dropdown based on current blog 414 415 } 416 ksort($list); 417 ksort($options); 418 419 $list = array_slice( $list, 0, 4 ); // First 4 420 421 $select = "\n\t\t<select>\n\t\t\t" . join( "\n\t\t\t", $options ) . "\n\t\t</select>"; 422 423 echo "<ul id=\"dashmenu\">\n\t" . join( "\n\t", $list ); 424 425 if ( count($list) < count($options) ) : 426 ?> 427 <li id="all-my-blogs-tab" class="wp-no-js-hidden"><a href="#" class="blog-picker-toggle"><?php _e( 'All my blogs' , 'buddypress'); ?></a></li> 428 429 </ul> 430 431 <form id="all-my-blogs" action="" method="get" style="display: none"> 432 <p> 433 <?php printf( __( 'Choose a blog: %s' , 'buddypress'), $select ); ?> 434 435 <input type="submit" class="button" value="<?php _e( 'Go' , 'buddypress'); ?>" /> 436 <a href="#" class="blog-picker-toggle"><?php _e( 'Cancel' , 'buddypress'); ?></a> 437 </p> 438 </form> 439 <?php 440 endif; // counts 441 } 442 443 /** 444 * bp_core_replace_home_base_dashboard() 445 * 446 * Sets up the hook to start replacement of the dashboard on the users home base. 447 * 448 * @package BuddyPress Core 449 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() 450 * @global $wpdb WordPress DB access object. 451 * @uses add_action() Hooks a function on to a specific action. 452 */ 453 function bp_core_replace_home_base_dashboard() { 454 global $wpdb, $bp; 455 456 if ( strpos( $_SERVER['SCRIPT_NAME'], '/index.php' ) && $wpdb->blogid == $bp['current_homebase_id'] ) { 457 add_action( 'admin_head', 'bp_core_start_dash_replacement' ); 458 } 459 } 460 add_action( 'admin_menu', 'bp_core_replace_home_base_dashboard' ); 461 462 /** 463 * bp_core_start_dash_replacement() 464 * 465 * Starts the output buffer. 466 * 467 * @package BuddyPress Core 468 * @uses add_action() Hooks a function on to a specific action. 469 */ 470 function bp_core_start_dash_replacement( $dash_contents ) { 471 ob_start(); 472 add_action('admin_footer', 'bp_core_end_dash_replacement'); 473 } 474 475 /** 476 * bp_core_insert_new_dashboard() 477 * 478 * Inserts the new dashboard content. 479 * 480 * @package BuddyPress Core 481 * @uses add_action() Hooks a function on to a specific action. 482 */ 483 function bp_core_insert_new_dashboard( $dash_contents ) { 484 global $bp; 485 486 $filter = preg_split( '/\<div class=\"wrap\"\>[\S\s]*\<div id=\"footer\"\>/', $dash_contents ); 487 488 $filter[0] .= '<div class="wrap">'; 489 $filter[1] .= '</div>'; 490 491 echo $filter[0]; 492 //echo ABSPATH . 'wp-content/mu-plugins/bp-core/admin-mods/bp-core-homebase-dashboard.php'; 493 require_once( ABSPATH . '/wp-content/mu-plugins/bp-core/admin-mods/bp-core-homebase-dashboard.php' ); 494 495 echo '<div style="clear: both"> <br clear="all" /></div></div><div id="footer">'; 496 echo $filter[1]; 497 } 498 499 /** 500 * bp_core_end_dash_replacement() 501 * 502 * Gets output buffer contents and stops the output buffer. 503 * 504 * @package BuddyPress Core 505 * @uses bp_core_insert_new_dashboard() Inserts the new dashboard content. 506 */ 507 function bp_core_end_dash_replacement() { 508 $dash_contents = ob_get_contents(); 509 ob_end_clean(); 510 bp_core_insert_new_dashboard($dash_contents); 213 function bp_core_get_current_userid( $user_login ) { 214 return bp_core_get_userid_from_user_login( $user_login ); 511 215 } 512 216 … … 565 269 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() 566 270 */ 567 function bp_core_add_subnav_item( $parent_id, $slug, $name, $link, $function, $css_id = false, $loggedin_user_only = true, $admin_only = false ) { 568 global $bp; 569 271 function bp_core_add_subnav_item( $parent_id, $slug, $name, $link, $function, $css_id = false, $user_has_access = true, $admin_only = false ) { 272 global $bp; 273 274 if ( !$user_has_access && !bp_core_is_home() ) 275 return false; 276 570 277 if ( $admin_only && !is_site_admin() ) 571 278 return false; … … 580 287 ); 581 288 582 if ( $loggedin_user_only && !bp_is_home() )583 return false;584 585 289 if ( function_exists($function) && $bp['current_action'] == $slug && $bp['current_component'] == $parent_id ) 586 290 add_action( 'wp', $function, 3 ); … … 616 320 function bp_core_add_nav_default( $parent_id, $function, $slug = false ) { 617 321 global $bp; 618 322 619 323 if ( $bp['current_component'] == $parent_id && !$bp['current_action'] ) { 620 324 if ( function_exists($function) ) { … … 646 350 647 351 /** 352 * bp_core_get_userid_from_user_login() 353 * 354 * Returns the user_id from a user login 355 * @package BuddyPress Core 356 * @param $path str Path to check. 357 * @global $wpdb WordPress DB access object. 358 * @return false on no match 359 * @return int the user ID of the matched user. 360 */ 361 function bp_core_get_userid_from_user_login( $user_login ) { 362 global $wpdb; 363 364 return $wpdb->get_var( $wpdb->prepare( "SELECT ID from {$wpdb->base_prefix}users WHERE user_login = %s", $user_login ) ); 365 } 366 367 /** 648 368 * bp_core_get_username() 649 369 * … … 682 402 */ 683 403 function bp_core_get_userurl( $uid ) { 684 if ( $home_base_id = get_usermeta( $uid, 'home_base' ) )685 return get_blog_option( $home_base_id, 'siteurl' ) . '/';686 else404 global $bp; 405 406 if ( !is_numeric($uid) ) 687 407 return false; 408 409 $ud = get_userdata($uid); 410 411 return $bp['root_domain'] . '/members/' . $ud->user_login . '/'; 688 412 } 689 413 … … 749 473 return $display_name; 750 474 751 if ( $home_base_id = get_usermeta( $user_id, 'home_base' ) ) 752 $home_base_url = get_blog_option( $home_base_id, 'siteurl' ) . '/'; 753 else 475 if ( !$url = bp_core_get_userurl($user_id) ) 754 476 return false; 755 477 756 478 if ( $just_link ) 757 return $ home_base_url;758 759 return '<a href="' . $ home_base_url . '">' . $display_name . '</a>';479 return $url; 480 481 return '<a href="' . $url . '">' . $display_name . '</a>'; 760 482 } 761 483 762 484 function bp_core_global_user_fullname( $user_id ) { 763 if ( function_exists('bp_ user_fullname') ) {485 if ( function_exists('bp_fetch_user_fullname') ) { 764 486 return bp_fetch_user_fullname( $user_id, false ); 765 487 } else { … … 772 494 * bp_core_get_userlink_by_email() 773 495 * 774 * Returns the email address for the user based on user ID496 * Returns the user link for the user based on user email address 775 497 * 776 498 * @package BuddyPress Core … … 783 505 $user = get_user_by_email( $email ); 784 506 return bp_core_get_userlink( $user->ID, false, false, true ); 507 } 508 509 /** 510 * bp_core_get_userlink_by_username() 511 * 512 * Returns the user link for the user based on user's username 513 * 514 * @package BuddyPress Core 515 * @param $username str The username for the user. 516 * @uses bp_core_get_userlink() BuddyPress function to get a userlink by user ID. 517 * @return str The link to the users home base. False on no match. 518 */ 519 function bp_core_get_userlink_by_username( $username ) { 520 global $wpdb; 521 522 $user_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->base_prefix}users WHERE user_login = %s", $username ) ); 523 return bp_core_get_userlink( $user_id, false, false, true ); 785 524 } 786 525 … … 852 591 853 592 /** 854 * bp_ upload_dir()855 * 856 * This function will create an upload directory for a new user.593 * bp_avatar_upload_dir() 594 * 595 * This function will create an avatar upload directory for a new user. 857 596 * This is directly copied from WordPress so that the code can be 858 597 * accessed on user activation *before* 'upload_path' is placed … … 863 602 * 864 603 * @package BuddyPress Core 865 * @param $time str? The time so that upload folders can be created for month and day.866 * @param $blog_id int The ID of the blog (or user in BP) to create the upload dir for.867 604 * @return array Containing path, url, subdirectory and error message (if applicable). 868 605 */ 869 function bp_ upload_dir( $time = NULL, $blog_id) {870 $siteurl = get_option( 'siteurl');871 $upload_path = 'wp-content/blogs.dir/ ' . $blog_id . '/files';606 function bp_avatar_upload_dir( $user_id, $path = '/avatars' ) { 607 $siteurl = site_url(); 608 $upload_path = 'wp-content/blogs.dir/1/files' . $path . '/' . $user_id; 872 609 if ( trim($upload_path) === '' ) 873 610 $upload_path = 'wp-content/uploads'; … … 885 622 } 886 623 887 $subdir = '';888 if ( get_option( 'uploads_use_yearmonth_folders' ) ) {889 // Generate the yearly and monthly dirs890 if ( !$time )891 $time = current_time( 'mysql' );892 $y = substr( $time, 0, 4 );893 $m = substr( $time, 5, 2 );894 $subdir = "/$y/$m";895 }896 897 $dir .= $subdir;898 $url .= $subdir;899 900 624 // Make sure we have an uploads dir 901 625 if ( ! wp_mkdir_p( $dir ) ) { 626 echo "no dir"; die; 902 627 $message = sprintf( __( 'Unable to create directory %s. Is its parent directory writable by the server?' , 'buddypress'), $dir ); 903 628 return array( 'error' => $message ); … … 1105 830 global $comment; 1106 831 1107 $bp_author_link = bp_core_get_userlink_by_email( $comment->comment_author_email ); 1108 1109 echo ( !$bp_author_link ) ? $author : $bp_author_link; 1110 } 1111 add_action( 'get_comment_author_link', 'bp_core_replace_comment_author_link', 10, 4 ); 832 if ( !$comment->comment_author_email ) { 833 $bp_author_link = bp_core_get_userlink_by_username( $comment->comment_author ); 834 } else { 835 $bp_author_link = bp_core_get_userlink_by_email( $comment->comment_author_email ); 836 } 837 838 return ( !$bp_author_link ) ? $author : $bp_author_link; 839 } 840 add_filter( 'get_comment_author_link', 'bp_core_replace_comment_author_link', 10, 4 ); 1112 841 1113 842 /** … … 1150 879 unset($nav_array[$key]); 1151 880 break; 881 case 'profile': 882 $new_nav[1] = $nav_array[$key]; 883 unset($nav_array[$key]); 884 break; 1152 885 case $bp['blogs']['slug']: 1153 886 $new_nav[2] = $nav_array[$key]; … … 1188 921 1189 922 function bp_core_remove_data( $user_id ) { 1190 /* When the user is deleted, we must automatically delete their home base blog */1191 if ( $home_base_id = bp_core_user_has_home($user_id) )1192 wpmu_delete_blog( $home_base_id, true );1193 1194 923 /* Remove usermeta */ 1195 delete_usermeta( $user_id, 'home_base' );1196 924 delete_usermeta( $user_id, 'last_activity' ); 1197 925 } -
trunk/bp-core/bp-core-adminbar.php
r391 r394 4 4 global $bp, $wpdb, $current_blog; 5 5 6 if ( is_user_logged_in() && bp_core_user_has_home()) {6 if ( is_user_logged_in() ) { 7 7 echo '<div id="wp-admin-bar">'; 8 8 echo '<a href="' . get_blog_option( 1, 'siteurl' ) . '"><img id="admin-bar-logo" src="' . site_url() . '/wp-content/mu-plugins/bp-core/images/admin_bar_logo.gif" alt="BuddyPress" /></a>'; … … 73 73 74 74 if ( $current_blog->blog_id > 1 ) { 75 if ( bp_core_is_home_base( $current_blog->blog_id ) ) { 76 // TODO: possible menu for current group/user/photo etc 77 } else { 78 $authors = get_users_of_blog(); 75 $authors = get_users_of_blog(); 76 77 if ( is_array( $authors ) ) { 78 /* This is a blog, render a menu with links to all authors */ 79 echo '<li><a href="/">'; 80 _e('Blog Authors', 'buddypress'); 81 echo '</a>'; 79 82 80 if ( is_array( $authors ) ) { 81 /* This is a blog, render a menu with links to all authors */ 82 echo '<li><a href="/">'; 83 _e('Blog Authors', 'buddypress'); 83 echo '<ul class="author-list">'; 84 foreach( $authors as $author ) { 85 $author = new BP_Core_User( $author->user_id ); 86 echo '<li>'; 87 88 echo '<div class="admin-bar-clear"><a href="' . $author->user_url . '">'; 89 echo $author->avatar_mini; 90 echo ' ' . $author->fullname; 91 echo '<span class="activity">' . $author->last_active . '</span>'; 84 92 echo '</a>'; 85 86 echo '<ul class="author-list">'; 87 foreach( $authors as $author ) { 88 $author = new BP_Core_User( $author->user_id ); 89 echo '<li>'; 90 91 echo '<div class="admin-bar-clear"><a href="' . $author->user_url . '">'; 92 echo $author->avatar_mini; 93 echo ' ' . $author->fullname; 94 echo '<span class="activity">' . $author->last_active . '</span>'; 95 echo '</a>'; 96 echo '</div>'; 97 echo '</li>'; 98 } 99 echo '</ul>'; 93 echo '</div>'; 100 94 echo '</li>'; 101 95 } 96 echo '</ul>'; 97 echo '</li>'; 102 98 } 103 99 } -
trunk/bp-core/bp-core-ajax-handler.php
r375 r394 1 1 <?php 2 2 define('DOING_AJAX', true); 3 require_once( $_SERVER['DOCUMENT_ROOT']. '/wp-load.php' );3 require_once( dirname(dirname(dirname(dirname(__FILE__)))) . '/wp-load.php' ); 4 4 5 5 do_action( 'wp_ajax_' . $_POST['action'] ); -
trunk/bp-core/bp-core-ajax.php
r391 r394 29 29 30 30 foreach ( (array) $users as $user ) { 31 if ( !bp_core_user_has_home($user->user_id) || !$user->user_id ) continue;32 31 ?> 33 32 <li> … … 64 63 add_action( 'wp_ajax_widget_members', 'bp_core_ajax_widget_members' ); 65 64 65 66 function bp_core_ajax_directory_members() { 67 global $bp; 68 69 check_ajax_referer('directory_members'); 70 71 if ( !$bp ) { 72 bp_core_setup_globals(); 73 74 if ( function_exists('friends_install') ) 75 friends_setup_globals(); 76 } 77 78 $users = BP_Core_User::get_users_by_letter( $_POST['letter'] ); 79 80 if ( $users ) { 81 echo '0[[SPLIT]]'; // return valid result. 82 83 foreach ( (array) $users as $user ) { 84 ?> 85 <li> 86 <div class="item-avatar"> 87 <?php echo bp_core_get_avatar( $user->user_id, 1 ) ?> 88 </div> 89 90 <div class="item"> 91 <div class="item-title"><?php echo bp_core_get_userlink( $user->user_id ) ?></div> 92 <div class="item-meta"> 93 <span class="activity"> 94 <?php echo bp_core_get_last_activity( get_usermeta( $user->user_id, 'last_activity' ), __('active '), __(' ago') ); ?> 95 </span> 96 </div> 97 </div> 98 </li> 99 <?php 100 } 101 } else { 102 echo "-1[[SPLIT]]<li>" . __("No members matched the current filter."); 103 } 104 } 105 add_action( 'wp_ajax_directory_members', 'bp_core_ajax_directory_members' ); 106 107 66 108 ?> -
trunk/bp-core/bp-core-avatars.php
r391 r394 19 19 20 20 function bp_core_get_avatar( $user, $version = 1, $no_tag = false, $width = null, $height = null ) { 21 global $bp, $current_blog; 22 21 23 if ( !is_int($version) ) 22 24 $version = (int) $version; … … 25 27 $version = 1; 26 28 27 if ( $home_base_id = get_usermeta( $user, 'home_base' ) )28 $url = get_blog_option($home_base_id, 'siteurl');29 30 29 if ( !$width ) 31 30 $width = constant('CORE_AVATAR_V' . $version . '_W'); … … 34 33 $height = constant('CORE_AVATAR_V' . $version . '_H'); 35 34 36 $str = get_usermeta( $user, "bp_core_avatar_v$version" ); 37 38 if ( strlen($str) ) { 35 36 $avatar_file = get_usermeta( $user, "bp_core_avatar_v$version" ); 37 $url = $bp['root_domain'] . '/' . $avatar_file; 38 39 if ( strlen($avatar_file) ) { 39 40 if ( $no_tag ) 40 return $ str;41 return $url; 41 42 else 42 return '<img src="' . $url . ' /' . $str . '" alt="" class="avatar" width="' . $width . '" height="' . $height . '" />';43 return '<img src="' . $url . '" alt="" class="avatar" width="' . $width . '" height="' . $height . '" />'; 43 44 } else { 45 $identicon = 'http://www.gravatar.com/avatar/' . md5( $user . '@buddypress.org') . '?d=wavatar&s='; 44 46 if ( $no_tag ) 45 return CORE_DEFAULT_AVATAR_THUMB;47 return $identicon . constant('CORE_AVATAR_V' . $version . '_W'); 46 48 else 47 return '<img src="' . CORE_DEFAULT_AVATAR. '" alt="" class="avatar" width="' . $width . '" height="' . $height . '" />';49 return '<img src="' . $identicon . constant('CORE_AVATAR_V' . $version . '_W') . '" alt="" class="avatar" width="' . $width . '" height="' . $height . '" />'; 48 50 } 49 51 } … … 72 74 73 75 // Main UI Rendering 74 function bp_core_avatar_admin( $message = null , $action = null, $delete_action = null) {76 function bp_core_avatar_admin( $message = null ) { 75 77 global $wp_upload_error; 76 78 ?> … … 90 92 91 93 <?php 92 if ( !$action ) 93 $action = site_url() . '/wp-admin/admin.php?page=bp-xprofile.php'; 94 95 if ( !$delete_action ) 96 $delete_action = site_url() . '/wp-admin/admin.php?page=bp-xprofile.php&slick_avatars_action=delete'; 97 94 98 95 bp_core_render_avatar_upload_form($action); 99 96 … … 132 129 133 130 if ( !bp_core_check_avatar_size($_FILES) ) 134 bp_core_ap_die( 'The file you uploaded is too big. Please upload a file under ' . size_format( 1024 *CORE_MAX_FILE_SIZE) );131 bp_core_ap_die( 'The file you uploaded is too big. Please upload a file under ' . size_format(CORE_MAX_FILE_SIZE) ); 135 132 136 133 if ( !bp_core_check_avatar_type($_FILES) ) … … 148 145 $canvas = $original; 149 146 150 // Render the cropper UI 151 if ( !$action ) 152 $action = get_option('home') .'/wp-admin/admin.php?page=bp-xprofile.php'; 153 147 // Render the cropper UI 154 148 bp_core_render_avatar_cropper($original, $canvas, $action); 155 149 … … 258 252 $user_id = $bp['loggedin_userid']; 259 253 260 if ( !$url ) { 261 $home_base_id = get_usermeta( $user_id, 'home_base' ); 262 $url = get_blog_option($home_base_id, 'siteurl'); 263 } 264 265 $src = str_replace( array(ABSPATH), array($url . '/'), $new ); 254 $src = str_replace( array(ABSPATH), array(site_url() . '/'), $new ); 266 255 267 256 // Load cropper details … … 401 390 } 402 391 403 function bp_core_avatar_save( $vars, $user_id = false , $upload_dir = false, $url = false) {392 function bp_core_avatar_save( $vars, $user_id = false ) { 404 393 if ( !$user_id ) 405 394 $user_id = get_current_user_id(); 406 407 if ( !$url ) {408 $home_base_id = get_usermeta( $user_id, 'home_base' );409 $url = get_blog_option($home_base_id, 'siteurl');410 }411 395 412 396 $old = get_usermeta( $user_id, 'bp_core_avatar_v1_path' ); … … 458 442 function bp_core_ap_die( $msg ) { 459 443 echo '<p><strong>' . $msg . '</strong></p>'; 460 echo '<p><a href="' . get_option('home') .'/wp-admin/admin.php?page=bp-xprofile.php">' . __('Try Again', 'buddypress') . '</a></p>';444 echo '<p><a href="' . $bp['loggedin_domain'] . '/' . $bp['profile']['slug'] . '/change-avatar">' . __('Try Again', 'buddypress') . '</a></p>'; 461 445 echo '</div>'; 462 446 exit; -
trunk/bp-core/bp-core-catchuri.php
r392 r394 29 29 function bp_core_set_uri_globals() { 30 30 global $current_component, $current_action, $action_variables; 31 31 global $current_userid; 32 global $is_member_page; 33 32 34 /* Fetch the current URI and explode each part seperated by '/' into an array */ 33 35 $bp_uri = explode( "/", $_SERVER['REQUEST_URI'] ); 36 37 /* Take empties off the end of complete URI */ 38 if ( $bp_uri[count($bp_uri) - 1] == "" ) 39 array_pop( $bp_uri ); 40 41 /* Take empties off the start of complete URI */ 42 if ( $bp_uri[0] == "" ) 43 array_shift( $bp_uri ); 44 45 /* Get total URI segment count */ 46 $bp_uri_count = count( $bp_uri ) - 1; 47 $is_member_page = false; 34 48 35 49 /* Set the indexes, these are incresed by one if we are not on a VHOST install */ … … 40 54 $paths = explode( '/', bp_core_get_site_path() ); 41 55 42 /* Take empties off the end */56 /* Take empties off the end of path */ 43 57 if ( $paths[count($paths) - 1] == "" ) 44 58 array_pop( $paths ); 45 59 46 /* Take empties off the start */60 /* Take empties off the start of path */ 47 61 if ( $paths[0] == "" ) 48 62 array_shift( $paths ); 49 50 /* Take empties off the end */51 if ( $bp_uri[count($bp_uri) - 1] == "" )52 array_pop( $bp_uri );53 54 /* Take empties off the start */55 if ( $bp_uri[0] == "" )56 array_shift( $bp_uri );57 58 /* Get total URI segment count */59 $bp_uri_count = count( $bp_uri ) - 1;60 63 61 64 for ( $i = 0; $i < $bp_uri_count; $i++ ) { … … 66 69 67 70 /* Reset the keys by merging with an empty array */ 68 $bp_uri = array_merge( array(), $bp_uri ); 71 $bp_uri = array_merge( array(), $bp_uri ); 72 73 if ( $bp_uri[0] == 'members' && $bp_uri[1] != '' ) { 74 $is_member_page = true; 75 $is_root_component = true; 76 77 // We are within a member home base, set up user id globals 78 $current_userid = bp_core_get_current_userid( $bp_uri[1] ); 79 80 unset($bp_uri[0]); 81 unset($bp_uri[1]); 82 83 /* Reset the keys by merging with an empty array */ 84 $bp_uri = array_merge( array(), $bp_uri ); 85 } 69 86 70 87 /* This is used to determine where the component and action indexes should start */ 71 88 $root_components = explode( ',', BP_CORE_ROOT_COMPONENTS ); 72 $is_root_component = in_array( $bp_uri[0], $root_components ); 73 89 90 if ( !isset($is_root_component) ) 91 $is_root_component = in_array( $bp_uri[0], $root_components ); 92 74 93 if ( VHOST == 'no' && !$is_root_component ) { 75 94 $component_index++; … … 82 101 /* Set the current action */ 83 102 $current_action = $bp_uri[$action_index]; 84 103 85 104 /* Set the entire URI as the action variables, we will unset the current_component and action in a second */ 86 105 $action_variables = $bp_uri; … … 96 115 /* Reset the keys by merging with an empty array */ 97 116 $action_variables = array_merge( array(), $action_variables ); 117 118 //var_dump($current_component, $current_action, $action_variables); 98 119 } 99 120 add_action( 'wp', 'bp_core_set_uri_globals', 1 ); … … 130 151 131 152 $pages = $bp_path; 132 153 133 154 if ( !file_exists( TEMPLATEPATH . "/header.php" ) || !file_exists( TEMPLATEPATH . "/footer.php" ) ) 134 155 wp_die( 'Please make sure your BuddyPress enabled theme includes a header.php and footer.php file.'); … … 158 179 die; 159 180 } 181 182 183 /** 184 * bp_core_catch_profile_uri() 185 * 186 * If the extended profiles component is not installed we still need 187 * to catch the /profile URI's and display whatever we have installed. 188 * 189 */ 190 function bp_core_catch_profile_uri() { 191 global $bp; 192 193 if ( !function_exists('xprofile_install') ) 194 bp_catch_uri( 'profile/index' ); 195 } 196 197 function bp_core_force_buddypress_theme() { 198 global $current_component, $current_action; 199 global $is_member_page; 200 201 // The theme filter does not recognize any globals, where as the stylesheet filter does. 202 // We have to set up the globals to use manually. 203 bp_core_set_uri_globals(); 204 205 if ( function_exists('groups_setup_globals') ) 206 $groups_bp = groups_setup_globals(true); 207 208 if ( $current_component == $groups_bp['groups']['slug'] ) 209 $is_single_group = BP_Groups_Group::group_exists( $current_action, $groups_bp['groups']['table_name'] ); 210 211 if ( $is_member_page ) 212 $theme = 'buddypress-member'; 213 else if ( $current_component == $groups_bp['groups']['slug'] && $is_single_group ) 214 $theme = 'buddypress-member'; 215 else 216 $theme = get_option('template'); 217 218 return $theme; 219 } 220 add_filter( 'template', 'bp_core_force_buddypress_theme' ); 221 222 function bp_core_force_buddypress_stylesheet() { 223 global $bp, $is_single_group, $is_member_page; 224 225 if ( $is_member_page ) 226 return 'buddypress-member'; 227 else if ( $bp['current_component'] == $bp['groups']['slug'] && $is_single_group ) 228 return 'buddypress-member'; 229 else 230 return get_option('stylesheet'); 231 } 232 add_filter( 'stylesheet', 'bp_core_force_buddypress_stylesheet' ); 233 234 235 160 236 ?> -
trunk/bp-core/bp-core-classes.php
r391 r394 61 61 $this->fullname = bp_core_get_userlink( $this->id, true ); 62 62 $this->email = bp_core_get_user_email( $this->id ); 63 $this->last_active = bp_core_get_last_activity( get_usermeta( $this->id, 'last_activity' ), __('active ' , 'buddypress'), __(' ago', 'buddypress') );63 $this->last_active = bp_core_get_last_activity( get_usermeta( $this->id, 'last_activity' ), __('active '), __(' ago') ); 64 64 65 65 if ( function_exists('xprofile_install') ) { … … 67 67 $this->avatar_thumb = bp_core_get_avatar( $this->id, 1 ); 68 68 $this->avatar_mini = bp_core_get_avatar( $this->id, 1, false, 25, 25 ); 69 70 $this->profile_last_updated = bp_profile_last_updated_date( $this->id, false );71 69 } 72 70 … … 117 115 return $wpdb->get_results( $wpdb->prepare( "SELECT user_id FROM {$wpdb->base_prefix}usermeta um WHERE meta_key = 'last_activity' AND DATE_ADD( FROM_UNIXTIME(meta_value), INTERVAL 5 MINUTE ) >= NOW() ORDER BY FROM_UNIXTIME(meta_value) DESC LIMIT %d", $limit ) ); 118 116 } 117 118 function get_users_by_letter( $letter, $limit = 5 ) { 119 global $wpdb, $bp; 120 121 if ( !function_exists('xprofile_install') ) 122 return false; 123 124 if ( !$bp ) { 125 bp_core_setup_globals(); 126 xprofile_setup_globals(); 127 } 128 129 if ( !$limit ) 130 $limit = 5; 131 132 if ( strlen($letter) > 1 || is_numeric($letter) || !$letter ) 133 return false; 134 135 like_escape($letter); 136 137 return $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT um.user_id FROM {$wpdb->base_prefix}usermeta um LEFT JOIN {$bp['profile']['table_name_data']} pd ON um.user_id = pd.user_id LEFT JOIN {$bp['profile']['table_name_fields']} pf ON pd.field_id = pf.id WHERE pf.name = 'First Name' AND pd.value LIKE '$letter%%' ORDER BY pf.name DESC" ) ); 138 } 119 139 } 120 140 -
trunk/bp-core/bp-core-cssjs.php
r392 r394 25 25 */ 26 26 function bp_core_add_ajax_js() { 27 echo '<script type="text/javascript">var ajaxurl = "' . site_url() . '/wp-content/mu-plugins/bp-core/bp-core-ajax-handler.php";</script>'; 27 echo 28 '<script type="text/javascript">var ajaxurl = "' . site_url() . '/wp-content/mu-plugins/bp-core/bp-core-ajax-handler.php";</script> 29 '; 28 30 } 29 31 add_action( 'wp_head', 'bp_core_add_ajax_js' ); … … 38 40 */ 39 41 function bp_core_add_css() { 40 if ( is_user_logged_in() && bp_core_user_has_home()) {42 if ( is_user_logged_in() ) { 41 43 wp_enqueue_style( 'bp-admin-bar', site_url() . '/wp-content/mu-plugins/bp-core/css/admin-bar.css' ); 42 wp_print_styles();43 44 } 45 wp_print_styles(); 44 46 } 45 47 add_action( 'wp_head', 'bp_core_add_css' ); -
trunk/bp-core/bp-core-templatetags.php
r392 r394 182 182 if ( !is_user_logged_in() || is_null($bp['loggedin_userid']) || is_null($bp['current_userid']) ) 183 183 return false; 184 184 185 185 if ( $bp['loggedin_userid'] == $bp['current_userid'] ) 186 186 return true; … … 199 199 } 200 200 201 function bp_loggedinuser_avatar_thumbnail( $width = false, $height = false ) { 202 global $bp; 203 204 if ( $width && $height ) 205 echo bp_core_get_avatar( $bp['loggedin_userid'], 1, false, $width, $height ); 206 else 207 echo bp_core_get_avatar( $bp['loggedin_userid'], 1 ); 208 } 209 210 function bp_fetch_user_fullname( $user_id = false, $echo = true ) { 211 global $bp; 212 213 if ( !$user_id ) 214 $user_id = $bp['current_userid']; 215 216 if ( function_exists('xprofile_install') ) { 217 $data = bp_get_field_data( array( 'First Name', 'Last Name' ), $user_id ); 218 219 if ( empty($data['First Name']) && empty($data['Last Name']) ) { 220 $ud = get_userdata($user_id); 221 $data = $ud->display_name; 222 } else { 223 $data = ucfirst($data['First Name']) . ' ' . ucfirst($data['Last Name']); 224 } 225 } else { 226 $ud = get_userdata($user_id); 227 $data = $ud->display_name; 228 } 229 230 if ( $echo ) 231 echo $data; 232 else 233 return $data; 234 235 } 236 237 function bp_last_activity( $user_id = false, $echo = true ) { 238 global $bp; 239 240 if ( !$user_id ) 241 $user_id = $bp['current_userid']; 242 243 $last_activity = bp_core_get_last_activity( get_usermeta( $user_id, 'last_activity' ), __('active ', 'buddypress'), __(' ago', 'buddypress') ); 244 245 if ( $echo ) 246 echo $last_activity; 247 else 248 return $last_activity; 249 } 250 251 function bp_the_avatar() { 252 global $bp; 253 echo bp_core_get_avatar( $bp['current_userid'], 2 ); 254 } 255 256 function bp_the_avatar_thumbnail() { 257 global $bp; 258 echo bp_core_get_avatar( $bp['current_userid'], 1 ); 259 } 260 261 function bp_user_link() { 262 echo ''; 263 } 264 265 function bp_core_get_wp_profile() { 266 267 } 268 269 function bp_get_profile_header() { 270 load_template( TEMPLATEPATH . '/profile/profile-header.php' ); 271 } 272 201 273 function bp_exists( $component_name ) { 202 274 if ( function_exists($component_name . '_install') ) … … 312 384 } 313 385 386 function bp_get_plugin_sidebar() { 387 if ( file_exists(TEMPLATEPATH . '/plugin-sidebar.php') ) 388 load_template( TEMPLATEPATH . '/plugin-sidebar.php' ); 389 } 390 314 391 /* Template functions for fetching globals, without querying the DB again 315 392 also means we dont have to use the $bp variable in the template (looks messy) */ -
trunk/bp-core/bp-core-widgets.php
r391 r394 107 107 <ul id="members-list" class="item-list"> 108 108 <?php foreach ( (array) $users as $user ) : ?> 109 <?php if ( !bp_core_user_has_home($user->user_id) ) continue; ?>110 109 <li> 111 110 <div class="item-avatar"> … … 178 177 <div class="avatar-block"> 179 178 <?php foreach ( (array) $users as $user ) : ?> 180 <?php if ( !bp_core_user_has_home($user->user_id) || !$user->user_id ) continue; ?>181 179 <div class="item-avatar"> 182 180 <a href="<?php echo bp_core_get_userurl($user->user_id) ?>" title="<?php bp_fetch_user_fullname( $user->user_id, true ) ?>"><?php echo bp_core_get_avatar( $user->user_id, 1 ) ?></a> -
trunk/bp-friends.php
r391 r394 173 173 if ( function_exists('bp_activity_record') ) { 174 174 extract($args); 175 bp_activity_record( $item_id, $component_name, $component_action, $is_private, $dual_record , $secondary_user_homebase_id);175 bp_activity_record( $item_id, $component_name, $component_action, $is_private, $dual_record ); 176 176 } 177 177 } … … 370 370 function friends_accept_friendship( $friendship_id ) { 371 371 $friendship = new BP_Friends_Friendship( $friendship_id, true, false ); 372 $secondary_user_homebase_id = get_usermeta( $friendship->friend_user_id, 'home_base' );373 372 374 373 if ( BP_Friends_Friendship::accept( $friendship_id ) ) { 375 374 friends_update_friend_totals( $friendship->initiator_user_id, $friendship->friend_user_id ); 376 375 377 do_action( 'bp_friends_friendship_accepted', array( 'item_id' => $friendship_id, 'component_name' => 'friends', 'component_action' => 'friendship_accepted', 'is_private' => 0, 'dual_record' => true , 'secondary_user_homebase_id' => $secondary_user_homebase_id) );376 do_action( 'bp_friends_friendship_accepted', array( 'item_id' => $friendship_id, 'component_name' => 'friends', 'component_action' => 'friendship_accepted', 'is_private' => 0, 'dual_record' => true ) ); 378 377 return true; 379 378 } -
trunk/bp-groups.php
r392 r394 161 161 /* Using "item" not "group" for generic support in other components. */ 162 162 $bp['is_item_admin'] = groups_is_user_admin( $bp['loggedin_userid'], $group_obj->id ); 163 164 /* Is the logged in user a member of the group? */ 165 $is_member = ( BP_Groups_Member::check_is_member( $bp['loggedin_userid'], $group_obj->id ) ) ? true : false; 166 167 /* Should this group be visible to the logged in user? */ 168 $is_visible = ( $group_obj->status == 'public' || $is_member ) ? true : false; 163 169 } 164 170 … … 186 192 $bp['bp_options_title'] = $bp['current_fullname']; 187 193 188 } else if ( $is_single_group ) { 194 } else if ( $is_single_group ) { 189 195 // We are viewing a single group, so set up the 190 196 // group navigation menu using the $group_obj global. … … 208 214 bp_core_add_nav_default( $bp['groups']['slug'], 'groups_screen_group_home', 'home' ); 209 215 210 bp_core_add_subnav_item( $bp['groups']['slug'], 'home', __('Home', 'buddypress'), $group_link, 'groups_screen_group_home', 'group-home' );211 bp_core_add_subnav_item( $bp['groups']['slug'], 'forum', __('Forum', 'buddypress'), $group_link , 'groups_screen_group_forum', 'group-forum' );216 bp_core_add_subnav_item( $bp['groups']['slug'], 'home', __('Home', 'buddypress'), $group_link, 'groups_screen_group_home', 'group-home', $is_visible ); 217 bp_core_add_subnav_item( $bp['groups']['slug'], 'forum', __('Forum', 'buddypress'), $group_link , 'groups_screen_group_forum', 'group-forum', $is_visible); 212 218 213 219 if ( function_exists('bp_wire_install') ) { 214 bp_core_add_subnav_item( $bp['groups']['slug'], 'wire', __('Wire', 'buddypress'), $group_link, 'groups_screen_group_wire', 'group-wire' );220 bp_core_add_subnav_item( $bp['groups']['slug'], 'wire', __('Wire', 'buddypress'), $group_link, 'groups_screen_group_wire', 'group-wire', $is_visible ); 215 221 } 216 222 217 223 if ( function_exists('bp_gallery_install') ) { 218 bp_core_add_subnav_item( $bp['groups']['slug'], 'photos', __('Photos', 'buddypress'), $group_link, 'groups_screen_group_photos', 'group-photos' );224 bp_core_add_subnav_item( $bp['groups']['slug'], 'photos', __('Photos', 'buddypress'), $group_link, 'groups_screen_group_photos', 'group-photos', $is_visible ); 219 225 } 220 226 221 bp_core_add_subnav_item( $bp['groups']['slug'], 'members', __('Members', 'buddypress'), $group_link, 'groups_screen_group_members', 'group-members' );227 bp_core_add_subnav_item( $bp['groups']['slug'], 'members', __('Members', 'buddypress'), $group_link, 'groups_screen_group_members', 'group-members', $is_visible ); 222 228 223 229 if ( is_user_logged_in() && groups_is_user_member( $bp['loggedin_userid'], $group_obj->id ) ) { 224 bp_core_add_subnav_item( $bp['groups']['slug'], 'send-invites', __('Send Invites', 'buddypress'), $group_link, 'groups_screen_group_invite', 'group-invite' );225 bp_core_add_subnav_item( $bp['groups']['slug'], 'leave-group', __('Leave Group', 'buddypress'), $group_link, 'groups_screen_group_leave', 'group-leave' );230 bp_core_add_subnav_item( $bp['groups']['slug'], 'send-invites', __('Send Invites', 'buddypress'), $group_link, 'groups_screen_group_invite', 'group-invite', $is_member ); 231 bp_core_add_subnav_item( $bp['groups']['slug'], 'leave-group', __('Leave Group', 'buddypress'), $group_link, 'groups_screen_group_leave', 'group-leave', $is_member ); 226 232 } 227 233 } … … 229 235 } 230 236 add_action( 'wp', 'groups_setup_nav', 2 ); 231 232 function groups_get_group_theme() {233 global $current_component, $current_action, $is_single_group;234 235 // The theme filter does not recognize any globals, where as the stylesheet filter does.236 // We have to set up the globals to use manually.237 bp_core_set_uri_globals();238 $groups_bp = groups_setup_globals(true);239 240 if ( $current_component == $groups_bp['groups']['slug'] )241 $is_single_group = BP_Groups_Group::group_exists( $current_action, $groups_bp['groups']['table_name'] );242 243 if ( $current_component == $groups_bp['groups']['slug'] && $is_single_group )244 $theme = 'buddypress';245 else246 $theme = get_option('template');247 248 return $theme;249 }250 add_filter( 'template', 'groups_get_group_theme' );251 252 function groups_get_group_stylesheet() {253 global $bp, $is_single_group;254 255 if ( $bp['current_component'] == $bp['groups']['slug'] && $is_single_group )256 return 'buddypress';257 else258 return get_option('stylesheet');259 }260 add_filter( 'stylesheet', 'groups_get_group_stylesheet' );261 237 262 238 … … 633 609 $avatar_error = true; 634 610 $avatar_size = size_format(1024 * CORE_MAX_FILE_SIZE); 635 $avatar_error_msg = __('The file you uploaded is too big. Please upload a file under', 'buddypress') . size_format( 1024 *CORE_MAX_FILE_SIZE);611 $avatar_error_msg = __('The file you uploaded is too big. Please upload a file under', 'buddypress') . size_format(CORE_MAX_FILE_SIZE); 636 612 } 637 613 -
trunk/bp-groups/bp-groups-classes.php
r380 r394 59 59 $this->total_member_count = groups_get_groupmeta( $this->id, 'total_member_count' ); 60 60 61 if ( !$group->avatar_thumb )62 $this->avatar_thumb = $bp['groups']['image_base'] . '/none-thumbnail.gif';61 if ( !$group->avatar_thumb || strpos( $group->avatar_thumb, 'none-thumbnail' ) ) 62 $this->avatar_thumb = 'http://www.gravatar.com/avatar/' . md5( $this->id . '@buddypress.org') . '?d=identicon&s=50'; 63 63 else 64 64 $this->avatar_thumb = $group->avatar_thumb; 65 65 66 if ( !$group->avatar_full )67 $this->avatar_full = $bp['groups']['image_base'] . '/none.gif';66 if ( !$group->avatar_full || strpos( $group->avatar_thumb, 'none-' ) ) 67 $this->avatar_full = 'http://www.gravatar.com/avatar/' . md5( $this->id . '@buddypress.org') . '?d=identicon&s=150'; 68 68 else 69 69 $this->avatar_full = $group->avatar_full; … … 417 417 418 418 /* Static Functions */ 419 420 function get_group_ids( $user_id, $page = false, $limit = false ) { 421 global $wpdb, $bp; 422 423 if ( $limit && $page ) 424 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); 425 426 $group_ids = $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT group_id FROM " . $bp['groups']['table_name_members'] . " WHERE user_id = %d AND is_confirmed = 1$pag_sql", $user_id ) ); 427 $group_count = BP_Groups_Member::total_group_count( $user_id ); 428 429 return array( 'ids' => $group_ids, 'count' => $group_count ); 430 } 431 432 function total_group_count( $user_id = false ) { 433 global $bp, $wpdb; 434 435 if ( !$user_id ) 436 $user_id = $bp['current_userid']; 437 438 return $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(group_id) FROM " . $bp['groups']['table_name_members'] . " WHERE user_id = %d AND is_confirmed = 1", $user_id ) ); 439 } 440 441 function get_invites( $user_id ) { 442 global $wpdb, $bp; 443 444 $group_ids = $wpdb->get_col( $wpdb->prepare( "SELECT group_id FROM " . $bp['groups']['table_name_members'] . " WHERE user_id = %d and is_confirmed = 0", $user_id ) ); 445 446 for ( $i = 0; $i < count($group_ids); $i++ ) { 447 $groups[] = new BP_Groups_Group($group_ids[$i]); 448 } 449 450 return $groups; 451 } 452 419 453 420 function delete( $user_id, $group_id ) { 454 421 global $wpdb, $bp; … … 464 431 } 465 432 433 function get_group_ids( $user_id, $page = false, $limit = false ) { 434 global $wpdb, $bp; 435 436 if ( $limit && $page ) 437 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); 438 439 $group_ids = $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT group_id FROM " . $bp['groups']['table_name_members'] . " WHERE user_id = %d AND is_confirmed = 1$pag_sql", $user_id ) ); 440 $group_count = BP_Groups_Member::total_group_count( $user_id ); 441 442 return array( 'ids' => $group_ids, 'count' => $group_count ); 443 } 444 445 function total_group_count( $user_id = false ) { 446 global $bp, $wpdb; 447 448 if ( !$user_id ) 449 $user_id = $bp['current_userid']; 450 451 return $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(group_id) FROM " . $bp['groups']['table_name_members'] . " WHERE user_id = %d AND is_confirmed = 1", $user_id ) ); 452 } 453 454 function get_invites( $user_id ) { 455 global $wpdb, $bp; 456 457 $group_ids = $wpdb->get_col( $wpdb->prepare( "SELECT group_id FROM " . $bp['groups']['table_name_members'] . " WHERE user_id = %d and is_confirmed = 0", $user_id ) ); 458 459 for ( $i = 0; $i < count($group_ids); $i++ ) { 460 $groups[] = new BP_Groups_Group($group_ids[$i]); 461 } 462 463 return $groups; 464 } 465 466 466 function check_is_admin( $user_id, $group_id ) { 467 467 global $wpdb, $bp; -
trunk/bp-xprofile.php
r391 r394 6 6 define ( 'BP_XPROFILE_VERSION', '0.3.10' ); 7 7 8 require_once( 'bp-xprofile/admin-mods/bp-xprofile-admin-mods.php' ); 8 9 require_once( 'bp-xprofile/bp-xprofile-classes.php' ); 9 10 require_once( 'bp-xprofile/bp-xprofile-admin.php' ); … … 11 12 require_once( 'bp-xprofile/bp-xprofile-templatetags.php' ); 12 13 require_once( 'bp-xprofile/bp-xprofile-cssjs.php' ); 14 13 15 14 16 /************************************************************************** … … 108 110 function xprofile_setup_globals() { 109 111 global $bp, $wpdb; 112 113 /* Need to start a session for signup metadata purposes */ 114 session_start(); 110 115 111 116 $bp['profile'] = array( … … 423 428 424 429 /************************************************************************** 425 xprofile_add_settings() 426 427 Renders the profile tab under settings for each member. 428 **************************************************************************/ 429 430 function xprofile_add_settings() { 430 xprofile_remove_data_on_blog_deletion() 431 432 Removes all profile data from the DB if the admin deletes a Home Base. 433 **************************************************************************/ 434 435 function xprofile_remove_data_on_user_deletion( $user_id ) { 436 BP_XProfile_ProfileData::delete_data_for_user( $user_id ); 437 438 // delete any avatar files. 439 @unlink( get_usermeta( $user_id, 'bp_core_avatar_v1_path' ) ); 440 @unlink( get_usermeta( $user_id, 'bp_core_avatar_v2_path' ) ); 441 442 // unset the usermeta for avatars from the usermeta table. 443 delete_usermeta( $user_id, 'bp_core_avatar_v1' ); 444 delete_usermeta( $user_id, 'bp_core_avatar_v1_path' ); 445 delete_usermeta( $user_id, 'bp_core_avatar_v2' ); 446 delete_usermeta( $user_id, 'bp_core_avatar_v2_path' ); 447 } 448 add_action( 'delete_user', 'xprofile_remove_data_on_user_deletion', 1 ); 449 431 450 ?> 432 <div class="wrap">433 <h2><?php _e('Profile Settings', 'buddypress'); ?></h2>434 <p>Member profile settings will appear here.</p>435 </div>436 <?php437 }438 439 /**************************************************************************440 xprofile_remove_data_on_blog_deletion()441 442 Removes all profile data from the DB if the admin deletes a Home Base.443 **************************************************************************/444 445 function xprofile_remove_data_on_blog_deletion( $blog_id ) {446 global $wpdb, $bp;447 448 /* Only delete profile data if we are removing a home base */449 if ( $user_id = bp_core_get_homebase_userid( $blog_id ) ) {450 BP_XProfile_ProfileData::delete_data_for_user( $user_id );451 452 // delete any avatar files.453 @unlink( get_usermeta( $user_id, 'bp_core_avatar_v1_path' ) );454 @unlink( get_usermeta( $user_id, 'bp_core_avatar_v2_path' ) );455 456 // unset the usermeta for avatars from the usermeta table.457 delete_usermeta( $user_id, 'bp_core_avatar_v1' );458 delete_usermeta( $user_id, 'bp_core_avatar_v1_path' );459 delete_usermeta( $user_id, 'bp_core_avatar_v2' );460 delete_usermeta( $user_id, 'bp_core_avatar_v2_path' );461 }462 }463 add_action( 'delete_blog', 'xprofile_remove_data_on_blog_deletion', 1 );464 465 ?> -
trunk/bp-xprofile/bp-xprofile-signup.php
r391 r394 80 80 **************************************************************************/ 81 81 82 function xprofile_validate_signup_fields( ) {82 function xprofile_validate_signup_fields( $result ) { 83 83 global $bp_xprofile_callback, $avatar_error, $avatar_error_msg, $has_errors; 84 84 global $canvas, $original; 85 85 global $current_site, $active_signup; 86 86 87 if ( isset( $_POST['validate_custom'] ) ) { 87 88 // form has been submitted, let's validate the form 88 89 // using the built in Wordpress functions and our own. 89 90 90 $active_signup = 'all'; 91 $active_signup = apply_filters( 'wpmu_active_signup', $active_signup ); // return "all", "none", "blog" or "user" 92 93 $newblogname = isset( $_GET['new'] ) ? strtolower(preg_replace('/^-|-$|[^-a-zA-Z0-9]/', '', $_GET['new'])) : null; 94 if ( $_POST['blog_public'] != 1 ) 95 $_POST['blog_public'] = 0; 96 97 if ( $active_signup == "none" ) { 98 _e( "Registration has been disabled." , 'buddypress'); 91 extract($result); 92 93 $counter = 0; 94 $has_errors = false; 95 $prev_field_id = -1; 96 97 // Validate all sign up fields 98 $fields = BP_XProfile_Field::get_signup_fields(); 99 foreach ( $fields as $field ) { 100 101 $value = $_POST['field_' . $field->id]; 102 103 // Need to check if the previous field had 104 // the same ID, as to not validate individual 105 // day/month/year dropdowns individually. 106 if ( $prev_field_id != $field->id ) { 107 $field = new BP_XProfile_Field($field->id); 108 109 if ( $field->type == "datebox" ) { 110 if ( $_POST['field_' . $field->id . '_day'] != "" && $_POST['field_' . $field->id . '_month'] != "" && $_POST['field_' . $field->id . '_year'] != "") { 111 $value = strtotime( $_POST['field_' . $field->id . '_day'] . " " . 112 $_POST['field_' . $field->id . '_month'] . " " . 113 $_POST['field_' . $field->id . '_year']); 114 } 115 } 116 117 if ( is_array($value) ) { 118 $value = serialize( $value ); 119 } 120 121 $bp_xprofile_callback[$counter] = array( 122 "field_id" => $field->id, 123 "type" => $field->type, 124 "value" => $value 125 ); 126 127 if ( $field->is_required && $value == '' ) { 128 $bp_xprofile_callback[$counter]["error_msg"] = $field->name . ' cannot be left blank.'; 129 $has_errors = true; 130 } 131 132 $counter++; 133 } 134 135 $prev_field_id = $field->id; 136 } 137 138 // validate the avatar upload if there is one. 139 $avatar_error = false; 140 141 if ( bp_core_check_avatar_upload($_FILES) ) { 142 if ( !bp_core_check_avatar_upload($_FILES) ) { 143 $avatar_error = true; 144 $avatar_error_msg = __('Your avatar upload failed, please try again.', 'buddypress'); 145 } 146 147 if ( !bp_core_check_avatar_size($_FILES) ) { 148 $avatar_error = true; 149 $avatar_size = size_format(CORE_MAX_FILE_SIZE); 150 $avatar_error_msg = sprintf( __('The file you uploaded is too big. Please upload a file under %s', 'buddypress'), $avatar_size); 151 } 152 153 if ( !bp_core_check_avatar_type($_FILES) ) { 154 $avatar_error = true; 155 $avatar_error_msg = __('Please upload only JPG, GIF or PNG photos.', 'buddypress'); 156 } 157 158 // "Handle" upload into temporary location 159 if ( !$original = bp_core_handle_avatar_upload($_FILES) ) { 160 $avatar_error = true; 161 $avatar_error_msg = __('Upload Failed! Your photo dimensions are likely too big.', 'buddypress'); 162 } 163 164 if ( !bp_core_check_avatar_dimensions($original) ) { 165 $avatar_error = true; 166 $avatar_error_msg = sprintf( __('The image you upload must have dimensions of %d x %d pixels or larger.', 'buddypress'), CORE_AVATAR_V2_W, CORE_AVATAR_V2_W ); 167 } 168 169 if ( !$canvas = bp_core_resize_avatar($original) ) 170 $canvas = $original; 171 } 172 173 if ( !$has_errors && !$avatar_error ) { 174 $public = (int) $_POST['blog_public']; 175 176 // put the user profile meta in a session ready to store. 177 for ( $i = 0; $i < count($bp_xprofile_callback); $i++ ) { 178 $meta['field_' . $bp_xprofile_callback[$i]['field_id']] .= $bp_xprofile_callback[$i]['value']; 179 } 180 181 $meta['xprofile_field_ids'] = $_POST['xprofile_ids']; 182 $meta['avatar_image_resized'] = $canvas; 183 $meta['avatar_image_original'] = $original; 184 $meta['public'] = $public; 185 $meta['lang_id'] = 1; 186 187 $_SESSION['xprofile_meta'] = $meta; 99 188 } else { 100 if ( $active_signup == 'all' || $active_signup == "blog" ) { 101 $_POST['blog_id'] = $_POST['user_name']; 102 $_POST['blog_title'] = $_POST['field_1'] . " " . $_POST['field_2']; // The core name fields. 103 104 $counter = 0; 105 $has_errors = false; 106 $prev_field_id = -1; 107 108 // Validate all sign up fields 109 $fields = BP_XProfile_Field::get_signup_fields(); 110 foreach ( $fields as $field ) { 111 112 $value = $_POST['field_' . $field->id]; 113 114 // Need to check if the previous field had 115 // the same ID, as to not validate individual 116 // day/month/year dropdowns individually. 117 if ( $prev_field_id != $field->id ) { 118 $field = new BP_XProfile_Field($field->id); 119 120 if ( $field->type == "datebox" ) { 121 if ( $_POST['field_' . $field->id . '_day'] != "" && $_POST['field_' . $field->id . '_month'] != "" && $_POST['field_' . $field->id . '_year'] != "") { 122 $value = strtotime( $_POST['field_' . $field->id . '_day'] . " " . 123 $_POST['field_' . $field->id . '_month'] . " " . 124 $_POST['field_' . $field->id . '_year']); 125 } 126 } 127 128 if ( is_array($value) ) { 129 $value = serialize( $value ); 130 } 131 132 $bp_xprofile_callback[$counter] = array( 133 "field_id" => $field->id, 134 "type" => $field->type, 135 "value" => $value 136 ); 137 138 if ( $field->is_required && $value == '' ) { 139 $bp_xprofile_callback[$counter]["error_msg"] = $field->name . ' cannot be left blank.'; 140 $has_errors = true; 141 } 142 143 $counter++; 144 } 145 146 $prev_field_id = $field->id; 147 } 148 149 // validate the avatar upload if there is one. 150 $avatar_error = false; 151 152 if ( bp_core_check_avatar_upload($_FILES) ) { 153 if ( !bp_core_check_avatar_upload($_FILES) ) { 154 $avatar_error = true; 155 $avatar_error_msg = __('Your avatar upload failed, please try again.', 'buddypress'); 156 } 157 158 if ( !bp_core_check_avatar_size($_FILES) ) { 159 $avatar_error = true; 160 $avatar_size = size_format(1024 * CORE_MAX_FILE_SIZE); 161 $avatar_error_msg = sprintf( __('The file you uploaded is too big. Please upload a file under %d', 'buddypress'), $avatar_size); 162 } 163 164 if ( !bp_core_check_avatar_type($_FILES) ) { 165 $avatar_error = true; 166 $avatar_error_msg = __('Please upload only JPG, GIF or PNG photos.', 'buddypress'); 167 } 168 169 // "Handle" upload into temporary location 170 if ( !$original = bp_core_handle_avatar_upload($_FILES) ) { 171 $avatar_error = true; 172 $avatar_error_msg = __('Upload Failed! Your photo dimensions are likely too big.', 'buddypress'); 173 } 174 175 if ( !bp_core_check_avatar_dimensions($original) ) { 176 $avatar_error = true; 177 $avatar_error_msg = sprintf( __('The image you upload must have dimensions of %d x %d pixels or larger.', 'buddypress'), CORE_AVATAR_V2_W, CORE_AVATAR_V2_W ); 178 } 179 180 if ( !$canvas = bp_core_resize_avatar($original) ) 181 $canvas = $original; 182 } 183 184 if ( !is_user_logged_in() ) { 185 $result = wpmu_validate_user_signup( $_POST['user_name'], $_POST['user_email'] ); 186 extract($result); 187 188 if ( $errors->get_error_code() || $has_errors || $avatar_error ) { 189 signup_user($user_name, $user_email, $errors); 190 191 echo '</div>'; 192 get_footer(); 193 die; 194 } 195 } 196 197 if ( !$has_errors ) { 198 if ( !is_user_logged_in() ) { 199 // This is a new user signing up, not an existing user creating a home base. 200 $result = wpmu_validate_blog_signup( $_POST['blog_id'], $_POST['blog_title'] ); 201 extract($result); 202 203 if ( $errors->get_error_code() ) { 204 signup_user( $user_name, $user_email, $errors ); 205 return; 206 } 207 208 $public = (int) $_POST['blog_public']; 209 $meta = array( 'lang_id' => 1, 'public' => $public ); 210 211 for ( $i = 0; $i < count($bp_xprofile_callback); $i++ ) { 212 $meta['field_' . $bp_xprofile_callback[$i]['field_id']] .= $bp_xprofile_callback[$i]['value']; 213 } 214 215 $meta['xprofile_field_ids'] = $_POST['xprofile_ids']; 216 $meta['avatar_image_resized'] = $canvas; 217 $meta['avatar_image_original'] = $original; 218 219 $meta = apply_filters( "add_signup_meta", $meta ); 220 221 wpmu_signup_blog( $domain, $path, $blog_title, $user_name, $user_email, $meta ); 222 confirm_blog_signup( $domain, $path, $blog_title, $user_name, $user_email, $meta ); 223 224 echo '</div></div>'; 225 get_footer(); 226 die; 227 } else { 228 bp_core_validate_homebase_form_secondary(); 229 } 230 } else { 231 if ( !is_user_logged_in() ) { 232 signup_user( $user_name, $user_email, $errors ); 233 234 echo '</div>'; 235 get_footer(); 236 die; 237 } else { 238 bp_core_validate_homebase_form_secondary( $user_name, $user_email, $errors ); 239 } 240 } 241 242 } else { 243 _e( "Registration has been disabled." , 'buddypress'); 244 } 245 } 246 } 247 } 248 249 add_action( 'preprocess_signup_form', 'xprofile_validate_signup_fields' ); 250 189 $errors->add( 'bp_xprofile_errors', '' ); 190 } 191 } 192 193 return array('user_name' => $user_name, 'user_email' => $user_email, 'errors' => $errors); 194 } 195 add_filter( 'wpmu_validate_user_signup', 'xprofile_validate_signup_fields', 10, 1 ); 196 197 198 function xprofile_add_profile_meta( $meta ) { 199 return $_SESSION['xprofile_meta']; 200 } 201 add_filter( 'add_signup_meta', 'xprofile_add_profile_meta' ); 251 202 252 203 /************************************************************************** … … 258 209 259 210 function xprofile_hidden_signup_fields() { 260 global $active_signup; 261 262 // Override the stage variable so we can redirect the validation of the form 263 // to our own custom validation function. 264 265 if( !is_user_logged_in() ) { 266 ?> 267 <input type="hidden" name="stage" value="" /> 268 <?php } ?> 269 <input type="hidden" name="validate_custom" value="1" /> 270 <?php 271 272 if ( $active_signup != 'none' ) 273 $active_signup = 'blog'; 211 ?><input type="hidden" name="validate_custom" value="1" /><?php 274 212 } 275 213 add_action( 'signup_hidden_fields', 'xprofile_hidden_signup_fields' ); … … 277 215 278 216 /************************************************************************** 279 xprofile_on_activate ()217 xprofile_on_activate_user() 280 218 281 219 When a user activates their account, move the extra field data to the 282 correct tables , and then remove the WP options table entries.220 correct tables. 283 221 **************************************************************************/ 284 222 285 function xprofile_on_activate( $blog_id = null, $user_id = null ) { 286 global $wpdb, $profile_picture_path; 287 288 if ( WP_INSTALLING ) 289 return false; 290 291 /* Only do this if this is a new user, and not a user creating a home base */ 292 if ( !is_user_logged_in() ) { 293 294 // Extract signup meta fields to fill out profile 295 $field_ids = get_blog_option( $blog_id, 'xprofile_field_ids' ); 296 $field_ids = explode( ",", $field_ids ); 297 298 // Get the new user ID. 299 $sql = "SELECT u.ID from " . $wpdb->base_prefix . "users u, 300 " . $wpdb->base_prefix . "usermeta um 301 WHERE u.ID = um.user_id 302 AND um.meta_key = 'primary_blog' 303 AND um.meta_value = " . $blog_id; 304 305 $user_id = $wpdb->get_var($sql); 306 307 // Loop through each bit of profile data and save it to profile. 308 for ( $i = 0; $i < count($field_ids); $i++ ) { 309 $field_value = get_blog_option( $blog_id, 'field_' . $field_ids[$i] ); 310 311 $field = new BP_XProfile_ProfileData(); 312 $field->user_id = $user_id; 313 $field->value = $field_value; 314 $field->field_id = $field_ids[$i]; 315 $field->last_updated = time(); 316 317 $field->save(); 318 delete_blog_option( $blog_id, 'field_' . $field_ids[$i] ); 319 } 320 delete_blog_option( $blog_id, 'xprofile_field_ids' ); 321 322 /* Make this blog the "home base" for the new user */ 323 update_usermeta( $user_id, 'home_base', $blog_id ); 324 update_usermeta( $user_id, 'last_activity', time() ); 325 326 /* Set the BuddyPress theme as the theme for this blog */ 327 $wpdb->set_blog_id($blog_id); 328 switch_theme( 'buddypress', 'buddypress' ); 329 330 // move and set the avatar if one has been provided. 331 $resized = get_blog_option( $blog_id, 'avatar_image_resized' ); 332 $original = get_blog_option( $blog_id, 'avatar_image_original' ); 333 334 if ( $resized && $original ) { 335 $upload_dir = bp_upload_dir(NULL, $blog_id); 336 337 if ( $upload_dir ) { 338 $resized_strip_path = explode( '/', $resized ); 339 $original_strip_path = explode( '/', $original ); 340 341 $resized_filename = $resized_strip_path[count($resized_strip_path) - 1]; 342 $original_filename = $original_strip_path[count($original_strip_path) - 1]; 343 344 $resized_new = $upload_dir['path'] . '/' . $resized_filename; 345 $original_new = $upload_dir['path'] . '/' . $original_filename; 346 347 @copy( $resized, $resized_new ); 348 @copy( $original, $original_new ); 349 350 @unlink($resized); 351 @unlink($original); 352 353 $resized = $resized_new; 354 $original = $original_new; 355 } 356 357 // Render the cropper UI 358 $action = get_blog_option( $blog_id, 'siteurl' ) . '/wp-activate.php?key=' . $_GET['key'] . '&cropped=true'; 359 bp_core_render_avatar_cropper($original, $resized, $action, $user_id); 360 } 361 } 362 363 } 364 add_action( 'wpmu_new_blog', 'xprofile_on_activate' ); 365 223 function xprofile_on_activate_blog( $blog_id, $user_id, $password, $title, $meta ) { 224 xprofile_extract_signup_meta( $user_id, $meta ); 225 226 // move and set the avatar if one has been provided. 227 xprofile_handle_signup_avatar( $user_id, $meta ); 228 } 229 add_action( 'wpmu_activate_blog', 'xprofile_on_activate_blog', 1, 5 ); 230 231 232 function xprofile_on_activate_user( $user_id, $password, $meta ) { 233 xprofile_extract_signup_meta( $user_id, $meta ); 234 235 // move and set the avatar if one has been provided. 236 xprofile_handle_signup_avatar( $user_id, $meta ); 237 } 238 add_action( 'wpmu_activate_user', 'xprofile_on_activate_user', 1, 3 ); 239 240 241 function xprofile_extract_signup_meta( $user_id, $meta ) { 242 // Extract signup meta fields to fill out profile 243 $field_ids = $meta['xprofile_field_ids']; 244 $field_ids = explode( ',', $field_ids ); 245 246 // Loop through each bit of profile data and save it to profile. 247 for ( $i = 0; $i < count($field_ids); $i++ ) { 248 if ( $field_ids[$i] == '' ) continue; 249 250 $field_value = $meta["field_{$field_ids[$i]}"]; 251 252 $field = new BP_XProfile_ProfileData(); 253 $field->user_id = $user_id; 254 $field->value = $field_value; 255 $field->field_id = $field_ids[$i]; 256 $field->last_updated = time(); 257 258 $field->save(); 259 } 260 261 update_usermeta( $user_id, 'last_activity', time() ); 262 } 263 264 function xprofile_handle_signup_avatar( $user_id, $meta ) { 265 $resized = $meta['avatar_image_resized']; 266 $original = $meta['avatar_image_original']; 267 268 if ( !empty($resized) && !empty($original) ) { 269 $upload_dir = bp_avatar_upload_dir( $user_id ); 270 271 if ( $upload_dir ) { 272 $resized_strip_path = explode( '/', $resized ); 273 $original_strip_path = explode( '/', $original ); 274 275 $resized_filename = $resized_strip_path[count($resized_strip_path) - 1]; 276 $original_filename = $original_strip_path[count($original_strip_path) - 1]; 277 278 $resized_new = $upload_dir['path'] . '/' . $resized_filename; 279 $original_new = $upload_dir['path'] . '/' . $original_filename; 280 281 @copy( $resized, $resized_new ); 282 @copy( $original, $original_new ); 283 284 @unlink($resized); 285 @unlink($original); 286 287 $resized = $resized_new; 288 $original = $original_new; 289 } 290 291 // Render the cropper UI 292 $action = site_url() . '/wp-activate.php?key=' . $_GET['key'] . '&cropped=true'; 293 bp_core_render_avatar_cropper($original, $resized, $action, $user_id); 294 } 295 } 366 296 367 297 function xprofile_catch_activate_crop() { … … 381 311 } 382 312 383 $ blog_id = get_usermeta( $user_id, 'home_base');384 $url = get_blog_option( $blog_id, 'siteurl' );313 $ud = get_userdata($user_id); 314 $url = site_url() . '/members/' . $ud->user_login; 385 315 386 316 wp_redirect( $url ); … … 404 334 405 335 406 // function xprofile_replace_blog_references() {407 // if ( strpos( $_SERVER['SCRIPT_NAME'], 'wp-signup.php' ) ) {408 // add_action( 'wp_head', 'xprofile_start_blog_reference_replacement' );409 // }410 // }411 // add_action( 'wp', 'xprofile_replace_blog_references' );412 413 // function xprofile_start_blog_reference_replacement( $contents ) {414 // ob_start();415 // add_action('wp_footer', 'xprofile_end_blog_reference_replacement');416 // }417 //418 // function xprofile_blog_reference_replacement( $contents ) {419 // echo str_replace( 'blog', 'account', $contents );420 // }421 //422 // function xprofile_end_blog_reference_replacement() {423 // $contents = ob_get_contents();424 // ob_end_clean();425 // xprofile_blog_reference_replacement($contents);426 // }427 428 429 430 336 ?> -
trunk/bp-xprofile/bp-xprofile-templatetags.php
r391 r394 133 133 134 134 // Begin template tags: 135 function xprofile_get_profile() { 136 load_template( TEMPLATEPATH . '/profile/profile-loop.php'); 137 } 135 138 136 139 function bp_has_profile() { 137 140 global $bp, $profile_template; 138 141 139 142 $profile_template = new BP_XProfile_Template($bp['current_userid']); 140 143 … … 222 225 } 223 226 224 function bp_the_avatar() {225 global $bp;226 echo bp_core_get_avatar( $bp['current_userid'], 2 );227 }228 229 function bp_the_avatar_thumbnail() {230 global $bp;231 echo bp_core_get_avatar( $bp['current_userid'], 1 );232 }233 234 function bp_loggedinuser_avatar_thumbnail( $width = false, $height = false ) {235 global $bp;236 237 if ( $width && $height )238 echo bp_core_get_avatar( $bp['loggedin_userid'], 1, false, $width, $height );239 else240 echo bp_core_get_avatar( $bp['loggedin_userid'], 1 );241 }242 243 function bp_fetch_user_fullname( $user_id = false, $echo = true ) {244 global $bp;245 246 if ( !$user_id )247 $user_id = $bp['current_userid'];248 249 $data = bp_get_field_data( array( 'First Name', 'Last Name' ), $user_id );250 251 if ( $echo )252 echo ucfirst($data['First Name']) . ' ' . ucfirst($data['Last Name']);253 else254 return ucfirst($data['First Name']) . ' ' . ucfirst($data['Last Name']);255 }256 257 227 function bp_get_field_data( $field, $user_id = null ) { 258 228 return BP_XProfile_ProfileData::get_value_byfieldname( $field, $user_id ); 259 }260 261 function bp_user_link() {262 echo '';263 }264 265 function bp_user_status() {266 // TODO: dummy function now, until status component is developed.267 return false;268 229 } 269 230 … … 321 282 } 322 283 323 function bp_profile_last_updated_date( $user_id = false, $echo = true ) {324 global $bp;325 326 if ( !$user_id )327 $user_id = $bp['current_userid'];328 329 $last_updated = BP_XProfile_ProfileData::get_last_updated( $user_id );330 331 if ( $echo )332 echo $last_updated;333 else334 return $last_updated;335 }336 337 284 function bp_profile_last_updated() { 338 285 global $bp;
Note: See TracChangeset
for help on using the changeset viewer.