Skip to:
Content

BuddyPress.org

Changeset 511 for trunk/bp-wire.php


Ignore:
Timestamp:
11/07/2008 06:01:12 PM (18 years ago)
Author:
apeatling
Message:

Added wp_redirect() to all confirmation messages to stop double posting
Added group delete option for group administrators

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-wire.php

    r476 r511  
    8585        global $bp;
    8686       
    87         if ( $bp['current_action'] != 'post' )
     87        if ( $bp['current_component'] != $bp['xprofile']['slug'] && $bp['current_action'] != 'post' )
    8888                return false;
    8989       
    90         if ( $wire_post_id = bp_wire_new_post( $bp['current_userid'], $_POST['wire-post-textarea'], $bp['profile']['table_name_wire'] ) ) {
    91                 $bp['message'] = __('Wire message successfully posted.', 'buddypress');
    92                 $bp['message_type'] = 'success';
    93 
    94                 do_action( 'bp_xprofile_new_wire_post', array( 'item_id' => $wire_post_id, 'component_name' => 'profile', 'component_action' => 'new_wire_post', 'is_private' => 0 ) );
    95                 add_action( 'template_notices', 'bp_core_render_notice' );
     90        if ( !$wire_post_id = bp_wire_new_post( $bp['current_userid'], $_POST['wire-post-textarea'], $bp['profile']['table_name_wire'] ) ) {
     91                bp_core_add_message( __('Wire message could not be posted. Please try again.', 'buddypress'), 'error' );
     92        } else {
     93                bp_core_add_message( __('Wire message successfully posted.', 'buddypress') );
     94                do_action( 'bp_xprofile_new_wire_post', array( 'item_id' => $wire_post_id, 'component_name' => 'profile', 'component_action' => 'new_wire_post', 'is_private' => 0 ) );
    9695        }
    9796       
    9897        if ( !strpos( $_SERVER['HTTP_REFERER'], $bp['wire']['slug'] ) ) {
    99                 $bp['current_component'] = $bp['profile']['slug'];
    100                 $bp['current_action'] = 'public';
    101                 bp_catch_uri( 'profile/index' );
     98                wp_redirect( $bp['current_domain'] );
    10299        } else {
    103                 bp_catch_uri( 'wire/latest' );
    104         }       
     100                wp_redirect( $bp['current_domain']. $bp['wire']['slug'] );
     101        }
    105102}
    106103add_action( 'wp', 'bp_wire_action_post', 3 );
     
    109106        global $bp;
    110107       
    111         if ( $bp['current_action'] != 'delete' )
     108        if ( $bp['current_component'] != $bp['xprofile']['slug'] && $bp['current_action'] != 'delete' )
    112109                return false;
    113110       
    114111        if ( bp_wire_delete_post( $bp['action_variables'][0], $bp['profile']['table_name_wire'] ) ) {
    115                 $bp['message'] = __('Wire message successfully deleted.', 'buddypress');
    116                 $bp['message_type'] = 'success';
    117                
    118                 do_action( 'bp_xprofile_delete_wire_post' );
    119                 add_action( 'template_notices', 'bp_core_render_notice' );                                                                     
     112                bp_core_add_message( __('Wire message successfully deleted.', 'buddypress'), false, true );
     113                do_action( 'bp_xprofile_delete_wire_post' );                                           
    120114        }
    121115       
    122116        if ( !strpos( $_SERVER['HTTP_REFERER'], $bp['wire']['slug'] ) ) {
    123                 $bp['current_component'] = $bp['profile']['slug'];
    124                 $bp['current_action'] = 'public';
    125                 bp_catch_uri( 'profile/index' );
     117                wp_redirect( $bp['current_domain'] );
    126118        } else {
    127                 bp_catch_uri( 'wire/latest' );
     119                wp_redirect( $bp['current_domain']. $bp['wire']['slug'] );
    128120        }
    129121}
Note: See TracChangeset for help on using the changeset viewer.