BuddyPress - Version 1.2.2

Version Description

Download this release

Release Info

Developer apeatling
Plugin Icon 128x128 BuddyPress
Version 1.2.2
Comparing to
See all releases

Code changes from version 1.2.1 to 1.2.2

bp-activity.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- define ( 'BP_ACTIVITY_DB_VERSION', '2060' );
4
 
5
  /* Define the slug for the component */
6
  if ( !defined( 'BP_ACTIVITY_SLUG' ) )
@@ -44,8 +44,8 @@ function bp_activity_install() {
44
  secondary_item_id varchar(75) DEFAULT NULL,
45
  date_recorded datetime NOT NULL,
46
  hide_sitewide bool DEFAULT 0,
47
- mptt_left int(11) NOT NULL,
48
- mptt_right int(11) NOT NULL,
49
  KEY date_recorded (date_recorded),
50
  KEY user_id (user_id),
51
  KEY item_id (item_id),
@@ -247,7 +247,11 @@ function bp_activity_screen_single_activity_permalink() {
247
 
248
  if ( !$has_access ) {
249
  bp_core_add_message( __( 'You do not have access to this activity.', 'buddypress' ), 'error' );
250
- bp_core_redirect( $bp->loggedin_user->domain );
 
 
 
 
251
  }
252
 
253
  bp_core_load_template( apply_filters( 'bp_activity_template_profile_activity_permalink', 'members/single/activity/permalink' ) );
@@ -311,19 +315,21 @@ function bp_activity_action_permalink_router() {
311
  /* Redirect based on the type of activity */
312
  if ( $activity->component == $bp->groups->id ) {
313
  if ( $activity->user_id )
314
- $redirect = bp_core_get_user_domain( $activity->user_id, $activity->user_nicename, $activity->user_login ) . $bp->activity->slug . '/' . $activity->id;
315
  else {
316
  if ( $group = groups_get_group( array( 'group_id' => $activity->item_id ) ) )
317
- $redirect = bp_get_group_permalink( $group ) . $bp->activity->slug . '/' . $activity->id;
318
  }
319
  } else
320
  $redirect = bp_core_get_user_domain( $activity->user_id, $activity->user_nicename, $activity->user_login ) . $bp->activity->slug . '/' . $activity->id;
321
 
 
 
322
  if ( !$redirect )
323
  bp_core_redirect( $bp->root_domain );
324
 
325
  /* Redirect to the actual activity permalink page */
326
- bp_core_redirect( apply_filters( 'bp_activity_action_permalink_url', $redirect . '/', &$activity ) );
327
  }
328
  add_action( 'wp', 'bp_activity_action_permalink_router', 3 );
329
 
@@ -714,6 +720,7 @@ function bp_activity_new_comment( $args = '' ) {
714
  global $bp;
715
 
716
  $defaults = array(
 
717
  'content' => false,
718
  'user_id' => $bp->loggedin_user->id,
719
  'activity_id' => false, // ID of the root activity item
@@ -735,6 +742,7 @@ function bp_activity_new_comment( $args = '' ) {
735
 
736
  /* Insert the activity comment */
737
  $comment_id = bp_activity_add( array(
 
738
  'action' => apply_filters( 'bp_activity_comment_action', sprintf( __( '%s posted a new activity comment:', 'buddypress' ), bp_core_get_userlink( $user_id ) ) ),
739
  'content' => apply_filters( 'bp_activity_comment_content', $content ),
740
  'component' => $bp->activity->id,
@@ -772,13 +780,14 @@ function bp_activity_get_activity_id( $args = '' ) {
772
  'item_id' => false,
773
  'secondary_item_id' => false,
774
  'action' => false,
775
- 'content' => false
 
776
  );
777
 
778
  $r = wp_parse_args( $args, $defaults );
779
  extract( $r, EXTR_SKIP );
780
 
781
- return apply_filters( 'bp_activity_get_activity_id', BP_Activity_Activity::get_id( $user_id, $component, $type, $item_id, $secondary_item_id, $action, $content ) );
782
  }
783
 
784
  /***
1
  <?php
2
 
3
+ define ( 'BP_ACTIVITY_DB_VERSION', '2100' );
4
 
5
  /* Define the slug for the component */
6
  if ( !defined( 'BP_ACTIVITY_SLUG' ) )
44
  secondary_item_id varchar(75) DEFAULT NULL,
45
  date_recorded datetime NOT NULL,
46
  hide_sitewide bool DEFAULT 0,
47
+ mptt_left int(11) NOT NULL DEFAULT 0,
48
+ mptt_right int(11) NOT NULL DEFAULT 0,
49
  KEY date_recorded (date_recorded),
50
  KEY user_id (user_id),
51
  KEY item_id (item_id),
247
 
248
  if ( !$has_access ) {
249
  bp_core_add_message( __( 'You do not have access to this activity.', 'buddypress' ), 'error' );
250
+
251
+ if ( is_user_logged_in() )
252
+ bp_core_redirect( $bp->loggedin_user->domain );
253
+ else
254
+ bp_core_redirect( site_url( 'wp-login.php?redirect_to=' . clean_url( $bp->root_domain . '/' . $bp->activity->slug . '/p/' . $bp->current_action ) ) );
255
  }
256
 
257
  bp_core_load_template( apply_filters( 'bp_activity_template_profile_activity_permalink', 'members/single/activity/permalink' ) );
315
  /* Redirect based on the type of activity */
316
  if ( $activity->component == $bp->groups->id ) {
317
  if ( $activity->user_id )
318
+ $redirect = bp_core_get_user_domain( $activity->user_id, $activity->user_nicename, $activity->user_login ) . $bp->activity->slug . '/' . $activity->id . '/';
319
  else {
320
  if ( $group = groups_get_group( array( 'group_id' => $activity->item_id ) ) )
321
+ $redirect = bp_get_group_permalink( $group ) . $bp->activity->slug . '/' . $activity->id . '/';
322
  }
323
  } else
324
  $redirect = bp_core_get_user_domain( $activity->user_id, $activity->user_nicename, $activity->user_login ) . $bp->activity->slug . '/' . $activity->id;
325
 
326
+ $redirect = apply_filters( 'bp_activity_permalink_redirect_url', $redirect, &$activity );
327
+
328
  if ( !$redirect )
329
  bp_core_redirect( $bp->root_domain );
330
 
331
  /* Redirect to the actual activity permalink page */
332
+ bp_core_redirect( $redirect );
333
  }
334
  add_action( 'wp', 'bp_activity_action_permalink_router', 3 );
335
 
720
  global $bp;
721
 
722
  $defaults = array(
723
+ 'id' => false,
724
  'content' => false,
725
  'user_id' => $bp->loggedin_user->id,
726
  'activity_id' => false, // ID of the root activity item
742
 
743
  /* Insert the activity comment */
744
  $comment_id = bp_activity_add( array(
745
+ 'id' => $id,
746
  'action' => apply_filters( 'bp_activity_comment_action', sprintf( __( '%s posted a new activity comment:', 'buddypress' ), bp_core_get_userlink( $user_id ) ) ),
747
  'content' => apply_filters( 'bp_activity_comment_content', $content ),
748
  'component' => $bp->activity->id,
780
  'item_id' => false,
781
  'secondary_item_id' => false,
782
  'action' => false,
783
+ 'content' => false,
784
+ 'date_recorded' => false,
785
  );
786
 
787
  $r = wp_parse_args( $args, $defaults );
788
  extract( $r, EXTR_SKIP );
789
 
790
+ return apply_filters( 'bp_activity_get_activity_id', BP_Activity_Activity::get_id( $user_id, $component, $type, $item_id, $secondary_item_id, $action, $content, $date_recorded ) );
791
  }
792
 
793
  /***
bp-activity/bp-activity-classes.php CHANGED
@@ -198,7 +198,7 @@ Class BP_Activity_Activity {
198
  return array( 'activities' => $activities, 'total' => (int)$total_activities );
199
  }
200
 
201
- function get_id( $user_id, $component, $type, $item_id, $secondary_item_id, $action, $content ) {
202
  global $bp, $wpdb;
203
 
204
  $where_args = false;
@@ -224,6 +224,9 @@ Class BP_Activity_Activity {
224
  if ( !empty( $content ) )
225
  $where_args[] = $wpdb->prepare( "content = %s", $content );
226
 
 
 
 
227
  if ( !empty( $where_args ) )
228
  $where_sql = 'WHERE ' . join( ' AND ', $where_args );
229
  else
198
  return array( 'activities' => $activities, 'total' => (int)$total_activities );
199
  }
200
 
201
+ function get_id( $user_id, $component, $type, $item_id, $secondary_item_id, $action, $content, $date_recorded ) {
202
  global $bp, $wpdb;
203
 
204
  $where_args = false;
224
  if ( !empty( $content ) )
225
  $where_args[] = $wpdb->prepare( "content = %s", $content );
226
 
227
+ if ( !empty( $date_recorded ) )
228
+ $where_args[] = $wpdb->prepare( "date_recorded = %s", $date_recorded );
229
+
230
  if ( !empty( $where_args ) )
231
  $where_sql = 'WHERE ' . join( ' AND ', $where_args );
232
  else
bp-activity/bp-activity-templatetags.php CHANGED
@@ -540,7 +540,7 @@ function bp_activity_parent_content( $args = '' ) {
540
  }
541
 
542
  function bp_activity_is_favorite() {
543
- echo bp_get_is_activity_favorite();
544
  }
545
  function bp_get_activity_is_favorite() {
546
  global $bp, $activities_template;
540
  }
541
 
542
  function bp_activity_is_favorite() {
543
+ echo bp_get_activity_is_favorite();
544
  }
545
  function bp_get_activity_is_favorite() {
546
  global $bp, $activities_template;
bp-blogs.php CHANGED
@@ -27,30 +27,6 @@ function bp_blogs_install() {
27
  KEY blog_id (blog_id)
28
  ) {$charset_collate};";
29
 
30
- $sql[] = "CREATE TABLE {$bp->blogs->table_name_blog_posts} (
31
- id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
32
- user_id bigint(20) NOT NULL,
33
- blog_id bigint(20) NOT NULL,
34
- post_id bigint(20) NOT NULL,
35
- date_created datetime NOT NULL,
36
- KEY user_id (user_id),
37
- KEY blog_id (blog_id),
38
- KEY post_id (post_id)
39
- ) {$charset_collate};";
40
-
41
- $sql[] = "CREATE TABLE {$bp->blogs->table_name_blog_comments} (
42
- id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
43
- user_id bigint(20) NOT NULL,
44
- blog_id bigint(20) NOT NULL,
45
- comment_id bigint(20) NOT NULL,
46
- comment_post_id bigint(20) NOT NULL,
47
- date_created datetime NOT NULL,
48
- KEY user_id (user_id),
49
- KEY blog_id (blog_id),
50
- KEY comment_id (comment_id),
51
- KEY comment_post_id (comment_post_id)
52
- ) {$charset_collate};";
53
-
54
  $sql[] = "CREATE TABLE {$bp->blogs->table_name_blogmeta} (
55
  id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
56
  blog_id bigint(20) NOT NULL,
@@ -93,8 +69,6 @@ function bp_blogs_setup_globals() {
93
  $bp->blogs->id = 'blogs';
94
 
95
  $bp->blogs->table_name = $wpdb->base_prefix . 'bp_user_blogs';
96
- $bp->blogs->table_name_blog_posts = $wpdb->base_prefix . 'bp_user_blogs_posts';
97
- $bp->blogs->table_name_blog_comments = $wpdb->base_prefix . 'bp_user_blogs_comments';
98
  $bp->blogs->table_name_blogmeta = $wpdb->base_prefix . 'bp_user_blogs_blogmeta';
99
  $bp->blogs->format_notification_function = 'bp_blogs_format_notifications';
100
  $bp->blogs->slug = BP_BLOGS_SLUG;
@@ -182,16 +156,6 @@ function bp_blogs_screen_my_blogs() {
182
  bp_core_load_template( apply_filters( 'bp_blogs_template_my_blogs', 'members/single/home' ) );
183
  }
184
 
185
- function bp_blogs_screen_recent_posts() {
186
- do_action( 'bp_blogs_screen_recent_posts' );
187
- bp_core_load_template( apply_filters( 'bp_blogs_template_recent_posts', 'members/single/home' ) );
188
- }
189
-
190
- function bp_blogs_screen_recent_comments() {
191
- do_action( 'bp_blogs_screen_recent_comments' );
192
- bp_core_load_template( apply_filters( 'bp_blogs_template_recent_comments', 'members/single/home' ) );
193
- }
194
-
195
  function bp_blogs_screen_create_a_blog() {
196
  global $bp;
197
 
@@ -330,7 +294,6 @@ function bp_blogs_get_blogs( $args = '' ) {
330
  return apply_filters( 'bp_blogs_get_blogs', BP_Blogs_Blog::get( $type, $per_page, $page, $user_id, $search_terms ), &$params );
331
  }
332
 
333
-
334
  function bp_blogs_record_existing_blogs() {
335
  global $bp, $wpdb;
336
 
@@ -402,7 +365,7 @@ function bp_blogs_record_post( $post_id, $post, $user_id = false ) {
402
  if ( !$user_id )
403
  $user_id = (int)$post->post_author;
404
 
405
- /* This is to stop infinate loops with Donncha's sitewide tags plugin */
406
  if ( (int)$bp->site_options['tags_blog_id'] == (int)$blog_id )
407
  return false;
408
 
@@ -410,59 +373,11 @@ function bp_blogs_record_post( $post_id, $post, $user_id = false ) {
410
  if ( $post->post_type != 'post' )
411
  return false;
412
 
413
- if ( !$is_recorded = BP_Blogs_Post::is_recorded( $post_id, $blog_id, $user_id ) ) {
414
- if ( 'publish' == $post->post_status && '' == $post->post_password ) {
415
-
416
- /* If we're on a multiblog install, record this post */
417
- if ( bp_core_is_multisite() ) {
418
- $recorded_post = new BP_Blogs_Post;
419
- $recorded_post->user_id = $user_id;
420
- $recorded_post->blog_id = $blog_id;
421
- $recorded_post->post_id = $post_id;
422
- $recorded_post->date_created = strtotime( $post->post_date );
423
-
424
- $recorded_post_id = $recorded_post->save();
425
-
426
- bp_blogs_update_blogmeta( $recorded_post->blog_id, 'last_activity', gmdate( "Y-m-d H:i:s" ) );
427
- }
428
-
429
- if ( (int)get_blog_option( $blog_id, 'blog_public' ) || !bp_core_is_multisite() ) {
430
- /* Record this in activity streams */
431
- $post_permalink = get_permalink( $post_id );
432
-
433
- $activity_action = sprintf( __( '%s wrote a new blog post: %s', 'buddypress' ), bp_core_get_userlink( (int)$post->post_author ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>' );
434
- $activity_content = $post->post_content;
435
-
436
- bp_blogs_record_activity( array(
437
- 'user_id' => (int)$post->post_author,
438
- 'action' => apply_filters( 'bp_blogs_activity_new_post_action', $activity_action, &$post, $post_permalink ),
439
- 'content' => apply_filters( 'bp_blogs_activity_new_post_content', $activity_content, &$post, $post_permalink ),
440
- 'primary_link' => apply_filters( 'bp_blogs_activity_new_post_primary_link', $post_permalink, $post_id ),
441
- 'type' => 'new_blog_post',
442
- 'item_id' => $blog_id,
443
- 'secondary_item_id' => $post_id,
444
- 'recorded_time' => $post->post_date_gmt
445
- ));
446
- }
447
- }
448
- } else {
449
- $existing_post = new BP_Blogs_Post( null, $blog_id, $post_id );
450
-
451
- /* Delete the recorded post if the status is not published or it is password protected */
452
- if ( 'publish' != $post->post_status || '' != $post->post_password ) {
453
- return bp_blogs_remove_post( $post_id, $blog_id, $existing_post );
454
-
455
- /* If the post author has changed, delete the post and re-add it. */
456
- } else if ( (int)$existing_post->user_id != (int)$post->post_author ) {
457
- // Delete the existing recorded post
458
- bp_blogs_remove_post( $post_id, $blog_id, $existing_post );
459
-
460
- // Re-record the post with the new author.
461
- bp_blogs_record_post( $post_id );
462
- }
463
 
464
  if ( (int)get_blog_option( $blog_id, 'blog_public' ) || !bp_core_is_multisite() ) {
465
- /* Now re-record the post in the activity streams */
466
  $post_permalink = get_permalink( $post_id );
467
 
468
  $activity_action = sprintf( __( '%s wrote a new blog post: %s', 'buddypress' ), bp_core_get_userlink( (int)$post->post_author ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>' );
@@ -477,20 +392,18 @@ function bp_blogs_record_post( $post_id, $post, $user_id = false ) {
477
  'item_id' => $blog_id,
478
  'secondary_item_id' => $post_id,
479
  'recorded_time' => $post->post_date_gmt
480
- ) );
481
  }
482
- }
 
483
 
484
- do_action( 'bp_blogs_new_blog_post', $existing_post, $is_private, $is_recorded );
485
  }
486
  add_action( 'save_post', 'bp_blogs_record_post', 10, 2 );
487
 
488
- function bp_blogs_record_comment( $comment_id, $is_approved ) {
489
  global $wpdb, $bp;
490
 
491
- if ( !$is_approved )
492
- return false;
493
-
494
  $comment = get_comment($comment_id);
495
  $comment->post = get_post( $comment->comment_post_ID );
496
 
@@ -505,20 +418,6 @@ function bp_blogs_record_comment( $comment_id, $is_approved ) {
505
  if ( !empty( $post->post_password ) )
506
  return false;
507
 
508
- /* If we're on a multiblog install, record this post */
509
- if ( bp_core_is_multisite() ) {
510
- $recorded_comment = new BP_Blogs_Comment;
511
- $recorded_comment->user_id = $user_id;
512
- $recorded_comment->blog_id = $wpdb->blogid;
513
- $recorded_comment->comment_id = $comment_id;
514
- $recorded_comment->comment_post_id = $comment->comment_post_ID;
515
- $recorded_comment->date_created = strtotime( $comment->comment_date_gmt );
516
-
517
- $recorded_commment_id = $recorded_comment->save();
518
-
519
- bp_blogs_update_blogmeta( $recorded_comment->blog_id, 'last_activity', gmdate( "Y-m-d H:i:s" ) );
520
- }
521
-
522
  if ( (int)get_blog_option( $recorded_comment->blog_id, 'blog_public' ) || !bp_core_is_multisite() ) {
523
  /* Record in activity streams */
524
  $comment_link = get_permalink( $comment->comment_post_ID ) . '#comment-' . $comment_id;
@@ -541,6 +440,7 @@ function bp_blogs_record_comment( $comment_id, $is_approved ) {
541
  return $recorded_comment;
542
  }
543
  add_action( 'comment_post', 'bp_blogs_record_comment', 10, 2 );
 
544
 
545
  function bp_blogs_manage_comment( $comment_id, $comment_status ) {
546
  if ( 'spam' == $comment_status || 'hold' == $comment_status || 'delete' == $comment_status || 'trash' == $comment_status )
@@ -600,7 +500,7 @@ function bp_blogs_remove_blog_for_user( $user_id, $blog_id ) {
600
  }
601
  add_action( 'remove_user_from_blog', 'bp_blogs_remove_blog_for_user', 10, 2 );
602
 
603
- function bp_blogs_remove_post( $post_id, $blog_id = false, $existing_post = false ) {
604
  global $current_blog, $bp;
605
 
606
  $post_id = (int)$post_id;
@@ -608,12 +508,6 @@ function bp_blogs_remove_post( $post_id, $blog_id = false, $existing_post = fals
608
  if ( !$blog_id )
609
  $blog_id = (int)$current_blog->blog_id;
610
 
611
- if ( !$existing_post )
612
- $existing_post = new BP_Blogs_Post( null, $blog_id, $post_id );
613
-
614
- // Delete post from the bp_blogs table
615
- BP_Blogs_Post::delete( $post_id, $blog_id );
616
-
617
  // Delete activity stream item
618
  bp_blogs_delete_activity( array( 'item_id' => $blog_id, 'secondary_item_id' => $post_id, 'component' => $bp->blogs->slug, 'type' => 'new_blog_post' ) );
619
 
@@ -624,9 +518,6 @@ add_action( 'delete_post', 'bp_blogs_remove_post' );
624
  function bp_blogs_remove_comment( $comment_id ) {
625
  global $wpdb, $bp;
626
 
627
- $recorded_comment = new BP_Blogs_Comment( false, $wpdb->blogid, $comment_id );
628
- BP_Blogs_Comment::delete( $comment_id, $wpdb->blogid );
629
-
630
  // Delete activity stream item
631
  bp_blogs_delete_activity( array( 'item_id' => $wpdb->blogid , 'secondary_item_id' => $comment_id, 'type' => 'new_blog_comment' ) );
632
 
@@ -662,8 +553,6 @@ function bp_blogs_remove_data_for_blog( $blog_id ) {
662
 
663
  /* If this is regular blog, delete all data for that blog. */
664
  BP_Blogs_Blog::delete_blog_for_all( $blog_id );
665
- BP_Blogs_Post::delete_posts_for_blog( $blog_id );
666
- BP_Blogs_Comment::delete_comments_for_blog( $blog_id );
667
 
668
  // Delete activity stream item
669
  bp_blogs_delete_activity( array( 'item_id' => $blog_id, 'component' => $bp->blogs->slug, 'type' => false ) );
@@ -676,25 +565,6 @@ function bp_blogs_get_blogs_for_user( $user_id, $show_hidden = false ) {
676
  return BP_Blogs_Blog::get_blogs_for_user( $user_id, $show_hidden );
677
  }
678
 
679
- /* DEPRECATED - scheduled for removal. Please use the activity stream with a 'new_blog_post' filter. */
680
- function bp_blogs_get_posts_for_user( $user_id ) {
681
- return BP_Blogs_Post::get_posts_for_user( $user_id );
682
- }
683
-
684
- /* DEPRECATED - scheduled for removal. Please use the activity stream with a 'new_blog_comment' filter. */
685
- function bp_blogs_get_comments_for_user( $user_id ) {
686
- return BP_Blogs_Comment::get_comments_for_user( $user_id );
687
- }
688
-
689
- function bp_blogs_get_latest_posts( $blog_id = null, $limit = 5 ) {
690
- global $bp;
691
-
692
- if ( !is_numeric( $limit ) )
693
- $limit = 5;
694
-
695
- return BP_Blogs_Post::get_latest_posts( $blog_id, $limit );
696
- }
697
-
698
  function bp_blogs_get_all_blogs( $limit = null, $page = null ) {
699
  return BP_Blogs_Blog::get_all( $limit, $page );
700
  }
@@ -703,18 +573,6 @@ function bp_blogs_get_random_blogs( $limit = null, $page = null ) {
703
  return BP_Blogs_Blog::get( 'random', $limit, $page );
704
  }
705
 
706
- function bp_blogs_get_all_posts( $limit = null, $page = null ) {
707
- return BP_Blogs_Post::get_all( $limit, $page );
708
- }
709
-
710
- function bp_blogs_total_post_count( $blog_id ) {
711
- return BP_Blogs_Post::total_post_count( $blog_id );
712
- }
713
-
714
- function bp_blogs_total_comment_count( $blog_id, $post_id = false ) {
715
- return BP_Blogs_Post::total_comment_count( $blog_id, $post_id );
716
- }
717
-
718
  function bp_blogs_is_blog_hidden( $blog_id ) {
719
  return BP_Blogs_Blog::is_hidden( $blog_id );
720
  }
@@ -831,10 +689,11 @@ function bp_blogs_update_blogmeta( $blog_id, $meta_key, $meta_value ) {
831
  }
832
 
833
  function bp_blogs_remove_data( $user_id ) {
 
 
 
834
  /* If this is regular blog, delete all data for that blog. */
835
  BP_Blogs_Blog::delete_blogs_for_user( $user_id );
836
- BP_Blogs_Post::delete_posts_for_user( $user_id );
837
- BP_Blogs_Comment::delete_comments_for_user( $user_id );
838
 
839
  do_action( 'bp_blogs_remove_data', $user_id );
840
  }
@@ -866,36 +725,9 @@ function bp_blogs_format_clear_blog_cache( $recorded_blog_obj ) {
866
  wp_cache_delete( 'bp_total_blogs', 'bp' );
867
  }
868
 
869
- function bp_blogs_clear_post_object_cache( $blog_id, $post_id, $user_id ) {
870
- wp_cache_delete( 'bp_user_posts_' . $user_id, 'bp' );
871
- }
872
-
873
- function bp_blogs_format_clear_post_cache( $recorded_post_obj ) {
874
- bp_blogs_clear_post_object_cache( false, false, $recorded_post_obj->user_id );
875
-
876
- /* Clear the sitewide activity cache */
877
- wp_cache_delete( 'sitewide_activity', 'bp' );
878
- }
879
-
880
- function bp_blogs_clear_comment_object_cache( $blog_id, $comment_id, $user_id ) {
881
- wp_cache_delete( 'bp_user_comments_' . $user_id, 'bp' );
882
- }
883
-
884
- function bp_blogs_format_clear_comment_cache( $recorded_comment_obj ) {
885
- bp_blogs_clear_comment_object_cache( false, false, $recorded_comment_obj->user_id );
886
-
887
- /* Clear the sitewide activity cache */
888
- wp_cache_delete( 'sitewide_activity', 'bp' );
889
- }
890
-
891
  // List actions to clear object caches on
892
  add_action( 'bp_blogs_remove_blog_for_user', 'bp_blogs_clear_blog_object_cache', 10, 2 );
893
- add_action( 'bp_blogs_remove_post', 'bp_blogs_clear_post_object_cache', 10, 3 );
894
- add_action( 'bp_blogs_remove_comment', 'bp_blogs_clear_comment_object_cache', 10, 3 );
895
-
896
  add_action( 'bp_blogs_new_blog', 'bp_blogs_format_clear_blog_cache', 10, 2 );
897
- add_action( 'bp_blogs_new_blog_post', 'bp_blogs_format_clear_post_cache', 10, 2 );
898
- add_action( 'bp_blogs_new_blog_comment', 'bp_blogs_format_clear_comment_cache', 10, 2 );
899
 
900
  // List actions to clear super cached pages on, if super cache is installed
901
  add_action( 'bp_blogs_remove_data_for_blog', 'bp_core_clear_cache' );
27
  KEY blog_id (blog_id)
28
  ) {$charset_collate};";
29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  $sql[] = "CREATE TABLE {$bp->blogs->table_name_blogmeta} (
31
  id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
32
  blog_id bigint(20) NOT NULL,
69
  $bp->blogs->id = 'blogs';
70
 
71
  $bp->blogs->table_name = $wpdb->base_prefix . 'bp_user_blogs';
 
 
72
  $bp->blogs->table_name_blogmeta = $wpdb->base_prefix . 'bp_user_blogs_blogmeta';
73
  $bp->blogs->format_notification_function = 'bp_blogs_format_notifications';
74
  $bp->blogs->slug = BP_BLOGS_SLUG;
156
  bp_core_load_template( apply_filters( 'bp_blogs_template_my_blogs', 'members/single/home' ) );
157
  }
158
 
 
 
 
 
 
 
 
 
 
 
159
  function bp_blogs_screen_create_a_blog() {
160
  global $bp;
161
 
294
  return apply_filters( 'bp_blogs_get_blogs', BP_Blogs_Blog::get( $type, $per_page, $page, $user_id, $search_terms ), &$params );
295
  }
296
 
 
297
  function bp_blogs_record_existing_blogs() {
298
  global $bp, $wpdb;
299
 
365
  if ( !$user_id )
366
  $user_id = (int)$post->post_author;
367
 
368
+ /* This is to stop infinite loops with Donncha's sitewide tags plugin */
369
  if ( (int)$bp->site_options['tags_blog_id'] == (int)$blog_id )
370
  return false;
371
 
373
  if ( $post->post_type != 'post' )
374
  return false;
375
 
376
+ if ( 'publish' == $post->post_status && '' == $post->post_password ) {
377
+ bp_blogs_update_blogmeta( $recorded_post->blog_id, 'last_activity', gmdate( "Y-m-d H:i:s" ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
378
 
379
  if ( (int)get_blog_option( $blog_id, 'blog_public' ) || !bp_core_is_multisite() ) {
380
+ /* Record this in activity streams */
381
  $post_permalink = get_permalink( $post_id );
382
 
383
  $activity_action = sprintf( __( '%s wrote a new blog post: %s', 'buddypress' ), bp_core_get_userlink( (int)$post->post_author ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>' );
392
  'item_id' => $blog_id,
393
  'secondary_item_id' => $post_id,
394
  'recorded_time' => $post->post_date_gmt
395
+ ));
396
  }
397
+ } else
398
+ bp_blogs_remove_post( $post_id, $blog_id );
399
 
400
+ do_action( 'bp_blogs_new_blog_post', $post_id, $post, $user_id );
401
  }
402
  add_action( 'save_post', 'bp_blogs_record_post', 10, 2 );
403
 
404
+ function bp_blogs_record_comment( $comment_id, $is_approved = true ) {
405
  global $wpdb, $bp;
406
 
 
 
 
407
  $comment = get_comment($comment_id);
408
  $comment->post = get_post( $comment->comment_post_ID );
409
 
418
  if ( !empty( $post->post_password ) )
419
  return false;
420
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
421
  if ( (int)get_blog_option( $recorded_comment->blog_id, 'blog_public' ) || !bp_core_is_multisite() ) {
422
  /* Record in activity streams */
423
  $comment_link = get_permalink( $comment->comment_post_ID ) . '#comment-' . $comment_id;
440
  return $recorded_comment;
441
  }
442
  add_action( 'comment_post', 'bp_blogs_record_comment', 10, 2 );
443
+ add_action( 'edit_comment', 'bp_blogs_record_comment', 10 );
444
 
445
  function bp_blogs_manage_comment( $comment_id, $comment_status ) {
446
  if ( 'spam' == $comment_status || 'hold' == $comment_status || 'delete' == $comment_status || 'trash' == $comment_status )
500
  }
501
  add_action( 'remove_user_from_blog', 'bp_blogs_remove_blog_for_user', 10, 2 );
502
 
503
+ function bp_blogs_remove_post( $post_id, $blog_id = false ) {
504
  global $current_blog, $bp;
505
 
506
  $post_id = (int)$post_id;
508
  if ( !$blog_id )
509
  $blog_id = (int)$current_blog->blog_id;
510
 
 
 
 
 
 
 
511
  // Delete activity stream item
512
  bp_blogs_delete_activity( array( 'item_id' => $blog_id, 'secondary_item_id' => $post_id, 'component' => $bp->blogs->slug, 'type' => 'new_blog_post' ) );
513
 
518
  function bp_blogs_remove_comment( $comment_id ) {
519
  global $wpdb, $bp;
520
 
 
 
 
521
  // Delete activity stream item
522
  bp_blogs_delete_activity( array( 'item_id' => $wpdb->blogid , 'secondary_item_id' => $comment_id, 'type' => 'new_blog_comment' ) );
523
 
553
 
554
  /* If this is regular blog, delete all data for that blog. */
555
  BP_Blogs_Blog::delete_blog_for_all( $blog_id );
 
 
556
 
557
  // Delete activity stream item
558
  bp_blogs_delete_activity( array( 'item_id' => $blog_id, 'component' => $bp->blogs->slug, 'type' => false ) );
565
  return BP_Blogs_Blog::get_blogs_for_user( $user_id, $show_hidden );
566
  }
567
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
568
  function bp_blogs_get_all_blogs( $limit = null, $page = null ) {
569
  return BP_Blogs_Blog::get_all( $limit, $page );
570
  }
573
  return BP_Blogs_Blog::get( 'random', $limit, $page );
574
  }
575
 
 
 
 
 
 
 
 
 
 
 
 
 
576
  function bp_blogs_is_blog_hidden( $blog_id ) {
577
  return BP_Blogs_Blog::is_hidden( $blog_id );
578
  }
689
  }
690
 
691
  function bp_blogs_remove_data( $user_id ) {
692
+ if ( !bp_core_is_multisite() )
693
+ return false;
694
+
695
  /* If this is regular blog, delete all data for that blog. */
696
  BP_Blogs_Blog::delete_blogs_for_user( $user_id );
 
 
697
 
698
  do_action( 'bp_blogs_remove_data', $user_id );
699
  }
725
  wp_cache_delete( 'bp_total_blogs', 'bp' );
726
  }
727
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
728
  // List actions to clear object caches on
729
  add_action( 'bp_blogs_remove_blog_for_user', 'bp_blogs_clear_blog_object_cache', 10, 2 );
 
 
 
730
  add_action( 'bp_blogs_new_blog', 'bp_blogs_format_clear_blog_cache', 10, 2 );
 
 
731
 
732
  // List actions to clear super cached pages on, if super cache is installed
733
  add_action( 'bp_blogs_remove_data_for_blog', 'bp_core_clear_cache' );
bp-blogs/bp-blogs-classes.php CHANGED
@@ -278,16 +278,8 @@ Class BP_Blogs_Blog {
278
  if ( empty( $blog_ids ) )
279
  return $paged_blogs;
280
 
281
- /* Fetch lastest post for each blog. */
282
- $post_ids = $wpdb->get_results( $wpdb->prepare( "SELECT p.post_id, p.blog_id FROM {$bp->blogs->table_name_blog_posts} p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND p.blog_id IN ( {$blog_ids} ) GROUP BY p.blog_id ORDER BY p.date_created DESC" ) );
283
-
284
- for ( $i = 0; $i < count( $paged_blogs ); $i++ ) {
285
- foreach ( (array)$post_ids as $post ) {
286
- if ( $post->blog_id == $paged_blogs[$i]->blog_id ) {
287
- $paged_blogs[$i]->latest_post = $wpdb->get_row( "SELECT post_title, guid FROM {$wpdb->base_prefix}" . $post->blog_id . "_posts WHERE post_status = 'publish' AND post_type = 'post' ORDER BY id DESC LIMIT 1" );
288
- }
289
- }
290
- }
291
 
292
  /* Fetch the blog description for each blog (as it may be empty we can't fetch it in the main query). */
293
  $blog_descs = $wpdb->get_results( $wpdb->prepare( "SELECT blog_id, meta_value as description FROM {$bp->blogs->table_name_blogmeta} WHERE meta_key = 'description' AND blog_id IN ( {$blog_ids} )" ) );
@@ -315,398 +307,4 @@ Class BP_Blogs_Blog {
315
  }
316
  }
317
 
318
- /* DEPRECATED - Post DB recording is scheduled for removal. Please use the activity stream to fetch a user's posts. */
319
- Class BP_Blogs_Post {
320
- var $id;
321
- var $user_id;
322
- var $blog_id;
323
- var $post_id;
324
- var $date_created;
325
-
326
- function bp_blogs_post( $id = null, $blog_id = null, $post_id = null ) {
327
- global $bp, $wpdb;
328
-
329
- if ( $id || ( !$id && $blog_id && $post_id ) ) {
330
- $this->id = $id;
331
- $this->blog_id = $blog_id;
332
- $this->post_id = $post_id;
333
- $this->populate();
334
- }
335
- }
336
-
337
- function populate() {
338
- global $wpdb, $bp;
339
-
340
- if ( $this->id )
341
- $post = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name_blog_posts} WHERE id = %d", $this->id ) );
342
- else
343
- $post = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name_blog_posts} WHERE blog_id = %d AND post_id = %d", $this->blog_id, $this->post_id ) );
344
-
345
- $this->id = $post->id;
346
- $this->user_id = $post->user_id;
347
- $this->blog_id = $post->blog_id;
348
- $this->post_id = $post->post_id;
349
- $this->date_created = $post->date_created;
350
- }
351
-
352
- function save() {
353
- global $wpdb, $bp;
354
-
355
- $this->post_id = apply_filters( 'bp_blogs_post_id_before_save', $this->post_id, $this->id );
356
- $this->blog_id = apply_filters( 'bp_blogs_post_blog_id_before_save', $this->blog_id, $this->id );
357
- $this->user_id = apply_filters( 'bp_blogs_post_user_id_before_save', $this->user_id, $this->id );
358
- $this->date_created = apply_filters( 'bp_blogs_post_date_created_before_save', $this->date_created, $this->id );
359
-
360
- do_action( 'bp_blogs_post_before_save', $this );
361
-
362
- if ( $this->id ) {
363
- // Update
364
- $sql = $wpdb->prepare( "UPDATE {$bp->blogs->table_name_blog_posts} SET post_id = %d, blog_id = %d, user_id = %d, date_created = FROM_UNIXTIME(%d) WHERE id = %d", $this->post_id, $this->blog_id, $this->user_id, $this->date_created, $this->id );
365
- } else {
366
- // Save
367
- $sql = $wpdb->prepare( "INSERT INTO {$bp->blogs->table_name_blog_posts} ( post_id, blog_id, user_id, date_created ) VALUES ( %d, %d, %d, FROM_UNIXTIME(%d) )", $this->post_id, $this->blog_id, $this->user_id, $this->date_created );
368
- }
369
-
370
- if ( !$wpdb->query($sql) )
371
- return false;
372
-
373
- do_action( 'bp_blogs_post_after_save', $this );
374
-
375
- if ( $this->id )
376
- return $this->id;
377
- else
378
- return $wpdb->insert_id;
379
- }
380
-
381
- /* Static Functions */
382
-
383
- function delete( $post_id, $blog_id ) {
384
- global $wpdb, $bp, $current_user;
385
-
386
- if ( !$bp->blogs )
387
- bp_blogs_setup_globals();
388
-
389
- return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_posts} WHERE blog_id = %d AND post_id = %d", $blog_id, $post_id ) );
390
- }
391
-
392
- function delete_oldest( $user_id = null ) {
393
- global $wpdb, $bp;
394
-
395
- if ( !$bp->blogs )
396
- bp_blogs_setup_globals();
397
-
398
- if ( !$user_id )
399
- $user_id = $current_user->ID;
400
-
401
- return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_posts} WHERE user_id = %d ORDER BY date_created ASC LIMIT 1", $user_id ) );
402
- }
403
-
404
- function delete_posts_for_user( $user_id = null ) {
405
- global $wpdb, $bp;
406
-
407
- if ( !$bp->blogs )
408
- bp_blogs_setup_globals();
409
-
410
- if ( !$user_id )
411
- $user_id = $bp->loggedin_user->id;
412
-
413
- return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_posts} WHERE user_id = %d", $user_id ) );
414
- }
415
-
416
- function delete_posts_for_blog( $blog_id ) {
417
- global $wpdb, $bp;
418
-
419
- if ( !$bp->blogs )
420
- bp_blogs_setup_globals();
421
-
422
- return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_posts} WHERE blog_id = %d", $blog_id ) );
423
- }
424
-
425
- function get_latest_posts( $blog_id = null, $limit = 5 ) {
426
- global $wpdb, $bp;
427
-
428
- if ( !$bp->blogs )
429
- bp_blogs_setup_globals();
430
-
431
- if ( $blog_id )
432
- $blog_sql = $wpdb->prepare( " AND p.blog_id = %d", $blog_id );
433
-
434
- $post_ids = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT p.post_id, p.blog_id FROM {$bp->blogs->table_name_blog_posts} p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 $blog_sql ORDER BY p.date_created DESC LIMIT $limit" ) );
435
-
436
- for ( $i = 0; $i < count($post_ids); $i++ ) {
437
- $posts[$i] = BP_Blogs_Post::fetch_post_content($post_ids[$i]);
438
- }
439
-
440
- return $posts;
441
- }
442
-
443
- function get_posts_for_user( $user_id = null ) {
444
- global $bp, $wpdb;
445
-
446
- if ( !$bp->blogs )
447
- bp_blogs_setup_globals();
448
-
449
- if ( !$user_id )
450
- $user_id = $bp->displayed_user->id;
451
-
452
- // Show a logged in user their posts on private blogs, but not anyone else.
453
- if ( !bp_is_my_profile() ) {
454
- $post_ids = $wpdb->get_results( $wpdb->prepare( "SELECT p.post_id, p.blog_id FROM {$bp->blogs->table_name_blog_posts} p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND p.user_id = %d ORDER BY p.date_created DESC", $user_id) );
455
- $total_post_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(p.post_id) FROM {$bp->blogs->table_name_blog_posts} p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND p.user_id = %d", $user_id) );
456
- } else {
457
- $post_ids = $wpdb->get_results( $wpdb->prepare( "SELECT p.post_id, p.blog_id FROM {$bp->blogs->table_name_blog_posts} p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND p.user_id = %d ORDER BY p.date_created DESC", $user_id) );
458
-
459
- $total_post_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(p.post_id) FROM {$bp->blogs->table_name_blog_posts} p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND p.user_id = %d", $user_id) );
460
- }
461
-
462
- for ( $i = 0; $i < count($post_ids); $i++ ) {
463
- $posts[$i] = BP_Blogs_Post::fetch_post_content($post_ids[$i]);
464
- }
465
-
466
- return array( 'posts' => $posts, 'count' => $total_post_count );
467
- }
468
-
469
- function fetch_post_content( $post_object ) {
470
- // TODO: switch_to_blog() calls are expensive and this needs to be changed.
471
- switch_to_blog( $post_object->blog_id );
472
- $post = get_post($post_object->post_id);
473
- $post->blog_id = $post_object->blog_id;
474
- restore_current_blog();
475
-
476
- return $post;
477
- }
478
-
479
- function get_total_recorded_for_user( $user_id = null ) {
480
- global $bp, $wpdb;
481
-
482
- if ( !$bp->blogs )
483
- bp_blogs_setup_globals();
484
-
485
- if ( !$user_id )
486
- $user_id = $current_user->ID;
487
-
488
- return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(post_id) FROM {$bp->blogs->table_name_blog_posts} WHERE user_id = %d", $user_id ) );
489
- }
490
-
491
- function is_recorded( $post_id, $blog_id, $user_id = null ) {
492
- global $bp, $wpdb, $current_user;
493
-
494
- if ( !$bp->blogs )
495
- bp_blogs_setup_globals();
496
-
497
- if ( !$user_id )
498
- $user_id = $current_user->ID;
499
-
500
- return $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM {$bp->blogs->table_name_blog_posts} WHERE post_id = %d AND blog_id = %d AND user_id = %d", $post_id, $blog_id, $user_id ) );
501
- }
502
-
503
- function total_post_count( $blog_id ) {
504
- global $bp, $wpdb;
505
-
506
- if ( !$bp->blogs )
507
- bp_blogs_setup_globals();
508
-
509
- if ( !$blog_id )
510
- return false;
511
-
512
- return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(post_id) FROM {$bp->blogs->table_name_blog_posts} WHERE blog_id = %d", $blog_id ) );
513
- }
514
-
515
- function get_all() {
516
- global $bp, $wpdb;
517
-
518
- if ( !$bp->blogs )
519
- bp_blogs_setup_globals();
520
-
521
- return $wpdb->get_col( $wpdb->prepare( "SELECT post_id, blog_id FROM " . $bp->blogs->table_name_blog_posts ) );
522
- }
523
-
524
- }
525
-
526
- /* DEPRECATED - Comment DB recording is scheduled for removal. Please use the activity stream to fetch a user's comments. */
527
- Class BP_Blogs_Comment {
528
- var $id;
529
- var $user_id;
530
- var $blog_id;
531
- var $comment_id;
532
- var $comment_post_id;
533
- var $date_created;
534
-
535
- function bp_blogs_comment( $id = false, $blog_id = false, $comment_id = false ) {
536
- global $bp, $wpdb;
537
-
538
- if ( !$user_id )
539
- $user_id = $bp->displayed_user->id;
540
-
541
- if ( $id || ( !$id && $blog_id && $comment_id ) ) {
542
- $this->id = $id;
543
- $this->blog_id = $blog_id;
544
- $this->comment_id = $comment_id;
545
- $this->populate();
546
- }
547
- }
548
-
549
- function populate() {
550
- global $wpdb, $bp;
551
-
552
- if ( $this->id )
553
- $comment = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name_blog_comments} WHERE id = %d", $this->id ) );
554
- else
555
- $comment = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name_blog_comments} WHERE blog_id = %d AND comment_id = %d", (int)$this->blog_id, (int)$this->comment_id ) );
556
-
557
- $this->comment_id = $comment->comment_id;
558
- $this->user_id = $comment->user_id;
559
- $this->blog_id = $comment->blog_id;
560
- $this->comment_post_id = $comment->comment_post_id;
561
- $this->date_created = $comment->date_created;
562
- }
563
-
564
- function save() {
565
- global $wpdb, $bp;
566
-
567
- $this->comment_id = apply_filters( 'bp_blogs_comment_id_before_save', $this->comment_id, $this->id );
568
- $this->comment_post_id = apply_filters( 'bp_blogs_comment_post_id_before_save', $this->comment_post_id, $this->id );
569
- $this->blog_id = apply_filters( 'bp_blogs_comment_blog_id_before_save', $this->blog_id, $this->id );
570
- $this->user_id = apply_filters( 'bp_blogs_comment_user_id_before_save', $this->user_id, $this->id );
571
- $this->date_created = apply_filters( 'bp_blogs_comment_date_created_before_save', $this->date_created, $this->id );
572
-
573
- do_action( 'bp_blogs_comment_before_save', $this );
574
-
575
- if ( $this->id ) {
576
- // Update
577
- $sql = $wpdb->prepare( "UPDATE {$bp->blogs->table_name_blog_comments} SET comment_id = %d, comment_post_id = %d, blog_id = %d, user_id = %d, date_created = FROM_UNIXTIME(%d) WHERE id = %d", $this->comment_id, $this->comment_post_id, $this->blog_id, $this->user_id, $this->date_created, $this->id );
578
- } else {
579
- // Save
580
- $sql = $wpdb->prepare( "INSERT INTO {$bp->blogs->table_name_blog_comments} ( comment_id, comment_post_id, blog_id, user_id, date_created ) VALUES ( %d, %d, %d, %d, FROM_UNIXTIME(%d) )", $this->comment_id, $this->comment_post_id, $this->blog_id, $this->user_id, $this->date_created );
581
- }
582
-
583
- if ( !$wpdb->query($sql) )
584
- return false;
585
-
586
- do_action( 'bp_blogs_comment_after_save', $this );
587
-
588
- if ( $this->id )
589
- return $this->id;
590
- else
591
- return $wpdb->insert_id;
592
- }
593
-
594
- /* Static Functions */
595
-
596
- function delete( $comment_id, $blog_id ) {
597
- global $wpdb, $bp, $current_user;
598
-
599
- if ( !$bp->blogs )
600
- bp_blogs_setup_globals();
601
-
602
- return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_comments} WHERE comment_id = %d AND blog_id = %d", $comment_id, $blog_id ) );
603
- }
604
-
605
- function delete_oldest( $user_id = null ) {
606
- global $wpdb, $bp, $current_user;
607
-
608
- if ( !$bp->blogs )
609
- bp_blogs_setup_globals();
610
-
611
- if ( !$user_id )
612
- $user_id = $current_user->ID;
613
-
614
- return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_comments} WHERE user_id = %d ORDER BY date_created ASC LIMIT 1", $user_id ) );
615
- }
616
-
617
- function delete_comments_for_user( $user_id = null ) {
618
- global $wpdb, $bp;
619
-
620
- if ( !$bp->blogs )
621
- bp_blogs_setup_globals();
622
-
623
- if ( !$user_id )
624
- $user_id = $bp->loggedin_user->id;
625
-
626
- return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_comments} WHERE user_id = %d", $user_id ) );
627
- }
628
-
629
- function delete_comments_for_blog( $blog_id ) {
630
- global $wpdb, $bp;
631
-
632
- if ( !$bp->blogs )
633
- bp_blogs_setup_globals();
634
-
635
- return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_comments} WHERE blog_id = %d", $blog_id ) );
636
- }
637
-
638
- function get_comments_for_user( $user_id = null ) {
639
- global $bp, $wpdb;
640
-
641
- if ( !$bp->blogs )
642
- bp_blogs_setup_globals();
643
-
644
- if ( !$user_id )
645
- $user_id = $bp->displayed_user->id;
646
-
647
- // Show the logged in user their comments on hidden blogs, but not to anyone else.
648
- if ( !bp_is_my_profile() ) {
649
- $comment_ids = $wpdb->get_results( $wpdb->prepare( "SELECT c.comment_id, c.blog_id FROM {$bp->blogs->table_name_blog_comments} c LEFT JOIN {$wpdb->base_prefix}blogs b ON c.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND c.user_id = %d ORDER BY c.date_created ASC", $user_id) );
650
- $total_comment_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(c.comment_id) FROM {$bp->blogs->table_name_blog_comments} c LEFT JOIN {$wpdb->base_prefix}blogs b ON c.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND c.user_id = %d", $user_id) );
651
- } else {
652
- $comment_ids = $wpdb->get_results( $wpdb->prepare( "SELECT c.comment_id, c.blog_id FROM {$bp->blogs->table_name_blog_comments} c LEFT JOIN {$wpdb->base_prefix}blogs b ON c.blog_id = b.blog_id WHERE b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND c.user_id = %d ORDER BY c.date_created ASC", $user_id) );
653
-
654
- $total_comment_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(c.comment_id) FROM {$bp->blogs->table_name_blog_comments} c LEFT JOIN {$wpdb->base_prefix}blogs b ON c.blog_id = b.blog_id WHERE b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND c.user_id = %d", $user_id) );
655
- }
656
-
657
- for ( $i = 0; $i < count($comment_ids); $i++ )
658
- $comments[$i] = BP_Blogs_Comment::fetch_comment_content($comment_ids[$i]);
659
-
660
- return array( 'comments' => $comments, 'count' => $total_comment_count );
661
- }
662
-
663
- function fetch_comment_content( $comment_object ) {
664
- switch_to_blog($comment_object->blog_id);
665
- $comment = get_comment($comment_object->comment_id);
666
- $comment->blog_id = $comment_object->blog_id;
667
- $comment->post = &get_post( $comment->comment_post_ID );
668
- restore_current_blog();
669
-
670
- return $comment;
671
- }
672
-
673
- function get_total_recorded_for_user( $user_id = null ) {
674
- global $bp, $wpdb, $current_user;
675
-
676
- if ( !$bp->blogs )
677
- bp_blogs_setup_globals();
678
-
679
- if ( !$user_id )
680
- $user_id = $current_user->ID;
681
-
682
- return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(comment_id) FROM {$bp->blogs->table_name_blog_comments} WHERE user_id = %d", $user_id ) );
683
- }
684
-
685
- function total_comment_count( $blog_id, $post_id ) {
686
- global $bp, $wpdb;
687
-
688
- if ( !$bp->blogs )
689
- bp_blogs_setup_globals();
690
-
691
- if ( $post_id )
692
- $post_sql = $wpdb->prepare( " AND comment_post_id = %d", $post_id );
693
-
694
- return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(comment_id) WHERE blog_id = %d{$post_sql}", $blog_id ) );
695
- }
696
-
697
-
698
- function is_recorded( $comment_id, $comment_post_id, $blog_id, $user_id = null ) {
699
- global $bp, $wpdb, $current_user;
700
-
701
- if ( !$bp->blogs )
702
- bp_blogs_setup_globals();
703
-
704
- if ( !$user_id )
705
- $user_id = $current_user->ID;
706
-
707
- return $wpdb->get_var( $wpdb->prepare( "SELECT comment_id FROM {$bp->blogs->table_name_blog_comments} WHERE comment_id = %d AND blog_id = %d AND comment_post_id = %d AND user_id = %d", $comment_id, $blog_id, $comment_post_id, $user_id ) );
708
- }
709
-
710
- }
711
-
712
  ?>
278
  if ( empty( $blog_ids ) )
279
  return $paged_blogs;
280
 
281
+ for ( $i = 0; $i < count( $paged_blogs ); $i++ )
282
+ $paged_blogs[$i]->latest_post = $wpdb->get_row( "SELECT post_title, guid FROM {$wpdb->base_prefix}" . $paged_blogs[$i]->blog_id . "_posts WHERE post_status = 'publish' AND post_type = 'post' AND id != 1 ORDER BY id DESC LIMIT 1" );
 
 
 
 
 
 
 
 
283
 
284
  /* Fetch the blog description for each blog (as it may be empty we can't fetch it in the main query). */
285
  $blog_descs = $wpdb->get_results( $wpdb->prepare( "SELECT blog_id, meta_value as description FROM {$bp->blogs->table_name_blogmeta} WHERE meta_key = 'description' AND blog_id IN ( {$blog_ids} )" ) );
307
  }
308
  }
309
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
310
  ?>
bp-blogs/bp-blogs-templatetags.php CHANGED
@@ -144,7 +144,7 @@ function bp_has_blogs( $args = '' ) {
144
  }
145
 
146
  $blogs_template = new BP_Blogs_Template( $type, $page, $per_page, $max, $user_id, $search_terms );
147
- return $blogs_template->has_blogs();
148
  }
149
 
150
  function bp_blogs() {
@@ -467,7 +467,7 @@ function bp_create_blog_link() {
467
  global $bp;
468
 
469
  if ( bp_is_my_profile() ) {
470
- echo apply_filters( 'bp_create_blog_link', '<a href="' . $bp->loggedin_user->domain . $bp->blogs->slug . '/create-a-blog">' . __('Create a Blog', 'buddypress') . '</a>' );
471
  }
472
  }
473
 
144
  }
145
 
146
  $blogs_template = new BP_Blogs_Template( $type, $page, $per_page, $max, $user_id, $search_terms );
147
+ return apply_filters( 'bp_has_blogs', $blogs_template->has_blogs(), &$blogs_template );
148
  }
149
 
150
  function bp_blogs() {
467
  global $bp;
468
 
469
  if ( bp_is_my_profile() ) {
470
+ echo apply_filters( 'bp_create_blog_link', '<a href="' . $bp->root_domain . '/' . $bp->blogs->slug . '/create">' . __('Create a Blog', 'buddypress') . '</a>' );
471
  }
472
  }
473
 
bp-core.php CHANGED
@@ -32,6 +32,7 @@ if ( !defined( 'CUSTOM_USER_META_TABLE' ) )
32
  /* Load the files containing functions that we globally will need. */
33
  require ( BP_PLUGIN_DIR . '/bp-core/bp-core-catchuri.php' );
34
  require ( BP_PLUGIN_DIR . '/bp-core/bp-core-classes.php' );
 
35
  require ( BP_PLUGIN_DIR . '/bp-core/bp-core-cssjs.php' );
36
  require ( BP_PLUGIN_DIR . '/bp-core/bp-core-avatars.php' );
37
  require ( BP_PLUGIN_DIR . '/bp-core/bp-core-templatetags.php' );
@@ -40,10 +41,6 @@ require ( BP_PLUGIN_DIR . '/bp-core/bp-core-widgets.php' );
40
  require ( BP_PLUGIN_DIR . '/bp-core/bp-core-notifications.php' );
41
  require ( BP_PLUGIN_DIR . '/bp-core/bp-core-signup.php' );
42
 
43
- /* Multisite includes built in account activation support. */
44
- if ( bp_core_is_multisite() )
45
- require ( BP_PLUGIN_DIR . '/bp-core/bp-core-activation.php' );
46
-
47
  /* If BP_DISABLE_ADMIN_BAR is defined, do not load the global admin bar. */
48
  if ( !defined( 'BP_DISABLE_ADMIN_BAR' ) )
49
  require ( BP_PLUGIN_DIR . '/bp-core/bp-core-adminbar.php' );
@@ -1664,37 +1661,6 @@ function bp_core_add_illegal_names() {
1664
  update_site_option( 'illegal_names', $new );
1665
  }
1666
 
1667
- /**
1668
- * bp_core_email_from_name_filter()
1669
- *
1670
- * Sets the "From" name in emails sent to the name of the site and not "WordPress"
1671
- *
1672
- * @package BuddyPress Core
1673
- * @uses get_blog_option() fetches the value for a meta_key in the wp_X_options table
1674
- * @return The blog name for the root blog
1675
- */
1676
- function bp_core_email_from_name_filter() {
1677
- return apply_filters( 'bp_core_email_from_name_filter', get_blog_option( BP_ROOT_BLOG, 'blogname' ) );
1678
- }
1679
- add_filter( 'wp_mail_from_name', 'bp_core_email_from_name_filter' );
1680
-
1681
-
1682
- /**
1683
- * bp_core_email_from_name_filter()
1684
- *
1685
- * Sets the "From" address in emails sent
1686
- *
1687
- * @package BuddyPress Core
1688
- * @global $current_site Object containing current site metadata
1689
- * @return noreply@sitedomain email address
1690
- */
1691
- function bp_core_email_from_address_filter() {
1692
- $domain = (array) explode( '/', site_url() );
1693
-
1694
- return apply_filters( 'bp_core_email_from_address_filter', __( 'noreply', 'buddypress' ) . '@' . $domain[2] );
1695
- }
1696
- add_filter( 'wp_mail_from', 'bp_core_email_from_address_filter' );
1697
-
1698
  /**
1699
  * bp_core_delete_account()
1700
  *
@@ -1970,48 +1936,6 @@ function bp_core_update_message() {
1970
  }
1971
  add_action( 'in_plugin_update_message-buddypress/bp-loader.php', 'bp_core_update_message' );
1972
 
1973
- /**
1974
- * bp_core_filter_parent_theme()
1975
- *
1976
- * Remove social network parent theme from the theme list.
1977
- *
1978
- * @package BuddyPress Core
1979
- */
1980
- function bp_core_filter_parent_theme() {
1981
- global $wp_themes, $pagenow;
1982
-
1983
- if ( is_admin() && 'themes.php' == $pagenow )
1984
- $wp_themes = get_themes();
1985
-
1986
- unset( $wp_themes['BuddyPress Classic Parent'] );
1987
- }
1988
- add_filter( 'admin_menu', 'bp_core_filter_parent_theme' );
1989
-
1990
- /**
1991
- * bp_core_allow_default_theme()
1992
- *
1993
- * On multiblog installations you must first allow themes to be activated and show
1994
- * up on the theme selection screen. This function will let the BuddyPress bundled
1995
- * themes show up on the root blog selection screen and bypass this step. It also
1996
- * means that the themes won't show for selection on other blogs.
1997
- *
1998
- * @package BuddyPress Core
1999
- */
2000
- function bp_core_allow_default_theme( $themes ) {
2001
- global $bp, $current_blog;
2002
-
2003
- if ( !is_site_admin() )
2004
- return $themes;
2005
-
2006
- if ( $current_blog->ID == $bp->root_blog ) {
2007
- $themes['bp-default'] = 1;
2008
- $themes['bp-classic'] = 1;
2009
- }
2010
-
2011
- return $themes;
2012
- }
2013
- add_filter( 'allowed_themes', 'bp_core_allow_default_theme' );
2014
-
2015
  /**
2016
  * bp_core_activation_notice()
2017
  *
@@ -2053,67 +1977,6 @@ function bp_core_activation_notice() {
2053
  }
2054
  add_action( 'admin_notices', 'bp_core_activation_notice' );
2055
 
2056
- /**
2057
- * bp_core_filter_comments()
2058
- *
2059
- * Filter the blog post comments array and insert BuddyPress URLs for users.
2060
- *
2061
- * @package BuddyPress Core
2062
- */
2063
- function bp_core_filter_comments( $comments, $post_id ) {
2064
- global $wpdb;
2065
-
2066
- foreach( (array)$comments as $comment ) {
2067
- if ( $comment->user_id )
2068
- $user_ids[] = $comment->user_id;
2069
- }
2070
-
2071
- if ( empty( $user_ids ) )
2072
- return $comments;
2073
-
2074
- $user_ids = implode( ',', $user_ids );
2075
-
2076
- if ( !$userdata = $wpdb->get_results( $wpdb->prepare( "SELECT ID as user_id, user_login, user_nicename FROM {$wpdb->users} WHERE ID IN ({$user_ids})" ) ) )
2077
- return $comments;
2078
-
2079
- foreach( (array)$userdata as $user )
2080
- $users[$user->user_id] = bp_core_get_user_domain( $user->user_id, $user->user_nicename, $user->user_login );
2081
-
2082
- foreach( (array)$comments as $i => $comment ) {
2083
- if ( !empty( $comment->user_id ) ) {
2084
- if ( !empty( $users[$comment->user_id] ) )
2085
- $comments[$i]->comment_author_url = $users[$comment->user_id];
2086
- }
2087
- }
2088
-
2089
- return $comments;
2090
- }
2091
- add_filter( 'comments_array', 'bp_core_filter_comments', 10, 2 );
2092
-
2093
- /**
2094
- * bp_core_login_redirect()
2095
- *
2096
- * When a user logs in, always redirect them back to the previous page. NOT the admin area.
2097
- *
2098
- * @package BuddyPress Core
2099
- */
2100
- function bp_core_login_redirect( $redirect_to ) {
2101
- global $bp, $current_blog;
2102
-
2103
- if ( bp_core_is_multisite() && $current_blog->blog_id != BP_ROOT_BLOG )
2104
- return $redirect_to;
2105
-
2106
- if ( !empty( $_REQUEST['redirect_to'] ) && strpos( $_REQUEST['redirect_to'], 'wp-admin' ) )
2107
- return $redirect_to;
2108
-
2109
- if ( false === strpos( wp_get_referer(), 'wp-login.php' ) && false === strpos( wp_get_referer(), 'activate' ) && empty( $_REQUEST['nr'] ) )
2110
- return wp_get_referer();
2111
-
2112
- return $bp->root_domain;
2113
- }
2114
- add_filter( 'login_redirect', 'bp_core_login_redirect' );
2115
-
2116
-
2117
  /********************************************************************************
2118
  * Custom Actions
2119
  *
32
  /* Load the files containing functions that we globally will need. */
33
  require ( BP_PLUGIN_DIR . '/bp-core/bp-core-catchuri.php' );
34
  require ( BP_PLUGIN_DIR . '/bp-core/bp-core-classes.php' );
35
+ require ( BP_PLUGIN_DIR . '/bp-core/bp-core-filters.php' );
36
  require ( BP_PLUGIN_DIR . '/bp-core/bp-core-cssjs.php' );
37
  require ( BP_PLUGIN_DIR . '/bp-core/bp-core-avatars.php' );
38
  require ( BP_PLUGIN_DIR . '/bp-core/bp-core-templatetags.php' );
41
  require ( BP_PLUGIN_DIR . '/bp-core/bp-core-notifications.php' );
42
  require ( BP_PLUGIN_DIR . '/bp-core/bp-core-signup.php' );
43
 
 
 
 
 
44
  /* If BP_DISABLE_ADMIN_BAR is defined, do not load the global admin bar. */
45
  if ( !defined( 'BP_DISABLE_ADMIN_BAR' ) )
46
  require ( BP_PLUGIN_DIR . '/bp-core/bp-core-adminbar.php' );
1661
  update_site_option( 'illegal_names', $new );
1662
  }
1663
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1664
  /**
1665
  * bp_core_delete_account()
1666
  *
1936
  }
1937
  add_action( 'in_plugin_update_message-buddypress/bp-loader.php', 'bp_core_update_message' );
1938
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1939
  /**
1940
  * bp_core_activation_notice()
1941
  *
1977
  }
1978
  add_action( 'admin_notices', 'bp_core_activation_notice' );
1979
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1980
  /********************************************************************************
1981
  * Custom Actions
1982
  *
bp-core/bp-core-cssjs.php CHANGED
@@ -47,7 +47,7 @@ add_action( 'admin_head', 'bp_core_admin_menu_icon_css' );
47
  function bp_core_confirmation_js() {
48
  global $current_blog;
49
 
50
- if ( $current_blog->blog_id != BP_ROOT_BLOG )
51
  return false;
52
  ?>
53
  <script type="text/javascript"> jQuery(document).ready( function() { jQuery("a.confirm").click( function() { if ( confirm( '<?php _e( 'Are you sure?', 'buddypress' ) ?>' ) ) return true; else return false; }); });</script>
47
  function bp_core_confirmation_js() {
48
  global $current_blog;
49
 
50
+ if ( bp_core_is_multisite() && $current_blog->blog_id != BP_ROOT_BLOG )
51
  return false;
52
  ?>
53
  <script type="text/javascript"> jQuery(document).ready( function() { jQuery("a.confirm").click( function() { if ( confirm( '<?php _e( 'Are you sure?', 'buddypress' ) ?>' ) ) return true; else return false; }); });</script>
bp-core/{bp-core-activation.php → bp-core-filters.php} RENAMED
@@ -1,79 +1,118 @@
1
  <?php
2
 
3
- function bp_core_screen_activation() {
4
- global $bp, $wpdb;
 
 
 
 
 
 
 
 
 
 
 
5
 
6
- if ( !bp_core_is_multisite() || BP_ACTIVATION_SLUG != $bp->current_component )
7
- return false;
 
 
 
 
 
 
 
 
 
8
 
9
- /* Check if an activation key has been passed */
10
- if ( isset( $_GET['key'] ) ) {
 
11
 
12
- require_once( ABSPATH . WPINC . '/registration.php' );
 
 
 
 
 
 
 
 
 
 
 
13
 
14
- /* Activate the signup */
15
- $signup = apply_filters( 'bp_core_activate_account', wpmu_activate_signup( $_GET['key'] ) );
16
 
17
- /* If there was errors, add a message and redirect */
18
- if ( $signup->errors ) {
19
- bp_core_add_message( __( 'There was an error activating your account, please try again.', 'buddypress' ), 'error' );
20
- bp_core_redirect( $bp->root_domain . '/' . BP_ACTIVATION_SLUG );
21
- }
22
 
23
- /* Set the password */
24
- if ( !empty( $signup['meta']['password'] ) )
25
- $wpdb->update( $wpdb->users, array( 'user_pass' => $signup['meta']['password'] ), array( 'ID' => $signup['user_id'] ), array( '%s' ), array( '%d' ) );
26
 
27
- /* Set any profile data */
28
- if ( function_exists( 'xprofile_set_field_data' ) ) {
 
 
 
 
 
 
 
29
 
30
- if ( !empty( $signup['meta']['profile_field_ids'] ) ) {
31
- $profile_field_ids = explode( ',', $signup['meta']['profile_field_ids'] );
 
 
32
 
33
- foreach( (array)$profile_field_ids as $field_id ) {
34
- $current_field = $signup['meta']["field_{$field_id}"];
35
 
36
- if ( !empty( $current_field ) )
37
- xprofile_set_field_data( $field_id, $signup['user_id'], $current_field );
38
- }
39
- }
40
 
41
- }
 
42
 
43
- /* Check for an uploaded avatar and move that to the correct user folder */
44
- $hashed_key = wp_hash( $_GET['key'] );
45
 
46
- /* Check if the avatar folder exists. If it does, move rename it, move it and delete the signup avatar dir */
47
- if ( file_exists( BP_AVATAR_UPLOAD_PATH . '/avatars/signups/' . $hashed_key ) ) {
48
- @rename( BP_AVATAR_UPLOAD_PATH . '/avatars/signups/' . $hashed_key, BP_AVATAR_UPLOAD_PATH . '/avatars/' . $signup['user_id'] );
 
49
  }
 
50
 
51
- /* Record the new user in the activity streams */
52
- if ( function_exists( 'bp_activity_add' ) ) {
53
- $userlink = bp_core_get_userlink( $signup['user_id'] );
54
 
55
- bp_activity_add( array(
56
- 'user_id' => $signup['user_id'],
57
- 'action' => apply_filters( 'bp_core_activity_registered_member_action', sprintf( __( '%s became a registered member', 'buddypress' ), $userlink ), $signup['user_id'] ),
58
- 'component' => 'profile',
59
- 'type' => 'new_member'
60
- ) );
61
- }
 
 
62
 
63
- do_action( 'bp_core_account_activated', &$signup, $_GET['key'] );
64
- wp_cache_delete( 'bp_total_member_count', 'bp' );
65
 
66
- bp_core_add_message( __( 'Your account is now active!', 'buddypress' ) );
 
67
 
68
- $bp->activation_complete = true;
69
- }
70
 
71
- if ( '' != locate_template( array( 'registration/activate' ), false ) )
72
- bp_core_load_template( apply_filters( 'bp_core_template_activate', 'activate' ) );
73
- else
74
- bp_core_load_template( apply_filters( 'bp_core_template_activate', 'registration/activate' ) );
75
  }
76
- add_action( 'wp', 'bp_core_screen_activation', 3 );
77
 
78
  /***
79
  * bp_core_filter_user_welcome_email()
1
  <?php
2
 
3
+ /**
4
+ * bp_core_email_from_name_filter()
5
+ *
6
+ * Sets the "From" name in emails sent to the name of the site and not "WordPress"
7
+ *
8
+ * @package BuddyPress Core
9
+ * @uses get_blog_option() fetches the value for a meta_key in the wp_X_options table
10
+ * @return The blog name for the root blog
11
+ */
12
+ function bp_core_email_from_name_filter() {
13
+ return apply_filters( 'bp_core_email_from_name_filter', get_blog_option( BP_ROOT_BLOG, 'blogname' ) );
14
+ }
15
+ add_filter( 'wp_mail_from_name', 'bp_core_email_from_name_filter' );
16
 
17
+ /**
18
+ * bp_core_email_from_name_filter()
19
+ *
20
+ * Sets the "From" address in emails sent
21
+ *
22
+ * @package BuddyPress Core
23
+ * @global $current_site Object containing current site metadata
24
+ * @return noreply@sitedomain email address
25
+ */
26
+ function bp_core_email_from_address_filter() {
27
+ $domain = (array) explode( '/', site_url() );
28
 
29
+ return apply_filters( 'bp_core_email_from_address_filter', __( 'noreply', 'buddypress' ) . '@' . $domain[2] );
30
+ }
31
+ add_filter( 'wp_mail_from', 'bp_core_email_from_address_filter' );
32
 
33
+ /**
34
+ * bp_core_allow_default_theme()
35
+ *
36
+ * On multiblog installations you must first allow themes to be activated and show
37
+ * up on the theme selection screen. This function will let the BuddyPress bundled
38
+ * themes show up on the root blog selection screen and bypass this step. It also
39
+ * means that the themes won't show for selection on other blogs.
40
+ *
41
+ * @package BuddyPress Core
42
+ */
43
+ function bp_core_allow_default_theme( $themes ) {
44
+ global $bp, $current_blog;
45
 
46
+ if ( !is_site_admin() )
47
+ return $themes;
48
 
49
+ if ( $current_blog->ID == $bp->root_blog ) {
50
+ $themes['bp-default'] = 1;
51
+ }
 
 
52
 
53
+ return $themes;
54
+ }
55
+ add_filter( 'allowed_themes', 'bp_core_allow_default_theme' );
56
 
57
+ /**
58
+ * bp_core_filter_comments()
59
+ *
60
+ * Filter the blog post comments array and insert BuddyPress URLs for users.
61
+ *
62
+ * @package BuddyPress Core
63
+ */
64
+ function bp_core_filter_comments( $comments, $post_id ) {
65
+ global $wpdb;
66
 
67
+ foreach( (array)$comments as $comment ) {
68
+ if ( $comment->user_id )
69
+ $user_ids[] = $comment->user_id;
70
+ }
71
 
72
+ if ( empty( $user_ids ) )
73
+ return $comments;
74
 
75
+ $user_ids = implode( ',', $user_ids );
 
 
 
76
 
77
+ if ( !$userdata = $wpdb->get_results( $wpdb->prepare( "SELECT ID as user_id, user_login, user_nicename FROM {$wpdb->users} WHERE ID IN ({$user_ids})" ) ) )
78
+ return $comments;
79
 
80
+ foreach( (array)$userdata as $user )
81
+ $users[$user->user_id] = bp_core_get_user_domain( $user->user_id, $user->user_nicename, $user->user_login );
82
 
83
+ foreach( (array)$comments as $i => $comment ) {
84
+ if ( !empty( $comment->user_id ) ) {
85
+ if ( !empty( $users[$comment->user_id] ) )
86
+ $comments[$i]->comment_author_url = $users[$comment->user_id];
87
  }
88
+ }
89
 
90
+ return $comments;
91
+ }
92
+ add_filter( 'comments_array', 'bp_core_filter_comments', 10, 2 );
93
 
94
+ /**
95
+ * bp_core_login_redirect()
96
+ *
97
+ * When a user logs in, always redirect them back to the previous page. NOT the admin area.
98
+ *
99
+ * @package BuddyPress Core
100
+ */
101
+ function bp_core_login_redirect( $redirect_to ) {
102
+ global $bp, $current_blog;
103
 
104
+ if ( bp_core_is_multisite() && $current_blog->blog_id != BP_ROOT_BLOG )
105
+ return $redirect_to;
106
 
107
+ if ( !empty( $_REQUEST['redirect_to'] ) || strpos( $_REQUEST['redirect_to'], 'wp-admin' ) )
108
+ return $redirect_to;
109
 
110
+ if ( false === strpos( wp_get_referer(), 'wp-login.php' ) && false === strpos( wp_get_referer(), 'activate' ) && empty( $_REQUEST['nr'] ) )
111
+ return wp_get_referer();
112
 
113
+ return $bp->root_domain;
 
 
 
114
  }
115
+ add_filter( 'login_redirect', 'bp_core_login_redirect' );
116
 
117
  /***
118
  * bp_core_filter_user_welcome_email()
bp-core/bp-core-signup.php CHANGED
@@ -1,5 +1,13 @@
1
  <?php
2
 
 
 
 
 
 
 
 
 
3
  function bp_core_screen_signup() {
4
  global $bp, $wpdb;
5
 
@@ -10,13 +18,6 @@ function bp_core_screen_signup() {
10
  if ( is_user_logged_in() )
11
  bp_core_redirect( $bp->root_domain );
12
 
13
- /***
14
- * For backwards compatibility with the old pre 1.1 two theme system, skip this screen function
15
- * if the user is using the old two theme method.
16
- */
17
- if ( file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
18
- return false;
19
-
20
  /* If signups are disabled, just re-direct */
21
  if ( !bp_get_signup_allowed() )
22
  bp_core_redirect( $bp->root_domain );
@@ -32,7 +33,7 @@ function bp_core_screen_signup() {
32
  require_once( ABSPATH . WPINC . '/registration.php' );
33
 
34
  /* Check the base account details for problems */
35
- $account_details = wpmu_validate_user_signup( $_POST['signup_username'], $_POST['signup_email'] );
36
 
37
  /* If there are errors with account details, set them for display */
38
  if ( !empty( $account_details['errors']->errors['user_name'] ) )
@@ -73,7 +74,7 @@ function bp_core_screen_signup() {
73
  $active_signup = $bp->site_options['registration'];
74
 
75
  if ( 'blog' == $active_signup || 'all' == $active_signup ) {
76
- $blog_details = wpmu_validate_blog_signup( $_POST['signup_blog_url'], $_POST['signup_blog_title'] );
77
 
78
  /* If there are errors with blog details, set them for display */
79
  if ( !empty( $blog_details['errors']->errors['blogname'] ) )
@@ -125,9 +126,9 @@ function bp_core_screen_signup() {
125
 
126
  $usermeta = apply_filters( 'bp_signup_usermeta', $usermeta );
127
 
128
- /* Finally, sign up the user and/or blog*/
129
  if ( isset( $_POST['signup_with_blog'] ) && bp_core_is_multisite() )
130
- wpmu_signup_blog( $blog_details['domain'], $blog_details['path'], $blog_details['blog_title'], $_POST['signup_username'], $_POST['signup_email'], $usermeta );
131
  else {
132
  bp_core_signup_user( $_POST['signup_username'], $_POST['signup_password'], $_POST['signup_email'], $usermeta );
133
  }
@@ -158,8 +159,10 @@ function bp_core_screen_signup() {
158
  /* Hash the key to create the upload folder (added security so people don't sniff the activation key) */
159
  $bp->signup->avatar_dir = wp_hash( $bp->signup->key );
160
  }
161
- } else
162
- $bp->signup->avatar_dir = wp_hash( $bp->signup->username );
 
 
163
 
164
  /* Pass the file to the avatar upload handler */
165
  if ( bp_core_avatar_handle_upload( $_FILES, 'bp_core_signup_avatar_upload_dir' ) ) {
@@ -184,59 +187,285 @@ function bp_core_screen_signup() {
184
  bp_core_add_message( __( 'There was a problem cropping your avatar, please try uploading it again', 'buddypress' ), 'error' );
185
  else
186
  bp_core_add_message( __( 'Your new avatar was uploaded successfully', 'buddypress' ) );
 
 
 
 
187
 
188
- /* If this is a single WP install, move the avatar to the user's folder since there is no activation process to move it. */
189
- if ( !bp_core_is_multisite() ) {
190
- $user_id = bp_core_get_userid( $_POST['signup_username'] );
191
 
192
- if ( !empty( $user_id ) && file_exists( BP_AVATAR_UPLOAD_PATH . '/avatars/signups/' . $_POST['signup_avatar_dir'] ) ) {
193
- @rename( BP_AVATAR_UPLOAD_PATH . '/avatars/signups/' . $_POST['signup_avatar_dir'], BP_AVATAR_UPLOAD_PATH . '/avatars/' . $user_id );
194
- }
 
 
 
 
 
 
 
 
 
 
 
 
195
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
196
  }
197
- bp_core_load_template( 'registration/register' );
 
 
 
 
198
  }
199
- add_action( 'wp', 'bp_core_screen_signup', 3 );
200
 
201
- function bp_core_signup_user( $user_login, $user_password, $user_email, $usermeta ) {
202
- global $bp;
203
 
204
- if ( bp_core_is_multisite() )
205
- return wpmu_signup_user( $user_login, $user_email, $usermeta );
 
 
 
 
 
 
 
 
 
206
 
207
  $errors = new WP_Error();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
208
 
209
- $user_id = wp_create_user( $user_login, $user_password, $user_email );
210
- if ( !$user_id ) {
211
- $errors->add('registerfail', sprintf(__('<strong>ERROR</strong>: Couldn&#8217;t register you... please contact the <a href="mailto:%s">webmaster</a> !'), get_option('admin_email')));
212
- return $errors;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
213
  }
214
 
215
- /* Set any profile data */
216
- if ( function_exists( 'xprofile_set_field_data' ) ) {
217
- if ( !empty( $usermeta['profile_field_ids'] ) ) {
218
- $profile_field_ids = explode( ',', $usermeta['profile_field_ids'] );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
219
 
220
- foreach( (array)$profile_field_ids as $field_id ) {
221
- $current_field = $usermeta["field_{$field_id}"];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
222
 
223
- if ( !empty( $current_field ) )
224
- xprofile_set_field_data( $field_id, $user_id, $current_field );
 
225
  }
226
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
227
  }
228
 
 
 
 
229
  /* Add a last active entry */
230
  update_usermeta( $user_id, 'last_activity', gmdate( "Y-m-d H:i:s" ) );
231
 
232
- wp_new_user_notification( $user_id, $user_pass );
 
 
 
 
233
  wp_cache_delete( 'bp_total_member_count', 'bp' );
234
 
235
- $bp->signup->username = $user_login;
236
 
237
  return $user_id;
238
  }
239
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
240
  function bp_core_map_user_registration( $user_id ) {
241
  /* Only map data when the site admin is adding users, not on registration. */
242
  if ( !is_admin() )
@@ -278,6 +507,43 @@ function bp_core_signup_avatar_upload_dir() {
278
  return apply_filters( 'bp_core_signup_avatar_upload_dir', array( 'path' => $path, 'url' => $newurl, 'subdir' => $newsubdir, 'basedir' => $newbdir, 'baseurl' => $newburl, 'error' => false ) );
279
  }
280
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
281
  /* Kill the wp-signup.php if custom registration signup templates are present */
282
  function bp_core_wpsignup_redirect() {
283
  if ( false === strpos( $_SERVER['SCRIPT_NAME'], 'wp-signup.php') && $_GET['action'] != 'register' )
1
  <?php
2
 
3
+ /********************************************************************************
4
+ * Screen Functions
5
+ *
6
+ * Screen functions are the controllers of BuddyPress. They will execute when their
7
+ * specific URL is caught. They will first save or manipulate data using business
8
+ * functions, then pass on the user to a template file.
9
+ */
10
+
11
  function bp_core_screen_signup() {
12
  global $bp, $wpdb;
13
 
18
  if ( is_user_logged_in() )
19
  bp_core_redirect( $bp->root_domain );
20
 
 
 
 
 
 
 
 
21
  /* If signups are disabled, just re-direct */
22
  if ( !bp_get_signup_allowed() )
23
  bp_core_redirect( $bp->root_domain );
33
  require_once( ABSPATH . WPINC . '/registration.php' );
34
 
35
  /* Check the base account details for problems */
36
+ $account_details = bp_core_validate_user_signup( $_POST['signup_username'], $_POST['signup_email'] );
37
 
38
  /* If there are errors with account details, set them for display */
39
  if ( !empty( $account_details['errors']->errors['user_name'] ) )
74
  $active_signup = $bp->site_options['registration'];
75
 
76
  if ( 'blog' == $active_signup || 'all' == $active_signup ) {
77
+ $blog_details = bp_core_validate_blog_signup( $_POST['signup_blog_url'], $_POST['signup_blog_title'] );
78
 
79
  /* If there are errors with blog details, set them for display */
80
  if ( !empty( $blog_details['errors']->errors['blogname'] ) )
126
 
127
  $usermeta = apply_filters( 'bp_signup_usermeta', $usermeta );
128
 
129
+ /* Finally, sign up the user and/or blog */
130
  if ( isset( $_POST['signup_with_blog'] ) && bp_core_is_multisite() )
131
+ bp_core_signup_blog( $blog_details['domain'], $blog_details['path'], $blog_details['blog_title'], $_POST['signup_username'], $_POST['signup_email'], $usermeta );
132
  else {
133
  bp_core_signup_user( $_POST['signup_username'], $_POST['signup_password'], $_POST['signup_email'], $usermeta );
134
  }
159
  /* Hash the key to create the upload folder (added security so people don't sniff the activation key) */
160
  $bp->signup->avatar_dir = wp_hash( $bp->signup->key );
161
  }
162
+ } else {
163
+ $user_id = bp_core_get_userid( $_POST['signup_username'] );
164
+ $bp->signup->avatar_dir = wp_hash( $user_id );
165
+ }
166
 
167
  /* Pass the file to the avatar upload handler */
168
  if ( bp_core_avatar_handle_upload( $_FILES, 'bp_core_signup_avatar_upload_dir' ) ) {
187
  bp_core_add_message( __( 'There was a problem cropping your avatar, please try uploading it again', 'buddypress' ), 'error' );
188
  else
189
  bp_core_add_message( __( 'Your new avatar was uploaded successfully', 'buddypress' ) );
190
+ }
191
+ bp_core_load_template( 'registration/register' );
192
+ }
193
+ add_action( 'wp', 'bp_core_screen_signup', 3 );
194
 
195
+ function bp_core_screen_activation() {
196
+ global $bp, $wpdb;
 
197
 
198
+ if ( BP_ACTIVATION_SLUG != $bp->current_component )
199
+ return false;
200
+
201
+ /* Check if an activation key has been passed */
202
+ if ( isset( $_GET['key'] ) ) {
203
+
204
+ require_once( ABSPATH . WPINC . '/registration.php' );
205
+
206
+ /* Activate the signup */
207
+ $user = apply_filters( 'bp_core_activate_account', bp_core_activate_signup( $_GET['key'] ) );
208
+
209
+ /* If there was errors, add a message and redirect */
210
+ if ( $user->errors ) {
211
+ bp_core_add_message( __( 'There was an error activating your account, please try again.', 'buddypress' ), 'error' );
212
+ bp_core_redirect( $bp->root_domain . '/' . BP_ACTIVATION_SLUG );
213
  }
214
+
215
+ /* Check for an uploaded avatar and move that to the correct user folder */
216
+ if ( bp_core_is_multisite() )
217
+ $hashed_key = wp_hash( $_GET['key'] );
218
+ else
219
+ $hashed_key = wp_hash( $user );
220
+
221
+ /* Check if the avatar folder exists. If it does, move rename it, move it and delete the signup avatar dir */
222
+ if ( file_exists( BP_AVATAR_UPLOAD_PATH . '/avatars/signups/' . $hashed_key ) )
223
+ @rename( BP_AVATAR_UPLOAD_PATH . '/avatars/signups/' . $hashed_key, BP_AVATAR_UPLOAD_PATH . '/avatars/' . $user );
224
+
225
+ bp_core_add_message( __( 'Your account is now active!', 'buddypress' ) );
226
+
227
+ $bp->activation_complete = true;
228
  }
229
+
230
+ if ( '' != locate_template( array( 'registration/activate' ), false ) )
231
+ bp_core_load_template( apply_filters( 'bp_core_template_activate', 'activate' ) );
232
+ else
233
+ bp_core_load_template( apply_filters( 'bp_core_template_activate', 'registration/activate' ) );
234
  }
235
+ add_action( 'wp', 'bp_core_screen_activation', 3 );
236
 
 
 
237
 
238
+ /********************************************************************************
239
+ * Business Functions
240
+ *
241
+ * Business functions are where all the magic happens in BuddyPress. They will
242
+ * handle the actual saving or manipulation of information. Usually they will
243
+ * hand off to a database class for data access, then return
244
+ * true or false on success or failure.
245
+ */
246
+
247
+ function bp_core_validate_user_signup( $user_name, $user_email ) {
248
+ global $wpdb;
249
 
250
  $errors = new WP_Error();
251
+ $user_email = sanitize_email( $user_email );
252
+
253
+ if ( empty( $user_name ) )
254
+ $errors->add( 'user_name', __( 'Please enter a username', 'buddypress' ) );
255
+
256
+ $maybe = array();
257
+ preg_match( "/[a-z0-9]+/", $user_name, $maybe );
258
+
259
+ $db_illegal_names = get_site_option( 'illegal_names' );
260
+ $filtered_illegal_names = apply_filters( 'bp_core_illegal_usernames', array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator', BP_GROUPS_SLUG, BP_MEMBERS_SLUG, BP_FORUMS_SLUG, BP_BLOGS_SLUG, BP_REGISTER_SLUG, BP_ACTIVATION_SLUG ) );
261
+
262
+ $illegal_names = array_merge( (array)$db_illegal_names, (array)$filtered_illegal_names );
263
+ update_site_option( 'illegal_names', $illegal_names );
264
+
265
+ if ( !validate_username( $user_name ) || in_array( $user_name, (array)$illegal_names ) || $user_name != $maybe[0] )
266
+ $errors->add( 'user_name', __( 'Only lowercase letters and numbers allowed', 'buddypress' ) );
267
+
268
+ if( strlen( $user_name ) < 4 )
269
+ $errors->add( 'user_name', __( 'Username must be at least 4 characters', 'buddypress' ) );
270
 
271
+ if ( strpos( ' ' . $user_name, '_' ) != false )
272
+ $errors->add( 'user_name', __( 'Sorry, usernames may not contain the character "_"!', 'buddypress' ) );
273
+
274
+ /* Is the user_name all numeric? */
275
+ $match = array();
276
+ preg_match( '/[0-9]*/', $user_name, $match );
277
+
278
+ if ( $match[0] == $user_name )
279
+ $errors->add( 'user_name', __( 'Sorry, usernames must have letters too!', 'buddypress' ) );
280
+
281
+ if ( !is_email( $user_email ) )
282
+ $errors->add( 'user_email', __( 'Please check your email address.', 'buddypress' ) );
283
+
284
+ $limited_email_domains = get_site_option( 'limited_email_domains', 'buddypress' );
285
+
286
+ if ( is_array( $limited_email_domains ) && empty( $limited_email_domains ) == false ) {
287
+ $emaildomain = substr( $user_email, 1 + strpos( $user_email, '@' ) );
288
+
289
+ if ( in_array( $emaildomain, (array)$limited_email_domains ) == false )
290
+ $errors->add( 'user_email', __( 'Sorry, that email address is not allowed!', 'buddypress' ) );
291
  }
292
 
293
+ /* Check if the username has been used already. */
294
+ if ( username_exists( $user_name ) )
295
+ $errors->add( 'user_name', __( 'Sorry, that username already exists!', 'buddypress' ) );
296
+
297
+ /* Check if the email address has been used already. */
298
+ if ( email_exists( $user_email ) )
299
+ $errors->add( 'user_email', __( 'Sorry, that email address is already used!', 'buddypress' ) );
300
+
301
+ $result = array( 'user_name' => $user_name, 'user_email' => $user_email, 'errors' => $errors );
302
+
303
+ /* Apply WPMU legacy filter */
304
+ $result = apply_filters( 'wpmu_validate_user_signup', $result );
305
+
306
+ return apply_filters( 'bp_core_validate_user_signup', $result );
307
+ }
308
+
309
+ function bp_core_validate_blog_signup( $blog_url, $blog_title ) {
310
+ if ( !bp_core_is_multisite() || !function_exists( 'wpmu_validate_blog_signup' ) )
311
+ return false;
312
+
313
+ return apply_filters( 'bp_core_validate_blog_signup', wpmu_validate_blog_signup( $blog_url, $blog_title ) );
314
+ }
315
+
316
+ function bp_core_signup_user( $user_login, $user_password, $user_email, $usermeta ) {
317
+ global $bp, $wpdb;
318
+
319
+ /* Multisite installs have their own install procedure */
320
+ if ( bp_core_is_multisite() ) {
321
+ wpmu_signup_user( $user_login, $user_email, $usermeta );
322
+
323
+ } else {
324
+ $errors = new WP_Error();
325
+
326
+ $user_id = wp_insert_user( array(
327
+ 'user_login' => $user_login,
328
+ 'user_pass' => $user_password,
329
+ 'display_name' => sanitize_title( $user_login ),
330
+ 'user_email' => $user_email
331
+ ) );
332
 
333
+ if ( !$user_id ) {
334
+ $errors->add( 'registerfail', sprintf( __('<strong>ERROR</strong>: Couldn&#8217;t register you... please contact the <a href="mailto:%s">webmaster</a> !', 'buddypress' ), get_option( 'admin_email' ) ) );
335
+ return $errors;
336
+ }
337
+
338
+ /* Update the user status to '2' which we will use as 'not activated' (0 = active, 1 = spam, 2 = not active) */
339
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->users SET user_status = 2 WHERE ID = %d", $user_id ) );
340
+
341
+ /* Set any profile data */
342
+ if ( function_exists( 'xprofile_set_field_data' ) ) {
343
+ if ( !empty( $usermeta['profile_field_ids'] ) ) {
344
+ $profile_field_ids = explode( ',', $usermeta['profile_field_ids'] );
345
+
346
+ foreach( (array)$profile_field_ids as $field_id ) {
347
+ $current_field = $usermeta["field_{$field_id}"];
348
+
349
+ if ( !empty( $current_field ) )
350
+ xprofile_set_field_data( $field_id, $user_id, $current_field );
351
+ }
352
+ }
353
+ }
354
+ }
355
+ $bp->signup->username = $user_login;
356
+
357
+ /***
358
+ * Now generate an activation key and send an email to the user so they can activate their account
359
+ * and validate their email address. Multisite installs send their own email, so this is only for single blog installs.
360
+ */
361
+ if ( !bp_core_is_multisite() ) {
362
+ $activation_key = wp_hash( $user_id );
363
+ update_usermeta( $user_id, 'activation_key', $activation_key );
364
+ bp_core_signup_send_validation_email( $user_id, $activation_key );
365
+ }
366
+
367
+ do_action( 'bp_core_signup_user', $user_id, $user_login, $user_password, $user_email, $usermeta );
368
+
369
+ return $user_id;
370
+ }
371
+
372
+ function bp_core_signup_blog( $blog_domain, $blog_path, $blog_title, $user_name, $user_email, $usermeta ) {
373
+ if ( !bp_core_is_multisite() || !function_exists( 'wpmu_signup_blog' ) )
374
+ return false;
375
+
376
+ return apply_filters( 'bp_core_signup_blog', wpmu_signup_blog( $blog_domain, $blog_path, $blog_title, $user_name, $user_email, $usermeta ) );
377
+ }
378
+
379
+ function bp_core_activate_signup( $key ) {
380
+ global $wpdb;
381
+
382
+ $user = false;
383
+
384
+ /* Multisite installs have their own activation routine */
385
+ if ( bp_core_is_multisite() ) {
386
+ $user = wpmu_activate_signup( $key );
387
+
388
+ /* If there was errors, add a message and redirect */
389
+ if ( $user->errors ) {
390
+ bp_core_add_message( __( 'There was an error activating your account, please try again.', 'buddypress' ), 'error' );
391
+ bp_core_redirect( $bp->root_domain . '/' . BP_ACTIVATION_SLUG );
392
+ }
393
+
394
+ $user_id = $user['user_id'];
395
+
396
+ /* Set any profile data */
397
+ if ( function_exists( 'xprofile_set_field_data' ) ) {
398
+ if ( !empty( $user['meta']['profile_field_ids'] ) ) {
399
+ $profile_field_ids = explode( ',', $user['meta']['profile_field_ids'] );
400
+
401
+ foreach( (array)$profile_field_ids as $field_id ) {
402
+ $current_field = $user['meta']["field_{$field_id}"];
403
 
404
+ if ( !empty( $current_field ) )
405
+ xprofile_set_field_data( $field_id, $user_id, $current_field );
406
+ }
407
  }
408
  }
409
+
410
+ } else {
411
+ /* Get the user_id based on the $key */
412
+ $user_id = $wpdb->get_var( $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_value = %s", $key ) );
413
+
414
+ if ( empty( $user_id ) )
415
+ return new WP_Error( 'invalid_key', __( 'Invalid activation key', 'buddypress' ) );
416
+
417
+ /* Change the user's status so they become active */
418
+ if ( !$wpdb->query( $wpdb->prepare( "UPDATE $wpdb->users SET user_status = 0 WHERE ID = %d", $user_id ) ) )
419
+ return new WP_Error( 'invalid_key', __( 'Invalid activation key', 'buddypress' ) );
420
+
421
+ /* Notify the site admin of a new user registration */
422
+ wp_new_user_notification( $user_id );
423
+
424
+ /* Remove the activation key meta */
425
+ delete_usermeta( $user_id, 'activation_key' );
426
  }
427
 
428
+ /* Update the user_url and display_name */
429
+ wp_update_user( array( 'ID' => $user_id, 'user_url' => bp_core_get_user_domain( $user_id, sanitize_title( $user_login ), $user_login ), 'display_name' => bp_core_get_user_displayname( $user_id ) ) );
430
+
431
  /* Add a last active entry */
432
  update_usermeta( $user_id, 'last_activity', gmdate( "Y-m-d H:i:s" ) );
433
 
434
+ /* Set the password on multisite installs */
435
+ if ( bp_core_is_multisite() && !empty( $user['meta']['password'] ) )
436
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->users SET user_pass = %s WHERE ID = %d", $user['meta']['password'], $user_id ) );
437
+
438
+ /* Delete the total member cache */
439
  wp_cache_delete( 'bp_total_member_count', 'bp' );
440
 
441
+ do_action( 'bp_core_activated_user', $user_id, $key, $user );
442
 
443
  return $user_id;
444
  }
445
 
446
+ function bp_core_new_user_activity( $user ) {
447
+ if ( empty( $user ) || !function_exists( 'bp_activity_add' ) )
448
+ return false;
449
+
450
+ if ( is_array( $user ) )
451
+ $user_id = $user['user_id'];
452
+ else
453
+ $user_id = $user;
454
+
455
+ if ( empty( $user_id ) )
456
+ return false;
457
+
458
+ $userlink = bp_core_get_userlink( $user_id );
459
+
460
+ bp_activity_add( array(
461
+ 'user_id' => $user_id,
462
+ 'action' => apply_filters( 'bp_core_activity_registered_member_action', sprintf( __( '%s became a registered member', 'buddypress' ), $userlink ), $user_id ),
463
+ 'component' => 'profile',
464
+ 'type' => 'new_member'
465
+ ) );
466
+ }
467
+ add_action( 'bp_core_activated_user', 'bp_core_new_user_activity' );
468
+
469
  function bp_core_map_user_registration( $user_id ) {
470
  /* Only map data when the site admin is adding users, not on registration. */
471
  if ( !is_admin() )
507
  return apply_filters( 'bp_core_signup_avatar_upload_dir', array( 'path' => $path, 'url' => $newurl, 'subdir' => $newsubdir, 'basedir' => $newbdir, 'baseurl' => $newburl, 'error' => false ) );
508
  }
509
 
510
+ function bp_core_signup_send_validation_email( $user_id, $key ) {
511
+ $activate_url = bp_get_activation_page() ."?key=$key";
512
+ $activate_url = clean_url( $activate_url );
513
+ $admin_email = get_site_option( "admin_email" );
514
+
515
+ if ( empty( $admin_email ) )
516
+ $admin_email = 'noreply@' . $_SERVER['SERVER_NAME'];
517
+
518
+ $from_name = ( '' == get_option( 'blogname' ) ) ? 'BuddyPress' : wp_specialchars( get_option( 'blogname' ) );
519
+ $message_headers = "MIME-Version: 1.0\n" . "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option( 'blog_charset' ) . "\"\n";
520
+ $message = sprintf( __( "Thanks for registering! To complete the activation of your account please click the following link:\n\n%s\n\n", 'buddypress' ), $activate_url );
521
+ $subject = '[' . $from_name . '] ' . __( 'Activate Your Account', 'buddypress' );
522
+
523
+ /* Send the message */
524
+ $to = apply_filters( 'bp_core_activation_signup_user_notification_to', $user_email );
525
+ $subject = apply_filters( 'bp_core_activation_signup_user_notification_subject', $subject );
526
+ $message = apply_filters( 'bp_core_activation_signup_user_notification_message', $message );
527
+
528
+ wp_mail( $to, $subject, $message, $message_headers );
529
+ }
530
+
531
+ /* Stop user accounts logging in that have not been activated (user_status = 2) */
532
+ function bp_core_signup_disable_inactive( $auth_obj, $username ) {
533
+ global $bp, $wpdb;
534
+
535
+ if ( !$user_id = bp_core_get_userid( $username ) )
536
+ return $auth_obj;
537
+
538
+ $user_status = (int) $wpdb->get_var( $wpdb->prepare( "SELECT user_status FROM $wpdb->users WHERE ID = %d", $user_id ) );
539
+
540
+ if ( 2 == $user_status )
541
+ bp_core_redirect( $bp->root_domain );
542
+ else
543
+ return $auth_obj;
544
+ }
545
+ add_filter( 'authenticate', 'bp_core_signup_disable_inactive', 11, 2 );
546
+
547
  /* Kill the wp-signup.php if custom registration signup templates are present */
548
  function bp_core_wpsignup_redirect() {
549
  if ( false === strpos( $_SERVER['SCRIPT_NAME'], 'wp-signup.php') && $_GET['action'] != 'register' )
bp-core/bp-core-templatetags.php CHANGED
@@ -309,8 +309,8 @@ function bp_member_profile_data( $args = '' ) {
309
  extract( $r, EXTR_SKIP );
310
 
311
  // Populate the user if it hasn't been already.
312
- if ( empty( $members_template->member->profile_data ) )
313
- $members_template->member = new BP_Core_User( $members_template->member->id );
314
 
315
  $data = xprofile_format_profile_field( $members_template->member->profile_data[$field]['field_type'], $members_template->member->profile_data[$field]['field_data'] );
316
 
@@ -916,6 +916,12 @@ function bp_get_page_title() {
916
 
917
  } else if ( bp_is_activation_page() ) {
918
  $title = __( 'Activate your Account', 'buddypress' );
 
 
 
 
 
 
919
  }
920
 
921
  if ( defined( 'BP_ENABLE_MULTIBLOG' ) ) {
@@ -1183,26 +1189,21 @@ function bp_signup_avatar( $args = '' ) {
1183
  $r = wp_parse_args( $args, $defaults );
1184
  extract( $r, EXTR_SKIP );
1185
 
1186
- if ( !bp_core_is_multisite() && !empty( $_POST['signup_username'] ) ) {
1187
- $user_id = bp_core_get_userid( $_POST['signup_username'] );
1188
- return apply_filters( 'bp_get_signup_avatar', bp_core_fetch_avatar( array( 'item_id' => $user_id, 'type' => 'full', 'width' => $size, 'height' => $size, 'alt' => $alt, 'class' => $class ) ) );
1189
- } else {
1190
- $signup_avatar_dir = ( !empty( $_POST['signup_avatar_dir'] ) ) ? $_POST['signup_avatar_dir'] : $bp->signup->avatar_dir;
1191
-
1192
- if ( empty( $signup_avatar_dir ) ) {
1193
- if ( empty( $bp->grav_default->user ) ) {
1194
- $default_grav = 'wavatar';
1195
- } else if ( 'mystery' == $bp->grav_default->user ) {
1196
- $default_grav = BP_PLUGIN_URL . '/bp-core/images/mystery-man.jpg';
1197
- } else {
1198
- $default_grav = $bp->grav_default->user;
1199
- }
1200
 
1201
- $gravatar_url = apply_filters( 'bp_gravatar_url', 'http://www.gravatar.com/avatar/' );
1202
- return apply_filters( 'bp_get_signup_avatar', '<img src="' . $gravatar_url . md5( $_POST['signup_email'] ) . '?d=' . $default_grav . '&amp;s=' . $size ) . '" width="' . $size . '" height="' . $size . '" alt="' . $alt . '" class="' . $class . '" />';
 
 
 
1203
  } else {
1204
- return apply_filters( 'bp_get_signup_avatar', bp_core_fetch_avatar( array( 'item_id' => $signup_avatar_dir, 'object' => 'signup', 'avatar_dir' => 'avatars/signups', 'type' => 'full', 'width' => $size, 'height' => $size, 'alt' => $alt, 'class' => $class ) ) );
1205
  }
 
 
 
 
 
1206
  }
1207
  }
1208
 
@@ -1245,7 +1246,7 @@ function bp_account_was_activated() {
1245
  }
1246
 
1247
  function bp_registration_needs_activation() {
1248
- return apply_filters( 'bp_registration_needs_activation', bp_core_is_multisite() );
1249
  }
1250
 
1251
  function bp_mentioned_user_display_name( $user_id_or_username ) {
@@ -1692,7 +1693,7 @@ function bp_is_user_recent_commments() {
1692
  function bp_is_create_blog() {
1693
  global $bp;
1694
 
1695
- if ( BP_BLOGS_SLUG == $bp->current_component && 'create-a-blog' == $bp->current_action )
1696
  return true;
1697
 
1698
  return false;
309
  extract( $r, EXTR_SKIP );
310
 
311
  // Populate the user if it hasn't been already.
312
+ if ( empty( $members_template->member->profile_data ) && method_exists( 'BP_XProfile_ProfileData', 'get_all_for_user' ) )
313
+ $members_template->member->profile_data = BP_XProfile_ProfileData::get_all_for_user( $members_template->member->id );
314
 
315
  $data = xprofile_format_profile_field( $members_template->member->profile_data[$field]['field_type'], $members_template->member->profile_data[$field]['field_data'] );
316
 
916
 
917
  } else if ( bp_is_activation_page() ) {
918
  $title = __( 'Activate your Account', 'buddypress' );
919
+
920
+ } else if ( bp_is_group_create() ) {
921
+ $title = __( 'Create a Group', 'buddypress' );
922
+
923
+ } else if ( bp_is_create_blog() ) {
924
+ $title = __( 'Create a Blog', 'buddypress' );
925
  }
926
 
927
  if ( defined( 'BP_ENABLE_MULTIBLOG' ) ) {
1189
  $r = wp_parse_args( $args, $defaults );
1190
  extract( $r, EXTR_SKIP );
1191
 
1192
+ $signup_avatar_dir = ( !empty( $_POST['signup_avatar_dir'] ) ) ? $_POST['signup_avatar_dir'] : $bp->signup->avatar_dir;
 
 
 
 
 
 
 
 
 
 
 
 
 
1193
 
1194
+ if ( empty( $signup_avatar_dir ) ) {
1195
+ if ( empty( $bp->grav_default->user ) ) {
1196
+ $default_grav = 'wavatar';
1197
+ } else if ( 'mystery' == $bp->grav_default->user ) {
1198
+ $default_grav = BP_PLUGIN_URL . '/bp-core/images/mystery-man.jpg';
1199
  } else {
1200
+ $default_grav = $bp->grav_default->user;
1201
  }
1202
+
1203
+ $gravatar_url = apply_filters( 'bp_gravatar_url', 'http://www.gravatar.com/avatar/' );
1204
+ return apply_filters( 'bp_get_signup_avatar', '<img src="' . $gravatar_url . md5( $_POST['signup_email'] ) . '?d=' . $default_grav . '&amp;s=' . $size ) . '" width="' . $size . '" height="' . $size . '" alt="' . $alt . '" class="' . $class . '" />';
1205
+ } else {
1206
+ return apply_filters( 'bp_get_signup_avatar', bp_core_fetch_avatar( array( 'item_id' => $signup_avatar_dir, 'object' => 'signup', 'avatar_dir' => 'avatars/signups', 'type' => 'full', 'width' => $size, 'height' => $size, 'alt' => $alt, 'class' => $class ) ) );
1207
  }
1208
  }
1209
 
1246
  }
1247
 
1248
  function bp_registration_needs_activation() {
1249
+ return apply_filters( 'bp_registration_needs_activation', true );
1250
  }
1251
 
1252
  function bp_mentioned_user_display_name( $user_id_or_username ) {
1693
  function bp_is_create_blog() {
1694
  global $bp;
1695
 
1696
+ if ( BP_BLOGS_SLUG == $bp->current_component && 'create' == $bp->current_action )
1697
  return true;
1698
 
1699
  return false;
bp-core/bp-core-wpabstraction.php CHANGED
@@ -89,65 +89,3 @@ if ( !function_exists( 'update_blog_status' ) ) {
89
  return true;
90
  }
91
  }
92
-
93
- if ( !function_exists( 'wpmu_validate_user_signup' ) ) {
94
- function wpmu_validate_user_signup( $user_name, $user_email ) {
95
- global $wpdb;
96
-
97
- $errors = new WP_Error();
98
-
99
- $user_email = sanitize_email( $user_email );
100
-
101
- if ( empty( $user_name ) )
102
- $errors->add('user_name', __("Please enter a username"));
103
-
104
- $maybe = array();
105
- preg_match( "/[a-z0-9]+/", $user_name, $maybe );
106
-
107
- $illegal_names = get_site_option( "illegal_names" );
108
- if( is_array( $illegal_names ) == false ) {
109
- $illegal_names = array( "www", "web", "root", "admin", "main", "invite", "administrator" );
110
- add_site_option( "illegal_names", $illegal_names );
111
- }
112
-
113
- if ( !validate_username( $user_name ) || in_array( $user_name, $illegal_names ) == true || $user_name != $maybe[0] ) {
114
- $errors->add('user_name', __("Only lowercase letters and numbers allowed"));
115
- }
116
-
117
- if( strlen( $user_name ) < 4 ) {
118
- $errors->add('user_name', __("Username must be at least 4 characters"));
119
- }
120
-
121
- if ( strpos( " " . $user_name, "_" ) != false )
122
- $errors->add('user_name', __("Sorry, usernames may not contain the character '_'!"));
123
-
124
- // all numeric?
125
- $match = array();
126
- preg_match( '/[0-9]*/', $user_name, $match );
127
- if ( $match[0] == $user_name )
128
- $errors->add('user_name', __("Sorry, usernames must have letters too!"));
129
-
130
- if ( !is_email( $user_email ) )
131
- $errors->add('user_email', __("Please check your email address."));
132
-
133
- $limited_email_domains = get_site_option( 'limited_email_domains' );
134
- if ( is_array( $limited_email_domains ) && empty( $limited_email_domains ) == false ) {
135
- $emaildomain = substr( $user_email, 1 + strpos( $user_email, '@' ) );
136
- if( in_array( $emaildomain, $limited_email_domains ) == false ) {
137
- $errors->add('user_email', __("Sorry, that email address is not allowed!"));
138
- }
139
- }
140
-
141
- // Check if the username has been used already.
142
- if ( username_exists($user_name) )
143
- $errors->add('user_name', __("Sorry, that username already exists!"));
144
-
145
- // Check if the email address has been used already.
146
- if ( email_exists($user_email) )
147
- $errors->add('user_email', __("Sorry, that email address is already used!"));
148
-
149
- $result = array('user_name' => $user_name, 'user_email' => $user_email, 'errors' => $errors);
150
-
151
- return apply_filters('wpmu_validate_user_signup', $result);
152
- }
153
- }
89
  return true;
90
  }
91
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bp-forums/bp-forums-templatetags.php CHANGED
@@ -289,7 +289,9 @@ function bp_the_topic_poster_name() {
289
  function bp_get_the_topic_poster_name() {
290
  global $forum_template;
291
 
292
- if ( !$name = bp_core_get_userlink( $forum_template->topic->poster_id ) )
 
 
293
  return __( 'Deleted User', 'buddypress' );
294
 
295
  return apply_filters( 'bp_get_the_topic_poster_name', $name );
289
  function bp_get_the_topic_poster_name() {
290
  global $forum_template;
291
 
292
+ $poster_id = ( empty( $forum_template->topic->poster_id ) ) ? $forum_template->topic->topic_poster : $forum_template->topic->poster_id;
293
+
294
+ if ( !$name = bp_core_get_userlink( $poster_id ) )
295
  return __( 'Deleted User', 'buddypress' );
296
 
297
  return apply_filters( 'bp_get_the_topic_poster_name', $name );
bp-friends.php CHANGED
@@ -98,7 +98,7 @@ function friends_screen_my_friends() {
98
  global $bp;
99
 
100
  // Delete any friendship acceptance notifications for the user when viewing a profile
101
- bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, 'friends', 'friendship_accepted' );
102
 
103
  do_action( 'friends_screen_my_friends' );
104
 
@@ -133,6 +133,9 @@ function friends_screen_requests() {
133
 
134
  do_action( 'friends_screen_requests' );
135
 
 
 
 
136
  bp_core_load_template( apply_filters( 'friends_template_requests', 'members/single/home' ) );
137
  }
138
 
@@ -317,11 +320,11 @@ function friends_format_notifications( $action, $item_id, $secondary_item_id, $t
317
 
318
  case 'friendship_request':
319
  if ( (int)$total_items > 1 ) {
320
- return apply_filters( 'bp_friends_multiple_friendship_request_notification', '<a href="' . $bp->loggedin_user->domain . $bp->friends->slug . '/requests" title="' . __( 'Friendship requests', 'buddypress' ) . '">' . sprintf( __('You have %d pending friendship requests', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );
321
  } else {
322
  $user_fullname = bp_core_get_user_displayname( $item_id );
323
  $user_url = bp_core_get_user_domain( $item_id );
324
- return apply_filters( 'bp_friends_single_friendship_request_notification', '<a href="' . $bp->loggedin_user->domain . $bp->friends->slug . '/requests" title="' . __( 'Friendship requests', 'buddypress' ) . '">' . sprintf( __('You have a friendship request from %s', 'buddypress' ), $user_fullname ) . '</a>', $user_fullname );
325
  }
326
  break;
327
  }
@@ -362,7 +365,7 @@ function friends_add_friend( $initiator_userid, $friend_userid, $force_accept =
362
 
363
  if ( !$force_accept ) {
364
  // Add the on screen notification
365
- bp_core_add_notification( $friendship->initiator_user_id, $friendship->friend_user_id, 'friends', 'friendship_request' );
366
 
367
  // Send the email notification
368
  require_once( BP_PLUGIN_DIR . '/bp-friends/bp-friends-notifications.php' );
@@ -408,10 +411,10 @@ function friends_accept_friendship( $friendship_id ) {
408
  friends_update_friend_totals( $friendship->initiator_user_id, $friendship->friend_user_id );
409
 
410
  /* Remove the friend request notice */
411
- bp_core_delete_notifications_for_user_by_item_id( $friendship->friend_user_id, $friendship->initiator_user_id, 'friends', 'friendship_request' );
412
 
413
  /* Add a friend accepted notice for the initiating user */
414
- bp_core_add_notification( $friendship->friend_user_id, $friendship->initiator_user_id, 'friends', 'friendship_accepted' );
415
 
416
  $initiator_link = bp_core_get_userlink( $friendship->initiator_user_id );
417
  $friend_link = bp_core_get_userlink( $friendship->friend_user_id );
@@ -449,7 +452,7 @@ function friends_reject_friendship( $friendship_id ) {
449
 
450
  if ( !$friendship->is_confirmed && BP_Friends_Friendship::reject( $friendship_id ) ) {
451
  // Remove the friend request notice
452
- bp_core_delete_notifications_for_user_by_item_id( $friendship->friend_user_id, $friendship->initiator_user_id, 'friends', 'friendship_request' );
453
 
454
  do_action( 'friends_friendship_rejected', $friendship_id, &$friendship );
455
  return true;
@@ -597,7 +600,7 @@ function friends_remove_data( $user_id ) {
597
  delete_usermeta( $user_id, 'total_friend_count' );
598
 
599
  /* Remove friendship requests FROM user */
600
- bp_core_delete_notifications_from_user( $user_id, $bp->friends->slug, 'friendship_request' );
601
 
602
  do_action( 'friends_remove_data', $user_id );
603
  }
@@ -631,7 +634,7 @@ function friends_clear_friend_notifications() {
631
  global $bp;
632
 
633
  if ( isset($_GET['new']) )
634
- bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, 'friends', 'friendship_accepted' );
635
  }
636
  add_action( 'bp_activity_screen_my_activity', 'friends_clear_friend_notifications' );
637
 
98
  global $bp;
99
 
100
  // Delete any friendship acceptance notifications for the user when viewing a profile
101
+ bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->friends->id, 'friendship_accepted' );
102
 
103
  do_action( 'friends_screen_my_friends' );
104
 
133
 
134
  do_action( 'friends_screen_requests' );
135
 
136
+ if ( isset( $_GET['new'] ) )
137
+ bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->friends->id, 'friendship_request' );
138
+
139
  bp_core_load_template( apply_filters( 'friends_template_requests', 'members/single/home' ) );
140
  }
141
 
320
 
321
  case 'friendship_request':
322
  if ( (int)$total_items > 1 ) {
323
+ return apply_filters( 'bp_friends_multiple_friendship_request_notification', '<a href="' . $bp->loggedin_user->domain . $bp->friends->slug . '/requests/?new" title="' . __( 'Friendship requests', 'buddypress' ) . '">' . sprintf( __('You have %d pending friendship requests', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );
324
  } else {
325
  $user_fullname = bp_core_get_user_displayname( $item_id );
326
  $user_url = bp_core_get_user_domain( $item_id );
327
+ return apply_filters( 'bp_friends_single_friendship_request_notification', '<a href="' . $bp->loggedin_user->domain . $bp->friends->slug . '/requests/?new" title="' . __( 'Friendship requests', 'buddypress' ) . '">' . sprintf( __('You have a friendship request from %s', 'buddypress' ), $user_fullname ) . '</a>', $user_fullname );
328
  }
329
  break;
330
  }
365
 
366
  if ( !$force_accept ) {
367
  // Add the on screen notification
368
+ bp_core_add_notification( $friendship->initiator_user_id, $friendship->friend_user_id, $bp->friends->id, 'friendship_request' );
369
 
370
  // Send the email notification
371
  require_once( BP_PLUGIN_DIR . '/bp-friends/bp-friends-notifications.php' );
411
  friends_update_friend_totals( $friendship->initiator_user_id, $friendship->friend_user_id );
412
 
413
  /* Remove the friend request notice */
414
+ bp_core_delete_notifications_for_user_by_item_id( $friendship->friend_user_id, $friendship->initiator_user_id, $bp->friends->id, 'friendship_request' );
415
 
416
  /* Add a friend accepted notice for the initiating user */
417
+ bp_core_add_notification( $friendship->friend_user_id, $friendship->initiator_user_id, $bp->friends->id, 'friendship_accepted' );
418
 
419
  $initiator_link = bp_core_get_userlink( $friendship->initiator_user_id );
420
  $friend_link = bp_core_get_userlink( $friendship->friend_user_id );
452
 
453
  if ( !$friendship->is_confirmed && BP_Friends_Friendship::reject( $friendship_id ) ) {
454
  // Remove the friend request notice
455
+ bp_core_delete_notifications_for_user_by_item_id( $friendship->friend_user_id, $friendship->initiator_user_id, $bp->friends->id, 'friendship_request' );
456
 
457
  do_action( 'friends_friendship_rejected', $friendship_id, &$friendship );
458
  return true;
600
  delete_usermeta( $user_id, 'total_friend_count' );
601
 
602
  /* Remove friendship requests FROM user */
603
+ bp_core_delete_notifications_from_user( $user_id, $bp->friends->id, 'friendship_request' );
604
 
605
  do_action( 'friends_remove_data', $user_id );
606
  }
634
  global $bp;
635
 
636
  if ( isset($_GET['new']) )
637
+ bp_core_delete_notifications_for_user_by_type( $bp->displayed_user->id, $bp->friends->id, 'friendship_accepted' );
638
  }
639
  add_action( 'bp_activity_screen_my_activity', 'friends_clear_friend_notifications' );
640
 
bp-groups.php CHANGED
@@ -268,10 +268,10 @@ function groups_screen_my_groups() {
268
 
269
  if ( isset($_GET['n']) ) {
270
  // Delete group request notifications for the user
271
- bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'membership_request_accepted' );
272
- bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'membership_request_rejected' );
273
- bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'member_promoted_to_mod' );
274
- bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'member_promoted_to_admin' );
275
  }
276
 
277
  do_action( 'groups_screen_my_groups' );
@@ -321,7 +321,7 @@ function groups_screen_group_invites() {
321
  }
322
 
323
  // Remove notifications
324
- bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'group_invite' );
325
 
326
  do_action( 'groups_screen_group_invites', $group_id );
327
 
@@ -334,10 +334,10 @@ function groups_screen_group_home() {
334
  if ( $bp->is_single_item ) {
335
  if ( isset($_GET['n']) ) {
336
  // Delete group request notifications for the user
337
- bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'membership_request_accepted' );
338
- bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'membership_request_rejected' );
339
- bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'member_promoted_to_mod' );
340
- bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'member_promoted_to_admin' );
341
  }
342
 
343
  do_action( 'groups_screen_group_home' );
@@ -868,11 +868,15 @@ function groups_screen_group_admin_requests() {
868
 
869
  if ( $bp->current_component == $bp->groups->slug && 'membership-requests' == $bp->action_variables[0] ) {
870
 
 
 
 
 
871
  if ( !$bp->is_item_admin || 'public' == $bp->groups->current_group->status )
872
  return false;
873
 
874
  // Remove any screen notifications
875
- bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'new_membership_request' );
876
 
877
  $request_action = $bp->action_variables[1];
878
  $membership_id = $bp->action_variables[2];
@@ -1544,6 +1548,7 @@ function groups_edit_group_settings( $group_id, $enable_forum, $status ) {
1544
  }
1545
  }
1546
 
 
1547
  do_action( 'groups_settings_updated', $group->id );
1548
 
1549
  return true;
@@ -1841,7 +1846,7 @@ function groups_post_update( $args = '' ) {
1841
  $defaults = array(
1842
  'content' => false,
1843
  'user_id' => $bp->loggedin_user->id,
1844
- 'group_id' => false
1845
  );
1846
 
1847
  $r = wp_parse_args( $args, $defaults );
@@ -1865,7 +1870,7 @@ function groups_post_update( $args = '' ) {
1865
  'action' => apply_filters( 'groups_activity_new_update_action', $activity_action ),
1866
  'content' => apply_filters( 'groups_activity_new_update_content', $activity_content ),
1867
  'type' => 'activity_update',
1868
- 'item_id' => $bp->groups->current_group->id
1869
  ) );
1870
 
1871
  /* Require the notifications code so email notifications can be set on the 'bp_activity_posted_update' action. */
@@ -1895,7 +1900,7 @@ function groups_new_group_forum( $group_id = false, $group_name = false, $group_
1895
 
1896
  groups_update_groupmeta( $group_id, 'forum_id', $forum_id );
1897
 
1898
- do_action( 'groups_new_group_forum', $forum, $group_id );
1899
  }
1900
 
1901
  function groups_new_group_forum_post( $post_text, $topic_id, $page = false ) {
@@ -2158,7 +2163,7 @@ function groups_accept_invite( $user_id, $group_id ) {
2158
  groups_update_groupmeta( $group_id, 'total_member_count', (int) groups_get_groupmeta( $group_id, 'total_member_count') + 1 );
2159
  groups_update_groupmeta( $group_id, 'last_activity', gmdate( "Y-m-d H:i:s" ) );
2160
 
2161
- bp_core_delete_notifications_for_user_by_item_id( $user_id, $group_id, $bp->groups->slug, 'group_invite' );
2162
 
2163
  do_action( 'groups_accept_invite', $user_id, $group_id );
2164
  return true;
@@ -2179,7 +2184,7 @@ function groups_delete_invite( $user_id, $group_id ) {
2179
  $delete = BP_Groups_Member::delete_invite( $user_id, $group_id );
2180
 
2181
  if ( $delete )
2182
- bp_core_delete_notifications_for_user_by_item_id( $user_id, $group_id, $bp->groups->slug, 'group_invite' );
2183
 
2184
  return $delete;
2185
  }
268
 
269
  if ( isset($_GET['n']) ) {
270
  // Delete group request notifications for the user
271
+ bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->id, 'membership_request_accepted' );
272
+ bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->id, 'membership_request_rejected' );
273
+ bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->id, 'member_promoted_to_mod' );
274
+ bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->id, 'member_promoted_to_admin' );
275
  }
276
 
277
  do_action( 'groups_screen_my_groups' );
321
  }
322
 
323
  // Remove notifications
324
+ bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->id, 'group_invite' );
325
 
326
  do_action( 'groups_screen_group_invites', $group_id );
327
 
334
  if ( $bp->is_single_item ) {
335
  if ( isset($_GET['n']) ) {
336
  // Delete group request notifications for the user
337
+ bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->id, 'membership_request_accepted' );
338
+ bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->id, 'membership_request_rejected' );
339
+ bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->id, 'member_promoted_to_mod' );
340
+ bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->id, 'member_promoted_to_admin' );
341
  }
342
 
343
  do_action( 'groups_screen_group_home' );
868
 
869
  if ( $bp->current_component == $bp->groups->slug && 'membership-requests' == $bp->action_variables[0] ) {
870
 
871
+ /* Ask for a login if the user is coming here via an email notification */
872
+ if ( !is_user_logged_in() )
873
+ bp_core_redirect( site_url( 'wp-login.php?redirect_to=' . $bp->root_domain . '/' . $bp->current_component . '/' . $bp->current_item . '/admin/membership-requests/' ) );
874
+
875
  if ( !$bp->is_item_admin || 'public' == $bp->groups->current_group->status )
876
  return false;
877
 
878
  // Remove any screen notifications
879
+ bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->id, 'new_membership_request' );
880
 
881
  $request_action = $bp->action_variables[1];
882
  $membership_id = $bp->action_variables[2];
1548
  }
1549
  }
1550
 
1551
+ groups_update_groupmeta( $group->id, 'last_activity', gmdate( "Y-m-d H:i:s" ) );
1552
  do_action( 'groups_settings_updated', $group->id );
1553
 
1554
  return true;
1846
  $defaults = array(
1847
  'content' => false,
1848
  'user_id' => $bp->loggedin_user->id,
1849
+ 'group_id' => $bp->groups->current_group->id
1850
  );
1851
 
1852
  $r = wp_parse_args( $args, $defaults );
1870
  'action' => apply_filters( 'groups_activity_new_update_action', $activity_action ),
1871
  'content' => apply_filters( 'groups_activity_new_update_content', $activity_content ),
1872
  'type' => 'activity_update',
1873
+ 'item_id' => $group_id
1874
  ) );
1875
 
1876
  /* Require the notifications code so email notifications can be set on the 'bp_activity_posted_update' action. */
1900
 
1901
  groups_update_groupmeta( $group_id, 'forum_id', $forum_id );
1902
 
1903
+ do_action( 'groups_new_group_forum', $forum_id, $group_id );
1904
  }
1905
 
1906
  function groups_new_group_forum_post( $post_text, $topic_id, $page = false ) {
2163
  groups_update_groupmeta( $group_id, 'total_member_count', (int) groups_get_groupmeta( $group_id, 'total_member_count') + 1 );
2164
  groups_update_groupmeta( $group_id, 'last_activity', gmdate( "Y-m-d H:i:s" ) );
2165
 
2166
+ bp_core_delete_notifications_for_user_by_item_id( $user_id, $group_id, $bp->groups->id, 'group_invite' );
2167
 
2168
  do_action( 'groups_accept_invite', $user_id, $group_id );
2169
  return true;
2184
  $delete = BP_Groups_Member::delete_invite( $user_id, $group_id );
2185
 
2186
  if ( $delete )
2187
+ bp_core_delete_notifications_for_user_by_item_id( $user_id, $group_id, $bp->groups->id, 'group_invite' );
2188
 
2189
  return $delete;
2190
  }
bp-loader.php CHANGED
@@ -4,12 +4,12 @@ Plugin Name: BuddyPress
4
  Plugin URI: http://buddypress.org/download/
5
  Description: Social networking in a box. Build a social network for your company, school, sports team or niche community all based on the power and flexibility of WordPress.
6
  Author: The BuddyPress Community
7
- Version: 1.2.1
8
  Author URI: http://buddypress.org/developers/
9
  Site Wide Only: true
10
  */
11
 
12
- define( 'BP_VERSION', '1.2.1' );
13
 
14
  /***
15
  * This file will load in each BuddyPress component based on which
4
  Plugin URI: http://buddypress.org/download/
5
  Description: Social networking in a box. Build a social network for your company, school, sports team or niche community all based on the power and flexibility of WordPress.
6
  Author: The BuddyPress Community
7
+ Version: 1.2.2
8
  Author URI: http://buddypress.org/developers/
9
  Site Wide Only: true
10
  */
11
 
12
+ define( 'BP_VERSION', '1.2.2' );
13
 
14
  /***
15
  * This file will load in each BuddyPress component based on which
bp-messages/bp-messages-templatetags.php CHANGED
@@ -161,7 +161,7 @@ function bp_has_message_threads( $args = '' ) {
161
  wp_redirect( $bp->displayed_user->id );
162
  } else {
163
  if ( 'inbox' == $bp->current_action )
164
- bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, 'messages', 'new_message' );
165
 
166
  if ( 'sentbox' == $bp->current_action )
167
  $box = 'sentbox';
161
  wp_redirect( $bp->displayed_user->id );
162
  } else {
163
  if ( 'inbox' == $bp->current_action )
164
+ bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->messages->id, 'new_message' );
165
 
166
  if ( 'sentbox' == $bp->current_action )
167
  $box = 'sentbox';
bp-themes/bp-default/_inc/css/default.css CHANGED
@@ -802,6 +802,12 @@ form.standard-form {
802
  margin-bottom: 5px;
803
  }
804
 
 
 
 
 
 
 
805
  form.standard-form #basic-details-section, form.standard-form #blog-details-section,
806
  form.standard-form #profile-details-section {
807
  float: left;
802
  margin-bottom: 5px;
803
  }
804
 
805
+ form.standard-form a.clear-value {
806
+ display: block;
807
+ margin-top: 5px;
808
+ outline: none;
809
+ }
810
+
811
  form.standard-form #basic-details-section, form.standard-form #blog-details-section,
812
  form.standard-form #profile-details-section {
813
  float: left;
bp-themes/bp-default/_inc/global.js CHANGED
@@ -1225,10 +1225,16 @@ function clear(container) {
1225
 
1226
  var container = document.getElementById(container);
1227
 
1228
- radioButtons = container.getElementsByTagName('INPUT');
 
 
 
 
1229
 
1230
- for(var i=0; i<radioButtons.length; i++) {
1231
- radioButtons[i].checked = '';
 
 
1232
  }
1233
 
1234
  return;
1225
 
1226
  var container = document.getElementById(container);
1227
 
1228
+ if ( radioButtons = container.getElementsByTagName('INPUT') ) {
1229
+ for(var i=0; i<radioButtons.length; i++) {
1230
+ radioButtons[i].checked = '';
1231
+ }
1232
+ }
1233
 
1234
+ if ( options = container.getElementsByTagName('OPTION') ) {
1235
+ for(var i=0; i<options.length; i++) {
1236
+ options[i].selected = false;
1237
+ }
1238
  }
1239
 
1240
  return;
bp-themes/bp-default/activity/index.php CHANGED
@@ -65,8 +65,11 @@
65
  <select>
66
  <option value="-1"><?php _e( 'No Filter', 'buddypress' ) ?></option>
67
  <option value="activity_update"><?php _e( 'Show Updates', 'buddypress' ) ?></option>
68
- <option value="new_blog_post"><?php _e( 'Show Blog Posts', 'buddypress' ) ?></option>
69
- <option value="new_blog_comment"><?php _e( 'Show Blog Comments', 'buddypress' ) ?></option>
 
 
 
70
 
71
  <?php if ( bp_is_active( 'forums' ) ) : ?>
72
  <option value="new_forum_topic"><?php _e( 'Show New Forum Topics', 'buddypress' ) ?></option>
65
  <select>
66
  <option value="-1"><?php _e( 'No Filter', 'buddypress' ) ?></option>
67
  <option value="activity_update"><?php _e( 'Show Updates', 'buddypress' ) ?></option>
68
+
69
+ <?php if ( bp_is_active( 'blogs' ) ) : ?>
70
+ <option value="new_blog_post"><?php _e( 'Show Blog Posts', 'buddypress' ) ?></option>
71
+ <option value="new_blog_comment"><?php _e( 'Show Blog Comments', 'buddypress' ) ?></option>
72
+ <?php endif; ?>
73
 
74
  <?php if ( bp_is_active( 'forums' ) ) : ?>
75
  <option value="new_forum_topic"><?php _e( 'Show New Forum Topics', 'buddypress' ) ?></option>
bp-themes/bp-default/functions.php CHANGED
@@ -71,6 +71,9 @@ function bp_dtheme_blog_comments( $comment, $args, $depth ) {
71
 
72
  /* Filter the dropdown for selecting the page to show on front to include "Activity Stream" */
73
  function bp_dtheme_wp_pages_filter( $page_html ) {
 
 
 
74
  if ( 'page_on_front' != substr( $page_html, 14, 13 ) )
75
  return $page_html;
76
 
71
 
72
  /* Filter the dropdown for selecting the page to show on front to include "Activity Stream" */
73
  function bp_dtheme_wp_pages_filter( $page_html ) {
74
+ if ( !bp_is_active( 'activity' ) )
75
+ return $page_html;
76
+
77
  if ( 'page_on_front' != substr( $page_html, 14, 13 ) )
78
  return $page_html;
79
 
bp-themes/bp-default/groups/single/plugins.php CHANGED
@@ -11,7 +11,7 @@
11
  </div>
12
 
13
  <div id="item-nav">
14
- <div class="item-list-tabs no-ajax" id="sub-nav">
15
  <ul>
16
  <?php bp_get_options_nav() ?>
17
 
11
  </div>
12
 
13
  <div id="item-nav">
14
+ <div class="item-list-tabs no-ajax" id="object-nav">
15
  <ul>
16
  <?php bp_get_options_nav() ?>
17
 
bp-themes/bp-default/header.php CHANGED
@@ -63,7 +63,7 @@
63
  <a href="<?php echo site_url() ?>/<?php echo BP_GROUPS_SLUG ?>/" title="<?php _e( 'Groups', 'buddypress' ) ?>"><?php _e( 'Groups', 'buddypress' ) ?></a>
64
  </li>
65
 
66
- <?php if ( bp_is_active( 'forums' ) && bp_is_active( 'groups' ) && ( function_exists( 'bp_forums_is_installed_correctly' ) && !(int) bp_get_option( 'bp-disable-forum-directory' ) ) && bp_forums_is_installed_correctly() ) : ?>
67
  <li<?php if ( bp_is_page( BP_FORUMS_SLUG ) ) : ?> class="selected"<?php endif; ?>>
68
  <a href="<?php echo site_url() ?>/<?php echo BP_FORUMS_SLUG ?>/" title="<?php _e( 'Forums', 'buddypress' ) ?>"><?php _e( 'Forums', 'buddypress' ) ?></a>
69
  </li>
63
  <a href="<?php echo site_url() ?>/<?php echo BP_GROUPS_SLUG ?>/" title="<?php _e( 'Groups', 'buddypress' ) ?>"><?php _e( 'Groups', 'buddypress' ) ?></a>
64
  </li>
65
 
66
+ <?php if ( bp_is_active( 'forums' ) && ( function_exists( 'bp_forums_is_installed_correctly' ) && !(int) bp_get_option( 'bp-disable-forum-directory' ) ) && bp_forums_is_installed_correctly() ) : ?>
67
  <li<?php if ( bp_is_page( BP_FORUMS_SLUG ) ) : ?> class="selected"<?php endif; ?>>
68
  <a href="<?php echo site_url() ?>/<?php echo BP_FORUMS_SLUG ?>/" title="<?php _e( 'Forums', 'buddypress' ) ?>"><?php _e( 'Forums', 'buddypress' ) ?></a>
69
  </li>
bp-themes/bp-default/members/single/activity.php CHANGED
@@ -8,8 +8,10 @@
8
  <option value="activity_update"><?php _e( 'Show Updates', 'buddypress' ) ?></option>
9
 
10
  <?php if ( 'groups' != bp_current_action() ) : ?>
11
- <option value="new_blog_post"><?php _e( 'Show Blog Posts', 'buddypress' ) ?></option>
12
- <option value="new_blog_comment"><?php _e( 'Show Blog Comments', 'buddypress' ) ?></option>
 
 
13
 
14
  <?php if ( bp_is_active( 'friends' ) ) : ?>
15
  <option value="friendship_accepted,friendship_created"><?php _e( 'Show Friendship Connections', 'buddypress' ) ?></option>
8
  <option value="activity_update"><?php _e( 'Show Updates', 'buddypress' ) ?></option>
9
 
10
  <?php if ( 'groups' != bp_current_action() ) : ?>
11
+ <?php if ( bp_is_active( 'blogs' ) ) : ?>
12
+ <option value="new_blog_post"><?php _e( 'Show Blog Posts', 'buddypress' ) ?></option>
13
+ <option value="new_blog_comment"><?php _e( 'Show Blog Comments', 'buddypress' ) ?></option>
14
+ <?php endif; ?>
15
 
16
  <?php if ( bp_is_active( 'friends' ) ) : ?>
17
  <option value="friendship_accepted,friendship_created"><?php _e( 'Show Friendship Connections', 'buddypress' ) ?></option>
bp-themes/bp-default/members/single/plugins.php CHANGED
@@ -13,8 +13,6 @@
13
  <div class="item-list-tabs no-ajax" id="object-nav">
14
  <ul>
15
  <?php bp_get_displayed_user_nav() ?>
16
-
17
- <?php do_action( 'bp_members_directory_member_types' ) ?>
18
  </ul>
19
  </div>
20
  </div>
@@ -24,13 +22,13 @@
24
  <div class="item-list-tabs no-ajax" id="subnav">
25
  <ul>
26
  <?php bp_get_options_nav() ?>
 
 
27
  </ul>
28
  </div>
29
 
30
  <?php do_action( 'bp_template_content' ) ?>
31
 
32
- <?php do_action( 'bp_directory_members_content' ) ?>
33
-
34
  </div><!-- #item-body -->
35
 
36
  <?php do_action( 'bp_after_member_plugin_template' ) ?>
13
  <div class="item-list-tabs no-ajax" id="object-nav">
14
  <ul>
15
  <?php bp_get_displayed_user_nav() ?>
 
 
16
  </ul>
17
  </div>
18
  </div>
22
  <div class="item-list-tabs no-ajax" id="subnav">
23
  <ul>
24
  <?php bp_get_options_nav() ?>
25
+
26
+ <?php do_action( 'bp_member_plugin_options_nav' ) ?>
27
  </ul>
28
  </div>
29
 
30
  <?php do_action( 'bp_template_content' ) ?>
31
 
 
 
32
  </div><!-- #item-body -->
33
 
34
  <?php do_action( 'bp_after_member_plugin_template' ) ?>
bp-themes/bp-default/members/single/profile/edit.php CHANGED
@@ -48,6 +48,10 @@
48
  <?php bp_the_profile_field_options() ?>
49
  </select>
50
 
 
 
 
 
51
  <?php endif; ?>
52
 
53
  <?php if ( 'radio' == bp_get_the_profile_field_type() ) : ?>
48
  <?php bp_the_profile_field_options() ?>
49
  </select>
50
 
51
+ <?php if ( !bp_get_the_profile_field_is_required() ) : ?>
52
+ <a class="clear-value" href="javascript:clear( '<?php bp_the_profile_field_input_name() ?>' );"><?php _e( 'Clear', 'buddypress' ) ?></a>
53
+ <?php endif; ?>
54
+
55
  <?php endif; ?>
56
 
57
  <?php if ( 'radio' == bp_get_the_profile_field_type() ) : ?>
bp-themes/bp-default/style.css CHANGED
@@ -2,7 +2,7 @@
2
  Theme Name: BuddyPress Default
3
  Theme URI: http://buddypress.org/extend/themes/
4
  Description: The default theme for BuddyPress.
5
- Version: 1.2.1
6
  Author: BuddyPress.org
7
  Author URI: http://buddypress.org
8
  Tags: buddypress, two-columns, custom-header, white, blue
2
  Theme Name: BuddyPress Default
3
  Theme URI: http://buddypress.org/extend/themes/
4
  Description: The default theme for BuddyPress.
5
+ Version: 1.2.2
6
  Author: BuddyPress.org
7
  Author URI: http://buddypress.org
8
  Tags: buddypress, two-columns, custom-header, white, blue
bp-xprofile.php CHANGED
@@ -321,7 +321,7 @@ function xprofile_screen_edit_profile() {
321
  $errors = true;
322
  }
323
 
324
- if ( $errors )
325
  bp_core_add_message( __( 'Please make sure you fill in all required fields in this profile field group before saving.', 'buddypress' ), 'error' );
326
  else {
327
  /* Reset the errors var */
@@ -335,7 +335,7 @@ function xprofile_screen_edit_profile() {
335
  do_action( 'xprofile_profile_field_data_updated', $field_id, $_POST['field_' . $field_id] );
336
  }
337
 
338
- do_action( 'xprofile_updated_profile', $posted_field_ids, $errors );
339
 
340
  /* Set the feedback messages */
341
  if ( $errors )
@@ -724,6 +724,12 @@ function xprofile_set_field_data( $field, $user_id, $value, $is_required = false
724
  if ( $is_required && ( empty( $value ) || !strlen( trim( $value ) ) ) )
725
  return false;
726
 
 
 
 
 
 
 
727
  $field = new BP_XProfile_Field( $field_id );
728
 
729
  /* Check the value is an acceptable value */
@@ -764,10 +770,10 @@ function xprofile_delete_field_data( $field, $user_id ) {
764
  else
765
  $field_id = xprofile_get_field_id_from_name( $field );
766
 
767
- if ( !$field_id )
768
  return false;
769
 
770
- $field = new BP_XProfile_ProfileData( $field_id );
771
  return $field->delete();
772
  }
773
 
@@ -887,13 +893,19 @@ function xprofile_avatar_upload_dir( $directory = false, $user_id = false ) {
887
  *
888
  * @package BuddyPress Core
889
  */
890
- function xprofile_sync_wp_profile() {
891
  global $bp, $wpdb;
892
 
893
  if ( (int)$bp->site_options['bp-disable-profile-sync'] )
894
  return true;
895
 
896
- $fullname = xprofile_get_field_data( BP_XPROFILE_FULLNAME_FIELD_NAME, $bp->loggedin_user->id );
 
 
 
 
 
 
897
  $space = strpos( $fullname, ' ' );
898
 
899
  if ( false === $space ) {
@@ -904,15 +916,15 @@ function xprofile_sync_wp_profile() {
904
  $lastname = trim( substr( $fullname, $space, strlen($fullname) ) );
905
  }
906
 
907
- update_usermeta( $bp->loggedin_user->id, 'nickname', $fullname );
908
- update_usermeta( $bp->loggedin_user->id, 'first_name', $firstname );
909
- update_usermeta( $bp->loggedin_user->id, 'last_name', $lastname );
910
 
911
- $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->users} SET display_name = %s WHERE ID = %d", $fullname, $bp->loggedin_user->id ) );
912
- $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->users} SET user_url = %s WHERE ID = %d", bp_core_get_user_domain( $bp->loggedin_user->id ), $bp->loggedin_user->id ) );
913
  }
914
  add_action( 'xprofile_updated_profile', 'xprofile_sync_wp_profile' );
915
-
916
 
917
  /**
918
  * xprofile_remove_screen_notifications()
321
  $errors = true;
322
  }
323
 
324
+ if ( !empty( $errors ) )
325
  bp_core_add_message( __( 'Please make sure you fill in all required fields in this profile field group before saving.', 'buddypress' ), 'error' );
326
  else {
327
  /* Reset the errors var */
335
  do_action( 'xprofile_profile_field_data_updated', $field_id, $_POST['field_' . $field_id] );
336
  }
337
 
338
+ do_action( 'xprofile_updated_profile', $bp->displayed_user->id, $posted_field_ids, $errors );
339
 
340
  /* Set the feedback messages */
341
  if ( $errors )
724
  if ( $is_required && ( empty( $value ) || !strlen( trim( $value ) ) ) )
725
  return false;
726
 
727
+ /* If the value is empty, then delete any field data that exists */
728
+ if ( empty( $value ) ) {
729
+ xprofile_delete_field_data( $field_id, $user_id );
730
+ return true;
731
+ }
732
+
733
  $field = new BP_XProfile_Field( $field_id );
734
 
735
  /* Check the value is an acceptable value */
770
  else
771
  $field_id = xprofile_get_field_id_from_name( $field );
772
 
773
+ if ( empty( $field_id ) || empty( $user_id ) )
774
  return false;
775
 
776
+ $field = new BP_XProfile_ProfileData( $field_id, $user_id );
777
  return $field->delete();
778
  }
779
 
893
  *
894
  * @package BuddyPress Core
895
  */
896
+ function xprofile_sync_wp_profile( $user_id = false ) {
897
  global $bp, $wpdb;
898
 
899
  if ( (int)$bp->site_options['bp-disable-profile-sync'] )
900
  return true;
901
 
902
+ if ( empty( $user_id ) )
903
+ $user_id = $bp->loggedin_user->id;
904
+
905
+ if ( empty( $user_id ) )
906
+ return false;
907
+
908
+ $fullname = xprofile_get_field_data( BP_XPROFILE_FULLNAME_FIELD_NAME, $user_id );
909
  $space = strpos( $fullname, ' ' );
910
 
911
  if ( false === $space ) {
916
  $lastname = trim( substr( $fullname, $space, strlen($fullname) ) );
917
  }
918
 
919
+ update_usermeta( $user_id, 'nickname', $fullname );
920
+ update_usermeta( $user_id, 'first_name', $firstname );
921
+ update_usermeta( $user_id, 'last_name', $lastname );
922
 
923
+ $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->users} SET display_name = %s WHERE ID = %d", $fullname, $user_id ) );
924
+ $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->users} SET user_url = %s WHERE ID = %d", bp_core_get_user_domain( $user_id ), $user_id ) );
925
  }
926
  add_action( 'xprofile_updated_profile', 'xprofile_sync_wp_profile' );
927
+ add_action( 'bp_core_signup_user', 'xprofile_sync_wp_profile' );
928
 
929
  /**
930
  * xprofile_remove_screen_notifications()
bp-xprofile/bp-xprofile-templatetags.php CHANGED
@@ -344,7 +344,11 @@ function bp_the_profile_field_input_name() {
344
  function bp_get_the_profile_field_input_name() {
345
  global $field;
346
 
347
- return apply_filters( 'bp_get_the_profile_field_input_name', 'field_' . $field->id );
 
 
 
 
348
  }
349
 
350
  function bp_the_profile_field_options( $args = '' ) {
@@ -372,15 +376,18 @@ function bp_the_profile_field_options( $args = '' ) {
372
  $html .= '<option value="">--------</option>';
373
 
374
  for ( $k = 0; $k < count($options); $k++ ) {
375
- $option_value = BP_XProfile_ProfileData::get_value_byid($options[$k]->parent_id);
 
376
 
377
  /* Check for updated posted values, but errors preventing them from being saved first time */
378
- if ( isset( $_POST['field_' . $field->id] ) && $option_value != $_POST['field_' . $field->id] ) {
379
- if ( !empty( $_POST['field_' . $field->id] ) )
380
- $option_value = $_POST['field_' . $field->id];
 
 
381
  }
382
 
383
- if ( $option_value == $options[$k]->name || $options[$k]->is_default_option ) {
384
  $selected = ' selected="selected"';
385
  } else {
386
  $selected = '';
344
  function bp_get_the_profile_field_input_name() {
345
  global $field;
346
 
347
+ $array_box = false;
348
+ if ( 'multiselectbox' == $field->type )
349
+ $array_box = '[]';
350
+
351
+ return apply_filters( 'bp_get_the_profile_field_input_name', 'field_' . $field->id . $array_box );
352
  }
353
 
354
  function bp_the_profile_field_options( $args = '' ) {
376
  $html .= '<option value="">--------</option>';
377
 
378
  for ( $k = 0; $k < count($options); $k++ ) {
379
+ $option_values = maybe_unserialize( BP_XProfile_ProfileData::get_value_byid( $options[$k]->parent_id ) );
380
+ $option_values = (array)$option_values;
381
 
382
  /* Check for updated posted values, but errors preventing them from being saved first time */
383
+ foreach( (array)$option_values as $i => $option_value ) {
384
+ if ( isset( $_POST['field_' . $field->id] ) && $_POST['field_' . $field->id] != $option_value ) {
385
+ if ( !empty( $_POST['field_' . $field->id] ) )
386
+ $option_values[$i] = $_POST['field_' . $field->id];
387
+ }
388
  }
389
 
390
+ if ( in_array( $options[$k]->name, (array)$option_values ) || $options[$k]->is_default_option ) {
391
  $selected = ' selected="selected"';
392
  } else {
393
  $selected = '';
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: apeatling
3
  Tags: buddypress, social networking, activity, profiles, messaging, friends, groups, forums, microblogging, twitter, facebook, mingle, social, community, networks, networking, cms
4
  Requires at least: WordPress 2.9.1
5
  Tested up to: WordPress 2.9.2
6
- Stable tag: 1.2.1
7
 
8
  == Description ==
9
 
@@ -21,6 +21,22 @@ If you're interested in seeing what a default installation of BuddyPress has to
21
 
22
  More and more WordPress with BuddyPress powered sites are popping up. You can take a look at some of the best sites on the <a href="http://buddypress.org/demo/">BuddyPress demo page</a> or the <a href="http://wordpress.org/showcase/flavor/buddypress/">BuddyPress section of the WordPress showcase</a>.
23
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  <h4>More Information</h4>
25
 
26
  Visit the <a href="http://buddypress.org/">BuddyPress website</a> for more information about BuddyPress.
@@ -43,7 +59,9 @@ BuddyPress also includes support for discussion forums. Each group created on yo
43
 
44
  = Can I use my existing WordPress theme? =
45
 
46
- Yes you can. First install and activate BuddyPress, then download and activate the <a href="http://wordpress.org/extend/plugins/bp-template-pack/">template extension pack</a>. This plugin will run you through the process step-by-step.
 
 
47
 
48
  = Will this work on standard WordPress and WordPress MU? =
49
 
@@ -65,6 +83,42 @@ Bugs can be reported here: http://trac.buddypress.org/newticket/
65
 
66
  BuddyPress subversion trunk can be found at: http://svn.buddypress.org/trunk/
67
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
  == Changelog ==
69
 
70
  See http://buddypress.org/about/release-history/ for a list of changes.
3
  Tags: buddypress, social networking, activity, profiles, messaging, friends, groups, forums, microblogging, twitter, facebook, mingle, social, community, networks, networking, cms
4
  Requires at least: WordPress 2.9.1
5
  Tested up to: WordPress 2.9.2
6
+ Stable tag: 1.2.2
7
 
8
  == Description ==
9
 
21
 
22
  More and more WordPress with BuddyPress powered sites are popping up. You can take a look at some of the best sites on the <a href="http://buddypress.org/demo/">BuddyPress demo page</a> or the <a href="http://wordpress.org/showcase/flavor/buddypress/">BuddyPress section of the WordPress showcase</a>.
23
 
24
+ <h4>Plugins: Adding So Much More</h4>
25
+
26
+ BuddyPress boasts an ever growing array of new features developed by the awesome plugin development community. Some of most popular BuddyPress plugins currently available are:
27
+
28
+ * <a href="http://wordpress.org/extend/plugins/buddypress-classifieds">BuddyPress Tweetstream</a> - allow your users to sync and post to their twitter stream.
29
+ * <a href="http://wordpress.org/extend/plugins/buddypress-like">BuddyPress Like</a> - add a "like" button to site activity.
30
+ * <a href="http://wordpress.org/extend/plugins/buddypress-links">BuddyPress Links</a> - rich media embedding for your BuddyPress powered site.
31
+ * <a href="http://wordpress.org/extend/plugins/bp-album">BuddyPress Album+</a> - allow your users to upload photos and create albums.
32
+ * <a href="http://wordpress.org/extend/plugins/buddypress-group-documents">BuddyPress Group Documents</a> - add file upload and document repositories to your groups.
33
+ * <a href="http://wordpress.org/extend/plugins/bp-profile-privacy">BuddyPress Profile Privacy</a> - allow your users to set privacy options on their profile data.
34
+ * <a href="http://wordpress.org/extend/plugins/welcome-pack">BuddyPress Welcome Pack</a> - set defaults for new users, auto join them to groups or send welcome messages.
35
+ * <a href="http://wordpress.org/extend/plugins/bp-groupblog">BuddyPress Group Blog</a> (WordPress MU only) - allow your groups to include a fully functional WordPress blog.
36
+ * <a href="http://wordpress.org/extend/plugins/buddypress-links">BuddyPress Group Wiki</a> - add wiki functionality to your groups so all members can contribute to pages.
37
+
38
+ There are already more than 125 BuddyPress plugins available, the list is growing every day. For a full list of plugins, please visit the <a href="http://buddypress.org/extend/plugins/">BuddyPress.org plugins page</a>. You can also install any of these plugins automatically through the plugin installer menu inside of your WordPress installation.
39
+
40
  <h4>More Information</h4>
41
 
42
  Visit the <a href="http://buddypress.org/">BuddyPress website</a> for more information about BuddyPress.
59
 
60
  = Can I use my existing WordPress theme? =
61
 
62
+ Of course! First install and activate BuddyPress, then download and activate the <a href="http://wordpress.org/extend/plugins/bp-template-pack/">template extension pack</a>. This plugin will run you through the process step-by-step.
63
+
64
+ Be sure to also try out the default theme bundled with BuddyPress. It provides all the awesome features of a standard WordPress blog, but also integrates the BuddyPress features both seamlessly and beautfully. It's also really easy to modify with custom header support, widget support and via a <a href="http://codex.buddypress.org/how-to-guides/building-a-buddypress-child-theme/">child theme</a>.
65
 
66
  = Will this work on standard WordPress and WordPress MU? =
67
 
83
 
84
  BuddyPress subversion trunk can be found at: http://svn.buddypress.org/trunk/
85
 
86
+ == Screenshots ==
87
+
88
+ 1. **Activity Streams** - Global, personal and group activity streams with threaded commenting, direct posting, favoriting and @mentions. All with full RSS feed and email notification support.
89
+ 2. **Extended Profiles** - Fully editable profile fields allow you to define the fields users can fill in to describe themselves. Tailor profile fields to suit your audience.
90
+ 3. **Extensible Groups** - Powerful public, private or hidden groups allow your users to break the discussion down into specific topics. Extend groups with your own custom features using the group extension API.
91
+ 4. **Friend Connections** - Let your users make connections so they can track the activity of others, or filter on only those users they care about the most.
92
+ 5. **Private Messaging** - Private messaging will allow your users to talk to each other directly, and in private. Not just limited to one on one discussions, your users can send messages to multiple recipients.
93
+ 6. **Discussion Forums** - Full powered discussion forums built directly into groups allow for more conventional in-depth conversations.
94
+ 7. **WordPress Blogging** - Start a blog built on the best blogging software in the world. Even allow each of your users to start their own full powered WordPress blog (with WordPress MU). Track new posts and comments across your site.
95
+
96
+ == Languages ==
97
+
98
+ BuddyPress is available in more than 20 languages. For more information about BuddyPress in your language please select a langauge site from the list below. Is your language missing? Please send a message to the <a href="http://lists.automattic.com/mailman/listinfo/wp-polyglots">WP-Polygots</a> mailing list and request for your language to be set up.
99
+
100
+ * <a href="http://br.buddypress.org/">Brasil</a>
101
+ * <a href="http://ca.buddypress.org/">Català</a>
102
+ * <a href="http://de.buddypress.org/">Deutsch</a>
103
+ * <a href="http://es.buddypress.org/">Español</a>
104
+ * <a href="http://fr.buddypress.org/">Français</a>
105
+ * <a href="http://id.buddypress.org/">Indonesia</a>
106
+ * <a href="http://it.buddypress.org/">Italia</a>
107
+ * <a href="http://lv.buddypress.org/">Latviešu valodā</a>
108
+ * <a href="http://nl.buddypress.org/">Nederland</a>
109
+ * <a href="http://pl.buddypress.org/">Polska</a>
110
+ * <a href="http://pt.buddypress.org/">Portugal</a>
111
+ * <a href="http://ru.buddypress.org/">Русский</a>
112
+ * <a href="http://fi.buddypress.org/">Suomi</a>
113
+ * <a href="http://th.buddypress.org/">Thai</a>
114
+ * <a href="http://uk.buddypress.org/">Україна</a>
115
+ * <a href="http://ja.buddypress.org/">日本語</a>
116
+ * <a href="http://cn.buddypress.org/">简体中文</a>
117
+ * <a href="http://ko.buddypress.org/">한국어</a>
118
+ * <a href="http://tw.buddypress.org/">正體中文</a>
119
+
120
+ The <a href="http://i18n.svn.buddypress.org/">BuddyPress langauge file repository</a> includes some language that have not yet set up a localization site.
121
+
122
  == Changelog ==
123
 
124
  See http://buddypress.org/about/release-history/ for a list of changes.
screenshot-1.gif ADDED
Binary file
screenshot-2.gif ADDED
Binary file
screenshot-3.gif ADDED
Binary file
screenshot-4.gif ADDED
Binary file
screenshot-5.gif ADDED
Binary file
screenshot-6.gif ADDED
Binary file
screenshot-7.gif ADDED
Binary file