diff --git src/bp-templates/bp-nouveau/buddypress/common/js-templates/messages/index.php src/bp-templates/bp-nouveau/buddypress/common/js-templates/messages/index.php
index 34844c983..3e1e5dfe1 100644
|
|
|
|
| 21 | 21 | </div> |
| 22 | 22 | </script> |
| 23 | 23 | |
| | 24 | <?php |
| | 25 | /** |
| | 26 | * This view is used to inject hooks buffer |
| | 27 | */ |
| | 28 | ?> |
| | 29 | <script type="text/html" id="tmpl-bp-messages-hook"> |
| | 30 | {{{data.extraContent}}} |
| | 31 | </script> |
| | 32 | |
| 24 | 33 | <script type="text/html" id="tmpl-bp-messages-form"> |
| 25 | 34 | <?php bp_nouveau_messages_hook( 'before', 'compose_content' ); ?> |
| 26 | 35 | |
diff --git src/bp-templates/bp-nouveau/includes/messages/ajax.php src/bp-templates/bp-nouveau/includes/messages/ajax.php
index f49175016..98d5bc287 100644
|
|
|
function bp_nouveau_ajax_get_user_message_threads() { |
| 223 | 223 | ) ); |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | | if ( isset( $_POST['box'] ) && 'starred' === $_POST['box'] ) { |
| 227 | | $star_filter = true; |
| | 226 | $bp = buddypress(); |
| | 227 | $reset_action = $bp->current_action; |
| | 228 | |
| | 229 | // Override bp_current_action(). |
| | 230 | if ( isset( $_POST['box'] ) ) { |
| | 231 | $bp->current_action = $_POST['box']; |
| | 232 | } |
| 228 | 233 | |
| 229 | | // Add the message thread filter. |
| | 234 | // Add the message thread filter. |
| | 235 | if ( 'starred' === $bp->current_action ) { |
| 230 | 236 | add_filter( 'bp_after_has_message_threads_parse_args', 'bp_messages_filter_starred_message_threads' ); |
| 231 | 237 | } |
| 232 | 238 | |
| 233 | 239 | // Simulate the loop. |
| 234 | 240 | if ( ! bp_has_message_threads( bp_ajax_querystring( 'messages' ) ) ) { |
| | 241 | // Remove the bp_current_action() override. |
| | 242 | $bp->current_action = $reset_action; |
| | 243 | |
| 235 | 244 | wp_send_json_error( array( |
| 236 | 245 | 'feedback' => __( 'Sorry, no messages were found.', 'buddypress' ), |
| 237 | 246 | 'type' => 'info' |
| 238 | 247 | ) ); |
| 239 | 248 | } |
| 240 | 249 | |
| 241 | | if ( ! empty( $star_filter ) ) { |
| 242 | | // remove the message thread filter. |
| | 250 | // remove the message thread filter. |
| | 251 | if ( 'starred' === $bp->current_action ) { |
| 243 | 252 | remove_filter( 'bp_after_has_message_threads_parse_args', 'bp_messages_filter_starred_message_threads' ); |
| 244 | 253 | } |
| 245 | 254 | |
| … |
… |
function bp_nouveau_ajax_get_user_message_threads() { |
| 319 | 328 | |
| 320 | 329 | $threads->threads = array_filter( $threads->threads ); |
| 321 | 330 | |
| | 331 | $extra_content = bp_nouveau_messages_catch_hook_content( array( |
| | 332 | 'beforeLoop' => 'bp_before_member_messages_loop', |
| | 333 | 'afterLoop' => 'bp_after_member_messages_loop', |
| | 334 | ) ); |
| | 335 | |
| | 336 | if ( array_filter( $extra_content ) ) { |
| | 337 | $threads->extraContent = $extra_content; |
| | 338 | } |
| | 339 | |
| | 340 | // Remove the bp_current_action() override. |
| | 341 | $bp->current_action = $reset_action; |
| | 342 | |
| | 343 | // Return the successfull reply. |
| 322 | 344 | wp_send_json_success( $threads ); |
| 323 | 345 | } |
| 324 | 346 | |
diff --git src/bp-templates/bp-nouveau/js/buddypress-messages.js src/bp-templates/bp-nouveau/js/buddypress-messages.js
index 7c1ad32d4..171883d25 100644
|
|
|
window.bp = window.bp || {}; |
| 351 | 351 | this.options.box = bp.Nouveau.Messages.box; |
| 352 | 352 | } |
| 353 | 353 | |
| | 354 | if ( ! _.isUndefined( resp.extraContent ) ) { |
| | 355 | _.extend( this.options, _.pick( resp.extraContent, [ |
| | 356 | 'beforeLoop', |
| | 357 | 'afterLoop' |
| | 358 | ] ) ); |
| | 359 | } |
| | 360 | |
| 354 | 361 | return resp.threads; |
| 355 | 362 | }, |
| 356 | 363 | |
| … |
… |
window.bp = window.bp || {}; |
| 463 | 470 | } |
| 464 | 471 | } ); |
| 465 | 472 | |
| | 473 | // Feedback view |
| | 474 | bp.Views.Hook = bp.Nouveau.Messages.View.extend( { |
| | 475 | tagName: 'div', |
| | 476 | template : bp.template( 'bp-messages-hook' ), |
| | 477 | |
| | 478 | initialize: function() { |
| | 479 | this.model = new Backbone.Model( { |
| | 480 | extraContent: this.options.extraContent |
| | 481 | } ); |
| | 482 | |
| | 483 | this.el.className = 'bp-messages-hook'; |
| | 484 | |
| | 485 | if ( this.options.className ) { |
| | 486 | this.el.className += ' ' + this.options.className; |
| | 487 | } |
| | 488 | } |
| | 489 | } ); |
| | 490 | |
| 466 | 491 | bp.Views.messageEditor = bp.Nouveau.Messages.View.extend( { |
| 467 | 492 | template : bp.template( 'bp-messages-editor' ), |
| 468 | 493 | |
| … |
… |
window.bp = window.bp || {}; |
| 639 | 664 | }, |
| 640 | 665 | |
| 641 | 666 | initialize: function() { |
| 642 | | // Add the threads parent view |
| 643 | | this.views.add( new bp.Nouveau.Messages.View( { tagName: 'ul', id: 'message-threads', className: 'message-lists' } ) ); |
| | 667 | var Views = [ |
| | 668 | new bp.Nouveau.Messages.View( { tagName: 'ul', id: 'message-threads', className: 'message-lists' } ), |
| | 669 | new bp.Views.previewThread( { collection: this.collection } ) |
| | 670 | ]; |
| 644 | 671 | |
| 645 | | // Add the preview Active Thread view |
| 646 | | this.views.add( new bp.Views.previewThread( { collection: this.collection } ) ); |
| | 672 | _.each( Views, function( view ) { |
| | 673 | this.views.add( view ); |
| | 674 | }, this ); |
| 647 | 675 | |
| 648 | 676 | // Load threads for the active view |
| 649 | 677 | this.requestThreads(); |
| … |
… |
window.bp = window.bp || {}; |
| 659 | 687 | |
| 660 | 688 | this.collection.fetch( { |
| 661 | 689 | data : _.pick( this.options, 'box' ), |
| 662 | | success : this.threadsFetched, |
| | 690 | success : _.bind( this.threadsFetched, this ), |
| 663 | 691 | error : this.threadsFetchError |
| 664 | 692 | } ); |
| 665 | 693 | }, |
| … |
… |
window.bp = window.bp || {}; |
| 667 | 695 | threadsFetched: function() { |
| 668 | 696 | bp.Nouveau.Messages.removeFeedback(); |
| 669 | 697 | |
| | 698 | // Display the bp_after_member_messages_loop hook. |
| | 699 | if ( this.collection.options.afterLoop ) { |
| | 700 | this.views.add( new bp.Views.Hook( { extraContent: this.collection.options.afterLoop, className: 'after-messages-loop' } ), { at: 1 } ); |
| | 701 | } |
| | 702 | |
| | 703 | // Display the bp_before_member_messages_loop hook. |
| | 704 | if ( this.collection.options.beforeLoop ) { |
| | 705 | this.views.add( new bp.Views.Hook( { extraContent: this.collection.options.beforeLoop, className: 'before-messages-loop' } ), { at: 0 } ); |
| | 706 | } |
| | 707 | |
| 670 | 708 | // Inform the user about how to use the UI. |
| 671 | 709 | bp.Nouveau.Messages.displayFeedback( BP_Nouveau.messages.howto, 'info' ); |
| 672 | 710 | }, |