Skip to:
Content

BuddyPress.org

Changeset 9276


Ignore:
Timestamp:
12/24/2014 08:09:13 PM (10 years ago)
Author:
djpaul
Message:

Groups, Suggestions: add support for @mentions UI in Group Activity screens.

This is achieved by adding support for a new data-suggestions-group-id property to the relevant textarea/input element.
See also r9242:9245 for incremental changes that support this new functionality.

Fixes #5934. Props m@rk, imath, DJPaul.

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-activity/bp-activity-actions.php

    r9194 r9276  
    754754    }
    755755
    756     $results = bp_core_get_suggestions( array(
     756    $args = array(
    757757        'term' => sanitize_text_field( $_GET['term'] ),
    758758        'type' => sanitize_text_field( $_GET['type'] ),
    759     ) );
     759    );
     760
     761    // Support per-Group suggestions.
     762    if ( ! empty( $_GET['group-id'] ) ) {
     763        $args['group_id'] = absint( $_GET['group-id'] );
     764    }
     765
     766    $results = bp_core_get_suggestions( $args );
    760767
    761768    if ( is_wp_error( $results ) ) {
  • trunk/src/bp-activity/js/mentions.js

    r9100 r9276  
    152152                 */
    153153                remote_filter: function( query, render_view ) {
    154                     var self = $( this );
     154                    var self = $( this ),
     155                        params = {};
    155156
    156157                    mentionsItem = mentionsQueryCache[ query ];
     
    164165                    }
    165166
    166                     self.xhr = $.getJSON( ajaxurl, { 'action': 'bp_get_suggestions', 'term': query, 'type': 'members' } )
     167                    params = { 'action': 'bp_get_suggestions', 'term': query, 'type': 'members' };
     168
     169                    if ( $.isNumeric( this.$inputor.data( 'suggestions-group-id' ) ) ) {
     170                        params['group-id'] = parseInt( this.$inputor.data( 'suggestions-group-id' ), 10 );
     171                    }
     172
     173                    self.xhr = $.getJSON( ajaxurl, params )
    167174                        /**
    168175                         * Success callback for the @suggestions lookup.
  • trunk/src/bp-groups/bp-groups-filters.php

    r9026 r9276  
    234234}
    235235add_filter( 'get_latest_topics_fields', 'groups_filter_forums_root_page_sql' );
     236
     237/**
     238 * Should BuddyPress load the mentions scripts and related assets, including results to prime the
     239 * mentions suggestions?
     240 *
     241 * @param bool $load_mentions True to load mentions assets, false otherwise.
     242 * @param bool $mentions_enabled True if mentions are enabled.
     243 * @return bool True if mentions scripts should be loaded.
     244 * @since BuddyPress (2.2.0)
     245 */
     246function bp_groups_maybe_load_mentions_scripts( $load_mentions, $mentions_enabled ) {
     247    if ( ! $mentions_enabled ) {
     248        return $load_mentions;
     249    }
     250
     251    if ( $load_mentions || ( bp_is_group_activity() || bp_is_group_home() ) ) {
     252        return true;
     253    }
     254
     255    return $load_mentions;
     256}
     257add_filter( 'bp_activity_maybe_load_mentions_scripts', 'bp_groups_maybe_load_mentions_scripts', 10, 2 );
  • trunk/src/bp-templates/bp-legacy/buddypress/activity/post-form.php

    r8754 r9276  
    2828    <div id="whats-new-content">
    2929        <div id="whats-new-textarea">
    30             <textarea class="bp-suggestions" name="whats-new" id="whats-new" cols="50" rows="10"><?php if ( isset( $_GET['r'] ) ) : ?>@<?php echo esc_textarea( $_GET['r'] ); ?> <?php endif; ?></textarea>
     30            <textarea class="bp-suggestions" name="whats-new" id="whats-new" cols="50" rows="10"
     31            <?php
     32            if ( bp_is_group() ) : ?>data-suggestions-group-id="<?php echo esc_attr( (int) bp_get_current_group_id() ); ?>" <?php endif;
     33            if ( isset( $_GET['r'] ) ) : ?>@<?php echo esc_textarea( $_GET['r'] ); ?> <?php endif;
     34            ?>
     35            ></textarea>
    3136        </div>
    3237
Note: See TracChangeset for help on using the changeset viewer.