Skip to:
Content

BuddyPress.org

Changeset 5696


Ignore:
Timestamp:
02/10/2012 09:02:53 PM (14 years ago)
Author:
johnjamesjacoby
Message:

Remove unneeded globals and clean up some code in Messages component. See #3989.

Location:
trunk/bp-messages
Files:
10 edited

Legend:

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

    r5417 r5696  
    11<?php
    2 /*******************************************************************************
     2
     3/**
     4 * BuddyPress Messages Actions
     5 *
    36 * Action functions are exactly the same as screen functions, however they do not
    47 * have a template screen associated with them. Usually they will send the user
    58 * back to the default screen after execution.
     9 *
     10 * @package BuddyPress
     11 * @subpackage SettingsLoader
    612 */
    713
     
    108114}
    109115add_action( 'bp_actions', 'messages_action_bulk_delete' );
     116
    110117?>
  • trunk/bp-messages/bp-messages-cache.php

    r4961 r5696  
    11<?php
    2 /*******************************************************************************
     2
     3/**
     4 * BuddyPress Messages Caching
     5 *
    36 * Caching functions handle the clearing of cached objects and pages on specific
    47 * actions throughout BuddyPress.
     8 *
     9 * @package BuddyPress
     10 * @subpackage SettingsLoader
    511 */
    612
  • trunk/bp-messages/bp-messages-classes.php

    r5302 r5696  
    11<?php
     2
     3/**
     4 * BuddyPress Messages Classes
     5 *
     6 * @package BuddyPress
     7 * @subpackage MessagesClasses
     8 */
     9
    210// Exit if accessed directly
    311if ( !defined( 'ABSPATH' ) ) exit;
    412
    5 Class BP_Messages_Thread {
     13class BP_Messages_Thread {
    614    var $thread_id;
    715    var $messages;
     
    1119    var $unread_count;
    1220
    13     function bp_messages_thread ( $thread_id = false, $order = 'ASC' ) {
    14         $this->__construct( $thread_id, $order);
    15     }
    16 
    1721    function __construct( $thread_id = false, $order = 'ASC' ) {
    1822        if ( $thread_id )
     
    5458        global $wpdb, $bp;
    5559
    56         $results = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->messages->table_name_recipients} WHERE thread_id = %d", $this->thread_id ) );
    57 
    58         foreach ( (array)$results as $recipient )
     60        $recipients = array();
     61        $results    = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->messages->table_name_recipients} WHERE thread_id = %d", $this->thread_id ) );
     62
     63        foreach ( (array) $results as $recipient )
    5964            $recipients[$recipient->user_id] = $recipient;
    6065
     
    203208            return count( $recipients ) . __(' Recipients', 'buddypress');
    204209
     210        $recipient_links = array();
     211
    205212        foreach ( (array)$recipients as $recipient )
    206213            $recipient_links[] = bp_core_get_userlink( $recipient->user_id );
     
    241248}
    242249
    243 Class BP_Messages_Message {
     250class BP_Messages_Message {
    244251    var $id;
    245252    var $thread_id;
     
    251258    var $recipients = false;
    252259
    253     function bp_messages_message( $id = null ) {
    254         $this->__construct( $id );
    255     }
    256 
    257260    function __construct( $id = null ) {
    258         global $bp;
    259 
    260261        $this->date_sent = bp_core_current_time();
    261262        $this->sender_id = bp_loggedin_user_id();
     
    344345        if ( is_array( $recipient_usernames ) ) {
    345346            for ( $i = 0, $count = count( $recipient_usernames ); $i < $count; ++$i ) {
    346                 if ( $rid = bp_core_get_userid( trim($recipient_usernames[$i]) ) )
     347                if ( $rid = bp_core_get_userid( trim($recipient_usernames[$i]) ) ) {
    347348                    $recipient_ids[] = $rid;
     349                }
    348350            }
    349351        }
     
    376378    var $is_active;
    377379
    378     function bp_messages_notice( $id = null ) {
    379         $this->__construct($id);
    380     }
    381 
    382380    function __construct( $id = null ) {
    383381        if ( $id ) {
     
    480478    }
    481479}
     480
    482481?>
  • trunk/bp-messages/bp-messages-cssjs.php

    r5574 r5696  
    11<?php
     2
     3/**
     4 * BuddyPress Messages CSS and JS
     5 *
     6 * Apply WordPress defined filters to private messages
     7 *
     8 * @package BuddyPress
     9 * @subpackage MessagesScripts
     10 */
     11
    212// Exit if accessed directly
    313if ( !defined( 'ABSPATH' ) ) exit;
    414
    515function messages_add_autocomplete_js() {
    6     global $bp;
    716
    817    // Include the autocomplete JS for composing a message.
     
    2736
    2837function messages_add_autocomplete_css() {
    29     global $bp;
    3038
    3139    if ( bp_is_messages_component() && bp_is_current_action( 'compose' ) ) {
    32         if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG )
     40        if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
    3341            wp_enqueue_style( 'bp-messages-autocomplete', BP_PLUGIN_URL . 'bp-messages/css/autocomplete/jquery.autocompletefb.dev.css', array(), '20110723' );
    34         else
     42        } else {
    3543            wp_enqueue_style( 'bp-messages-autocomplete', BP_PLUGIN_URL . 'bp-messages/css/autocomplete/jquery.autocompletefb.css', array(), '20110723' );
     44        }
    3645
    3746        wp_print_styles();
     
    4251function messages_autocomplete_init_jsblock() {
    4352?>
     53
    4454    <script type="text/javascript">
    4555        jQuery(document).ready(function() {
     
    5363        });
    5464    </script>
     65
    5566<?php
    5667}
     68
     69?>
  • trunk/bp-messages/bp-messages-filters.php

    r4825 r5696  
    11<?php
     2
     3/**
     4 * BuddyPress Messages Filters
     5 *
     6 * Apply WordPress defined filters to private messages
     7 *
     8 * @package BuddyPress
     9 * @subpackage MessagesFilters
     10 */
     11
    212// Exit if accessed directly
    313if ( !defined( 'ABSPATH' ) ) exit;
    414
    5 /* Apply WordPress defined filters */
    6 add_filter( 'bp_get_message_notice_subject', 'wp_filter_kses', 1 );
    7 add_filter( 'bp_get_message_notice_text', 'wp_filter_kses', 1 );
    8 add_filter( 'bp_get_message_thread_subject', 'wp_filter_kses', 1 );
    9 add_filter( 'bp_get_message_thread_excerpt', 'wp_filter_kses', 1 );
    10 add_filter( 'bp_get_messages_subject_value', 'wp_filter_kses', 1 );
    11 add_filter( 'bp_get_messages_content_value', 'wp_filter_kses', 1 );
    12 add_filter( 'bp_get_the_thread_message_content', 'wp_filter_kses', 1 );
     15add_filter( 'bp_get_message_notice_subject',        'wp_filter_kses', 1 );
     16add_filter( 'bp_get_message_notice_text',           'wp_filter_kses', 1 );
     17add_filter( 'bp_get_message_thread_subject',        'wp_filter_kses', 1 );
     18add_filter( 'bp_get_message_thread_excerpt',        'wp_filter_kses', 1 );
     19add_filter( 'bp_get_messages_subject_value',        'wp_filter_kses', 1 );
     20add_filter( 'bp_get_messages_content_value',        'wp_filter_kses', 1 );
     21add_filter( 'bp_get_the_thread_message_content',    'wp_filter_kses', 1 );
    1322
    1423add_filter( 'messages_message_content_before_save', 'wp_filter_kses', 1 );
    1524add_filter( 'messages_message_subject_before_save', 'wp_filter_kses', 1 );
    16 add_filter( 'messages_notice_message_before_save', 'wp_filter_kses', 1 );
    17 add_filter( 'messages_notice_subject_before_save', 'wp_filter_kses', 1 );
     25add_filter( 'messages_notice_message_before_save',  'wp_filter_kses', 1 );
     26add_filter( 'messages_notice_subject_before_save',  'wp_filter_kses', 1 );
    1827
    19 add_filter( 'bp_get_the_thread_message_content', 'wp_filter_kses', 1 );
    20 add_filter( 'bp_get_the_thread_subject', 'wp_filter_kses', 1 );
     28add_filter( 'bp_get_the_thread_message_content',    'wp_filter_kses', 1 );
     29add_filter( 'bp_get_the_thread_subject',            'wp_filter_kses', 1 );
    2130
    2231add_filter( 'messages_message_content_before_save', 'force_balance_tags' );
    2332add_filter( 'messages_message_subject_before_save', 'force_balance_tags' );
    24 add_filter( 'messages_notice_message_before_save', 'force_balance_tags' );
    25 add_filter( 'messages_notice_subject_before_save', 'force_balance_tags' );
     33add_filter( 'messages_notice_message_before_save',  'force_balance_tags' );
     34add_filter( 'messages_notice_subject_before_save',  'force_balance_tags' );
    2635
    27 add_filter( 'bp_get_message_notice_subject', 'wptexturize' );
    28 add_filter( 'bp_get_message_notice_text', 'wptexturize' );
    29 add_filter( 'bp_get_message_thread_subject', 'wptexturize' );
    30 add_filter( 'bp_get_message_thread_excerpt', 'wptexturize' );
     36add_filter( 'bp_get_message_notice_subject',     'wptexturize' );
     37add_filter( 'bp_get_message_notice_text',        'wptexturize' );
     38add_filter( 'bp_get_message_thread_subject',     'wptexturize' );
     39add_filter( 'bp_get_message_thread_excerpt',     'wptexturize' );
    3140add_filter( 'bp_get_the_thread_message_content', 'wptexturize' );
    3241
    33 add_filter( 'bp_get_message_notice_subject', 'convert_smilies', 2 );
    34 add_filter( 'bp_get_message_notice_text', 'convert_smilies', 2 );
    35 add_filter( 'bp_get_message_thread_subject', 'convert_smilies', 2 );
    36 add_filter( 'bp_get_message_thread_excerpt', 'convert_smilies', 2 );
     42add_filter( 'bp_get_message_notice_subject',     'convert_smilies', 2 );
     43add_filter( 'bp_get_message_notice_text',        'convert_smilies', 2 );
     44add_filter( 'bp_get_message_thread_subject',     'convert_smilies', 2 );
     45add_filter( 'bp_get_message_thread_excerpt',     'convert_smilies', 2 );
    3746add_filter( 'bp_get_the_thread_message_content', 'convert_smilies', 2 );
    3847
    39 add_filter( 'bp_get_message_notice_subject', 'convert_chars' );
    40 add_filter( 'bp_get_message_notice_text', 'convert_chars' );
    41 add_filter( 'bp_get_message_thread_subject', 'convert_chars' );
    42 add_filter( 'bp_get_message_thread_excerpt', 'convert_chars' );
     48add_filter( 'bp_get_message_notice_subject',     'convert_chars' );
     49add_filter( 'bp_get_message_notice_text',        'convert_chars' );
     50add_filter( 'bp_get_message_thread_subject',     'convert_chars' );
     51add_filter( 'bp_get_message_thread_excerpt',     'convert_chars' );
    4352add_filter( 'bp_get_the_thread_message_content', 'convert_chars' );
    4453
    45 add_filter( 'bp_get_message_notice_text', 'make_clickable', 9 );
    46 add_filter( 'bp_get_message_thread_excerpt', 'make_clickable', 9 );
     54add_filter( 'bp_get_message_notice_text',        'make_clickable', 9 );
     55add_filter( 'bp_get_message_thread_excerpt',     'make_clickable', 9 );
    4756add_filter( 'bp_get_the_thread_message_content', 'make_clickable', 9 );
    4857
    49 add_filter( 'bp_get_message_notice_text', 'wpautop' );
     58add_filter( 'bp_get_message_notice_text',        'wpautop' );
    5059add_filter( 'bp_get_the_thread_message_content', 'wpautop' );
    5160
    52 add_filter( 'bp_get_message_notice_subject', 'stripslashes_deep' );
    53 add_filter( 'bp_get_message_notice_text', 'stripslashes_deep' );
    54 add_filter( 'bp_get_message_thread_subject', 'stripslashes_deep' );
    55 add_filter( 'bp_get_message_thread_excerpt', 'stripslashes_deep' );
    56 add_filter( 'bp_get_messages_subject_value', 'stripslashes_deep' );
    57 add_filter( 'bp_get_messages_content_value', 'stripslashes_deep' );
     61add_filter( 'bp_get_message_notice_subject',     'stripslashes_deep' );
     62add_filter( 'bp_get_message_notice_text',        'stripslashes_deep' );
     63add_filter( 'bp_get_message_thread_subject',     'stripslashes_deep' );
     64add_filter( 'bp_get_message_thread_excerpt',     'stripslashes_deep' );
     65add_filter( 'bp_get_messages_subject_value',     'stripslashes_deep' );
     66add_filter( 'bp_get_messages_content_value',     'stripslashes_deep' );
    5867add_filter( 'bp_get_the_thread_message_content', 'stripslashes_deep' );
    59 
    60 add_filter( 'bp_get_the_thread_message_content', 'stripslashes_deep' );
    61 add_filter( 'bp_get_the_thread_subject', 'stripslashes_deep' );
     68add_filter( 'bp_get_the_thread_subject',         'stripslashes_deep' );
    6269
    6370?>
  • trunk/bp-messages/bp-messages-functions.php

    r5417 r5696  
    11<?php
    2 /*******************************************************************************
     2
     3/**
     4 * BuddyPress Messages Functions
     5 *
    36 * Business functions are where all the magic happens in BuddyPress. They will
    47 * handle the actual saving or manipulation of information. Usually they will
    58 * hand off to a database class for data access, then return
    69 * true or false on success or failure.
     10 *
     11 * @package BuddyPress
     12 * @subpackage MessagesFunctions
    713 */
    814
     
    1117
    1218function messages_new_message( $args = '' ) {
    13     global $bp;
    1419
    1520    $defaults = array (
     
    144149        $error = 0;
    145150        for ( $i = 0, $count = count( $thread_ids ); $i < $count; ++$i ) {
    146             if ( !$status = BP_Messages_Thread::delete( $thread_ids[$i]) )
     151            if ( !$status = BP_Messages_Thread::delete( $thread_ids[$i]) ) {
    147152                $error = 1;
     153            }
    148154        }
    149155
     
    165171
    166172function messages_check_thread_access( $thread_id, $user_id = 0 ) {
    167     global $bp;
    168 
    169173    if ( empty( $user_id ) )
    170174        $user_id = bp_loggedin_user_id();
     
    194198
    195199function messages_get_unread_count( $user_id = 0 ) {
    196     global $bp;
    197 
    198200    if ( empty( $user_id ) )
    199201        $user_id = bp_loggedin_user_id();
     
    213215    return BP_Messages_Thread::is_valid( $thread_id );
    214216}
    215 
    216 /*******************************************************************************
    217  * These functions handle the recording, deleting and formatting of activity and
    218  * notifications for the user and for this specific component.
    219  */
    220217
    221218/**
     
    231228 */
    232229function messages_format_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) {
    233     global $bp;
    234230
    235231    if ( 'new_message' == $action ) {
     
    237233        $title = __( 'Inbox', 'buddypress' );
    238234
    239         if ( (int)$total_items > 1 ) {
     235        if ( (int) $total_items > 1 ) {
    240236            $text = sprintf( __('You have %d new messages', 'buddypress' ), (int)$total_items );
    241237            $filter = 'bp_messages_multiple_new_message_notification';
     
    252248            'text' => $text,
    253249            'link' => $link
    254         ), $link, (int)$total_items, $text, $link );
     250        ), $link, (int) $total_items, $text, $link );
    255251    }
    256252
     
    259255    return $return;
    260256}
     257
    261258?>
  • trunk/bp-messages/bp-messages-loader.php

    r5501 r5696  
    11<?php
     2
    23/**
    3  * BuddyPress Private Messages Loader
     4 * BuddyPress Messages Loader
    45 *
    56 * A private messages component, for users to send messages to each other
    67 *
    78 * @package BuddyPress
    8  * @subpackage Messages Core
     9 * @subpackage MessagesLoader
    910 */
    1011
     
    9394        global $bp;
    9495
    95         $name = sprintf( __( 'Messages <span>%s</span>', 'buddypress' ), bp_get_total_unread_messages_count() );
     96        $sub_nav = array();
     97        $name    = sprintf( __( 'Messages <span>%s</span>', 'buddypress' ), bp_get_total_unread_messages_count() );
    9698
    9799        // Add 'Messages' to the main navigation
     
    174176
    175177            // Unread message count
    176             if ( $count = messages_get_unread_count() ) {
    177                 $title = sprintf( __( 'Messages <span class="count">%s</span>', 'buddypress' ), $count );
    178                 $inbox = sprintf( __( 'Inbox <span class="count">%s</span>',    'buddypress' ), $count );
     178            $count = messages_get_unread_count();
     179            if ( !empty( $count ) ) {
     180                $title = sprintf( __( 'Messages <span class="count">%s</span>', 'buddypress' ), number_format_i18n( $count ) );
     181                $inbox = sprintf( __( 'Inbox <span class="count">%s</span>',    'buddypress' ), number_format_i18n( $count ) );
    179182            } else {
    180183                $title = __( 'Messages', 'buddypress' );
  • trunk/bp-messages/bp-messages-notifications.php

    r5445 r5696  
    11<?php
     2
     3/**
     4 * BuddyPress Messages Notifications
     5 *
     6 * @package BuddyPress
     7 * @subpackage MessagesNotifications
     8 */
     9
     10
    211// Exit if accessed directly
    312if ( !defined( 'ABSPATH' ) ) exit;
    413
    5 function messages_notification_new_message( $args ) {
    6     global $bp;
     14function messages_notification_new_message( $args = array() ) {
    715
    8     extract($args);
     16    // These should be extracted below
     17    $recipients    = array();
     18    $email_subject = $email_content = '';
    919
    10     $email_subject = $email_content = $args = '';
    11     $sender_name   = bp_core_get_user_displayname( $sender_id );
     20    extract( $args );
    1221
    13     foreach( $recipients as $recipient ) {
    14         if ( $sender_id == $recipient->user_id || 'no' == bp_get_user_meta( $recipient->user_id, 'notification_messages_new_message', true ) )
    15             continue;
     22    $sender_name = bp_core_get_user_displayname( $sender_id );
    1623
    17         // User data and links
    18         $ud            = get_userdata( $recipient->user_id );
    19         $message_link  = bp_core_get_user_domain( $recipient->user_id ) . bp_get_messages_slug() .'/';
    20         $settings_slug = function_exists( 'bp_get_settings_slug' ) ? bp_get_settings_slug() : 'settings';
    21         $settings_link = bp_core_get_user_domain( $recipient->user_id ) . $settings_slug . '/notifications/';
     24    // Bail if no recipients
     25    if ( ! empty( $recipients ) ) {
    2226
    23         // Sender info
    24         $sender_name   = stripslashes( $sender_name );
    25         $subject       = stripslashes( wp_filter_kses( $subject ) );
    26         $content       = stripslashes( wp_filter_kses( $content ) );
     27        foreach( $recipients as $recipient ) {
    2728
    28         // Set up and send the message
    29         $email_to      = $ud->user_email;
    30         $sitename      = wp_specialchars_decode( get_blog_option( bp_get_root_blog_id(), 'blogname' ), ENT_QUOTES );
    31         $email_subject = '[' . $sitename . '] ' . sprintf( __( 'New message from %s', 'buddypress' ), $sender_name );
     29            if ( $sender_id == $recipient->user_id || 'no' == bp_get_user_meta( $recipient->user_id, 'notification_messages_new_message', true ) )
     30                continue;
    3231
    33         $email_content = sprintf( __(
     32            // User data and links
     33            $ud            = get_userdata( $recipient->user_id );
     34            $message_link  = bp_core_get_user_domain( $recipient->user_id ) . bp_get_messages_slug() .'/';
     35            $settings_slug = function_exists( 'bp_get_settings_slug' ) ? bp_get_settings_slug() : 'settings';
     36            $settings_link = bp_core_get_user_domain( $recipient->user_id ) . $settings_slug . '/notifications/';
     37
     38            // Sender info
     39            $sender_name   = stripslashes( $sender_name );
     40            $subject       = stripslashes( wp_filter_kses( $subject ) );
     41            $content       = stripslashes( wp_filter_kses( $content ) );
     42
     43            // Set up and send the message
     44            $email_to      = $ud->user_email;
     45            $sitename      = wp_specialchars_decode( get_blog_option( bp_get_root_blog_id(), 'blogname' ), ENT_QUOTES );
     46            $email_subject = '[' . $sitename . '] ' . sprintf( __( 'New message from %s', 'buddypress' ), $sender_name );
     47
     48            $email_content = sprintf( __(
    3449'%1$s sent you a new message:
    3550
     
    4358', 'buddypress' ), $sender_name, $subject, $content, $message_link );
    4459
    45         $email_content .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
     60            $email_content .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
    4661
    47         // Send the message
    48         $email_to = apply_filters( 'messages_notification_new_message_to', $email_to );
    49         $email_subject = apply_filters( 'messages_notification_new_message_subject', $email_subject, $sender_name );
    50         $email_content = apply_filters( 'messages_notification_new_message_message', $email_content, $sender_name, $subject, $content, $message_link, $settings_link );
     62            // Send the message
     63            $email_to      = apply_filters( 'messages_notification_new_message_to',      $email_to );
     64            $email_subject = apply_filters( 'messages_notification_new_message_subject', $email_subject, $sender_name );
     65            $email_content = apply_filters( 'messages_notification_new_message_message', $email_content, $sender_name, $subject, $content, $message_link, $settings_link );
    5166
    52         wp_mail( $email_to, $email_subject, $email_content );
     67            wp_mail( $email_to, $email_subject, $email_content );
     68        }
    5369    }
    5470
  • trunk/bp-messages/bp-messages-screens.php

    r5417 r5696  
    11<?php
    2 /*******************************************************************************
     2
     3/**
     4 * BuddyPress Messages Screens
     5 *
    36 * Screen functions are the controllers of BuddyPress. They will execute when their
    47 * specific URL is caught. They will first save or manipulate data using business
    58 * functions, then pass on the user to a template file.
     9 *
     10 * @package BuddyPress
     11 * @subpackage MessagesScreens
    612 */
    713
     
    1016
    1117function messages_screen_inbox() {
    12     global $bp;
    13 
    1418    if ( bp_action_variables() ) {
    1519        bp_do_404();
     
    2226
    2327function messages_screen_sentbox() {
    24     global $bp;
    25 
    2628    if ( bp_action_variables() ) {
    2729        bp_do_404();
     
    129131
    130132function messages_screen_notification_settings() {
    131     global $bp;
    132 
    133133    if ( bp_action_variables() ) {
    134134        bp_do_404();
     
    140140
    141141    if ( !$new_notices = bp_get_user_meta( bp_displayed_user_id(), 'notification_messages_new_notice', true ) )
    142         $new_notices  = 'yes';
    143 ?>
     142        $new_notices  = 'yes'; ?>
    144143
    145144    <table class="notification-settings" id="messages-notification-settings">
  • trunk/bp-messages/bp-messages-template.php

    r5641 r5696  
    11<?php
     2
     3/**
     4 * BuddyPress Messages Template Tags
     5 *
     6 * @package BuddyPress
     7 * @subpackage MessagesTemplate
     8 */
     9
    210// Exit if accessed directly
    311if ( !defined( 'ABSPATH' ) ) exit;
    412
    5 /*****************************************************************************
     13/**
    614 * Message Box Template Class
    7  **/
    8 Class BP_Messages_Box_Template {
     15 */
     16class BP_Messages_Box_Template {
    917    var $current_thread = -1;
    1018    var $current_thread_count;
     
    211219}
    212220    function bp_get_message_thread_subject() {
    213         global $messages_template, $message_template_subject;
     221        global $messages_template;
    214222
    215223        return apply_filters( 'bp_get_message_thread_subject', stripslashes_deep( $messages_template->thread->last_message_subject ) );
     
    307315}
    308316    function bp_get_message_thread_avatar() {
    309         global $messages_template, $bp;
     317        global $messages_template;
    310318       
    311319        return apply_filters( 'bp_get_message_thread_avatar', bp_core_fetch_avatar( array( 'item_id' => $messages_template->thread->last_sender_id, 'type' => 'thumb', 'alt' => sprintf( __( 'Profile picture of %s', 'buddypress' ), bp_core_get_user_displayname( $messages_template->thread->last_sender_id ) ) ) ) );
     
    397405
    398406function bp_messages_options() {
    399     global $bp;
    400 ?>
     407    global $bp; ?>
     408
    401409    <?php _e( 'Select:', 'buddypress' ) ?>
     410
    402411    <select name="message-type-select" id="message-type-select">
    403412        <option value=""></option>
     
    406415        <option value="all"><?php _e('All', 'buddypress') ?></option>
    407416    </select> &nbsp;
     417
    408418    <?php if ( $bp->current_action != 'sentbox' && $bp->current_action != 'notices' ) : ?>
     419
    409420        <a href="#" id="mark_as_read"><?php _e('Mark as Read', 'buddypress') ?></a> &nbsp;
    410421        <a href="#" id="mark_as_unread"><?php _e('Mark as Unread', 'buddypress') ?></a> &nbsp;
     422
    411423    <?php endif; ?>
     424
    412425    <a href="#" id="delete_<?php echo $bp->current_action ?>_messages"><?php _e('Delete Selected', 'buddypress') ?></a> &nbsp;
     426
    413427<?php
    414428}
     
    651665    var $total_message_count;
    652666
    653     function bp_messages_thread_template( $thread_id, $order ) {
    654         $this->__construct( $thread_id, $order );
    655     }
    656 
    657667    function __construct( $thread_id, $order ) {
    658         global $bp;
    659 
    660         $this->thread = new BP_Messages_Thread( $thread_id, $order );
     668        $this->thread        = new BP_Messages_Thread( $thread_id, $order );
    661669        $this->message_count = count( $this->thread->messages );
    662670
     
    704712
    705713    function the_message() {
    706         global $message;
    707 
    708714        $this->in_the_loop = true;
    709         $this->message = $this->next_message();
    710 
    711         if ( 0 == $this->current_message ) // loop has just started
     715        $this->message     = $this->next_message();
     716
     717        // loop has just started
     718        if ( 0 == $this->current_message )
    712719            do_action('thread_loop_start');
    713720    }
     
    715722
    716723function bp_thread_has_messages( $args = '' ) {
    717     global $bp, $thread_template, $group_id;
     724    global $thread_template;
    718725
    719726    $defaults = array(
    720727        'thread_id' => false,
    721         'order' => 'ASC'
     728        'order'     => 'ASC'
    722729    );
    723730
     
    725732    extract( $r, EXTR_SKIP );
    726733
    727     if ( !$thread_id && bp_is_messages_component() && bp_is_current_action( 'view' ) )
    728         $thread_id = (int)bp_action_variable( 0 );
     734    if ( empty( $thread_id ) && bp_is_messages_component() && bp_is_current_action( 'view' ) )
     735        $thread_id = (int) bp_action_variable( 0 );
    729736
    730737    $thread_template = new BP_Messages_Thread_Template( $thread_id, $order );
     
    775782}
    776783    function bp_get_the_thread_recipients() {
    777         global $thread_template, $bp;
     784        global $thread_template;
    778785
    779786        $recipient_links = array();
     
    811818
    812819        $defaults = array(
    813             'type' => 'thumb',
    814             'width' => false,
     820            'type'   => 'thumb',
     821            'width'  => false,
    815822            'height' => false,
    816823        );
     
    882889}
    883890add_action( 'messages_box_loop_start', 'bp_messages_embed' );
     891
    884892?>
Note: See TracChangeset for help on using the changeset viewer.