Skip to:
Content

BuddyPress.org

Ticket #7850: 7850.patch

File 7850.patch, 5.4 KB (added by imath, 8 years ago)
  • src/bp-templates/bp-nouveau/buddypress/common/js-templates/messages/index.php

    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
     
    2121        </div>
    2222</script>
    2323
     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
    2433<script type="text/html" id="tmpl-bp-messages-form">
    2534        <?php bp_nouveau_messages_hook( 'before', 'compose_content' ); ?>
    2635
  • src/bp-templates/bp-nouveau/includes/messages/ajax.php

    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() { 
    214214                ) );
    215215        }
    216216
    217         if ( isset( $_POST['box'] ) && 'starred' === $_POST['box'] ) {
    218                 $star_filter = true;
     217        $bp           = buddypress();
     218        $reset_action = $bp->current_action;
    219219
    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 ) {
    221227                add_filter( 'bp_after_has_message_threads_parse_args', 'bp_messages_filter_starred_message_threads' );
    222228        }
    223229
    224230        // Simulate the loop.
    225231        if ( ! bp_has_message_threads( bp_ajax_querystring( 'messages' ) ) ) {
     232                // Remove the bp_current_action() override.
     233                $bp->current_action = $reset_action;
     234
    226235                wp_send_json_error( array(
    227236                        'feedback' => __( 'Sorry, no messages were found.', 'buddypress' ),
    228237                        'type'     => 'info'
    229238                ) );
    230239        }
    231240
    232         if ( ! empty( $star_filter ) ) {
    233                 // remove the message thread filter.
     241        // remove the message thread filter.
     242        if ( 'starred' === $bp->current_action ) {
    234243                remove_filter( 'bp_after_has_message_threads_parse_args', 'bp_messages_filter_starred_message_threads' );
    235244        }
    236245
    function bp_nouveau_ajax_get_user_message_threads() { 
    310319
    311320        $threads->threads = array_filter( $threads->threads );
    312321
     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.
    313335        wp_send_json_success( $threads );
    314336}
    315337
  • src/bp-templates/bp-nouveau/js/buddypress-messages.js

    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 || {}; 
    351351                                this.options.box = bp.Nouveau.Messages.box;
    352352                        }
    353353
     354                        if ( ! _.isUndefined( resp.extraContent ) ) {
     355                                _.extend( this.options, _.pick( resp.extraContent, [
     356                                        'beforeContent',
     357                                        'afterContent'
     358                                ] ) );
     359                        }
     360
    354361                        return resp.threads;
    355362                },
    356363
    window.bp = window.bp || {}; 
    463470                }
    464471        } );
    465472
     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
    466486        bp.Views.messageEditor = bp.Nouveau.Messages.View.extend( {
    467487                template  : bp.template( 'bp-messages-editor' ),
    468488
    window.bp = window.bp || {}; 
    639659                },
    640660
    641661                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                        ];
    644666
    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 );
    647670
    648671                        // Load threads for the active view
    649672                        this.requestThreads();
    window.bp = window.bp || {}; 
    659682
    660683                        this.collection.fetch( {
    661684                                data    : _.pick( this.options, 'box' ),
    662                                 success : this.threadsFetched,
     685                                success : _.bind( this.threadsFetched, this ),
    663686                                error   : this.threadsFetchError
    664687                        } );
    665688                },
    window.bp = window.bp || {}; 
    667690                threadsFetched: function() {
    668691                        bp.Nouveau.Messages.removeFeedback();
    669692
     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
    670703                        // Inform the user about how to use the UI.
    671704                        bp.Nouveau.Messages.displayFeedback( BP_Nouveau.messages.howto, 'info' );
    672705                },