PluginProbe
bbPress / 2.6.6
bbPress v2.6.6
trunk 2.0 2.0-beta-1 2.0-beta-2b 2.0-beta-3 2.0-beta-3b 2.0-rc-2 2.0-rc-3 2.0-rc-4 2.0-rc-5 2.0.1 2.0.2 2.0.3 2.1 2.1-beta-1 2.1-rc1 2.1-rc2 2.1-rc3 2.1-rc4 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.2.2 All 71 releases
← All changes | includes/forums/capabilities.php +28 -39 trunk2.6.6 View file →
@@ -1,8 +1,8 @@
1 1 <?php
2 2
3 3 /**
4 - * bbPress Forum Capabilities.
4 + * bbPress Forum Capabilites
5 5 *
6 6 * Used to map forum capabilities to WordPress's existing capabilities.
7 7 *
8 8 * @package bbPress
@@ -9,41 +9,38 @@
9 9 * @subpackage Capabilities
10 10 */
11 11
12 12 /**
13 - * Return forum capabilities.
13 + * Return forum capabilities
14 14 *
15 15 * @since 2.0.0 bbPress (r2593)
16 16 *
17 - * @return array Forum capabilities.
17 + * @return array Forum capabilities
18 18 */
19 19 function bbp_get_forum_caps() {
20 20
21 21 // Filter & return
22 - return (array) apply_filters(
23 - 'bbp_get_forum_caps',
24 - array(
25 - 'edit_posts' => 'edit_forums',
26 - 'edit_others_posts' => 'edit_others_forums',
27 - 'publish_posts' => 'publish_forums',
28 - 'read_private_posts' => 'read_private_forums',
29 - 'read_hidden_posts' => 'read_hidden_forums',
30 - 'delete_posts' => 'delete_forums',
31 - 'delete_others_posts' => 'delete_others_forums'
32 - )
33 - );
22 + return (array) apply_filters( 'bbp_get_forum_caps', array(
23 + 'edit_posts' => 'edit_forums',
24 + 'edit_others_posts' => 'edit_others_forums',
25 + 'publish_posts' => 'publish_forums',
26 + 'read_private_posts' => 'read_private_forums',
27 + 'read_hidden_posts' => 'read_hidden_forums',
28 + 'delete_posts' => 'delete_forums',
29 + 'delete_others_posts' => 'delete_others_forums'
30 + ) );
34 31 }
35 32
36 33 /**
37 - * Maps forum capabilities.
34 + * Maps forum capabilities
38 35 *
39 36 * @since 2.2.0 bbPress (r4242)
40 37 *
41 - * @param array $caps Capabilities for meta capability.
42 - * @param string $cap Capability name.
43 - * @param int $user_id User id.
44 - * @param array $args Arguments.
45 - * @return array Actual capabilities for meta capability.
38 + * @param array $caps Capabilities for meta capability
39 + * @param string $cap Capability name
40 + * @param int $user_id User id
41 + * @param array $args Arguments
42 + * @return array Actual capabilities for meta capability
46 43 */
47 44 function bbp_map_forum_meta_caps( $caps = array(), $cap = '', $user_id = 0, $args = array() ) {
48 45
49 46 // What capability is being checked?
@@ -63,9 +60,9 @@
63 60
64 61 case 'read_forum' :
65 62
66 63 // User cannot spectate
67 - if ( ! user_can( $user_id, 'spectate' ) && ! bbp_is_anonymous() ) {
64 + if ( ! user_can( $user_id, 'spectate' ) ) {
68 65 $caps = array( 'do_not_allow' );
69 66
70 67 // Do some post ID based logic
71 68 } else {
@@ -83,18 +80,10 @@
83 80 $post_type = get_post_type_object( $_post->post_type );
84 81
85 82 // Post is public
86 83 if ( bbp_get_public_status_id() === $_post->post_status ) {
84 + $caps = array( 'spectate' );
87 85
88 - // Anonymous users do not have caps, but can 'exist'
89 - if ( bbp_is_anonymous() ) {
90 - $caps = array( 'exist' );
91 -
92 - // Registered users need the 'spectate' cap
93 - } else {
94 - $caps = array( 'spectate' );
95 - }
96 -
97 86 // User is author so allow read
98 87 } elseif ( (int) $user_id === (int) $_post->post_author ) {
99 88 $caps = array( 'spectate' );
100 89
@@ -120,9 +109,9 @@
120 109 break;
121 110
122 111 /** Publishing ********************************************************/
123 112
124 - case 'publish_forums' :
113 + case 'publish_forums' :
125 114
126 115 // Moderators can always edit
127 116 if ( user_can( $user_id, 'moderate' ) ) {
128 117 $caps = array( 'moderate' );
@@ -132,14 +121,14 @@
132 121
133 122 /** Editing ***********************************************************/
134 123
135 124 // Used primarily in wp-admin
136 - case 'edit_forums' :
137 - case 'edit_others_forums' :
125 + case 'edit_forums' :
126 + case 'edit_others_forums' :
138 127
139 128 // Moderators can always edit
140 - if ( user_can( $user_id, 'moderate' ) ) {
141 - $caps = array( 'moderate' );
129 + if ( bbp_is_user_keymaster( $user_id ) ) {
130 + $caps = array( 'spectate' );
142 131
143 132 // Otherwise, block
144 133 } else {
145 134 $caps = array( 'do_not_allow' );
@@ -234,9 +223,9 @@
234 223 *
235 224 * @param int $user_id User id.
236 225 * @param int $forum_id Forum id.
237 226 *
238 - * @return bool Return true if user is moderator of forum.
227 + * @return bool Return true if user is moderator of forum
239 228 */
240 229 function bbp_is_user_forum_moderator( $user_id = 0, $forum_id = 0 ) {
241 230 $user_id = bbp_get_user_id( $user_id, false, empty( $user_id ) );
242 231 $forum_id = bbp_get_forum_id( $forum_id );
@@ -258,10 +247,10 @@
258 247 * - `bbp_get_hidden_forum_ids()`
259 248 *
260 249 * @since 2.6.0 bbPress (r6426)
261 250 *
262 - * @param array $forum_ids Forum IDs to check if the user ID is a moderator of.
263 - * @param int $user_id User ID to check if is a moderator of forums.
251 + * @param array $forum_ids Forum IDs to check if the user ID is a moderator of
252 + * @param int $user_id User ID to check if is a moderator of forums
264 253 *
265 254 * @return array
266 255 */
267 256 function bbp_allow_forums_of_user( $forum_ids = array(), $user_id = 0 ) {