Changeset 4599
- Timestamp:
- 07/04/2011 03:00:00 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/bp-core-buddybar.php
r4559 r4599 201 201 'screen_function' => &$screen_function 202 202 ); 203 204 // Look for current component 205 if ( ( $bp->current_action == $slug && $bp->current_component == $parent_slug ) && $user_has_access ) { 206 if ( !is_object( $screen_function[0] ) ) 207 add_action( 'bp_screens', $screen_function ); 208 else 209 add_action( 'bp_screens', array( &$screen_function[0], $screen_function[1] ) ); 210 211 // Look for current item 212 } elseif ( ( $bp->current_action == $slug && $bp->current_item == $parent_slug ) && $user_has_access ) { 213 if ( !is_object( $screen_function[0] ) ) 214 add_action( 'bp_screens', $screen_function ); 215 else 216 add_action( 'bp_screens', array( &$screen_function[0], $screen_function[1] ) ); 203 204 /** 205 * The last step is to hook the screen function for the added subnav item. But this only 206 * needs to be done if this subnav item is the current view, and the user has access to the 207 * subnav item. We figure out whether we're currently viewing this subnav by checking the 208 * following two conditions: 209 * (1) Either: 210 * (a) the parent slug matches the current_component, or 211 * (b) the parent slug matches the current_item 212 * (2) And either: 213 * (a) the current_action matches $slug, or 214 * (b) there is no current_action (ie, this is the default subnav for the parent nav) 215 * and this subnav item is the default for the parent item (which we check by 216 * comparing this subnav item's screen function with the screen function of the 217 * parent nav item in $bp->bp_nav). 218 */ 219 220 // If we *don't* meet condition (1), return 221 if ( $bp->current_component != $parent_slug && $bp->current_item != $parent_slug ) 222 return; 223 224 // If we *do* meet condition (2), then the added subnav item is currently being requested 225 if ( ( !empty( $bp->current_action ) && $slug == $bp->current_action ) || ( empty( $bp->current_action ) && $screen_function == $bp->bp_nav[$parent_slug]['screen_function'] ) ) { 226 // Before hooking the screen function, check user access 227 if ( $user_has_access ) { 228 if ( !is_object( $screen_function[0] ) ) 229 add_action( 'bp_screens', $screen_function ); 230 else 231 add_action( 'bp_screens', array( &$screen_function[0], $screen_function[1] ) ); 232 } else { 233 // When the content is off-limits, we handle the situation differently 234 // depending on whether the current user is logged in 235 if ( is_user_logged_in() ) { 236 // Off-limits to this user. Throw an error and redirect to the displayed user's domain 237 bp_core_no_access( array( 238 'message' => __( 'You do not have access to this page.', 'buddypress' ), 239 'root' => bp_displayed_user_domain(), 240 'redirect' => false 241 ) ); 242 } else { 243 // Not logged in. Allow the user to log in, and attempt to redirect 244 bp_core_no_access(); 245 } 246 } 217 247 } 218 248 }
Note: See TracChangeset
for help on using the changeset viewer.