Changeset 1356
- Timestamp:
- 04/20/2009 10:56:00 AM (15 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-friends/bp-friends-classes.php
r1351 r1356 142 142 global $wpdb, $bp; 143 143 144 // TODO: Optimize this function. 145 144 146 if ( !$user_id ) 145 147 $user_id = $bp->loggedin_user->id; 146 148 147 149 like_escape($filter); 148 $usermeta_table = $wpdb->prefix . 'usermeta';149 150 150 151 if ( $limit && $page ) … … 156 157 // Get all the user ids for the current user's friends. 157 158 $fids = implode( ',', $friend_ids ); 159 160 if ( empty($fids) ) 161 return false; 158 162 159 163 // filter the user_ids based on the search criteria. 160 164 if ( function_exists('xprofile_install') ) { 161 $sql = $wpdb->prepare( "SELECT DISTINCT user_id FROM {$bp->profile->table_name_data} WHERE user_id IN ($fids) AND value LIKE '$filter%%' " );162 } else {163 $sql = $wpdb->prepare( "SELECT DISTINCT user_id FROM $usermeta_table WHERE user_id IN ($fids) AND meta_key = 'nickname' AND meta_value LIKE '$filter%%'" );164 }165 166 $filtered_friends = $wpdb->get_results( $sql, ARRAY_A );167 168 if ( !$filtered_friends )169 return false;170 171 // Get the total number of friendships172 $total_friends = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->friends->table_name} WHERE (friend_user_id IN ($filtered_fids) AND initiator_user_id = %d) OR (initiator_user_id IN ($filtered_fids) AND friend_user_id = %d)", $user_id, $user_id ) );173 174 return array( 'friends' => $filtered_friend s, 'total' => $total_friends );175 } 176 165 $sql = $wpdb->prepare( "SELECT DISTINCT user_id FROM {$bp->profile->table_name_data} WHERE user_id IN ($fids) AND value LIKE '$filter%%' {$pag_sql}" ); 166 $total_sql = $wpdb->prepare( "SELECT DISTINCT count(user_id) FROM {$bp->profile->table_name_data} WHERE user_id IN ($fids) AND value LIKE '$filter%%'" ); 167 } else { 168 $sql = $wpdb->prepare( "SELECT DISTINCT user_id FROM " . CUSTOM_USER_META_TABLE . " WHERE user_id IN ($fids) AND meta_key = 'nickname' AND meta_value LIKE '$filter%%' {$pag_sql}" ); 169 $total_sql = $wpdb->prepare( "SELECT DISTINCT count(user_id) FROM " . CUSTOM_USER_META_TABLE . " WHERE user_id IN ($fids) AND meta_key = 'nickname' AND meta_value LIKE '$filter%%'" ); 170 } 171 172 $filtered_friend_ids = $wpdb->get_results($sql); 173 $total_friend_ids = $wpdb->get_var($sql); 174 175 if ( !$filtered_friend_ids ) 176 return false; 177 178 return array( 'friends' => $filtered_friend_ids, 'total' => (int)$total_friend_ids ); 179 } 180 177 181 function check_is_friend( $loggedin_userid, $possible_friend_userid ) { 178 182 global $wpdb, $bp; -
trunk/bp-friends/bp-friends-templatetags.php
r1238 r1356 101 101 $this->in_the_loop = true; 102 102 $this->friendship = $this->next_friendship(); 103 103 104 104 if ( 'requests' == $bp->current_action ) { 105 105 $this->friendship = new BP_Friends_Friendship( $this->friendship ); 106 $this->friendship->user_id = ( $this->friendship->friend_user_id == $bp->loggedin_user->id ) ? $this->friendship->initiator_user_id : $this->friendship->friend_user_id; 106 107 } else { 107 108 $this->friendship = (object) $this->friendship; 108 109 109 110 if ( !$this->friendship->friend = wp_cache_get( 'bp_user_' . $this->friendship->user_id, 'bp' ) ) { 110 111 $this->friendship->friend = new BP_Core_User( $this->friendship->user_id ); … … 112 113 } 113 114 } 114 115 115 116 if ( 0 == $this->current_friendship ) // loop has just started 116 117 do_action('loop_start'); … … 263 264 </form> 264 265 <?php 266 } 267 268 function bp_friends_is_filtered() { 269 if ( isset( $_POST['friend-search-box'] ) ) 270 return true; 271 272 return false; 265 273 } 266 274 -
trunk/bp-themes/buddypress-member/friends/friends-loop.php
r1052 r1356 24 24 <?php else: ?> 25 25 26 <div id="message" class="info"> 27 <p><?php bp_word_or_name( __( "Your friends list is currently empty", 'buddypress' ), __( "%s's friends list is currently empty", 'buddypress' ) ) ?></p> 28 </div> 26 <?php if ( bp_friends_is_filtered() ) : ?> 27 <div id="message" class="info"> 28 <p><?php _e( "No friends matched your search filter terms", 'buddypress' ) ?></p> 29 </div> 30 <?php else : ?> 31 <div id="message" class="info"> 32 <p><?php bp_word_or_name( __( "Your friends list is currently empty", 'buddypress' ), __( "%s's friends list is currently empty", 'buddypress' ) ) ?></p> 33 </div> 34 <?php endif; ?> 29 35 30 <?php if ( bp_is_home() ) : ?>36 <?php if ( bp_is_home() && !bp_friends_is_filtered() ) : ?> 31 37 <h3><?php _e( 'Why not make friends with some of these members?', 'buddypress' ) ?></h3> 32 38 <?php bp_friends_random_members() ?>
Note: See TracChangeset
for help on using the changeset viewer.