Skip to:
Content

BuddyPress.org

Changeset 4842


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

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

Location:
trunk
Files:
4 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}
  • trunk/bp-messages/bp-messages-screens.php

    r4825 r4842  
    1212    global $bp;
    1313
    14     if ( !empty( $bp->action_variables ) ) {
     14    if ( bp_action_variables() ) {
    1515        bp_do_404();
    1616        return;
     
    2424    global $bp;
    2525
    26     if ( !empty( $bp->action_variables ) ) {
     26    if ( bp_action_variables() ) {
    2727        bp_do_404();
    2828        return;
     
    3636    global $bp;
    3737
    38     if ( !empty( $bp->action_variables ) ) {
     38    if ( bp_action_variables() ) {
    3939        bp_do_404();
    4040        return;
     
    8686
    8787function messages_screen_notices() {
    88     global $bp, $notice_id;
     88    global $notice_id;
    8989
    9090    if ( !is_super_admin() )
    9191        return false;
    9292
    93     $notice_id = isset( $bp->action_variables[1] ) ? $bp->action_variables[1] : 0;
    94 
     93    $notice_id = (int)bp_action_variable( 1 );
     94   
    9595    if ( !empty( $notice_id ) && is_numeric( $notice_id ) ) {
    9696        $notice = new BP_Messages_Notice( $notice_id );
    9797
    98         if ( 'deactivate' == $bp->action_variables[0] ) {
     98        if ( bp_is_action_variable( 'deactivate', 0 ) ) {
    9999            if ( !$notice->deactivate() ) {
    100100                bp_core_add_message( __('There was a problem deactivating that notice.', 'buddypress'), 'error' );
     
    102102                bp_core_add_message( __('Notice deactivated.', 'buddypress') );
    103103            }
    104         } else if ( 'activate' == $bp->action_variables[0] ) {
     104        } else if ( bp_is_action_variable( 'activate', 0 ) ) {
    105105            if ( !$notice->activate() ) {
    106106                bp_core_add_message( __('There was a problem activating that notice.', 'buddypress'), 'error' );
     
    108108                bp_core_add_message( __('Notice activated.', 'buddypress') );
    109109            }
    110         } else if ( 'delete' == $bp->action_variables[0] ) {
     110        } else if ( bp_is_action_variable( 'delete' ) ) {
    111111            if ( !$notice->delete() ) {
    112112                bp_core_add_message( __('There was a problem deleting that notice.', 'buddypress'), 'buddypress' );
     
    115115            }
    116116        }
    117         bp_core_redirect( $bp->loggedin_user->domain . $bp->messages->slug . '/notices' );
     117        bp_core_redirect( bp_loggedin_user_domain() . bp_get_messages_slug() . '/notices' );
    118118    }
    119119
    120     if ( !empty( $bp->action_variables ) ) {
     120    if ( bp_action_variables() ) {
    121121        bp_do_404();
    122122        return;
     
    131131    global $bp;
    132132
    133     if ( !empty( $bp->action_variables ) ) {
     133    if ( bp_action_variables() ) {
    134134        bp_do_404();
    135135        return;
  • trunk/bp-messages/bp-messages-template.php

    r4829 r4842  
    344344}
    345345
     346/**
     347 * Echoes the form action for Messages HTML forms
     348 *
     349 * @package BuddyPress
     350 */
    346351function bp_messages_form_action() {
    347352    echo bp_get_messages_form_action();
    348353}
     354    /**
     355     * Returns the form action for Messages HTML forms
     356     *
     357     * @package BuddyPress
     358     *
     359     * @return str The form action
     360     */
    349361    function bp_get_messages_form_action() {
    350         global $bp;
    351 
    352         if ( isset( $bp->action_variables[0] ) )
    353             $av = $bp->action_variables[0];
    354         else
    355             $av = '';
    356 
    357         return apply_filters( 'bp_get_messages_form_action', trailingslashit( $bp->loggedin_user->domain . $bp->messages->slug . '/' . $bp->current_action . '/' . $av . '/' ) );
     362        return apply_filters( 'bp_get_messages_form_action', trailingslashit( bp_loggedin_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() . '/' . bp_action_variable( 0 ) ) );
    358363    }
    359364
     
    719724
    720725    if ( !$thread_id && bp_is_current_component( 'messages' ) && bp_is_current_action( 'view' ) )
    721         $thread_id = (int)$bp->action_variables[0];
     726        $thread_id = (int)bp_action_variable( 0 );
    722727
    723728    $thread_template = new BP_Messages_Thread_Template( $thread_id, $order );
  • trunk/bp-settings/bp-settings-actions.php

    r4826 r4842  
    88    global $bp;
    99
    10     if ( !empty( $bp->action_variables ) ) {
     10    if ( bp_action_variables() ) {
    1111        bp_do_404();
    1212        return;
     
    118118    global $bp;
    119119
    120     if ( !empty( $bp->action_variables ) ) {
     120    if ( bp_action_variables() ) {
    121121        bp_do_404();
    122122        return;
     
    146146    global $bp;
    147147
    148     if ( !empty( $bp->action_variables ) ) {
     148    if ( bp_action_variables() ) {
    149149        bp_do_404();
    150150        return;
Note: See TracChangeset for help on using the changeset viewer.