Skip to:
Content

BuddyPress.org

Changeset 2951


Ignore:
Timestamp:
04/24/2010 05:14:47 PM (11 years ago)
Author:
apeatling
Message:

User join filters.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity/bp-activity-classes.php

    r2946 r2951  
    131131        if ( $per_page && $page ) {
    132132            $pag_sql = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $per_page ), intval( $per_page ) );
    133             $activities = $wpdb->get_results( $wpdb->prepare( "{$select_sql} {$from_sql} {$where_sql} ORDER BY a.date_recorded {$sort} {$pag_sql}" ) );
     133            $activities = $wpdb->get_results( apply_filters( 'bp_activity_get_user_join_filter', $wpdb->prepare( "{$select_sql} {$from_sql} {$where_sql} ORDER BY a.date_recorded {$sort} {$pag_sql}", $select_sql, $from_sql, $where_sql, $sort, $pag_sql ) ) );
    134134        } else
    135             $activities = $wpdb->get_results( $wpdb->prepare( "{$select_sql} {$from_sql} {$where_sql} ORDER BY a.date_recorded {$sort} {$pag_sql}" ) );
     135            $activities = $wpdb->get_results( apply_filters( 'bp_activity_get_user_join_filter', $wpdb->prepare( "{$select_sql} {$from_sql} {$where_sql} ORDER BY a.date_recorded {$sort}", $select_sql, $from_sql, $where_sql, $sort ) ) );
    136136
    137137        $total_activities = $wpdb->get_var( $wpdb->prepare( "SELECT count(a.id) FROM {$bp->activity->table_name} a {$where_sql} ORDER BY a.date_recorded {$sort}" ) );
     
    367367
    368368            /* Retrieve all descendants of the $root node */
    369             $descendants = $wpdb->get_results( $wpdb->prepare( "SELECT a.*, u.user_email, u.user_nicename, u.user_login, u.display_name{$fullname_select} FROM {$bp->activity->table_name} a, {$wpdb->users} u{$fullname_from} WHERE u.ID = a.user_id {$fullname_where} AND a.type = 'activity_comment' AND a.item_id = %d AND a.mptt_left BETWEEN %d AND %d ORDER BY a.date_recorded ASC", $activity_id, $left, $right ) );
     369            $descendants = $wpdb->get_results( apply_filters( 'bp_activity_comments_user_join_filter', $wpdb->prepare( "SELECT a.*, u.user_email, u.user_nicename, u.user_login, u.display_name{$fullname_select} FROM {$bp->activity->table_name} a, {$wpdb->users} u{$fullname_from} WHERE u.ID = a.user_id {$fullname_where} AND a.type = 'activity_comment' AND a.item_id = %d AND a.mptt_left BETWEEN %d AND %d ORDER BY a.date_recorded ASC", $activity_id, $left, $right ), $activity_id, $left, $right ) );
    370370
    371371            /* Loop descendants and build an assoc array */
  • trunk/bp-core/bp-core-classes.php

    r2925 r2951  
    125125        $sql['from'] = "FROM " . CUSTOM_USER_TABLE . " u LEFT JOIN " . CUSTOM_USER_META_TABLE . " um ON um.user_id = u.ID";
    126126
    127         if ( $search_terms && bp_is_active( 'xprofile' ) || 'alphabetical' == $type )
    128             $sql['join_profiledata'] = "LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id";
    129 
    130127        $sql['where'] = 'WHERE ' . bp_core_get_status_sql( 'u.' );
    131128
     
    164161        }
    165162
    166         if ( $search_terms && bp_is_active( 'xprofile' ) ) {
     163        if ( $search_terms ) {
    167164            $search_terms = like_escape( $wpdb->escape( $search_terms ) );
    168             $sql['where_searchterms'] = "AND pd.value LIKE '%%$search_terms%%'";
     165            $sql['where_searchterms'] = "AND u.display_name LIKE '%%$search_terms%%'";
    169166        }
    170167
     
    177174                break;
    178175            case 'alphabetical':
    179                 $sql[] = "ORDER BY pd.value ASC";
     176                $sql[] = "ORDER BY u.display_name ASC";
    180177                break;
    181178            case 'random':
  • trunk/bp-groups/bp-groups-classes.php

    r2946 r2951  
    3838
    3939            /* Get group admins and mods */
    40             $admin_mods = $wpdb->get_results( $wpdb->prepare( "SELECT u.ID as user_id, u.user_login, u.user_email, u.user_nicename, m.is_admin, m.is_mod FROM {$wpdb->users} u, {$bp->groups->table_name_members} m WHERE u.ID = m.user_id AND m.group_id = %d AND ( m.is_admin = 1 OR m.is_mod = 1 )", $this->id ) );
     40            $admin_mods = $wpdb->get_results( apply_filters( 'bp_group_admin_mods_user_join_filter', $wpdb->prepare( "SELECT u.ID as user_id, u.user_login, u.user_email, u.user_nicename, m.is_admin, m.is_mod FROM {$wpdb->users} u, {$bp->groups->table_name_members} m WHERE u.ID = m.user_id AND m.group_id = %d AND ( m.is_admin = 1 OR m.is_mod = 1 )", $this->id ), $this->id ) );
    4141            foreach( (array)$admin_mods as $user ) {
    4242                if ( (int)$user->is_admin )
Note: See TracChangeset for help on using the changeset viewer.