Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/02/2009 06:56:42 PM (17 years ago)
Author:
apeatling
Message:

Merging last few trunk changes and stripping all whitespace.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/1.1/bp-messages/bp-messages-templatetags.php

    r1989 r2076  
    1111        var $threads;
    1212        var $thread;
    13        
     13
    1414        var $in_the_loop;
    1515        var $user_id;
    1616        var $box;
    17        
     17
    1818        var $pag_page;
    1919        var $pag_num;
    … …  
    2525                $this->user_id = $user_id;
    2626                $this->box = $box;
    27                
     27
    2828                if ( 'notices' == $this->box )
    2929                        $this->threads = BP_Messages_Notice::get_notices();
    3030                else
    3131                        $this->threads = BP_Messages_Thread::get_current_threads_for_user( $this->user_id, $this->box, $this->pag_num, $this->pag_page, $type );
    32                
     32
    3333                if ( !$this->threads ) {
    3434                        $this->thread_count = 0;
    3535                        $this->total_thread_count = 0;
    36                 } else { 
     36                } else {
    3737                        $total_notice_count = BP_Messages_Notice::get_total_notice_count();
    38                        
     38
    3939                        if ( !$max || $max >= (int)$total_notice_count ) {
    4040                                if ( 'notices' == $this->box )
    … …  
    4545                                $this->total_thread_count = (int)$max;
    4646                        }
    47                        
     47
    4848                        if ( $max ) {
    4949                                if ( $max >= count($this->threads) )
    … …  
    6666                ));
    6767        }
    68        
     68
    6969        function has_threads() {
    7070                if ( $this->thread_count )
    7171                        return true;
    72                
     72
    7373                return false;
    7474        }
    75        
     75
    7676        function next_thread() {
    7777                $this->current_thread++;
    7878                $this->thread = $this->threads[$this->current_thread];
    79                
     79
    8080                return $this->thread;
    8181        }
    82        
     82
    8383        function rewind_threads() {
    8484                $this->current_thread = -1;
    … …  
    8787                }
    8888        }
    89        
    90         function message_threads() { 
     89
     90        function message_threads() {
    9191                if ( $this->current_thread + 1 < $this->thread_count ) {
    9292                        return true;
    … …  
    100100                return false;
    101101        }
    102        
     102
    103103        function the_message_thread() {
    104104                global $thread;
    … …  
    114114function bp_has_message_threads( $args = '' ) {
    115115        global $bp, $messages_template;
    116        
     116
    117117        $defaults = array(
    118118                'user_id' => $bp->loggedin_user->id,
    … …  
    131131                if ( 'inbox' == $bp->current_action )
    132132                        bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, 'messages', 'new_message' );
    133                
     133
    134134                if ( 'sentbox' == $bp->current_action )
    135135                        $box = 'sentbox';
    … …  
    137137                if ( 'notices' == $bp->current_action )
    138138                        $box = 'notices';
    139        
     139
    140140                $messages_template = new BP_Messages_Box_Template( $user_id, $box, $per_page, $max, $type );
    141141        }
    142        
     142
    143143        return apply_filters( 'bp_has_message_threads', $messages_template->has_threads(), &$messages_template );
    144144}
    145145
    146 function bp_message_threads() { 
     146function bp_message_threads() {
    147147        global $messages_template;
    148148        return $messages_template->message_threads();
    … …  
    202202                return apply_filters( 'bp_get_message_thread_view_link', $bp->loggedin_user->domain . $bp->messages->slug . '/view/' . $messages_template->thread->thread_id );
    203203        }
    204        
     204
    205205function bp_message_thread_delete_link() {
    206206        echo bp_get_message_thread_delete_link();
    … …  
    210210                return apply_filters( 'bp_get_message_thread_delete_link', wp_nonce_url( $bp->loggedin_user->domain . $bp->messages->slug . '/' . $bp->current_action . '/delete/' . $messages_template->thread->thread_id, 'messages_delete_thread' ) );
    211211        }
    212        
     212
    213213function bp_message_thread_has_unread() {
    214214        global $messages_template;
    … …  
    216216        if ( $messages_template->thread->unread_count )
    217217                return true;
    218        
     218
    219219        return false;
    220220}
    … …  
    225225        function bp_get_message_thread_unread_count() {
    226226                global $messages_template;
    227                
     227
    228228                if ( (int)$messages_template->thread->unread_count )
    229229                        return apply_filters( 'bp_get_message_thread_unread_count', $messages_template->thread->unread_count );
    230                
     230
    231231                return false;
    232232        }
    … …  
    276276
    277277        echo sprintf( __( 'Viewing message %d to %d (of %d messages)', 'buddypress' ), $from_num, $to_num, $messages_template->total_thread_count ); ?> &nbsp;
    278         <span class="ajax-loader"></span><?php 
     278        <span class="ajax-loader"></span><?php
    279279}
    280280
    … …  
    315315function bp_messages_options() {
    316316        global $bp;
    317        
     317
    318318        if ( $bp->current_action != 'sentbox' ) {
    319319?>
    320                 <?php _e( 'Select:', 'buddypress' ) ?> 
     320                <?php _e( 'Select:', 'buddypress' ) ?>
    321321                <select name="message-type-select" id="message-type-select">
    322322                        <option value=""></option>
    … …  
    329329        <?php } ?>
    330330                <a href="#" id="delete_<?php echo $bp->current_action ?>_messages"><?php _e('Delete Selected', 'buddypress') ?></a> &nbsp;
    331 <?php   
     331<?php
    332332}
    333333
    334334function bp_message_is_active_notice() {
    335335        global $messages_template;
    336        
     336
    337337        if ( $messages_template->thread->is_active ) {
    338338                echo "<strong>";
    … …  
    346346                if ( $messages_template->thread->is_active )
    347347                        return true;
    348                
     348
    349349                return false;
    350350        }
    … …  
    392392                        $link = wp_nonce_url( $bp->loggedin_user->domain . $bp->messages->slug . '/notices/deactivate/' . $messages_template->thread->id, 'messages_deactivate_notice' );
    393393                } else {
    394                         $link = wp_nonce_url( $bp->loggedin_user->domain . $bp->messages->slug . '/notices/activate/' . $messages_template->thread->id, 'messages_activate_notice' );           
     394                        $link = wp_nonce_url( $bp->loggedin_user->domain . $bp->messages->slug . '/notices/activate/' . $messages_template->thread->id, 'messages_activate_notice' );
    395395                }
    396396                return apply_filters( 'bp_get_message_activate_deactivate_link', $link );
    … …  
    406406                        $text = __('Deactivate', 'buddypress');
    407407                } else {
    408                         $text = __('Activate', 'buddypress');           
     408                        $text = __('Activate', 'buddypress');
    409409                }
    410410                return apply_filters( 'bp_message_activate_deactivate_text', $text );
    … …  
    413413function bp_message_get_notices() {
    414414        global $userdata;
    415        
     415
    416416        $notice = BP_Messages_Notice::get_active();
    417417        $closed_notices = get_usermeta( $userdata->ID, 'closed_notices');
    … …  
    429429                        </div>
    430430                        <?php
    431                 }       
     431                }
    432432        }
    433433}
    … …  
    438438        function bp_get_send_message_button() {
    439439                global $bp;
    440        
     440
    441441                if ( bp_is_home() || !is_user_logged_in() )
    442442                        return false;
    443        
    444                 $ud = get_userdata( $bp->displayed_user->id ); 
    445                
     443
     444                $ud = get_userdata( $bp->displayed_user->id );
     445
    446446                return apply_filters( 'bp_get_send_message_button', '<div class="generic-button"><a class="send-message" title="' . __( 'Send Message', 'buddypress' ) . '" href="' . $bp->loggedin_user->domain . $bp->messages->slug . '/compose/?r=' . $ud->user_login . '">' . __( 'Send Message', 'buddypress' ) . '</a></div>' );
    447447        }
    … …  
    457457function bp_message_get_recipient_tabs() {
    458458        global $bp;
    459        
     459
    460460        if ( isset( $_GET['r'] ) ) {
    461461                $user_id = bp_core_get_userid( $_GET['r'] );
    462                
     462
    463463                if ( $user_id ) {
    464464                        ?>
    … …  
    467467                                        <?php echo bp_core_fetch_avatar( array( 'item_id' => $user_id, 'type' => 'thumb', 'width' => 15, 'height' => 15 ) ) ?>
    468468                                        <?php echo bp_core_get_userlink( $user_id ) ?>
    469                                 </span> 
     469                                </span>
    470470                        </li>
    471471                        <?php
    … …  
    490490        var $message_count;
    491491        var $message;
    492        
     492
    493493        var $thread;
    494        
     494
    495495        var $in_the_loop;
    496        
     496
    497497        var $pag_page;
    498498        var $pag_num;
    499499        var $pag_links;
    500500        var $total_message_count;
    501        
     501
    502502        function bp_messages_thread_template( $thread_id, $order ) {
    503503                global $bp;
    504                
     504
    505505                $this->thread = new BP_Messages_Thread( $thread_id, true );
    506506                $this->message_count = count( $this->thread->messages );
    507507        }
    508        
     508
    509509        function has_messages() {
    510510                if ( $this->message_count )
    511511                        return true;
    512                
     512
    513513                return false;
    514514        }
    515        
     515
    516516        function next_message() {
    517517                $this->current_message++;
    518518                $this->message = $this->thread->messages[$this->current_message];
    519                
     519
    520520                return $this->message;
    521521        }
    522        
     522
    523523        function rewind_messages() {
    524524                $this->current_message = -1;
    … …  
    527527                }
    528528        }
    529        
    530         function messages() { 
     529
     530        function messages() {
    531531                if ( $this->current_message + 1 < $this->message_count ) {
    532532                        return true;
    … …  
    540540                return false;
    541541        }
    542        
     542
    543543        function the_message() {
    544544                global $message;
    … …  
    554554function bp_thread_has_messages( $args = '' ) {
    555555        global $bp, $thread_template, $group_id;
    556        
     556
    557557        $defaults = array(
    558558                'thread_id' => false,
    … …  
    572572function bp_thread_messages() {
    573573        global $thread_template;
    574        
     574
    575575        return $thread_template->messages();
    576576}
    … …  
    578578function bp_thread_the_message() {
    579579        global $thread_template;
    580        
     580
    581581        return $thread_template->the_message();
    582582}
    … …  
    587587        function bp_get_the_thread_id() {
    588588                global $thread_template;
    589                
     589
    590590                return apply_filters( 'bp_get_the_thread_id', $thread_template->thread->thread_id );
    591591        }
    … …  
    605605        function bp_get_the_thread_recipients() {
    606606                global $thread_template;
    607                
     607
    608608                if ( count($thread_template->thread->recipients) >= 5 )
    609609                        return apply_filters( 'bp_get_the_thread_recipients', sprintf( __( '%d Recipients', 'buddypress' ), count($thread_template->thread->recipients) ) );
    610                
     610
    611611                foreach( $thread_template->thread->recipients as $recipient )
    612612                        $recipient_links[] = bp_core_get_userlink( $recipient );
    … …  
    620620        function bp_get_the_thread_message_alt_class() {
    621621                global $thread_template;
    622                
     622
    623623                if ( $thread_template->current_message % 2 == 1 )
    624624                        $class = ' alt';
    625625                else
    626626                        $class = '';
    627                
     627
    628628                return apply_filters( 'bp_get_the_thread_message_alt_class', $class );
    629629        }
    630        
     630
    631631function bp_the_thread_message_sender_avatar( $args = '' ) {
    632632        echo bp_get_the_thread_message_sender_avatar_thumb( $args );
    633633}
    634634        function bp_get_the_thread_message_sender_avatar_thumb( $args = '' ) {
    635                 global $thread_template;       
    636                        
     635                global $thread_template;
     636
    637637                $defaults = array(
    638638                        'type' => 'thumb',
    … …  
    652652        function bp_get_the_thread_message_sender_link() {
    653653                global $thread_template;
    654                
     654
    655655                return apply_filters( 'bp_get_the_thread_message_sender_link', bp_core_get_userlink( $thread_template->message->sender_id, false, true ) );
    656656        }
    657        
     657
    658658function bp_the_thread_message_sender_name() {
    659659        echo bp_get_the_thread_message_sender_name();
    … …  
    661661        function bp_get_the_thread_message_sender_name() {
    662662                global $thread_template;
    663                
    664                 return apply_filters( 'bp_get_the_thread_message_sender_name', bp_core_get_user_displayname( $thread_template->message->sender_id ) );         
     663
     664                return apply_filters( 'bp_get_the_thread_message_sender_name', bp_core_get_user_displayname( $thread_template->message->sender_id ) );
    665665        }
    666666
    … …  
    670670        function bp_get_the_thread_message_time_since() {
    671671                global $thread_template;
    672                
     672
    673673                return apply_filters( 'bp_get_the_thread_message_time_since', sprintf( __( 'Sent %s ago', 'buddypress' ), bp_core_time_since( strtotime( $thread_template->message->date_sent ) ) ) );
    674674        }
    … …  
    679679        function bp_get_the_thread_message_content() {
    680680                global $thread_template;
    681                
    682                 return apply_filters( 'bp_get_the_thread_message_content', $thread_template->message->message );               
    683         }
    684        
     681
     682                return apply_filters( 'bp_get_the_thread_message_content', $thread_template->message->message );
     683        }
     684
    685685
    686686/*** DEPRECATED FUNCTIONS (DO NOT USE) **********************************************************/
    687687
    688 /* DEPRECATED - please use the view message template loop. */   
     688/* DEPRECATED - please use the view message template loop. */
    689689function messages_view_thread( $thread_id ) {
    690690        global $bp;
    691691
    692692        $thread = new BP_Messages_Thread( $thread_id, true );
    693        
     693
    694694        if ( !$thread->has_access ) {
    695695                unset($_GET['mode']); ?>
    … …  
    697697                        <p><?php _e( 'There was an error when viewing that message', 'buddypress' ) ?></p>
    698698                </div>
    699         <?php   
     699        <?php
    700700        } else {
    701701                if ( $thread->messages ) { ?>
    702702                        <?php $thread->mark_read() ?>
    703                                
     703
    704704                        <div class="wrap">
    705705                                <h2 id="message-subject"><?php echo $thread->subject; ?></h2>
    … …  
    709709                                                        <td>
    710710                                                                <img src="<?php echo $bp->messages->image_base ?>/email_open.gif" alt="Message" style="vertical-align: top;" /> &nbsp;
    711                                                                 <?php _e('Sent between ', 'buddypress') ?> <?php echo BP_Messages_Thread::get_recipient_links($thread->recipients) ?> 
    712                                                                 <?php _e('and', 'buddypress') ?> <?php echo bp_core_get_userlink($bp->loggedin_user->id) ?>. 
     711                                                                <?php _e('Sent between ', 'buddypress') ?> <?php echo BP_Messages_Thread::get_recipient_links($thread->recipients) ?>
     712                                                                <?php _e('and', 'buddypress') ?> <?php echo bp_core_get_userlink($bp->loggedin_user->id) ?>.
    713713                                                        </td>
    714714                                                </tr>
    715715                                        </tbody>
    716716                                </table>
    717                                
     717
    718718                <?php
    719719                        $counter = 0;
    720                        
     720
    721721                        foreach ( $thread->messages as $message ) {
    722722                                $alt = ( $counter % 2 == 1 ) ? ' alt' : '';
    … …  
    729729                                                        <small><?php echo apply_filters( 'bp_get_message_date_sent', bp_format_time( strtotime($message->date_sent ) ) ) ?></small>
    730730                                                </div>
    731                                                
     731
    732732                                                <?php do_action( 'messages_custom_fields_output_before' ) ?>
    733                                                
     733
    734734                                                <?php echo apply_filters( 'bp_get_the_message_thread_content', stripslashes($message->message) ); ?>
    735                                                
     735
    736736                                                <?php do_action( 'messages_custom_fields_output_after' ) ?>
    737                
     737
    738738                                                <div class="clear"></div>
    739739                                        </div>
    … …  
    741741                                $counter++;
    742742                        }
    743                
     743
    744744                        ?>
    745745                                <form id="send-reply" action="<?php bp_messages_form_action() ?>" method="post">
    … …  
    748748                                                                <div class="avatar-box">
    749749                                                                        <?php echo  bp_core_fetch_avatar( array( 'item_id' => $bp->loggedin_user->id, 'type' => 'thumb' ) ); ?>
    750                                        
     750
    751751                                                                        <h3><?php _e("Reply: ", 'buddypress') ?></h3>
    752752                                                                </div>
    … …  
    762762                                                        <input type="hidden" name="subject" id="subject" value="<?php _e('Re: ', 'buddypress'); echo str_replace( 'Re: ', '', $thread->last_message_subject); ?>" />
    763763                                        </div>
    764                                        
     764
    765765                                        <?php wp_nonce_field( 'messages_send_message', '_wpnonce_send_message' ) ?>
    766766                                </form>
Note: See TracChangeset for help on using the changeset viewer.