Skip to:
Content

BuddyPress.org


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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.