Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/02/2009 07:54:21 PM (16 years ago)
Author:
apeatling
Message:

Merging 1.1 branch changes and syncing.

File:
1 edited

Legend:

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

    r1957 r2077  
    44 *
    55 * This file contains functions that are deprecated.
    6  * You should not under any circumstance use these functions as they are 
     6 * You should not under any circumstance use these functions as they are
    77 * either no longer valid, or have been replaced with something much more awesome.
    88 *
     
    1313 * Of course, things will still work if you use these functions but you will
    1414 * be the laughing stock of the BuddyPress community. We will all point and laugh at
    15  * you. You'll also be making things harder for yourself in the long run, 
     15 * you. You'll also be making things harder for yourself in the long run,
    1616 * and you will miss out on lovely performance and functionality improvements.
    17  * 
     17 *
    1818 * If you've checked you are not using any deprecated functions and finished your little
    1919 * dance, you can add the following line to your wp-config.php file to prevent any of
     
    2424function messages_deprecated_globals() {
    2525    global $bp;
    26    
     26
    2727    /* If we are using a BuddyPress 1.1+ theme ignore this. */
    2828    if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
     
    3131    $bp->groups->image_base = BP_PLUGIN_URL . '/bp-messages/deprecated/images';
    3232}
    33 add_action( 'plugins_loaded', 'messages_deprecated_globals', 5 );   
     33add_action( 'plugins_loaded', 'messages_deprecated_globals', 5 );
    3434add_action( 'admin_menu', 'messages_deprecated_globals', 2 );
    3535
     
    5050    if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
    5151        return $template;
    52        
     52
    5353    /* Enqueue the structure CSS file to give basic positional formatting for components */
    54     wp_enqueue_style( 'bp-messages-structure', BP_PLUGIN_URL . '/bp-messages/deprecated/css/structure.css' );   
     54    wp_enqueue_style( 'bp-messages-structure', BP_PLUGIN_URL . '/bp-messages/deprecated/css/structure.css' );
    5555}
    5656add_action( 'bp_styles', 'messages_add_structure_css' );
     
    6262    if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
    6363        return false;
    64        
     64
    6565    check_ajax_referer( 'messages_send_message' );
    66    
    67     $result = messages_send_message($_REQUEST['send_to'], $_REQUEST['subject'], $_REQUEST['content'], $_REQUEST['thread_id'], true, false, true); 
     66
     67    $result = messages_send_message($_REQUEST['send_to'], $_REQUEST['subject'], $_REQUEST['content'], $_REQUEST['thread_id'], true, false, true);
    6868
    6969    if ( $result['status'] ) { ?>
    7070            <div class="avatar-box">
    7171                <?php echo bp_core_fetch_avatar( array( 'item_id' => $result['reply']->sender_id, 'type' => 'thumb' ) ); ?>
    72    
     72
    7373                <h3><?php echo bp_core_get_userlink($result['reply']->sender_id) ?></h3>
    7474                <small><?php echo bp_format_time($result['reply']->date_sent) ?></small>
     
    9090    if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
    9191        return false;
    92        
     92
    9393    if ( !isset($_POST['thread_ids']) ) {
    9494        echo "-1[[split]]" . __('There was a problem marking messages as unread.', 'buddypress');
    9595    } else {
    9696        $thread_ids = explode( ',', $_POST['thread_ids'] );
    97        
     97
    9898        for ( $i = 0; $i < count($thread_ids); $i++ ) {
    9999            BP_Messages_Thread::mark_as_unread($thread_ids[$i]);
     
    108108    /* If we are using a BuddyPress 1.1+ theme ignore this. */
    109109    if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
    110         return false;   
    111        
     110        return false;
     111
    112112    if ( !isset($_POST['thread_ids']) ) {
    113113        echo "-1[[split]]" . __('There was a problem marking messages as read.', 'buddypress');
     
    128128    if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
    129129        return false;
    130        
     130
    131131    if ( !isset($_POST['thread_ids']) ) {
    132132        echo "-1[[split]]" . __( 'There was a problem deleting messages.', 'buddypress' );
     
    137137            BP_Messages_Thread::delete($thread_ids[$i]);
    138138        }
    139        
     139
    140140        _e('Messages deleted.', 'buddypress');
    141141    }
     
    149149    if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
    150150        return false;
    151        
     151
    152152    if ( !isset($_POST['notice_id']) ) {
    153153        echo "-1[[split]]" . __('There was a problem closing the notice.', 'buddypress');
    154154    } else {
    155155        $notice_ids = get_usermeta( $userdata->ID, 'closed_notices' );
    156    
     156
    157157        $notice_ids[] = (int) $_POST['notice_id'];
    158        
     158
    159159        update_usermeta( $userdata->ID, 'closed_notices', $notice_ids );
    160160    }
     
    168168    if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
    169169        return false;
    170            
     170
    171171    $friends = false;
    172172
     
    183183            echo bp_core_fetch_avatar( array( 'item_id' => $user_id, 'type' => 'thumb', 'width' => 15, 'height' => 15 ) )  . ' ' . bp_core_get_user_displayname( $user_id ) . ' (' . $username . ')
    184184            ';
    185         }       
     185        }
    186186    }
    187187}
     
    193193    global $message, $type;
    194194    global $bp, $current_user;
    195        
     195
    196196    messages_add_callback_values( $recipients, $subject, $content );
    197    
     197
    198198    if ( isset( $_POST['send-notice'] ) ) {
    199199        if ( messages_send_notice( $subject, $content, $from_template ) ) {
    200200            bp_core_add_message( __('Notice posted successfully.', 'buddypress') );
    201201        } else {
    202             bp_core_add_message( __('There was an error posting that notice.', 'buddypress'), 'error' );           
     202            bp_core_add_message( __('There was an error posting that notice.', 'buddypress'), 'error' );
    203203        }
    204204        bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/notices' );
    205205        return true;
    206206    }
    207    
     207
    208208    $recipients = explode( ' ', $recipients );
    209    
     209
    210210    // If there are no recipients
    211211    if ( count( $recipients ) < 1 ) {
    212         if ( !$from_ajax ) {   
     212        if ( !$from_ajax ) {
    213213            bp_core_add_message( __('Please enter at least one valid user to send this message to.', 'buddypress'), 'error' );
    214214            bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/compose' );
     
    216216            return array('status' => 0, 'message' => __('There was an error sending the reply, please try again.', 'buddypress'));
    217217        }
    218        
     218
    219219    // If there is only 1 recipient and it is the logged in user.
    220220    } else if ( 1 == count( $recipients ) && $recipients[0] == $current_user->user_login ) {
    221221        bp_core_add_message( __('You must send your message to one or more users not including yourself.', 'buddypress'), 'error' );
    222         bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/compose' );   
    223    
     222        bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/compose' );
     223
    224224    // If the subject or content boxes are empty.
    225225    } else if ( empty( $subject ) || empty( $content ) ) {
     
    230230            return array('status' => 0, 'message' => __('Please make sure you have typed a message before sending a reply.', 'buddypress'));
    231231        }
    232        
     232
    233233    // Passed validation continue.
    234234    } else {
     
    237237        if ( $key = array_search( $current_user->user_login, $recipients ) )
    238238            unset( $recipients[$key] );
    239        
     239
    240240        $pmessage = new BP_Messages_Message;
    241241
     
    245245        $pmessage->thread_id = $thread_id;
    246246        $pmessage->date_sent = time();
    247        
     247
    248248        if ( $is_reply ) {
    249249            $thread = new BP_Messages_Thread($thread_id);
     
    257257                $message = __('Message could not be sent, please try again.', 'buddypress');
    258258                $type = 'error';
    259        
     259
    260260                if ( $from_ajax ) {
    261261                    return array('status' => 0, 'message' => $message);
     
    263263                    bp_core_add_message( $message, $type );
    264264                    bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/compose' );
    265                 } 
     265                }
    266266            } else {
    267267                $message = __('Message sent successfully!', 'buddypress');
    268268                $type = 'success';
    269                
     269
    270270                // Send screen notifications to the recipients
    271271                for ( $i = 0; $i < count($pmessage->recipients); $i++ ) {
    272272                    if ( $pmessage->recipients[$i] != $bp->loggedin_user->id ) {
    273                         bp_core_add_notification( $pmessage->id, $pmessage->recipients[$i], 'messages', 'new_message' );   
     273                        bp_core_add_notification( $pmessage->id, $pmessage->recipients[$i], 'messages', 'new_message' );
    274274                    }
    275275                }
    276                
     276
    277277                // Send email notifications to the recipients
    278278                require_once( BP_PLUGIN_DIR . '/bp-messages/bp-messages-notifications.php' );
     
    280280
    281281                do_action( 'messages_send_message', array( 'item_id' => $pmessage->id, 'recipient_ids' => $pmessage->recipients, 'thread_id' => $pmessage->thread_id, 'component_name' => $bp->messages->slug, 'component_action' => 'message_sent', 'is_private' => 1 ) );
    282        
     282
    283283                if ( $from_ajax ) {
    284284                    return array('status' => 1, 'message' => $message, 'reply' => $pmessage);
     
    291291            $message = __('Message could not be sent, please try again.', 'buddypress');
    292292            $type = 'error';
    293        
     293
    294294            if ( $from_ajax ) {
    295295                return array('status' => 0, 'message' => $message);
Note: See TracChangeset for help on using the changeset viewer.