bbPress - Version 2.0.2

Version Description

  • Fix forum and topic freshness recount
  • Fix non-admin post editing
  • Fix topic closing
Download this release

Release Info

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

Code changes from version 2.0.1 to 2.0.2

bbp-admin/bbp-functions.php CHANGED
@@ -827,7 +827,7 @@ function bbp_recount_rewalk() {
827
  $result = __( 'Failed!', 'bbpress' );
828
 
829
  // First, delete everything.
830
- if ( is_wp_error( $wpdb->query( "DELETE FROM `$wpdb->postmeta` WHERE `meta_key` IN ( '_bbp_last_reply_id', '_bbp_last_topic_id', '_bbp_last_active_id' );" ) ) )
831
  return array( 1, sprintf( $statement, $result ) );
832
 
833
  // Next, give all the topics with replies the ID their last reply.
827
  $result = __( 'Failed!', 'bbpress' );
828
 
829
  // First, delete everything.
830
+ if ( is_wp_error( $wpdb->query( "DELETE FROM `$wpdb->postmeta` WHERE `meta_key` IN ( '_bbp_last_reply_id', '_bbp_last_topic_id', '_bbp_last_active_id', '_bbp_last_active_time' );" ) ) )
831
  return array( 1, sprintf( $statement, $result ) );
832
 
833
  // Next, give all the topics with replies the ID their last reply.
bbp-includes/bbp-common-template.php CHANGED
@@ -434,6 +434,9 @@ function bbp_is_topics_created() {
434
  function bbp_is_user_home() {
435
  global $bbp;
436
 
 
 
 
437
  if ( empty( $bbp->displayed_user ) )
438
  return false;
439
 
434
  function bbp_is_user_home() {
435
  global $bbp;
436
 
437
+ if ( !is_user_logged_in() )
438
+ return false;
439
+
440
  if ( empty( $bbp->displayed_user ) )
441
  return false;
442
 
bbp-includes/bbp-core-compatibility.php CHANGED
@@ -1570,11 +1570,6 @@ function bbp_pre_get_posts( $posts_query ) {
1570
  // View or edit?
1571
  if ( !empty( $is_edit ) ) {
1572
 
1573
- // Only allow super admins on multisite to edit every user.
1574
- if ( !is_user_logged_in() || ( is_multisite() && !current_user_can( 'manage_network_users' ) && ( $user->ID != bbp_get_current_user_id() ) && !apply_filters( 'enable_edit_any_user_configuration', true ) ) || !current_user_can( 'edit_user', $user->ID ) ) {
1575
- wp_die( __( 'You do not have the permission to edit this user.', 'bbpress' ) );
1576
- }
1577
-
1578
  // We are editing a profile
1579
  $posts_query->bbp_is_single_user_edit = true;
1580
 
@@ -1631,11 +1626,6 @@ function bbp_pre_get_posts( $posts_query ) {
1631
  // Topic/Reply Edit Page
1632
  } elseif ( !empty( $is_edit ) ) {
1633
 
1634
- // Bail from edit if user is not logged in
1635
- if ( !is_user_logged_in() ) {
1636
- return;
1637
- }
1638
-
1639
  // We are editing a topic
1640
  if ( $posts_query->get( 'post_type' ) == bbp_get_topic_post_type() ) {
1641
  $posts_query->bbp_is_topic_edit = true;
1570
  // View or edit?
1571
  if ( !empty( $is_edit ) ) {
1572
 
 
 
 
 
 
1573
  // We are editing a profile
1574
  $posts_query->bbp_is_single_user_edit = true;
1575
 
1626
  // Topic/Reply Edit Page
1627
  } elseif ( !empty( $is_edit ) ) {
1628
 
 
 
 
 
 
1629
  // We are editing a topic
1630
  if ( $posts_query->get( 'post_type' ) == bbp_get_topic_post_type() ) {
1631
  $posts_query->bbp_is_topic_edit = true;
bbp-includes/bbp-core-hooks.php CHANGED
@@ -36,6 +36,7 @@ add_action( 'init', 'bbp_init', 10 );
36
  add_action( 'widgets_init', 'bbp_widgets_init', 10 );
37
  add_action( 'generate_rewrite_rules', 'bbp_generate_rewrite_rules', 10 );
38
  add_action( 'wp_enqueue_scripts', 'bbp_enqueue_scripts', 10 );
 
39
  add_filter( 'template_include', 'bbp_template_include', 10 );
40
 
41
  /**
@@ -228,6 +229,12 @@ add_action( 'bbp_new_reply', 'bbp_global_access_auto_role' );
228
  add_action( 'bbp_activation', 'flush_rewrite_rules' );
229
  add_action( 'bbp_deactivation', 'flush_rewrite_rules' );
230
 
 
 
 
 
 
 
231
  /**
232
  * When a new site is created in a multisite installation, run the activation
233
  * routine on that site
@@ -709,4 +716,18 @@ function bbp_template_include( $template = '' ) {
709
  return apply_filters( 'bbp_template_include', $template );
710
  }
711
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
712
  ?>
36
  add_action( 'widgets_init', 'bbp_widgets_init', 10 );
37
  add_action( 'generate_rewrite_rules', 'bbp_generate_rewrite_rules', 10 );
38
  add_action( 'wp_enqueue_scripts', 'bbp_enqueue_scripts', 10 );
39
+ add_action( 'template_redirect', 'bbp_template_redirect', 10 );
40
  add_filter( 'template_include', 'bbp_template_include', 10 );
41
 
42
  /**
229
  add_action( 'bbp_activation', 'flush_rewrite_rules' );
230
  add_action( 'bbp_deactivation', 'flush_rewrite_rules' );
231
 
232
+ // Redirect user if needed
233
+ add_action( 'bbp_template_redirect', 'bbp_check_user_edit', 10 );
234
+ add_action( 'bbp_template_redirect', 'bbp_check_topic_edit', 10 );
235
+ add_action( 'bbp_template_redirect', 'bbp_check_reply_edit', 10 );
236
+ add_action( 'bbp_template_redirect', 'bbp_check_topic_tag_edit', 10 );
237
+
238
  /**
239
  * When a new site is created in a multisite installation, run the activation
240
  * routine on that site
716
  return apply_filters( 'bbp_template_include', $template );
717
  }
718
 
719
+ /** Theme Permissions *********************************************************/
720
+
721
+ /**
722
+ * The main action used for redirecting bbPress theme actions that are not
723
+ * permitted by the current_user
724
+ *
725
+ * @since bbPress (r3605)
726
+ *
727
+ * @uses do_action()
728
+ */
729
+ function bbp_template_redirect() {
730
+ do_action( 'bbp_template_redirect' );
731
+ }
732
+
733
  ?>
bbp-includes/bbp-reply-functions.php CHANGED
@@ -1443,4 +1443,30 @@ function bbp_display_replies_feed_rss2( $replies_query = array() ) {
1443
  exit();
1444
  }
1445
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1446
  ?>
1443
  exit();
1444
  }
1445
 
1446
+ /** Permissions ***************************************************************/
1447
+
1448
+ /**
1449
+ * Redirect if unathorized user is attempting to edit a reply
1450
+ *
1451
+ * @since bbPress (r3605)
1452
+ *
1453
+ * @uses bbp_is_reply_edit()
1454
+ * @uses current_user_can()
1455
+ * @uses bbp_get_topic_id()
1456
+ * @uses wp_safe_redirect()
1457
+ * @uses bbp_get_topic_permalink()
1458
+ */
1459
+ function bbp_check_reply_edit() {
1460
+
1461
+ // Bail if not editing a topic
1462
+ if ( !bbp_is_reply_edit() )
1463
+ return;
1464
+
1465
+ // User cannot edit topic, so redirect back to reply
1466
+ if ( !current_user_can( 'edit_reply', bbp_get_reply_id() ) ) {
1467
+ wp_safe_redirect( bbp_get_reply_url() );
1468
+ exit();
1469
+ }
1470
+ }
1471
+
1472
  ?>
bbp-includes/bbp-topic-functions.php CHANGED
@@ -2400,7 +2400,7 @@ function bbp_close_topic( $topic_id = 0 ) {
2400
  return $topic;
2401
 
2402
  // Bail if already closed
2403
- if ( bbp_get_closed_status_id == $topic['post_status'] )
2404
  return false;
2405
 
2406
  // Execute pre close code
@@ -3041,4 +3041,54 @@ function bbp_display_topics_feed_rss2( $topics_query = array() ) {
3041
  exit();
3042
  }
3043
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3044
  ?>
2400
  return $topic;
2401
 
2402
  // Bail if already closed
2403
+ if ( bbp_get_closed_status_id() == $topic['post_status'] )
2404
  return false;
2405
 
2406
  // Execute pre close code
3041
  exit();
3042
  }
3043
 
3044
+ /** Permissions ***************************************************************/
3045
+
3046
+ /**
3047
+ * Redirect if unathorized user is attempting to edit a topic
3048
+ *
3049
+ * @since bbPress (r3605)
3050
+ *
3051
+ * @uses bbp_is_topic_edit()
3052
+ * @uses current_user_can()
3053
+ * @uses bbp_get_topic_id()
3054
+ * @uses wp_safe_redirect()
3055
+ * @uses bbp_get_topic_permalink()
3056
+ */
3057
+ function bbp_check_topic_edit() {
3058
+
3059
+ // Bail if not editing a topic
3060
+ if ( !bbp_is_topic_edit() )
3061
+ return;
3062
+
3063
+ // User cannot edit topic, so redirect back to topic
3064
+ if ( !current_user_can( 'edit_topic', bbp_get_topic_id() ) ) {
3065
+ wp_safe_redirect( bbp_get_topic_permalink() );
3066
+ exit();
3067
+ }
3068
+ }
3069
+
3070
+ /**
3071
+ * Redirect if unathorized user is attempting to edit a topic tag
3072
+ *
3073
+ * @since bbPress (r3605)
3074
+ *
3075
+ * @uses bbp_is_topic_tag_edit()
3076
+ * @uses current_user_can()
3077
+ * @uses bbp_get_topic_tag_id()
3078
+ * @uses wp_safe_redirect()
3079
+ * @uses bbp_get_topic_tag_link()
3080
+ */
3081
+ function bbp_check_topic_tag_edit() {
3082
+
3083
+ // Bail if not editing a topic tag
3084
+ if ( !bbp_is_topic_tag_edit() )
3085
+ return;
3086
+
3087
+ // Bail if current user cannot edit topic tags
3088
+ if ( !current_user_can( 'edit_topic_tags', bbp_get_topic_tag_id() ) ) {
3089
+ wp_safe_redirect( bbp_get_topic_tag_link() );
3090
+ exit();
3091
+ }
3092
+ }
3093
+
3094
  ?>
bbp-includes/bbp-user-functions.php CHANGED
@@ -1248,4 +1248,34 @@ function bbp_is_user_inactive( $user_id = 0 ) {
1248
  return !bbp_is_user_active( $user_id );
1249
  }
1250
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1251
  ?>
1248
  return !bbp_is_user_active( $user_id );
1249
  }
1250
 
1251
+ /** Premissions ***************************************************************/
1252
+
1253
+ /**
1254
+ * Redirect if unathorized user is attempting to edit a topic
1255
+ *
1256
+ * @since bbPress (r3605)
1257
+ *
1258
+ * @uses bbp_is_single_user_edit()
1259
+ * @uses is_user_logged_in()
1260
+ * @uses current_user_can()
1261
+ * @uses bbp_is_user_home()
1262
+ * @uses apply_filters()
1263
+ * @uses is_multisite()
1264
+ * @uses bbp_get_displayed_user_id()
1265
+ * @uses wp_safe_redirect()
1266
+ * @uses bbp_get_user_profile_url()
1267
+ */
1268
+ function bbp_check_user_edit() {
1269
+
1270
+ // Bail if not editing a topic
1271
+ if ( !bbp_is_single_user_edit() )
1272
+ return;
1273
+
1274
+ // Only allow super admins on multisite to edit every user.
1275
+ if ( !is_user_logged_in() || ( is_multisite() && !current_user_can( 'manage_network_users' ) && bbp_is_user_home() && !apply_filters( 'enable_edit_any_user_configuration', true ) ) || !current_user_can( 'edit_user', bbp_get_displayed_user_id() ) ) {
1276
+ wp_safe_redirect( bbp_get_user_profile_url( bbp_get_displayed_user_id() ) );
1277
+ exit();
1278
+ }
1279
+ }
1280
+
1281
  ?>
bbpress.php CHANGED
@@ -15,7 +15,7 @@
15
  * Description: bbPress is forum software with a twist from the creators of WordPress.
16
  * Author: The bbPress Community
17
  * Author URI: http://bbpress.org
18
- * Version: 2.0.1
19
  * Text Domain: bbpress
20
  * Domain Path: /bbp-languages/
21
  */
@@ -48,12 +48,12 @@ class bbPress {
48
  /**
49
  * @public string bbPress version
50
  */
51
- public $version = '2.0.1';
52
 
53
  /**
54
  * @public string bbPress DB version
55
  */
56
- public $db_version = '200';
57
 
58
  /** Post types ************************************************************/
59
 
15
  * Description: bbPress is forum software with a twist from the creators of WordPress.
16
  * Author: The bbPress Community
17
  * Author URI: http://bbpress.org
18
+ * Version: 2.0.2
19
  * Text Domain: bbpress
20
  * Domain Path: /bbp-languages/
21
  */
48
  /**
49
  * @public string bbPress version
50
  */
51
+ public $version = '2.0.2';
52
 
53
  /**
54
  * @public string bbPress DB version
55
  */
56
+ public $db_version = '202';
57
 
58
  /** Post types ************************************************************/
59
 
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: matt, johnjamesjacoby
3
  Tags: bbpress, forums, discussion, support, theme, buddypress, akismet, multisite
4
  Requires at least: 3.2.1
5
  Tested up to: 3.2.1
6
- Stable tag: 2.0.1
7
 
8
  bbPress is forum software with a twist from the creators of WordPress
9
 
@@ -24,6 +24,11 @@ We're keeping things as small and light as possible while still allowing for gre
24
 
25
  == Changelog ==
26
 
 
 
 
 
 
27
  = 2.0.1 =
28
  * Fix anonymous post editing bug
29
 
3
  Tags: bbpress, forums, discussion, support, theme, buddypress, akismet, multisite
4
  Requires at least: 3.2.1
5
  Tested up to: 3.2.1
6
+ Stable tag: 2.0.2
7
 
8
  bbPress is forum software with a twist from the creators of WordPress
9
 
24
 
25
  == Changelog ==
26
 
27
+ = 2.0.2 =
28
+ * Fix forum and topic freshness recount
29
+ * Fix non-admin post editing
30
+ * Fix topic closing
31
+
32
  = 2.0.1 =
33
  * Fix anonymous post editing bug
34