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/user-view-post.php +19 -16 1.72.3 View file →
@@ -7,9 +7,9 @@
7 7
8 8 * Keymasters can always view, and moderators with no group set can view
9 9 *
10 10 *
11 - *Much of this code is Justin Tadlocks' from the members plugin - thanks Justin for awesome work !
11 + *Some of this code is Justin Tadlocks' from the members plugin - thanks Justin for awesome work !
12 12 */
13 13
14 14 function private_groups_can_user_view_post_id($forum_id) {
15 15 //get user ID
@@ -28,9 +28,9 @@
28 28
29 29 /* Get the groups for the forum */
30 30 $groups = get_post_meta( $forum_id, '_private_group', false );
31 31
32 - /* If we have groups set for this forum let's get to work. */
32 + /* If we have groups set for this forum let's get to work. */
33 33 if ( !empty( $groups ) && is_array( $groups ) ) {
34 34
35 35 /**
36 36 * Since specific groups exist let's assume the user can't view the post at
@@ -41,32 +41,35 @@
41 41 /* If the user's not logged in, assume it's blocked at this point. */
42 42 if (!is_user_logged_in() ) {
43 43 $can_view = false;
44 44 }
45 +
45 46
46 -
47 -
48 47 /*Check if user is keymaster*/
49 - if ( bbp_is_user_keymaster())
50 - $can_view = true;
51 -
52 - if (user_can( $user_id, 'moderate' ) ) {
48 + if ( bbp_is_user_keymaster()) $can_view = true;
49 + //now we'll check if the user is a moderator.
50 + else {
51 + $role = bbp_get_user_role( $user_id );
53 52 $check=get_user_meta( $user_id, 'private_group',true);
54 - if ($check=='') $can_view= true ;
55 - }
56 -
57 -
58 -
53 + //if they are a mod, and they have no forum groups set, then they can moderate and see across all forums
54 + if ($role == 'bbp_moderator' && (empty($check))) $can_view= true ;
55 + //otherwise if they are a moderator with groups set, then they can see (and moderate) only their visible forums
56 + //- just as everyone else does
57 +
59 58 /* Else, let's check the user's group against the selected group. */
60 59 else {
61 60
62 61 /* Loop through each group and set $can_view to true if the user has this group. */
63 62 $check=get_user_meta( $user_id, 'private_group',true);
63 +
64 64 foreach ( $groups as $group ) {
65 - if ($check==$group )
66 -
67 - $can_view = true;
65 + //single group set?
66 + if ($check==$group ) $can_view = true;
67 + //multiple group set
68 + if (strpos($check, '*'.$group.'*') !== FALSE) $can_view = true;
69 +
68 70 }
71 + }
69 72 }
70 73 }
71 74
72 75