Skip to:
Content

BuddyPress.org

Ticket #6935: 6935.4.patch

File 6935.4.patch, 3.1 KB (added by imath, 8 years ago)
  • src/bp-messages/bp-messages-cssjs.php

    diff --git src/bp-messages/bp-messages-cssjs.php src/bp-messages/bp-messages-cssjs.php
    index 33cdf16..8a2359a 100644
    function messages_autocomplete_init_jsblock() { 
    6868                                var users = document.getElementById('send-to-usernames').className;
    6969                                document.getElementById('send-to-usernames').value = String(users);
    7070                        });
     71
     72                        /**
     73                         * This part is a temporary fix to make sure the recipient added using PHP is not a li nested
     74                         * in another li and is displayed like autocomplete results. It preserves back compat with
     75                         * themes overriding the Messages compose screen template.
     76                         *
     77                         * The right fix would be to put the <?php bp_message_get_recipient_tabs(); ?> before the li
     78                         * in bp-templates/bp-legacy/buddypress/members/single/messages/compose.php.
     79                         *
     80                         * @see https://buddypress.trac.wordpress.org/ticket/6935
     81                         */
     82                        var move = [];
     83
     84                        jQuery( 'ul.first.acfb-holder li' ).each( function( i, element ) {
     85                                if ( jQuery( element ).hasClass( 'friend-tab' ) ) {
     86                                        move.push( jQuery( element ) );
     87                                }
     88                        } );
     89
     90                        if ( move.length > 0 ) {
     91                                var first = jQuery( 'ul.first.acfb-holder li' ).first();
     92
     93                                first.html( jQuery( '#send-to-input' ) );
     94                                jQuery.each( move, function( i, m ) {
     95                                        first.before( m );
     96                                } );
     97                        }
    7198                });
    7299        </script>
    73100
  • src/bp-messages/bp-messages-template.php

    diff --git src/bp-messages/bp-messages-template.php src/bp-messages/bp-messages-template.php
    index b5b7f8e..a765842 100644
    function bp_message_get_recipient_tabs() { 
    13801380                if ( ! empty( $user_id ) ) : ?>
    13811381
    13821382                        <li id="un-<?php echo esc_attr( $recipient ); ?>" class="friend-tab">
    1383                                 <span><?php
    1384                                         echo bp_core_fetch_avatar( array( 'item_id' => $user_id, 'type' => 'thumb', 'width' => 15, 'height' => 15 ) );
    1385                                         echo bp_core_get_userlink( $user_id );
    1386                                 ?></span>
     1383                                <span>
     1384                                        <?php printf( '<a href="%1$s">%2$s &nbsp; %3$s</a>',
     1385                                                esc_url( bp_core_get_user_domain( $user_id ) ),
     1386                                                bp_core_fetch_avatar( array( 'item_id' => $user_id, 'type' => 'thumb', 'width' => 15, 'height' => 15, 'class' => '' ) ),
     1387                                                esc_html( bp_core_get_user_displayname( $user_id ) )
     1388                                        ); ?>
     1389                                </span>
    13871390                        </li>
    13881391
    13891392                <?php endif;
  • src/bp-messages/js/autocomplete/jquery.autocompletefb.js

    diff --git src/bp-messages/js/autocomplete/jquery.autocompletefb.js src/bp-messages/js/autocomplete/jquery.autocompletefb.js
    index a63386e..4b6a321 100644
    jQuery.fn.autoCompletefb = function(options) 
    5353                var un = d[1].substr(0, d[1].length-1);
    5454
    5555                /* Don't add the same user multiple times */
    56                 if( 0 === jQuery(settings.inputClass).siblings('#un-' + un).length ) {
     56                if( 0 === jQuery( settings.inputClass ).closest( 'ul' ).find( '#un-' + un ).length ) {
    5757                        var ln = '#link-' + un;
    5858                        var l = jQuery(ln).attr('href');
    5959                        var v = '<li class="'+f+'" id="un-'+un+'"><span><a href="'+l+'">'+d[0]+'</a></span> <span class="p">X</span></li>';