bbPress - Version 2.2.3

Version Description

  • Improve compatibility with some themes
  • Fix integration with BuddyPress Group Forums
  • Fix BuddyPress Activity Stream integration
Download this release

Release Info

Developer johnjamesjacoby
Plugin Icon 128x128 bbPress
Version 2.2.3
Comparing to
See all releases

Code changes from version 2.2.2 to 2.2.3

bbpress.php CHANGED
@@ -5,7 +5,7 @@
5
  *
6
  * bbPress is forum software with a twist from the creators of WordPress.
7
  *
8
- * $Id: bbpress.php 4471 2012-11-23 11:24:58Z johnjamesjacoby $
9
  *
10
  * @package bbPress
11
  * @subpackage Main
@@ -17,7 +17,7 @@
17
  * Description: bbPress is forum software with a twist from the creators of WordPress.
18
  * Author: The bbPress Community
19
  * Author URI: http://bbpress.org
20
- * Version: 2.2.2
21
  * Text Domain: bbpress
22
  * Domain Path: /languages/
23
  */
@@ -180,8 +180,8 @@ final class bbPress {
180
 
181
  /** Versions **********************************************************/
182
 
183
- $this->version = '2.2.2';
184
- $this->db_version = '220';
185
 
186
  /** Paths *************************************************************/
187
 
5
  *
6
  * bbPress is forum software with a twist from the creators of WordPress.
7
  *
8
+ * $Id: bbpress.php 4567 2012-12-11 09:20:41Z johnjamesjacoby $
9
  *
10
  * @package bbPress
11
  * @subpackage Main
17
  * Description: bbPress is forum software with a twist from the creators of WordPress.
18
  * Author: The bbPress Community
19
  * Author URI: http://bbpress.org
20
+ * Version: 2.2.3
21
  * Text Domain: bbpress
22
  * Domain Path: /languages/
23
  */
180
 
181
  /** Versions **********************************************************/
182
 
183
+ $this->version = '2.2.3';
184
+ $this->db_version = '223';
185
 
186
  /** Paths *************************************************************/
187
 
includes/admin/tools.php CHANGED
@@ -380,6 +380,13 @@ function bbp_admin_repair_group_forum_relationship() {
380
  update_option( '_bbp_group_forums_root_id', $posts[0]->ID );
381
  }
382
 
 
 
 
 
 
 
 
383
  // Complete results
384
  $result = sprintf( __( 'Complete! %s groups updated; %s forums updated.', 'bbpress' ), bbp_number_format( $g_count ), bbp_number_format( $f_count ) );
385
  return array( 0, sprintf( $statement, $result ) );
@@ -1108,14 +1115,15 @@ function bbp_admin_reset_handler() {
1108
  /** Options ***********************************************************/
1109
 
1110
  $statement = __( 'Deleting Settings… %s', 'bbpress' );
1111
- $sql_delete = bbp_delete_options();
1112
  $messages[] = sprintf( $statement, $success );
1113
 
1114
  /** Roles *************************************************************/
1115
 
1116
  $statement = __( 'Deleting Roles and Capabilities… %s', 'bbpress' );
1117
- $sql_delete = bbp_remove_roles();
1118
- $sql_delete = bbp_remove_caps();
 
1119
  $messages[] = sprintf( $statement, $success );
1120
 
1121
  /** Output ************************************************************/
380
  update_option( '_bbp_group_forums_root_id', $posts[0]->ID );
381
  }
382
 
383
+ // Remove bbPress 1.1 roles (BuddyPress)
384
+ remove_role( 'member' );
385
+ remove_role( 'inactive' );
386
+ remove_role( 'blocked' );
387
+ remove_role( 'moderator' );
388
+ remove_role( 'keymaster' );
389
+
390
  // Complete results
391
  $result = sprintf( __( 'Complete! %s groups updated; %s forums updated.', 'bbpress' ), bbp_number_format( $g_count ), bbp_number_format( $f_count ) );
392
  return array( 0, sprintf( $statement, $result ) );
1115
  /** Options ***********************************************************/
1116
 
1117
  $statement = __( 'Deleting Settings… %s', 'bbpress' );
1118
+ bbp_delete_options();
1119
  $messages[] = sprintf( $statement, $success );
1120
 
1121
  /** Roles *************************************************************/
1122
 
1123
  $statement = __( 'Deleting Roles and Capabilities… %s', 'bbpress' );
1124
+ remove_role( bbp_get_moderator_role() );
1125
+ remove_role( bbp_get_participant_role() );
1126
+ bbp_remove_caps();
1127
  $messages[] = sprintf( $statement, $success );
1128
 
1129
  /** Output ************************************************************/
includes/admin/users.php CHANGED
@@ -93,11 +93,11 @@ class BBP_Users_Admin {
93
 
94
  <?php if ( ! empty( $user_role ) ) : ?>
95
 
96
- <option value=""><?php _e( '&mdash; No role for this forum &mdash;', 'bbpress' ); ?></option>
97
 
98
  <?php else : ?>
99
 
100
- <option value="" selected="selected"><?php _e( '&mdash; No role for this forum &mdash;', 'bbpress' ); ?></option>
101
 
102
  <?php endif; ?>
103
 
93
 
94
  <?php if ( ! empty( $user_role ) ) : ?>
95
 
96
+ <option value=""><?php _e( '&mdash; No role for these forums &mdash;', 'bbpress' ); ?></option>
97
 
98
  <?php else : ?>
99
 
100
+ <option value="" selected="selected"><?php _e( '&mdash; No role for these forums &mdash;', 'bbpress' ); ?></option>
101
 
102
  <?php endif; ?>
103
 
includes/common/template-tags.php CHANGED
@@ -1463,7 +1463,7 @@ function bbp_reply_form_fields() {
1463
 
1464
  if ( bbp_is_reply_edit() ) : ?>
1465
 
1466
- <input type="hidden" name="bbp_reply_title" id="bbp_reply_title" value="<?php printf( __( 'Reply To: %s', 'bbpress' ), bbp_get_topic_title() ); ?>" />
1467
  <input type="hidden" name="bbp_reply_id" id="bbp_reply_id" value="<?php bbp_reply_id(); ?>" />
1468
  <input type="hidden" name="action" id="bbp_post_action" value="bbp-edit-reply" />
1469
 
@@ -2002,7 +2002,7 @@ function bbp_breadcrumb( $args = array() ) {
2002
  /** Ancestors *********************************************************/
2003
 
2004
  // Get post ancestors
2005
- if ( is_page() || is_single() || bbp_is_forum_edit() || bbp_is_topic_edit() || bbp_is_reply_edit() )
2006
  $ancestors = array_reverse( (array) get_post_ancestors( get_the_ID() ) );
2007
 
2008
  // Do we want to include a link to home?
1463
 
1464
  if ( bbp_is_reply_edit() ) : ?>
1465
 
1466
+ <input type="hidden" name="bbp_reply_title" id="bbp_reply_title" value="<?php bbp_reply_title(); ?>" />
1467
  <input type="hidden" name="bbp_reply_id" id="bbp_reply_id" value="<?php bbp_reply_id(); ?>" />
1468
  <input type="hidden" name="action" id="bbp_post_action" value="bbp-edit-reply" />
1469
 
2002
  /** Ancestors *********************************************************/
2003
 
2004
  // Get post ancestors
2005
+ if ( is_singular() || bbp_is_forum_edit() || bbp_is_topic_edit() || bbp_is_reply_edit() )
2006
  $ancestors = array_reverse( (array) get_post_ancestors( get_the_ID() ) );
2007
 
2008
  // Do we want to include a link to home?
includes/core/theme-compat.php CHANGED
@@ -647,14 +647,18 @@ function bbp_template_include_theme_compat( $template = '' ) {
647
  * normally be handled by bbPress, but proper single page templates do not
648
  * exist in the currently active theme.
649
  *
 
 
 
 
650
  * @since bbPress (r3034)
651
  * @param string $content
652
  * @return type
653
  */
654
  function bbp_replace_the_content( $content = '' ) {
655
 
656
- // Bail if not inside the main query loop
657
- if ( ! in_the_loop() || ! is_main_query() )
658
  return $content;
659
 
660
  $bbp = bbpress();
647
  * normally be handled by bbPress, but proper single page templates do not
648
  * exist in the currently active theme.
649
  *
650
+ * Note that we do *not* currently use is_main_query() here. This is because so
651
+ * many existing themes either use query_posts() or fail to use wp_reset_query()
652
+ * when running queries before the main loop, causing theme compat to fail.
653
+ *
654
  * @since bbPress (r3034)
655
  * @param string $content
656
  * @return type
657
  */
658
  function bbp_replace_the_content( $content = '' ) {
659
 
660
+ // Bail if not inside the query loop
661
+ if ( ! in_the_loop() )
662
  return $content;
663
 
664
  $bbp = bbpress();
includes/core/update.php CHANGED
@@ -246,14 +246,13 @@ function bbp_version_updater() {
246
  /** 2.2 Branch ************************************************************/
247
 
248
  // 2.2
249
- if ( $raw_db_version < 220 ) {
250
-
251
- // Remove bbPress 1.1 roles (BuddyPress)
252
- remove_role( 'member' );
253
- remove_role( 'inactive' );
254
- remove_role( 'blocked' );
255
- remove_role( 'moderator' );
256
- remove_role( 'keymaster' );
257
 
258
  // Refresh capabilities
259
  bbp_remove_caps();
246
  /** 2.2 Branch ************************************************************/
247
 
248
  // 2.2
249
+ if ( $raw_db_version < 223 ) {
250
+
251
+ // Remove the Moderator role from the database
252
+ remove_role( bbp_get_moderator_role() );
253
+
254
+ // Remove the Participant role from the database
255
+ remove_role( bbp_get_participant_role() );
 
256
 
257
  // Refresh capabilities
258
  bbp_remove_caps();
includes/extend/buddypress/activity.php CHANGED
@@ -254,7 +254,7 @@ class BBP_BuddyPress_Activity {
254
  private function record_activity( $args = '' ) {
255
 
256
  // Default activity args
257
- $defaults = array (
258
  'id' => null,
259
  'user_id' => bbp_get_current_user_id(),
260
  'type' => '',
@@ -266,8 +266,7 @@ class BBP_BuddyPress_Activity {
266
  'component' => $this->component,
267
  'recorded_time' => bp_core_current_time(),
268
  'hide_sitewide' => false
269
- );
270
- $activity = bbp_parse_args( $args, $defaults, 'record_activity' );
271
 
272
  // Add the activity
273
  return bp_activity_add( $activity );
@@ -447,22 +446,18 @@ class BBP_BuddyPress_Activity {
447
  if ( !bbp_is_topic_published( $topic_id ) )
448
  return;
449
 
450
- // Bail if forum is not public
451
- if ( !bbp_is_forum_public( $forum_id, false ) )
452
- return;
453
-
454
  // User link for topic author
455
  $user_link = bbp_get_user_profile_link( $user_id );
456
 
457
  // Topic
458
  $topic_permalink = bbp_get_topic_permalink( $topic_id );
459
- $topic_title = bbp_get_topic_title ( $topic_id );
460
- $topic_content = bbp_get_topic_content ( $topic_id );
461
  $topic_link = '<a href="' . $topic_permalink . '" title="' . $topic_title . '">' . $topic_title . '</a>';
462
 
463
  // Forum
464
  $forum_permalink = bbp_get_forum_permalink( $forum_id );
465
- $forum_title = bbp_get_forum_title ( $forum_id );
466
  $forum_link = '<a href="' . $forum_permalink . '" title="' . $forum_title . '">' . $forum_title . '</a>';
467
 
468
  // Activity action & text
@@ -481,6 +476,7 @@ class BBP_BuddyPress_Activity {
481
  'item_id' => $topic_id,
482
  'secondary_item_id' => $forum_id,
483
  'recorded_time' => get_post_time( 'Y-m-d H:i:s', true, $topic_id ),
 
484
  );
485
 
486
  // Record the activity
@@ -597,25 +593,21 @@ class BBP_BuddyPress_Activity {
597
  if ( !bbp_is_reply_published( $reply_id ) )
598
  return;
599
 
600
- // Bail if forum is not public
601
- if ( !bbp_is_forum_public( $forum_id, false ) )
602
- return;
603
-
604
  // Setup links for activity stream
605
  $user_link = bbp_get_user_profile_link( $user_id );
606
 
607
  // Reply
608
- $reply_url = bbp_get_reply_url ( $reply_id );
609
- $reply_content = bbp_get_reply_content( $reply_id );
610
 
611
  // Topic
612
  $topic_permalink = bbp_get_topic_permalink( $topic_id );
613
- $topic_title = bbp_get_topic_title ( $topic_id );
614
  $topic_link = '<a href="' . $topic_permalink . '" title="' . $topic_title . '">' . $topic_title . '</a>';
615
 
616
  // Forum
617
  $forum_permalink = bbp_get_forum_permalink( $forum_id );
618
- $forum_title = bbp_get_forum_title ( $forum_id );
619
  $forum_link = '<a href="' . $forum_permalink . '" title="' . $forum_title . '">' . $forum_title . '</a>';
620
 
621
  // Activity action & text
@@ -634,6 +626,7 @@ class BBP_BuddyPress_Activity {
634
  'item_id' => $reply_id,
635
  'secondary_item_id' => $topic_id,
636
  'recorded_time' => get_post_time( 'Y-m-d H:i:s', true, $reply_id ),
 
637
  );
638
 
639
  // Record the activity
@@ -706,3 +699,4 @@ class BBP_BuddyPress_Activity {
706
  }
707
  }
708
  endif;
 
254
  private function record_activity( $args = '' ) {
255
 
256
  // Default activity args
257
+ $activity = bbp_parse_args( $args, array(
258
  'id' => null,
259
  'user_id' => bbp_get_current_user_id(),
260
  'type' => '',
266
  'component' => $this->component,
267
  'recorded_time' => bp_core_current_time(),
268
  'hide_sitewide' => false
269
+ ), 'record_activity' );
 
270
 
271
  // Add the activity
272
  return bp_activity_add( $activity );
446
  if ( !bbp_is_topic_published( $topic_id ) )
447
  return;
448
 
 
 
 
 
449
  // User link for topic author
450
  $user_link = bbp_get_user_profile_link( $user_id );
451
 
452
  // Topic
453
  $topic_permalink = bbp_get_topic_permalink( $topic_id );
454
+ $topic_title = get_post_field( 'post_title', $topic_id, 'raw' );
455
+ $topic_content = get_post_field( 'post_content', $topic_id, 'raw' );
456
  $topic_link = '<a href="' . $topic_permalink . '" title="' . $topic_title . '">' . $topic_title . '</a>';
457
 
458
  // Forum
459
  $forum_permalink = bbp_get_forum_permalink( $forum_id );
460
+ $forum_title = get_post_field( 'post_title', $forum_id, 'raw' );
461
  $forum_link = '<a href="' . $forum_permalink . '" title="' . $forum_title . '">' . $forum_title . '</a>';
462
 
463
  // Activity action & text
476
  'item_id' => $topic_id,
477
  'secondary_item_id' => $forum_id,
478
  'recorded_time' => get_post_time( 'Y-m-d H:i:s', true, $topic_id ),
479
+ 'hide_sitewide' => ! bbp_is_forum_public( $forum_id, false )
480
  );
481
 
482
  // Record the activity
593
  if ( !bbp_is_reply_published( $reply_id ) )
594
  return;
595
 
 
 
 
 
596
  // Setup links for activity stream
597
  $user_link = bbp_get_user_profile_link( $user_id );
598
 
599
  // Reply
600
+ $reply_url = bbp_get_reply_url( $reply_id );
601
+ $reply_content = get_post_field( 'post_content', $reply_id, 'raw' );
602
 
603
  // Topic
604
  $topic_permalink = bbp_get_topic_permalink( $topic_id );
605
+ $topic_title = get_post_field( 'post_title', $topic_id, 'raw' );
606
  $topic_link = '<a href="' . $topic_permalink . '" title="' . $topic_title . '">' . $topic_title . '</a>';
607
 
608
  // Forum
609
  $forum_permalink = bbp_get_forum_permalink( $forum_id );
610
+ $forum_title = get_post_field( 'post_title', $forum_id, 'raw' );
611
  $forum_link = '<a href="' . $forum_permalink . '" title="' . $forum_title . '">' . $forum_title . '</a>';
612
 
613
  // Activity action & text
626
  'item_id' => $reply_id,
627
  'secondary_item_id' => $topic_id,
628
  'recorded_time' => get_post_time( 'Y-m-d H:i:s', true, $reply_id ),
629
+ 'hide_sitewide' => ! bbp_is_forum_public( $forum_id, false )
630
  );
631
 
632
  // Record the activity
699
  }
700
  }
701
  endif;
702
+
includes/extend/buddypress/functions.php CHANGED
@@ -385,7 +385,7 @@ function bbp_remove_group_id_from_forum( $forum_id = 0, $group_id = 0 ) {
385
 
386
  // Maybe update the groups forums
387
  if ( in_array( $group_id, $group_ids ) ) {
388
- unset( $group_ids[$group_id] );
389
  return bbp_update_forum_group_ids( $forum_id, $group_ids );
390
  }
391
  }
@@ -410,7 +410,7 @@ function bbp_remove_forum_id_from_group( $group_id = 0, $forum_id = 0 ) {
410
 
411
  // Maybe update the groups forums
412
  if ( in_array( $forum_id, $forum_ids ) ) {
413
- unset( $forum_ids[$forum_id] );
414
  return bbp_update_group_forum_ids( $group_id, $forum_ids );
415
  }
416
  }
385
 
386
  // Maybe update the groups forums
387
  if ( in_array( $group_id, $group_ids ) ) {
388
+ $group_ids = array_diff( array_values( $group_ids ), (array) $group_id );
389
  return bbp_update_forum_group_ids( $forum_id, $group_ids );
390
  }
391
  }
410
 
411
  // Maybe update the groups forums
412
  if ( in_array( $forum_id, $forum_ids ) ) {
413
+ $forum_ids = array_diff( array_values( $forum_ids ), (array) $forum_id );
414
  return bbp_update_group_forum_ids( $group_id, $forum_ids );
415
  }
416
  }
includes/extend/buddypress/group.php CHANGED
@@ -31,6 +31,18 @@ class BBP_Forums_Group_Extension extends BP_Group_Extension {
31
  * @since bbPress (r3552)
32
  */
33
  public function __construct() {
 
 
 
 
 
 
 
 
 
 
 
 
34
 
35
  // Name and slug
36
  $this->name = __( 'Forum', 'bbpress' );
@@ -54,17 +66,28 @@ class BBP_Forums_Group_Extension extends BP_Group_Extension {
54
  // Template file to load, and action to hook display on to
55
  $this->template_file = 'groups/single/plugins';
56
  $this->display_hook = 'bp_template_content';
 
57
 
58
- // Add handlers to bp_actions
59
- add_action( 'bp_actions', 'bbp_new_forum_handler' );
60
- add_action( 'bp_actions', 'bbp_new_topic_handler' );
61
- add_action( 'bp_actions', 'bbp_new_reply_handler' );
62
- add_action( 'bp_actions', 'bbp_edit_forum_handler' );
63
- add_action( 'bp_actions', 'bbp_edit_topic_handler' );
64
- add_action( 'bp_actions', 'bbp_edit_reply_handler' );
65
 
66
  // Possibly redirect
67
- add_action( 'bbp_template_redirect', array( $this, 'redirect_canonical' ) );
 
 
 
 
 
 
 
 
 
 
 
68
 
69
  // Group forum pagination
70
  add_filter( 'bbp_topic_pagination', array( $this, 'topic_pagination' ) );
@@ -91,9 +114,6 @@ class BBP_Forums_Group_Extension extends BP_Group_Extension {
91
  add_filter( 'bbp_map_topic_meta_caps', array( $this, 'map_topic_meta_caps' ), 10, 4 );
92
  add_filter( 'bbp_map_reply_meta_caps', array( $this, 'map_topic_meta_caps' ), 10, 4 );
93
 
94
- // Remove topic cap map when view is done
95
- add_action( 'bbp_after_group_forum_display', array( $this, 'remove_topic_meta_cap_map' ) );
96
-
97
  // Map group forum activity items to groups
98
  add_filter( 'bbp_before_record_activity_parse_args', array( $this, 'map_activity_to_group' ) );
99
 
@@ -122,6 +142,26 @@ class BBP_Forums_Group_Extension extends BP_Group_Extension {
122
  $this->display_forums( 0 );
123
  }
124
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
  /**
126
  * Allow group members to have advanced priviledges in group forum topics.
127
  *
@@ -147,7 +187,7 @@ class BBP_Forums_Group_Extension extends BP_Group_Extension {
147
  case 'publish_topics' :
148
  case 'read_hidden_forums' :
149
  case 'read_private_forums' :
150
- if ( bp_group_is_member() ) {
151
  $caps = array( 'participate' );
152
  }
153
  break;
@@ -234,15 +274,62 @@ class BBP_Forums_Group_Extension extends BP_Group_Extension {
234
  $edit_forum = !empty( $_POST['bbp-edit-group-forum'] ) ? true : false;
235
  $forum_id = 0;
236
  $group_id = bp_get_current_group_id();
237
- $forum_ids = bbp_get_group_forum_ids( $group_id );
238
- if ( !empty( $forum_ids ) )
239
- $forum_id = (int) is_array( $forum_ids ) ? $forum_ids[0] : $forum_ids;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
240
 
241
  // Update the group forum setting
242
  $group = new BP_Groups_Group( $group_id );
243
  $group->enable_forum = $edit_forum;
244
  $group->save();
245
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
246
  // Redirect after save
247
  bp_core_redirect( trailingslashit( bp_get_group_permalink( buddypress()->groups->current_group ) . '/admin/' . $this->slug ) );
248
  }
@@ -425,6 +512,7 @@ class BBP_Forums_Group_Extension extends BP_Group_Extension {
425
  $bbp = bbpress();
426
 
427
  // Forum data
 
428
  $forum_ids = bbp_get_group_forum_ids( bp_get_current_group_id() );
429
  $forum_args = array( 'post__in' => $forum_ids, 'post_parent' => null );
430
 
@@ -452,7 +540,7 @@ class BBP_Forums_Group_Extension extends BP_Group_Extension {
452
  <?php
453
 
454
  // Looking at the group forum root
455
- if ( !bp_action_variable( $offset ) ) :
456
 
457
  // Query forums and show them if they exist
458
  if ( !empty( $forum_ids ) && bbp_has_forums( $forum_args ) ) :
@@ -460,10 +548,15 @@ class BBP_Forums_Group_Extension extends BP_Group_Extension {
460
  // Only one forum found
461
  if ( 1 == $bbp->forum_query->post_count ) :
462
 
463
- // Get forum data
464
- $forum_slug = bp_action_variable( $offset );
465
- $forum_args = array( 'name' => $forum_slug, 'post_type' => bbp_get_forum_post_type() );
466
- $forums = get_posts( $forum_args );
 
 
 
 
 
467
 
468
  bbp_the_forum();
469
 
@@ -475,18 +568,18 @@ class BBP_Forums_Group_Extension extends BP_Group_Extension {
475
  add_filter( 'bbp_get_forum_subforum_count', '__return_false' );
476
 
477
  // Set up forum data
478
- $forum_id = bbpress()->current_forum_id = $forum->ID;
479
  bbp_set_query_name( 'bbp_single_forum' ); ?>
480
 
481
  <h3><?php bbp_forum_title(); ?></h3>
482
 
483
  <?php bbp_get_template_part( 'content', 'single-forum' ); ?>
484
 
485
- <?php
486
 
487
  // Remove the subforum suppression filter
488
  remove_filter( 'bbp_get_forum_subforum_count', '__return_false' );
489
-
490
  ?>
491
 
492
  <?php else : ?>
@@ -571,7 +664,6 @@ class BBP_Forums_Group_Extension extends BP_Group_Extension {
571
  $post = $forum;
572
 
573
  bbp_set_query_name( 'bbp_forum_form' );
574
-
575
  bbp_get_template_part( 'form', 'forum' );
576
 
577
  else :
@@ -625,13 +717,11 @@ class BBP_Forums_Group_Extension extends BP_Group_Extension {
625
  // Merge
626
  if ( !empty( $_GET['action'] ) && 'merge' == $_GET['action'] ) :
627
  bbp_set_query_name( 'bbp_topic_merge' );
628
-
629
  bbp_get_template_part( 'form', 'topic-merge' );
630
 
631
  // Split
632
  elseif ( !empty( $_GET['action'] ) && 'split' == $_GET['action'] ) :
633
  bbp_set_query_name( 'bbp_topic_split' );
634
-
635
  bbp_get_template_part( 'form', 'topic-split' );
636
 
637
  // Edit
@@ -643,7 +733,6 @@ class BBP_Forums_Group_Extension extends BP_Group_Extension {
643
 
644
  // Single Topic
645
  else:
646
-
647
  bbp_set_query_name( 'bbp_single_topic' ); ?>
648
 
649
  <h3><?php bbp_topic_title(); ?></h3>
@@ -862,7 +951,7 @@ class BBP_Forums_Group_Extension extends BP_Group_Extension {
862
  return $url;
863
  break;
864
  }
865
-
866
  // Get group ID's for this forum
867
  $group_ids = bbp_get_forum_group_ids( $forum_id );
868
 
@@ -1021,7 +1110,7 @@ class BBP_Forums_Group_Extension extends BP_Group_Extension {
1021
 
1022
  return $args;
1023
  }
1024
-
1025
  /**
1026
  * Ensure that forum content associated with a BuddyPress group can only be
1027
  * viewed via the group URL.
@@ -1096,6 +1185,6 @@ class BBP_Forums_Group_Extension extends BP_Group_Extension {
1096
  $args['item_id'] = $group->id;
1097
 
1098
  return $args;
1099
- }
1100
  }
1101
  endif;
31
  * @since bbPress (r3552)
32
  */
33
  public function __construct() {
34
+ $this->setup_variables();
35
+ $this->setup_actions();
36
+ $this->setup_filters();
37
+ $this->maybe_unset_forum_menu();
38
+ }
39
+
40
+ /**
41
+ * Setup the group forums class variables
42
+ *
43
+ * @since bbPress ()
44
+ */
45
+ private function setup_variables() {
46
 
47
  // Name and slug
48
  $this->name = __( 'Forum', 'bbpress' );
66
  // Template file to load, and action to hook display on to
67
  $this->template_file = 'groups/single/plugins';
68
  $this->display_hook = 'bp_template_content';
69
+ }
70
 
71
+ /**
72
+ * Setup the group forums class actions
73
+ *
74
+ * @since bbPress (r4552)
75
+ */
76
+ private function setup_actions() {
 
77
 
78
  // Possibly redirect
79
+ add_action( 'bbp_template_redirect', array( $this, 'redirect_canonical' ) );
80
+
81
+ // Remove topic cap map when view is done
82
+ add_action( 'bbp_after_group_forum_display', array( $this, 'remove_topic_meta_cap_map' ) );
83
+ }
84
+
85
+ /**
86
+ * Setup the group forums class filters
87
+ *
88
+ * @since bbPress (r4552)
89
+ */
90
+ private function setup_filters() {
91
 
92
  // Group forum pagination
93
  add_filter( 'bbp_topic_pagination', array( $this, 'topic_pagination' ) );
114
  add_filter( 'bbp_map_topic_meta_caps', array( $this, 'map_topic_meta_caps' ), 10, 4 );
115
  add_filter( 'bbp_map_reply_meta_caps', array( $this, 'map_topic_meta_caps' ), 10, 4 );
116
 
 
 
 
117
  // Map group forum activity items to groups
118
  add_filter( 'bbp_before_record_activity_parse_args', array( $this, 'map_activity_to_group' ) );
119
 
142
  $this->display_forums( 0 );
143
  }
144
 
145
+ /**
146
+ * Maybe unset the group forum nav item if group does not have a forum
147
+ *
148
+ * @since bbPress (r4552)
149
+ *
150
+ * @return If not viewing a single group
151
+ */
152
+ public function maybe_unset_forum_menu() {
153
+
154
+ // Bail if not viewing a single group
155
+ if ( ! bp_is_group() )
156
+ return;
157
+
158
+ // Are forums enabled for this group?
159
+ $checked = (bool) ( bp_get_new_group_enable_forum() );
160
+
161
+ // Tweak the nav item variable based on if group has forum or not
162
+ $this->enable_nav_item = $checked;
163
+ }
164
+
165
  /**
166
  * Allow group members to have advanced priviledges in group forum topics.
167
  *
187
  case 'publish_topics' :
188
  case 'read_hidden_forums' :
189
  case 'read_private_forums' :
190
+ if ( bp_group_is_member() || bp_group_is_mod() || bp_group_is_admin() ) {
191
  $caps = array( 'participate' );
192
  }
193
  break;
274
  $edit_forum = !empty( $_POST['bbp-edit-group-forum'] ) ? true : false;
275
  $forum_id = 0;
276
  $group_id = bp_get_current_group_id();
277
+ $forum_ids = array_values( bbp_get_group_forum_ids( $group_id ) );
278
+
279
+ // Normalize group forum relationships now
280
+ if ( !empty( $forum_ids ) ) {
281
+
282
+ // Loop through forums, and make sure they exist
283
+ foreach ( $forum_ids as $forum_id ) {
284
+
285
+ // Look for forum
286
+ $forum = bbp_get_forum( $forum_id );
287
+
288
+ // No forum exists, so break the relationship
289
+ if ( empty( $forum ) ) {
290
+ $this->remove_forum( array( 'forum_id' => $forum_id ) );
291
+ unset( $forum_ids[$forum_id] );
292
+ }
293
+ }
294
+
295
+ // No support for multiple forums yet
296
+ $forum_id = (int) ( is_array( $forum_ids ) ? $forum_ids[0] : $forum_ids );
297
+ }
298
 
299
  // Update the group forum setting
300
  $group = new BP_Groups_Group( $group_id );
301
  $group->enable_forum = $edit_forum;
302
  $group->save();
303
 
304
+ // Create a new forum
305
+ if ( empty( $forum_id ) && ( true === $edit_forum ) ) {
306
+
307
+ // Set the default forum status
308
+ switch ( $group->status ) {
309
+ case 'hidden' :
310
+ $status = bbp_get_hidden_status_id();
311
+ break;
312
+ case 'private' :
313
+ $status = bbp_get_private_status_id();
314
+ break;
315
+ case 'public' :
316
+ default :
317
+ $status = bbp_get_public_status_id();
318
+ break;
319
+ }
320
+
321
+ // Create the initial forum
322
+ $forum_id = bbp_insert_forum( array(
323
+ 'post_parent' => bbp_get_group_forums_root_id(),
324
+ 'post_title' => $group->name,
325
+ 'post_content' => $group->description,
326
+ 'post_status' => $status
327
+ ) );
328
+
329
+ // Run the BP-specific functions for new groups
330
+ $this->new_forum( array( 'forum_id' => $forum_id ) );
331
+ }
332
+
333
  // Redirect after save
334
  bp_core_redirect( trailingslashit( bp_get_group_permalink( buddypress()->groups->current_group ) . '/admin/' . $this->slug ) );
335
  }
512
  $bbp = bbpress();
513
 
514
  // Forum data
515
+ $forum_slug = bp_action_variable( $offset );
516
  $forum_ids = bbp_get_group_forum_ids( bp_get_current_group_id() );
517
  $forum_args = array( 'post__in' => $forum_ids, 'post_parent' => null );
518
 
540
  <?php
541
 
542
  // Looking at the group forum root
543
+ if ( empty( $forum_slug ) || ( 'page' == $forum_slug ) ) :
544
 
545
  // Query forums and show them if they exist
546
  if ( !empty( $forum_ids ) && bbp_has_forums( $forum_args ) ) :
548
  // Only one forum found
549
  if ( 1 == $bbp->forum_query->post_count ) :
550
 
551
+ // Remove 'name' check for paginated requests
552
+ if ( 'page' == $forum_slug ) {
553
+ $forum_args = array( 'post_type' => bbp_get_forum_post_type() );
554
+ } else {
555
+ $forum_args = array( 'name' => $forum_slug, 'post_type' => bbp_get_forum_post_type() );
556
+ }
557
+
558
+ // Get the forums
559
+ $forums = get_posts( $forum_args );
560
 
561
  bbp_the_forum();
562
 
568
  add_filter( 'bbp_get_forum_subforum_count', '__return_false' );
569
 
570
  // Set up forum data
571
+ bbpress()->current_forum_id = $forum->ID;
572
  bbp_set_query_name( 'bbp_single_forum' ); ?>
573
 
574
  <h3><?php bbp_forum_title(); ?></h3>
575
 
576
  <?php bbp_get_template_part( 'content', 'single-forum' ); ?>
577
 
578
+ <?php
579
 
580
  // Remove the subforum suppression filter
581
  remove_filter( 'bbp_get_forum_subforum_count', '__return_false' );
582
+
583
  ?>
584
 
585
  <?php else : ?>
664
  $post = $forum;
665
 
666
  bbp_set_query_name( 'bbp_forum_form' );
 
667
  bbp_get_template_part( 'form', 'forum' );
668
 
669
  else :
717
  // Merge
718
  if ( !empty( $_GET['action'] ) && 'merge' == $_GET['action'] ) :
719
  bbp_set_query_name( 'bbp_topic_merge' );
 
720
  bbp_get_template_part( 'form', 'topic-merge' );
721
 
722
  // Split
723
  elseif ( !empty( $_GET['action'] ) && 'split' == $_GET['action'] ) :
724
  bbp_set_query_name( 'bbp_topic_split' );
 
725
  bbp_get_template_part( 'form', 'topic-split' );
726
 
727
  // Edit
733
 
734
  // Single Topic
735
  else:
 
736
  bbp_set_query_name( 'bbp_single_topic' ); ?>
737
 
738
  <h3><?php bbp_topic_title(); ?></h3>
951
  return $url;
952
  break;
953
  }
954
+
955
  // Get group ID's for this forum
956
  $group_ids = bbp_get_forum_group_ids( $forum_id );
957
 
1110
 
1111
  return $args;
1112
  }
1113
+
1114
  /**
1115
  * Ensure that forum content associated with a BuddyPress group can only be
1116
  * viewed via the group URL.
1185
  $args['item_id'] = $group->id;
1186
 
1187
  return $args;
1188
+ }
1189
  }
1190
  endif;
includes/users/template-tags.php CHANGED
@@ -1014,7 +1014,7 @@ function bbp_edit_user_forums_role() {
1014
  unset( $dynamic_roles[ bbp_get_keymaster_role() ] ); ?>
1015
 
1016
  <select name="bbp-forums-role" id="bbp-forums-role">
1017
- <option value=""><?php _e( '&mdash; No role for this forum &mdash;', 'bbpress' ); ?></option>
1018
 
1019
  <?php foreach ( $dynamic_roles as $role => $details ) : ?>
1020
 
@@ -1509,7 +1509,7 @@ function bbp_current_user_can_publish_topics() {
1509
  }
1510
 
1511
  // Allow access to be filtered
1512
- return (bool) apply_filters( 'bbp_current_user_can_publish_forums', $retval );
1513
  }
1514
 
1515
  /**
1014
  unset( $dynamic_roles[ bbp_get_keymaster_role() ] ); ?>
1015
 
1016
  <select name="bbp-forums-role" id="bbp-forums-role">
1017
+ <option value=""><?php _e( '&mdash; No role for these forums &mdash;', 'bbpress' ); ?></option>
1018
 
1019
  <?php foreach ( $dynamic_roles as $role => $details ) : ?>
1020
 
1509
  }
1510
 
1511
  // Allow access to be filtered
1512
+ return (bool) apply_filters( 'bbp_current_user_can_publish_topics', $retval );
1513
  }
1514
 
1515
  /**
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: matt, johnjamesjacoby
3
  Tags: forums, discussion, support, theme, akismet, multisite
4
  Requires at least: 3.4
5
  Tested up to: 3.5
6
- Stable tag: 2.2.2
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -26,6 +26,11 @@ We're keeping things as small and light as possible while still allowing for gre
26
 
27
  == Changelog ==
28
 
 
 
 
 
 
29
  = 2.2.2 =
30
  * RTL and i18n fixes
31
  * Improved user profile theme compatibility
3
  Tags: forums, discussion, support, theme, akismet, multisite
4
  Requires at least: 3.4
5
  Tested up to: 3.5
6
+ Stable tag: 2.2.3
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
26
 
27
  == Changelog ==
28
 
29
+ = 2.2.3 =
30
+ * Improve compatibility with some themes
31
+ * Fix integration with BuddyPress Group Forums
32
+ * Fix BuddyPress Activity Stream integration
33
+
34
  = 2.2.2 =
35
  * RTL and i18n fixes
36
  * Improved user profile theme compatibility
templates/default/bbpress/user-details.php CHANGED
@@ -16,7 +16,7 @@
16
 
17
  <span class='vcard'>
18
  <a class="url fn n" href="<?php bbp_user_profile_url(); ?>" title="<?php bbp_displayed_user_field( 'display_name' ); ?>" rel="me">
19
- <?php echo get_avatar( bbp_get_displayed_user_field( 'user_email' ), apply_filters( 'twentyten_author_bio_avatar_size', 150 ) ); ?>
20
  </a>
21
  </span>
22
 
16
 
17
  <span class='vcard'>
18
  <a class="url fn n" href="<?php bbp_user_profile_url(); ?>" title="<?php bbp_displayed_user_field( 'display_name' ); ?>" rel="me">
19
+ <?php echo get_avatar( bbp_get_displayed_user_field( 'user_email' ), apply_filters( 'bbp_single_user_details_avatar_size', 150 ) ); ?>
20
  </a>
21
  </span>
22