Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/10/2012 09:02:53 PM (13 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-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?>
Note: See TracChangeset for help on using the changeset viewer.