Changeset 2077 for trunk/bp-messages/bp-messages-templatetags.php
- Timestamp:
- 11/02/2009 07:54:21 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/bp-messages/bp-messages-templatetags.php (modified) (43 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-messages/bp-messages-templatetags.php
r1989 r2077 11 11 var $threads; 12 12 var $thread; 13 13 14 14 var $in_the_loop; 15 15 var $user_id; 16 16 var $box; 17 17 18 18 var $pag_page; 19 19 var $pag_num; … … 25 25 $this->user_id = $user_id; 26 26 $this->box = $box; 27 27 28 28 if ( 'notices' == $this->box ) 29 29 $this->threads = BP_Messages_Notice::get_notices(); 30 30 else 31 31 $this->threads = BP_Messages_Thread::get_current_threads_for_user( $this->user_id, $this->box, $this->pag_num, $this->pag_page, $type ); 32 32 33 33 if ( !$this->threads ) { 34 34 $this->thread_count = 0; 35 35 $this->total_thread_count = 0; 36 } else { 36 } else { 37 37 $total_notice_count = BP_Messages_Notice::get_total_notice_count(); 38 38 39 39 if ( !$max || $max >= (int)$total_notice_count ) { 40 40 if ( 'notices' == $this->box ) … … 45 45 $this->total_thread_count = (int)$max; 46 46 } 47 47 48 48 if ( $max ) { 49 49 if ( $max >= count($this->threads) ) … … 66 66 )); 67 67 } 68 68 69 69 function has_threads() { 70 70 if ( $this->thread_count ) 71 71 return true; 72 72 73 73 return false; 74 74 } 75 75 76 76 function next_thread() { 77 77 $this->current_thread++; 78 78 $this->thread = $this->threads[$this->current_thread]; 79 79 80 80 return $this->thread; 81 81 } 82 82 83 83 function rewind_threads() { 84 84 $this->current_thread = -1; … … 87 87 } 88 88 } 89 90 function message_threads() { 89 90 function message_threads() { 91 91 if ( $this->current_thread + 1 < $this->thread_count ) { 92 92 return true; … … 100 100 return false; 101 101 } 102 102 103 103 function the_message_thread() { 104 104 global $thread; … … 114 114 function bp_has_message_threads( $args = '' ) { 115 115 global $bp, $messages_template; 116 116 117 117 $defaults = array( 118 118 'user_id' => $bp->loggedin_user->id, … … 131 131 if ( 'inbox' == $bp->current_action ) 132 132 bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, 'messages', 'new_message' ); 133 133 134 134 if ( 'sentbox' == $bp->current_action ) 135 135 $box = 'sentbox'; … … 137 137 if ( 'notices' == $bp->current_action ) 138 138 $box = 'notices'; 139 139 140 140 $messages_template = new BP_Messages_Box_Template( $user_id, $box, $per_page, $max, $type ); 141 141 } 142 142 143 143 return apply_filters( 'bp_has_message_threads', $messages_template->has_threads(), &$messages_template ); 144 144 } 145 145 146 function bp_message_threads() { 146 function bp_message_threads() { 147 147 global $messages_template; 148 148 return $messages_template->message_threads(); … … 202 202 return apply_filters( 'bp_get_message_thread_view_link', $bp->loggedin_user->domain . $bp->messages->slug . '/view/' . $messages_template->thread->thread_id ); 203 203 } 204 204 205 205 function bp_message_thread_delete_link() { 206 206 echo bp_get_message_thread_delete_link(); … … 210 210 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' ) ); 211 211 } 212 212 213 213 function bp_message_thread_has_unread() { 214 214 global $messages_template; … … 216 216 if ( $messages_template->thread->unread_count ) 217 217 return true; 218 218 219 219 return false; 220 220 } … … 225 225 function bp_get_message_thread_unread_count() { 226 226 global $messages_template; 227 227 228 228 if ( (int)$messages_template->thread->unread_count ) 229 229 return apply_filters( 'bp_get_message_thread_unread_count', $messages_template->thread->unread_count ); 230 230 231 231 return false; 232 232 } … … 276 276 277 277 echo sprintf( __( 'Viewing message %d to %d (of %d messages)', 'buddypress' ), $from_num, $to_num, $messages_template->total_thread_count ); ?> 278 <span class="ajax-loader"></span><?php 278 <span class="ajax-loader"></span><?php 279 279 } 280 280 … … 315 315 function bp_messages_options() { 316 316 global $bp; 317 317 318 318 if ( $bp->current_action != 'sentbox' ) { 319 319 ?> 320 <?php _e( 'Select:', 'buddypress' ) ?> 320 <?php _e( 'Select:', 'buddypress' ) ?> 321 321 <select name="message-type-select" id="message-type-select"> 322 322 <option value=""></option> … … 329 329 <?php } ?> 330 330 <a href="#" id="delete_<?php echo $bp->current_action ?>_messages"><?php _e('Delete Selected', 'buddypress') ?></a> 331 <?php 331 <?php 332 332 } 333 333 334 334 function bp_message_is_active_notice() { 335 335 global $messages_template; 336 336 337 337 if ( $messages_template->thread->is_active ) { 338 338 echo "<strong>"; … … 346 346 if ( $messages_template->thread->is_active ) 347 347 return true; 348 348 349 349 return false; 350 350 } … … 392 392 $link = wp_nonce_url( $bp->loggedin_user->domain . $bp->messages->slug . '/notices/deactivate/' . $messages_template->thread->id, 'messages_deactivate_notice' ); 393 393 } 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' ); 395 395 } 396 396 return apply_filters( 'bp_get_message_activate_deactivate_link', $link ); … … 406 406 $text = __('Deactivate', 'buddypress'); 407 407 } else { 408 $text = __('Activate', 'buddypress'); 408 $text = __('Activate', 'buddypress'); 409 409 } 410 410 return apply_filters( 'bp_message_activate_deactivate_text', $text ); … … 413 413 function bp_message_get_notices() { 414 414 global $userdata; 415 415 416 416 $notice = BP_Messages_Notice::get_active(); 417 417 $closed_notices = get_usermeta( $userdata->ID, 'closed_notices'); … … 429 429 </div> 430 430 <?php 431 } 431 } 432 432 } 433 433 } … … 438 438 function bp_get_send_message_button() { 439 439 global $bp; 440 440 441 441 if ( bp_is_home() || !is_user_logged_in() ) 442 442 return false; 443 444 $ud = get_userdata( $bp->displayed_user->id ); 445 443 444 $ud = get_userdata( $bp->displayed_user->id ); 445 446 446 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>' ); 447 447 } … … 457 457 function bp_message_get_recipient_tabs() { 458 458 global $bp; 459 459 460 460 if ( isset( $_GET['r'] ) ) { 461 461 $user_id = bp_core_get_userid( $_GET['r'] ); 462 462 463 463 if ( $user_id ) { 464 464 ?> … … 467 467 <?php echo bp_core_fetch_avatar( array( 'item_id' => $user_id, 'type' => 'thumb', 'width' => 15, 'height' => 15 ) ) ?> 468 468 <?php echo bp_core_get_userlink( $user_id ) ?> 469 </span> 469 </span> 470 470 </li> 471 471 <?php … … 490 490 var $message_count; 491 491 var $message; 492 492 493 493 var $thread; 494 494 495 495 var $in_the_loop; 496 496 497 497 var $pag_page; 498 498 var $pag_num; 499 499 var $pag_links; 500 500 var $total_message_count; 501 501 502 502 function bp_messages_thread_template( $thread_id, $order ) { 503 503 global $bp; 504 504 505 505 $this->thread = new BP_Messages_Thread( $thread_id, true ); 506 506 $this->message_count = count( $this->thread->messages ); 507 507 } 508 508 509 509 function has_messages() { 510 510 if ( $this->message_count ) 511 511 return true; 512 512 513 513 return false; 514 514 } 515 515 516 516 function next_message() { 517 517 $this->current_message++; 518 518 $this->message = $this->thread->messages[$this->current_message]; 519 519 520 520 return $this->message; 521 521 } 522 522 523 523 function rewind_messages() { 524 524 $this->current_message = -1; … … 527 527 } 528 528 } 529 530 function messages() { 529 530 function messages() { 531 531 if ( $this->current_message + 1 < $this->message_count ) { 532 532 return true; … … 540 540 return false; 541 541 } 542 542 543 543 function the_message() { 544 544 global $message; … … 554 554 function bp_thread_has_messages( $args = '' ) { 555 555 global $bp, $thread_template, $group_id; 556 556 557 557 $defaults = array( 558 558 'thread_id' => false, … … 572 572 function bp_thread_messages() { 573 573 global $thread_template; 574 574 575 575 return $thread_template->messages(); 576 576 } … … 578 578 function bp_thread_the_message() { 579 579 global $thread_template; 580 580 581 581 return $thread_template->the_message(); 582 582 } … … 587 587 function bp_get_the_thread_id() { 588 588 global $thread_template; 589 589 590 590 return apply_filters( 'bp_get_the_thread_id', $thread_template->thread->thread_id ); 591 591 } … … 605 605 function bp_get_the_thread_recipients() { 606 606 global $thread_template; 607 607 608 608 if ( count($thread_template->thread->recipients) >= 5 ) 609 609 return apply_filters( 'bp_get_the_thread_recipients', sprintf( __( '%d Recipients', 'buddypress' ), count($thread_template->thread->recipients) ) ); 610 610 611 611 foreach( $thread_template->thread->recipients as $recipient ) 612 612 $recipient_links[] = bp_core_get_userlink( $recipient ); … … 620 620 function bp_get_the_thread_message_alt_class() { 621 621 global $thread_template; 622 622 623 623 if ( $thread_template->current_message % 2 == 1 ) 624 624 $class = ' alt'; 625 625 else 626 626 $class = ''; 627 627 628 628 return apply_filters( 'bp_get_the_thread_message_alt_class', $class ); 629 629 } 630 630 631 631 function bp_the_thread_message_sender_avatar( $args = '' ) { 632 632 echo bp_get_the_thread_message_sender_avatar_thumb( $args ); 633 633 } 634 634 function bp_get_the_thread_message_sender_avatar_thumb( $args = '' ) { 635 global $thread_template; 636 635 global $thread_template; 636 637 637 $defaults = array( 638 638 'type' => 'thumb', … … 652 652 function bp_get_the_thread_message_sender_link() { 653 653 global $thread_template; 654 654 655 655 return apply_filters( 'bp_get_the_thread_message_sender_link', bp_core_get_userlink( $thread_template->message->sender_id, false, true ) ); 656 656 } 657 657 658 658 function bp_the_thread_message_sender_name() { 659 659 echo bp_get_the_thread_message_sender_name(); … … 661 661 function bp_get_the_thread_message_sender_name() { 662 662 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 ) ); 665 665 } 666 666 … … 670 670 function bp_get_the_thread_message_time_since() { 671 671 global $thread_template; 672 672 673 673 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 ) ) ) ); 674 674 } … … 679 679 function bp_get_the_thread_message_content() { 680 680 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 685 685 686 686 /*** DEPRECATED FUNCTIONS (DO NOT USE) **********************************************************/ 687 687 688 /* DEPRECATED - please use the view message template loop. */ 688 /* DEPRECATED - please use the view message template loop. */ 689 689 function messages_view_thread( $thread_id ) { 690 690 global $bp; 691 691 692 692 $thread = new BP_Messages_Thread( $thread_id, true ); 693 693 694 694 if ( !$thread->has_access ) { 695 695 unset($_GET['mode']); ?> … … 697 697 <p><?php _e( 'There was an error when viewing that message', 'buddypress' ) ?></p> 698 698 </div> 699 <?php 699 <?php 700 700 } else { 701 701 if ( $thread->messages ) { ?> 702 702 <?php $thread->mark_read() ?> 703 703 704 704 <div class="wrap"> 705 705 <h2 id="message-subject"><?php echo $thread->subject; ?></h2> … … 709 709 <td> 710 710 <img src="<?php echo $bp->messages->image_base ?>/email_open.gif" alt="Message" style="vertical-align: top;" /> 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) ?>. 713 713 </td> 714 714 </tr> 715 715 </tbody> 716 716 </table> 717 717 718 718 <?php 719 719 $counter = 0; 720 720 721 721 foreach ( $thread->messages as $message ) { 722 722 $alt = ( $counter % 2 == 1 ) ? ' alt' : ''; … … 729 729 <small><?php echo apply_filters( 'bp_get_message_date_sent', bp_format_time( strtotime($message->date_sent ) ) ) ?></small> 730 730 </div> 731 731 732 732 <?php do_action( 'messages_custom_fields_output_before' ) ?> 733 733 734 734 <?php echo apply_filters( 'bp_get_the_message_thread_content', stripslashes($message->message) ); ?> 735 735 736 736 <?php do_action( 'messages_custom_fields_output_after' ) ?> 737 737 738 738 <div class="clear"></div> 739 739 </div> … … 741 741 $counter++; 742 742 } 743 743 744 744 ?> 745 745 <form id="send-reply" action="<?php bp_messages_form_action() ?>" method="post"> … … 748 748 <div class="avatar-box"> 749 749 <?php echo bp_core_fetch_avatar( array( 'item_id' => $bp->loggedin_user->id, 'type' => 'thumb' ) ); ?> 750 750 751 751 <h3><?php _e("Reply: ", 'buddypress') ?></h3> 752 752 </div> … … 762 762 <input type="hidden" name="subject" id="subject" value="<?php _e('Re: ', 'buddypress'); echo str_replace( 'Re: ', '', $thread->last_message_subject); ?>" /> 763 763 </div> 764 764 765 765 <?php wp_nonce_field( 'messages_send_message', '_wpnonce_send_message' ) ?> 766 766 </form>
Note: See TracChangeset
for help on using the changeset viewer.