Changeset 3607
- Timestamp:
- 11/14/2011 03:50:25 AM (13 years ago)
- Location:
- branches/plugin/bbp-includes
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/plugin/bbp-includes/bbp-common-template.php
r3586 r3607 484 484 $retval = false; 485 485 486 if ( !empty( $bbp->displayed_user) && is_user_logged_in() )486 if ( bbp_is_single_user() && is_user_logged_in() ) 487 487 $retval = (bool) ( bbp_get_displayed_user_id() == bbp_get_current_user_id() ); 488 488 -
branches/plugin/bbp-includes/bbp-core-compatibility.php
r3601 r3607 1685 1685 if ( !empty( $is_edit ) ) { 1686 1686 1687 // Only allow super admins on multisite to edit every user.1688 if ( !is_user_logged_in() || ( is_multisite() && !current_user_can( 'manage_network_users' ) && ( $user->ID != bbp_get_current_user_id() ) && !apply_filters( 'enable_edit_any_user_configuration', true ) ) || !current_user_can( 'edit_user', $user->ID ) ) {1689 wp_die( __( 'You do not have permission to edit this user.', 'bbpress' ) );1690 }1691 1692 1687 // We are editing a profile 1693 1688 $posts_query->bbp_is_single_user_edit = true; … … 1748 1743 // Topic/Reply Edit Page 1749 1744 } elseif ( !empty( $is_edit ) ) { 1750 1751 // Bail from edit if user is not logged in1752 if ( !is_user_logged_in() )1753 return;1754 1745 1755 1746 // Get the post type from the main query loop -
branches/plugin/bbp-includes/bbp-core-hooks.php
r3589 r3607 37 37 add_action( 'generate_rewrite_rules', 'bbp_generate_rewrite_rules', 10 ); 38 38 add_action( 'wp_enqueue_scripts', 'bbp_enqueue_scripts', 10 ); 39 add_action( 'template_redirect', 'bbp_template_redirect', 10 ); 39 40 add_filter( 'template_include', 'bbp_template_include', 10 ); 40 41 … … 228 229 add_action( 'bbp_activation', 'flush_rewrite_rules' ); 229 230 add_action( 'bbp_deactivation', 'flush_rewrite_rules' ); 231 232 // Redirect user if needed 233 add_action( 'bbp_template_redirect', 'bbp_check_user_edit', 10 ); 234 add_action( 'bbp_template_redirect', 'bbp_check_forum_edit', 10 ); 235 add_action( 'bbp_template_redirect', 'bbp_check_topic_edit', 10 ); 236 add_action( 'bbp_template_redirect', 'bbp_check_reply_edit', 10 ); 237 add_action( 'bbp_template_redirect', 'bbp_check_topic_tag_edit', 10 ); 230 238 231 239 /** … … 741 749 } 742 750 751 /** Theme Permissions *********************************************************/ 752 753 /** 754 * The main action used for redirecting bbPress theme actions that are not 755 * permitted by the current_user 756 * 757 * @since bbPress (r3605) 758 * 759 * @uses do_action() 760 */ 761 function bbp_template_redirect() { 762 do_action( 'bbp_template_redirect' ); 763 } 764 743 765 ?> -
branches/plugin/bbp-includes/bbp-forum-functions.php
r3589 r3607 1147 1147 } 1148 1148 1149 /** Permissions ***************************************************************/ 1150 1151 /** 1152 * Redirect if unathorized user is attempting to edit a forum 1153 * 1154 * @since bbPress (r3607) 1155 * 1156 * @uses bbp_is_forum_edit() 1157 * @uses current_user_can() 1158 * @uses bbp_get_forum_id() 1159 * @uses wp_safe_redirect() 1160 * @uses bbp_get_forum_permalink() 1161 */ 1162 function bbp_check_forum_edit() { 1163 1164 // Bail if not editing a topic 1165 if ( !bbp_is_forum_edit() ) 1166 return; 1167 1168 // User cannot edit topic, so redirect back to reply 1169 if ( !current_user_can( 'edit_forum', bbp_get_forum_id() ) ) { 1170 wp_safe_redirect( bbp_get_forum_permalink() ); 1171 exit(); 1172 } 1173 } 1174 1149 1175 ?> -
branches/plugin/bbp-includes/bbp-reply-functions.php
r3589 r3607 1459 1459 } 1460 1460 1461 /** Permissions ***************************************************************/ 1462 1463 /** 1464 * Redirect if unathorized user is attempting to edit a reply 1465 * 1466 * @since bbPress (r3605) 1467 * 1468 * @uses bbp_is_reply_edit() 1469 * @uses current_user_can() 1470 * @uses bbp_get_topic_id() 1471 * @uses wp_safe_redirect() 1472 * @uses bbp_get_topic_permalink() 1473 */ 1474 function bbp_check_reply_edit() { 1475 1476 // Bail if not editing a topic 1477 if ( !bbp_is_reply_edit() ) 1478 return; 1479 1480 // User cannot edit topic, so redirect back to reply 1481 if ( !current_user_can( 'edit_reply', bbp_get_reply_id() ) ) { 1482 wp_safe_redirect( bbp_get_reply_url() ); 1483 exit(); 1484 } 1485 } 1486 1461 1487 ?> -
branches/plugin/bbp-includes/bbp-topic-functions.php
r3589 r3607 3057 3057 } 3058 3058 3059 /** Permissions ***************************************************************/ 3060 3061 /** 3062 * Redirect if unathorized user is attempting to edit a topic 3063 * 3064 * @since bbPress (r3605) 3065 * 3066 * @uses bbp_is_topic_edit() 3067 * @uses current_user_can() 3068 * @uses bbp_get_topic_id() 3069 * @uses wp_safe_redirect() 3070 * @uses bbp_get_topic_permalink() 3071 */ 3072 function bbp_check_topic_edit() { 3073 3074 // Bail if not editing a topic 3075 if ( !bbp_is_topic_edit() ) 3076 return; 3077 3078 // User cannot edit topic, so redirect back to topic 3079 if ( !current_user_can( 'edit_topic', bbp_get_topic_id() ) ) { 3080 wp_safe_redirect( bbp_get_topic_permalink() ); 3081 exit(); 3082 } 3083 } 3084 3085 /** 3086 * Redirect if unathorized user is attempting to edit a topic tag 3087 * 3088 * @since bbPress (r3605) 3089 * 3090 * @uses bbp_is_topic_tag_edit() 3091 * @uses current_user_can() 3092 * @uses bbp_get_topic_tag_id() 3093 * @uses wp_safe_redirect() 3094 * @uses bbp_get_topic_tag_link() 3095 */ 3096 function bbp_check_topic_tag_edit() { 3097 3098 // Bail if not editing a topic tag 3099 if ( !bbp_is_topic_tag_edit() ) 3100 return; 3101 3102 // Bail if current user cannot edit topic tags 3103 if ( !current_user_can( 'edit_topic_tags', bbp_get_topic_tag_id() ) ) { 3104 wp_safe_redirect( bbp_get_topic_tag_link() ); 3105 exit(); 3106 } 3107 } 3108 3059 3109 ?> -
branches/plugin/bbp-includes/bbp-user-functions.php
r3505 r3607 1249 1249 } 1250 1250 1251 /** Premissions ***************************************************************/ 1252 1253 /** 1254 * Redirect if unathorized user is attempting to edit a topic 1255 * 1256 * @since bbPress (r3605) 1257 * 1258 * @uses bbp_is_topic_edit() 1259 * @uses current_user_can() 1260 * @uses bbp_get_topic_id() 1261 * @uses wp_safe_redirect() 1262 * @uses bbp_get_topic_permalink() 1263 */ 1264 function bbp_check_user_edit() { 1265 1266 // Bail if not editing a topic 1267 if ( !bbp_is_single_user_edit() ) 1268 return; 1269 1270 // Only allow super admins on multisite to edit every user. 1271 if ( !is_user_logged_in() || ( is_multisite() && !current_user_can( 'manage_network_users' ) && bbp_is_user_home() && !apply_filters( 'enable_edit_any_user_configuration', true ) ) || !current_user_can( 'edit_user', bbp_get_displayed_user_id() ) ) { 1272 wp_safe_redirect( bbp_get_user_profile_url( bbp_get_displayed_user_id() ) ); 1273 exit(); 1274 } 1275 } 1276 1251 1277 ?>
Note: See TracChangeset
for help on using the changeset viewer.