Ticket #3330: 3330.patch
| File 3330.patch, 12.2 KB (added by , 6 years ago) |
|---|
-
src/includes/replies/capabilities.php
1 1 <?php 2 2 3 3 /** 4 * bbPress Reply Capabilit es4 * bbPress Reply Capabilities 5 5 * 6 6 * Used to map reply capabilities to WordPress's existing capabilities. 7 7 * … … 18 18 */ 19 19 function bbp_get_reply_caps() { 20 20 21 // Filter & return 21 // Filter & return. 22 22 return (array) apply_filters( 'bbp_get_reply_caps', array( 23 23 'edit_posts' => 'edit_replies', 24 24 'edit_others_posts' => 'edit_others_replies', … … 50 50 51 51 case 'read_reply' : 52 52 53 // User cannot spectate 53 // User cannot spectate. 54 54 if ( ! user_can( $user_id, 'spectate' ) ) { 55 55 $caps = array( 'do_not_allow' ); 56 56 … … 57 57 // Do some post ID based logic 58 58 } else { 59 59 60 // Bail if no post ID 60 // Bail if no post ID. 61 61 if ( empty( $args[0] ) ) { 62 62 break; 63 63 } … … 66 66 $_post = get_post( $args[0] ); 67 67 if ( ! empty( $_post ) ) { 68 68 69 // Get post type object 69 // Get post type object. 70 70 $post_type = get_post_type_object( $_post->post_type ); 71 71 72 // Post is public 72 // Post is public. 73 73 if ( bbp_get_public_status_id() === $_post->post_status ) { 74 74 $caps = array( 'spectate' ); 75 75 76 // User is author so allow read 76 // User is author so allow read. 77 77 } elseif ( (int) $user_id === (int) $_post->post_author ) { 78 78 $caps = array( 'spectate' ); 79 79 80 // Moderators can always edit forum content 80 // Moderators can always edit forum content. 81 81 } elseif ( user_can( $user_id, 'moderate', $_post->ID ) ) { 82 82 $caps = array( 'spectate' ); 83 83 84 // Unknown so map to private posts 84 // Unknown so map to private posts. 85 85 } else { 86 86 $caps = array( $post_type->cap->read_private_posts ); 87 87 } … … 94 94 95 95 case 'publish_replies' : 96 96 97 // Moderators can always publish 97 // Moderators can always publish. 98 98 if ( user_can( $user_id, 'moderate' ) ) { 99 99 $caps = array( 'moderate' ); 100 100 } … … 103 103 104 104 /** Editing ***********************************************************/ 105 105 106 // Used primarily in wp-admin 106 // Used primarily in wp-admin. 107 107 case 'edit_replies' : 108 108 case 'edit_others_replies' : 109 109 110 // Moderators can always edit 110 // Moderators can always edit. 111 111 if ( user_can( $user_id, 'moderate' ) ) { 112 112 $caps = array( 'moderate' ); 113 113 114 // Otherwise, check forum 114 // Otherwise, check forum. 115 115 } else { 116 116 $forum_id = bbp_get_forum_id(); 117 117 … … 119 119 if ( user_can( $user_id, 'moderate', $forum_id ) ) { 120 120 $caps = array( 'spectate' ); 121 121 122 // Fallback to do_not_allow 122 // Fallback to do_not_allow. 123 123 } else { 124 124 $caps = array( 'do_not_allow' ); 125 125 } … … 127 127 128 128 break; 129 129 130 // Used everywhere 130 // Used everywhere. 131 131 case 'edit_reply' : 132 132 133 // Bail if no post ID 133 // Bail if no post ID. 134 134 if ( empty( $args[0] ) ) { 135 135 break; 136 136 } … … 139 139 $_post = get_post( $args[0] ); 140 140 if ( ! empty( $_post ) ) { 141 141 142 // Get post type object 142 // Get post type object. 143 143 $post_type = get_post_type_object( $_post->post_type ); 144 144 145 // Add 'do_not_allow' cap if user is spam or deleted 145 // Add 'do_not_allow' cap if user is spam or deleted. 146 146 if ( bbp_is_user_inactive( $user_id ) ) { 147 147 $caps = array( 'do_not_allow' ); 148 148 149 // Moderators can always edit forum content 149 // Moderators can always edit forum content. 150 150 } elseif ( user_can( $user_id, 'moderate', $_post->ID ) ) { 151 151 $caps = array( 'spectate' ); 152 152 153 // Allow author or mod to edit if not in admin, unless past edit lock time 153 // Allow author or mod to edit if not in admin, unless past edit lock time. 154 154 } elseif ( ! is_admin() && ( (int) $user_id === (int) $_post->post_author ) ) { 155 155 156 156 // If editing... 157 157 if ( bbp_is_reply_edit() ) { 158 158 159 // Only allow if not past the edit-lock period 159 // Only allow if not past the edit-lock period. 160 160 $caps = ! bbp_past_edit_lock( $_post->post_date_gmt ) 161 161 ? array( $post_type->cap->edit_posts ) 162 162 : array( 'do_not_allow' ); … … 178 178 179 179 case 'delete_reply' : 180 180 181 // Bail if no post ID 181 // Bail if no post ID. 182 182 if ( empty( $args[0] ) ) { 183 183 break; 184 184 } 185 185 186 // Get the post 186 // Get the post. 187 187 $_post = get_post( $args[0] ); 188 188 if ( ! empty( $_post ) ) { 189 189 190 // Get post type object 190 // Get post type object. 191 191 $post_type = get_post_type_object( $_post->post_type ); 192 192 193 // Add 'do_not_allow' cap if user is spam or deleted 193 // Add 'do_not_allow' cap if user is spam or deleted. 194 194 if ( bbp_is_user_inactive( $user_id ) ) { 195 195 $caps = array( 'do_not_allow' ); 196 196 197 // Moderators can always edit forum content 197 // Moderators can always edit forum content. 198 198 } elseif ( user_can( $user_id, 'moderate', $_post->ID ) ) { 199 199 $caps = array( 'spectate' ); 200 200 201 // User is author so allow delete if not in admin 201 // User is author so allow delete if not in admin. 202 202 } elseif ( ! is_admin() && ( (int) $user_id === (int) $_post->post_author ) ) { 203 203 $caps = array( $post_type->cap->delete_posts ); 204 204 205 // Unknown so map to delete_others_posts 205 // Unknown so map to delete_others_posts. 206 206 } else { 207 207 $caps = array( $post_type->cap->delete_others_posts ); 208 208 } … … 210 210 211 211 break; 212 212 213 // Moderation override 213 // Moderation override. 214 214 case 'delete_replies' : 215 215 case 'delete_others_replies' : 216 216 217 // Moderators can always delete 217 // Moderators can always delete. 218 218 if ( user_can( $user_id, 'moderate' ) ) { 219 219 $caps = array( 'moderate' ); 220 220 } … … 228 228 break; 229 229 } 230 230 231 // Filter & return 231 // Filter & return. 232 232 return (array) apply_filters( 'bbp_map_reply_meta_caps', $caps, $cap, $user_id, $args ); 233 233 } -
src/templates/default/bbpress/alert-topic-lock.php
7 7 * @subpackage Theme 8 8 */ 9 9 10 // Exit if accessed directly 10 // Exit if accessed directly. 11 11 defined( 'ABSPATH' ) || exit; 12 12 13 13 do_action( 'bbp_theme_before_alert_topic_lock' ); ?> -
src/templates/default/bbpress/content-archive-forum.php
7 7 * @subpackage Theme 8 8 */ 9 9 10 // Exit if accessed directly 10 // Exit if accessed directly. 11 11 defined( 'ABSPATH' ) || exit; 12 12 13 13 ?> -
src/templates/default/bbpress/content-archive-topic.php
7 7 * @subpackage Theme 8 8 */ 9 9 10 // Exit if accessed directly 10 // Exit if accessed directly. 11 11 defined( 'ABSPATH' ) || exit; 12 12 13 13 ?> -
src/templates/default/bbpress/content-search.php
7 7 * @subpackage Theme 8 8 */ 9 9 10 // Exit if accessed directly 10 // Exit if accessed directly. 11 11 defined( 'ABSPATH' ) || exit; 12 12 13 13 ?> -
src/templates/default/bbpress/content-single-forum.php
7 7 * @subpackage Theme 8 8 */ 9 9 10 // Exit if accessed directly 10 // Exit if accessed directly. 11 11 defined( 'ABSPATH' ) || exit; 12 12 13 13 ?> -
src/templates/default/bbpress/content-single-reply.php
7 7 * @subpackage Theme 8 8 */ 9 9 10 // Exit if accessed directly 10 // Exit if accessed directly. 11 11 defined( 'ABSPATH' ) || exit; 12 12 13 13 ?> -
src/templates/default/bbpress/content-single-topic-lead.php
7 7 * @subpackage Theme 8 8 */ 9 9 10 // Exit if accessed directly 10 // Exit if accessed directly. 11 11 defined( 'ABSPATH' ) || exit; 12 12 13 13 do_action( 'bbp_template_before_lead_topic' ); ?> -
src/templates/default/bbpress/content-single-topic.php
7 7 * @subpackage Theme 8 8 */ 9 9 10 // Exit if accessed directly 10 // Exit if accessed directly. 11 11 defined( 'ABSPATH' ) || exit; 12 12 13 13 ?> -
src/templates/default/bbpress/content-single-user.php
7 7 * @subpackage Theme 8 8 */ 9 9 10 // Exit if accessed directly 10 // Exit if accessed directly. 11 11 defined( 'ABSPATH' ) || exit; 12 12 13 13 ?> -
src/templates/default/bbpress/content-single-view.php
7 7 * @subpackage Theme 8 8 */ 9 9 10 // Exit if accessed directly 10 // Exit if accessed directly. 11 11 defined( 'ABSPATH' ) || exit; 12 12 13 13 ?> -
src/templates/default/bbpress/content-statistics.php
7 7 * @subpackage Theme 8 8 */ 9 9 10 // Exit if accessed directly 10 // Exit if accessed directly. 11 11 defined( 'ABSPATH' ) || exit; 12 12 13 13 // Get the statistics -
src/templates/default/bbpress/content-topic-tag-edit.php
7 7 * @subpackage Theme 8 8 */ 9 9 10 // Exit if accessed directly 10 // Exit if accessed directly. 11 11 defined( 'ABSPATH' ) || exit; 12 12 13 13 ?> -
src/templates/default/bbpress/feedback-logged-in.php
7 7 * @subpackage Theme 8 8 */ 9 9 10 // Exit if accessed directly 10 // Exit if accessed directly. 11 11 defined( 'ABSPATH' ) || exit; 12 12 13 13 ?> -
src/templates/default/bbpress/feedback-no-access.php
7 7 * @subpackage Theme 8 8 */ 9 9 10 // Exit if accessed directly 10 // Exit if accessed directly. 11 11 defined( 'ABSPATH' ) || exit; 12 12 13 13 ?> -
src/templates/default/bbpress/feedback-no-forums.php
7 7 * @subpackage Theme 8 8 */ 9 9 10 // Exit if accessed directly 10 // Exit if accessed directly. 11 11 defined( 'ABSPATH' ) || exit; 12 12 13 13 ?>
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)