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 71f6e520c..b5b9cb4e4 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 d833f3573..c92e26122 100644
|
|
|
function bp_nouveau_ajax_get_user_message_threads() { |
| 214 | 214 | ) ); |
| 215 | 215 | } |
| 216 | 216 | |
| 217 | | if ( isset( $_POST['box'] ) && 'starred' === $_POST['box'] ) { |
| 218 | | $star_filter = true; |
| | 217 | $bp = buddypress(); |
| | 218 | $reset_action = $bp->current_action; |
| 219 | 219 | |
| 220 | | // Add the message thread filter. |
| | 220 | // Override bp_current_action(). |
| | 221 | if ( isset( $_POST['box'] ) ) { |
| | 222 | $bp->current_action = $_POST['box']; |
| | 223 | } |
| | 224 | |
| | 225 | // Add the message thread filter. |
| | 226 | if ( 'starred' === $bp->current_action ) { |
| 221 | 227 | add_filter( 'bp_after_has_message_threads_parse_args', 'bp_messages_filter_starred_message_threads' ); |
| 222 | 228 | } |
| 223 | 229 | |
| 224 | 230 | // Simulate the loop. |
| 225 | 231 | if ( ! bp_has_message_threads( bp_ajax_querystring( 'messages' ) ) ) { |
| | 232 | // Remove the bp_current_action() override. |
| | 233 | $bp->current_action = $reset_action; |
| | 234 | |
| 226 | 235 | wp_send_json_error( array( |
| 227 | 236 | 'feedback' => __( 'Sorry, no messages were found.', 'buddypress' ), |
| 228 | 237 | 'type' => 'info' |
| 229 | 238 | ) ); |
| 230 | 239 | } |
| 231 | 240 | |
| 232 | | if ( ! empty( $star_filter ) ) { |
| 233 | | // remove the message thread filter. |
| | 241 | // remove the message thread filter. |
| | 242 | if ( 'starred' === $bp->current_action ) { |
| 234 | 243 | remove_filter( 'bp_after_has_message_threads_parse_args', 'bp_messages_filter_starred_message_threads' ); |
| 235 | 244 | } |
| 236 | 245 | |
| … |
… |
function bp_nouveau_ajax_get_user_message_threads() { |
| 310 | 319 | |
| 311 | 320 | $threads->threads = array_filter( $threads->threads ); |
| 312 | 321 | |
| | 322 | $extra_content = bp_nouveau_messages_catch_hook_content( array( |
| | 323 | 'beforeContent' => 'bp_before_member_messages_loop', |
| | 324 | 'afterContent' => 'bp_after_member_messages_loop', |
| | 325 | ) ); |
| | 326 | |
| | 327 | if ( array_filter( $extra_content ) ) { |
| | 328 | $threads->extraContent = $extra_content; |
| | 329 | } |
| | 330 | |
| | 331 | // Remove the bp_current_action() override. |
| | 332 | $bp->current_action = $reset_action; |
| | 333 | |
| | 334 | // Return the successfull reply. |
| 313 | 335 | wp_send_json_success( $threads ); |
| 314 | 336 | } |
| 315 | 337 | |
diff --git src/bp-templates/bp-nouveau/js/buddypress-messages.js src/bp-templates/bp-nouveau/js/buddypress-messages.js
index 7c1ad32d4..d76451283 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 | 'beforeContent', |
| | 357 | 'afterContent' |
| | 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 | className: 'bp-messages-hook', |
| | 477 | template : bp.template( 'bp-messages-hook' ), |
| | 478 | |
| | 479 | initialize: function() { |
| | 480 | this.model = new Backbone.Model( { |
| | 481 | extraContent: this.options.extraContent |
| | 482 | } ); |
| | 483 | } |
| | 484 | } ); |
| | 485 | |
| 466 | 486 | bp.Views.messageEditor = bp.Nouveau.Messages.View.extend( { |
| 467 | 487 | template : bp.template( 'bp-messages-editor' ), |
| 468 | 488 | |
| … |
… |
window.bp = window.bp || {}; |
| 639 | 659 | }, |
| 640 | 660 | |
| 641 | 661 | 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' } ) ); |
| | 662 | var Views = [ |
| | 663 | new bp.Nouveau.Messages.View( { tagName: 'ul', id: 'message-threads', className: 'message-lists' } ), |
| | 664 | new bp.Views.previewThread( { collection: this.collection } ) |
| | 665 | ]; |
| 644 | 666 | |
| 645 | | // Add the preview Active Thread view |
| 646 | | this.views.add( new bp.Views.previewThread( { collection: this.collection } ) ); |
| | 667 | _.each( Views, function( view ) { |
| | 668 | this.views.add( view ); |
| | 669 | }, this ); |
| 647 | 670 | |
| 648 | 671 | // Load threads for the active view |
| 649 | 672 | this.requestThreads(); |
| … |
… |
window.bp = window.bp || {}; |
| 659 | 682 | |
| 660 | 683 | this.collection.fetch( { |
| 661 | 684 | data : _.pick( this.options, 'box' ), |
| 662 | | success : this.threadsFetched, |
| | 685 | success : _.bind( this.threadsFetched, this ), |
| 663 | 686 | error : this.threadsFetchError |
| 664 | 687 | } ); |
| 665 | 688 | }, |
| … |
… |
window.bp = window.bp || {}; |
| 667 | 690 | threadsFetched: function() { |
| 668 | 691 | bp.Nouveau.Messages.removeFeedback(); |
| 669 | 692 | |
| | 693 | // Display the bp_before_member_messages_loop hook. |
| | 694 | if ( this.collection.options.afterContent ) { |
| | 695 | this.views.add( new bp.Views.Hook( { extraContent: this.collection.options.afterContent } ), { at: 1 } ); |
| | 696 | } |
| | 697 | |
| | 698 | // Display the bp_after_member_messages_loop hook. |
| | 699 | if ( this.collection.options.beforeContent ) { |
| | 700 | this.views.add( new bp.Views.Hook( { extraContent: this.collection.options.beforeContent } ), { at: 0 } ); |
| | 701 | } |
| | 702 | |
| 670 | 703 | // Inform the user about how to use the UI. |
| 671 | 704 | bp.Nouveau.Messages.displayFeedback( BP_Nouveau.messages.howto, 'info' ); |
| 672 | 705 | }, |