Changeset 6384 for trunk/src/includes/replies/capabilities.php
- Timestamp:
- 03/20/2017 10:44:00 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/replies/capabilities.php
r6265 r6384 78 78 $caps = array( 'spectate' ); 79 79 80 // Moderators can always edit forum content 81 } elseif ( user_can( $user_id, 'moderate', $_post->ID ) ) { 82 $caps = array( 'spectate' ); 83 80 84 // Unknown so map to private posts 81 85 } else { … … 108 112 $caps = array( 'moderate' ); 109 113 110 // Otherwise, block114 // Otherwise, check forum 111 115 } else { 112 $caps = array( 'do_not_allow' ); 116 $forum_id = bbp_get_forum_id(); 117 118 // Moderators can always edit forum content 119 if ( user_can( $user_id, 'moderate', $forum_id ) ) { 120 $caps = array( 'spectate' ); 121 122 // Fallback to do_not_allow 123 } else { 124 $caps = array( 'do_not_allow' ); 125 } 113 126 } 114 127 … … 124 137 // Get post type object 125 138 $post_type = get_post_type_object( $_post->post_type ); 126 $caps = array();127 139 128 140 // Add 'do_not_allow' cap if user is spam or deleted 129 141 if ( bbp_is_user_inactive( $user_id ) ) { 130 $caps [] = 'do_not_allow';142 $caps = array( 'do_not_allow' ); 131 143 132 144 // User is author so allow edit if not in admin 133 145 } elseif ( ! is_admin() && ( (int) $user_id === (int) $_post->post_author ) ) { 134 $caps [] = $post_type->cap->edit_posts;135 136 // User is a per-forum moderator, make sure they can spectate.137 } elseif ( bbp_is_user_forum_moderator( $user_id, bbp_get_reply_forum_id( $_post->ID )) ) {146 $caps = array( $post_type->cap->edit_posts ); 147 148 // Moderators can always edit forum content 149 } elseif ( user_can( $user_id, 'moderate', $_post->ID ) ) { 138 150 $caps = array( 'spectate' ); 139 151 140 152 // Fallback to edit_others_posts. 141 153 } else { 142 $caps [] = $post_type->cap->edit_others_posts;154 $caps = array( $post_type->cap->edit_others_posts ); 143 155 } 144 156 } … … 156 168 // Get post type object 157 169 $post_type = get_post_type_object( $_post->post_type ); 158 $caps = array();159 170 160 171 // Add 'do_not_allow' cap if user is spam or deleted 161 172 if ( bbp_is_user_inactive( $user_id ) ) { 162 $caps[] = 'do_not_allow'; 163 164 // Moderators can always edit forum content 165 } elseif ( user_can( $user_id, 'moderate' ) ) { 166 $caps[] = 'moderate'; 173 $caps = array( 'do_not_allow' ); 167 174 168 175 // User is author so allow delete if not in admin 169 176 } elseif ( ! is_admin() && ( (int) $user_id === (int) $_post->post_author ) ) { 170 $caps[] = $post_type->cap->delete_posts; 177 $caps = array( $post_type->cap->delete_posts ); 178 179 // Moderators can always edit forum content 180 } elseif ( user_can( $user_id, 'moderate', $_post->ID ) ) { 181 $caps = array( 'spectate' ); 171 182 172 183 // Unknown so map to delete_others_posts 173 184 } else { 174 $caps [] = $post_type->cap->delete_others_posts;185 $caps = array( $post_type->cap->delete_others_posts ); 175 186 } 176 187 }
Note: See TracChangeset
for help on using the changeset viewer.