Skip to:
Content

BuddyPress.org

Changeset 9946


Ignore:
Timestamp:
06/15/2015 09:01:31 PM (9 years ago)
Author:
johnjamesjacoby
Message:

Messages: Remove unused redirect in bp_has_message_threads().

This change prevents a debug notice for themes with built-in BuddyPress support, by removing a tightly-scoped redirect attempt that only occurs after page output has already started. It also removes a superfluous bp_moderate capability check from the message notices screen function, as that function is only hooked in if the user has bp_moderate previously.

Fixes #6506 (in trunk, for 2.4)

Location:
trunk/src/bp-messages
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-messages/bp-messages-screens.php

    r9862 r9946  
    196196    global $notice_id;
    197197
    198     if ( !bp_current_user_can( 'bp_moderate' ) ) {
    199         return false;
    200     }
    201 
    202     $notice_id = (int)bp_action_variable( 1 );
     198    $notice_id = (int) bp_action_variable( 1 );
    203199
    204200    if ( !empty( $notice_id ) && is_numeric( $notice_id ) ) {
  • trunk/src/bp-messages/bp-messages-template.php

    r9927 r9946  
    389389 * @return bool True if there are threads to display, otherwise false.
    390390 */
    391 function bp_has_message_threads( $args = '' ) {
     391function bp_has_message_threads( $args = array() ) {
    392392    global $messages_template;
    393393
    394394    // The default box the user is looking at
    395     if ( bp_is_current_action( 'sentbox' ) ) {
    396         $default_box = 'sentbox';
    397     } elseif ( bp_is_current_action( 'notices' ) ) {
    398         $default_box = 'notices';
    399     } else {
    400         $default_box = 'inbox';
    401     }
     395    $current_action = bp_current_action();
     396    switch ( $current_action ) {
     397        case 'sentbox' :
     398        case 'notices' :
     399        case 'inbox'   :
     400            $default_box = $current_action;
     401            break;
     402        default :
     403            $default_box = 'inbox';
     404            break;
     405    }
     406
     407    // User ID
     408    // @todo displayed user for moderators that get this far?
     409    $user_id = bp_loggedin_user_id();
     410
     411    // Search Terms
     412    $search_terms = isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : '';
    402413
    403414    // Parse the arguments
    404415    $r = bp_parse_args( $args, array(
    405         'user_id'      => bp_loggedin_user_id(),
     416        'user_id'      => $user_id,
    406417        'box'          => $default_box,
    407418        'per_page'     => 10,
    408419        'max'          => false,
    409420        'type'         => 'all',
    410         'search_terms' => isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : '',
     421        'search_terms' => $search_terms,
    411422        'page_arg'     => 'mpage', // See https://buddypress.trac.wordpress.org/ticket/3679
    412423        'meta_query'   => array()
    413424    ), 'has_message_threads' );
    414 
    415     // If trying to access notices without capabilities, redirect to root domain
    416     if ( bp_is_current_action( 'notices' ) && !bp_current_user_can( 'bp_moderate' ) ) {
    417         bp_core_redirect( bp_displayed_user_domain() );
    418     }
    419425
    420426    // Load the messages loop global up with messages
Note: See TracChangeset for help on using the changeset viewer.