PluginProbe
Private groups / 2.3
Private groups v2.3
trunk 1.5 1.6 1.7 1.8 1.8.1 1.9.1 1.9.2 2.0 2.0.1 2.2 2.3 2.4 2.5 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 All 116 releases
← All changes | includes/topics.php +22 -7 1.6 → 2.3 View file →
@@ -1,21 +1,35 @@
1 1 <?php
2 2
3 +//version 1.9.2 fixed private groups forums for subscriptions
4 +
3 5 add_filter ('bbp_before_has_topics_parse_args', 'pg_has_topics') ;
4 6
5 7 function pg_has_topics( $args = '' ) {
6 -
8 + //check if being called by subscriptions and if so skip filtering (as you can only subscribe to forums you can already see)
9 + if($args['post__in']) {
10 + return $args ;
11 + }
7 12 $default_post_parent = bbp_is_single_forum() ? bbp_get_forum_id() : 'any';
8 13
9 14 if ($default_post_parent == 'any') {
15 + if ( bbp_is_user_keymaster()) return $args;
16 + $user_id = wp_get_current_user()->ID;
17 +
18 + if (user_can( $user_id, 'moderate' ) ) {
19 + $check=get_user_meta( $user_id, 'private_group',true);
20 + if ($check=='') return $args;
21 + }
22 +
23 +
10 24 global $wpdb;
25 + $topic=bbp_get_topic_post_type() ;
26 + $post_ids=$wpdb->get_col("select ID from $wpdb->posts where post_type = '$topic'") ;
27 + //check this list against those the user is allowed to see, and create a list of valid ones for the wp_query in bbp_has_topics
28 + $allowed_posts = check_private_groups_topic_ids($post_ids) ;
11 29
12 - $post_ids=$wpdb->get_col("select ID from $wpdb->posts where post_type = 'topic'") ;
13 -//check this list against those the user is allowed to see, and create a list of valid ones for the wp_query in bbp_has_topics
14 -$allowed_posts = check_private_groups_topic_ids($post_ids) ;
15 -
16 30 $args['post__in'] = $allowed_posts;
17 - }
31 +}
18 32 return $args;
19 33 }
20 34
21 35
@@ -28,9 +42,10 @@
28 42
29 43 //Loop through all the posts
30 44 foreach ( $post_ids as $post_id ) {
31 45 //Get the Forum ID based on Post Type Topic
32 - $forum_id = private_groups_get_forum_id_from_post_id($post_id, 'topic');
46 + $topic=bbp_get_topic_post_type() ;
47 + $forum_id = private_groups_get_forum_id_from_post_id($post_id, $topic);
33 48 //Check if User has permissions to view this Post ID
34 49 //by calling the function that checks if the user can view this forum, and hence this post
35 50 if (private_groups_can_user_view_post_id($forum_id)) {
36 51