Changeset 6384 for trunk/src/includes/topics/capabilities.php
- Timestamp:
- 03/20/2017 10:44:00 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/topics/capabilities.php
r6265 r6384 96 96 $caps = array( 'spectate' ); 97 97 98 // Moderators can always edit forum content 99 } elseif ( user_can( $user_id, 'moderate', $_post->ID ) ) { 100 $caps = array( 'spectate' ); 101 98 102 // Unknown so map to private posts 99 103 } else { … … 126 130 $caps = array( $cap ); 127 131 128 // Otherwise, block132 // Otherwise, check forum 129 133 } else { 130 $caps = array( 'do_not_allow' ); 134 $forum_id = bbp_get_forum_id(); 135 136 // Moderators can always edit forum content 137 if ( user_can( $user_id, 'moderate', $forum_id ) ) { 138 $caps = array( 'spectate' ); 139 140 // Fallback to do_not_allow 141 } else { 142 $caps = array( 'do_not_allow' ); 143 } 131 144 } 132 145 … … 142 155 // Get caps for post type object 143 156 $post_type = get_post_type_object( $_post->post_type ); 144 $caps = array();145 157 146 158 // Add 'do_not_allow' cap if user is spam or deleted 147 159 if ( bbp_is_user_inactive( $user_id ) ) { 148 $caps [] = 'do_not_allow';160 $caps = array( 'do_not_allow' ); 149 161 150 162 // User is author so allow edit if not in admin 151 163 } elseif ( ! is_admin() && ( (int) $user_id === (int) $_post->post_author ) ) { 152 $caps[] = $post_type->cap->edit_posts; 164 $caps = array( $post_type->cap->edit_posts ); 165 166 // Moderators can always edit forum content 167 } elseif ( user_can( $user_id, 'moderate', $_post->ID ) ) { 168 $caps = array( 'spectate' ); 153 169 154 170 // Unknown, so map to edit_others_posts 155 171 } else { 156 157 // If user is a per-forum moderator, make sure they can spectate. 158 if ( bbp_is_user_forum_moderator( $user_id, bbp_get_topic_forum_id( $_post->ID ) ) ) { 159 $caps = array( 'spectate' ); 160 161 // Fallback to edit_others_posts. 162 } else { 163 $caps[] = $post_type->cap->edit_others_posts; 164 } 172 $caps = array( $post_type->cap->edit_others_posts ); 165 173 } 166 174 } … … 178 186 // Get caps for post type object 179 187 $post_type = get_post_type_object( $_post->post_type ); 180 $caps = array();181 188 182 189 // Add 'do_not_allow' cap if user is spam or deleted 183 190 if ( bbp_is_user_inactive( $user_id ) ) { 184 $caps [] = 'do_not_allow';191 $caps = array( 'do_not_allow' ); 185 192 186 193 // Moderators can always edit forum content 187 } elseif ( user_can( $user_id, 'moderate' ) ) {188 $caps [] = 'moderate';194 } elseif ( user_can( $user_id, 'moderate', $_post->ID ) ) { 195 $caps = array( 'spectate' ); 189 196 190 197 // User is author so allow delete if not in admin 191 198 } elseif ( ! is_admin() && ( (int) $user_id === (int) $_post->post_author ) ) { 192 $caps [] = $post_type->cap->delete_posts;199 $caps = array( $post_type->cap->delete_posts ); 193 200 194 201 // Unknown so map to delete_others_posts 195 202 } else { 196 $caps [] = $post_type->cap->delete_others_posts;203 $caps = array( $post_type->cap->delete_others_posts ); 197 204 } 198 205 }
Note: See TracChangeset
for help on using the changeset viewer.