Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
07/24/2011 10:51:38 PM (15 years ago)
Author:
boonebgorges
Message:

Global/slug review in Settings and Messages component. See #3325

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-messages/bp-messages-actions.php

    r4825 r4842  
    1010
    1111function messages_action_view_message() {
    12     global $bp, $thread_id;
     12    global $thread_id;
    1313
    14     if ( $bp->current_component != $bp->messages->slug || $bp->current_action != 'view' )
     14    if ( !bp_is_messages_component() || !bp_is_current_action( 'view' ) )
    1515        return false;
    1616
    17     $thread_id = 0;
    18     if ( !empty( $bp->action_variables[0] ) )
    19         $thread_id = $bp->action_variables[0];
    20 
    21     if ( !$thread_id || !messages_is_valid_thread( $thread_id ) || ( !messages_check_thread_access($thread_id) && !is_super_admin() ) )
    22         bp_core_redirect( $bp->displayed_user->domain . $bp->current_component );
     17    $thread_id = (int)bp_action_variable( 0 );
     18   
     19    if ( !$thread_id || !messages_is_valid_thread( $thread_id ) || ( !messages_check_thread_access( $thread_id ) && !is_super_admin() ) )
     20        bp_core_redirect( bp_displayed_user_domain() . bp_get_messages_slug() );
    2321
    2422    // Check if a new reply has been submitted
     
    3432            bp_core_add_message( __( 'There was a problem sending your reply, please try again', 'buddypress' ), 'error' );
    3533
    36         bp_core_redirect( $bp->displayed_user->domain . $bp->current_component . '/view/' . $thread_id . '/' );
     34        bp_core_redirect( bp_displayed_user_domain() . bp_get_messages_slug() . '/view/' . $thread_id . '/' );
    3735    }
    3836
     
    5048        'name'            => sprintf( __( 'From: %s', 'buddypress' ), BP_Messages_Thread::get_last_sender( $thread_id ) ),
    5149        'slug'            => 'view',
    52         'parent_url'      => $bp->loggedin_user->domain . $bp->messages->slug . '/',
    53         'parent_slug'     => $bp->messages->slug,
     50        'parent_url'      => trailingslashit( bp_displayed_user_domain() . bp_get_messages_slug() ),
     51        'parent_slug'     => bp_get_messages_slug(),
    5452        'screen_function' => true,
    5553        'position'        => 40,
    5654        'user_has_access' => bp_is_my_profile(),
    57         'link'            => $bp->loggedin_user->domain . $bp->messages->slug . '/view/' . (int) $thread_id
     55        'link'            => bp_displayed_user_domain() . bp_get_messages_slug() . '/view/' . (int) $thread_id
    5856    ) );
    5957
     
    6361
    6462function messages_action_delete_message() {
    65     global $bp, $thread_id;
     63    global $thread_id;
    6664
    67     if ( $bp->current_component != $bp->messages->slug || 'notices' == $bp->current_action || empty( $bp->action_variables[0] ) || 'delete' != $bp->action_variables[0] )
     65    if ( !bp_is_messages_component() || bp_is_current_action( 'notices' ) || !bp_is_action_variable( 'delete', 0 ) )
    6866        return false;
    6967
    70     $thread_id = $bp->action_variables[1];
    71 
    72     if ( !$thread_id || !is_numeric($thread_id) || !messages_check_thread_access($thread_id) ) {
    73         bp_core_redirect( $bp->displayed_user->domain . $bp->current_component . '/' . $bp->current_action );
     68    $thread_id = bp_action_variable( 1 );
     69   
     70    if ( !$thread_id || !is_numeric( $thread_id ) || !messages_check_thread_access( $thread_id ) ) {
     71        bp_core_redirect( bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() );
    7472    } else {
    7573        if ( !check_admin_referer( 'messages_delete_thread' ) )
     
    7775
    7876        // Delete message
    79         if ( !messages_delete_thread($thread_id) ) {
     77        if ( !messages_delete_thread( $thread_id ) ) {
    8078            bp_core_add_message( __('There was an error deleting that message.', 'buddypress'), 'error' );
    8179        } else {
    8280            bp_core_add_message( __('Message deleted.', 'buddypress') );
    8381        }
    84         bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/' . $bp->current_action );
     82        bp_core_redirect( bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() );
    8583    }
    8684}
     
    8886
    8987function messages_action_bulk_delete() {
    90     global $bp, $thread_ids;
     88    global $thread_ids;
    9189
    92     if ( $bp->current_component != $bp->messages->slug || empty( $bp->action_variables[0] ) || 'bulk-delete' != $bp->action_variables[0] )
     90    if ( !bp_is_messages_component() || !bp_is_action_variable( 'bulk-delete', 0 ) )
    9391        return false;
    9492
    9593    $thread_ids = $_POST['thread_ids'];
    9694
    97     if ( !$thread_ids || !messages_check_thread_access($thread_ids) ) {
    98         bp_core_redirect( $bp->displayed_user->domain . $bp->current_component . '/' . $bp->current_action );
     95    if ( !$thread_ids || !messages_check_thread_access( $thread_ids ) ) {
     96        bp_core_redirect( bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() );
    9997    } else {
    10098        if ( !check_admin_referer( 'messages_delete_thread' ) )
     
    106104            bp_core_add_message( __('Messages deleted.', 'buddypress') );
    107105
    108         bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/' . $bp->current_action );
     106        bp_core_redirect( bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() );
    109107    }
    110108}
Note: See TracChangeset for help on using the changeset viewer.