Changeset 1021 for trunk/bp-core/bp-core-classes.php
- Timestamp:
- 02/06/2009 03:07:48 AM (17 years ago)
- File:
-
- 1 edited
-
trunk/bp-core/bp-core-classes.php (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/bp-core-classes.php
r973 r1021 91 91 $this->total_friends .= ' ' . __( 'friends', 'buddypress' ); 92 92 93 $this->total_friends = '<a href="' . $this->user_url . $bp ['friends']['slug']. '" title="' . sprintf( __( "%s's friend list", 'buddypress' ), $this->fullname ) . '">' . $this->total_friends . '</a>';93 $this->total_friends = '<a href="' . $this->user_url . $bp->friends->slug . '" title="' . sprintf( __( "%s's friend list", 'buddypress' ), $this->fullname ) . '">' . $this->total_friends . '</a>'; 94 94 } 95 95 } … … 102 102 $this->total_blogs .= ' ' . __( 'blogs', 'buddypress' ); 103 103 104 $this->total_blogs = '<a href="' . $this->user_url . $bp ['blogs']['slug']. '" title="' . sprintf( __( "%s's blog list", 'buddypress' ), $this->fullname ) . '">' . $this->total_blogs . '</a>';104 $this->total_blogs = '<a href="' . $this->user_url . $bp->blogs->slug . '" title="' . sprintf( __( "%s's blog list", 'buddypress' ), $this->fullname ) . '">' . $this->total_blogs . '</a>'; 105 105 } 106 106 } … … 115 115 $this->total_groups .= ' ' . __( 'groups', 'buddypress' ); 116 116 117 $this->total_groups = '<a href="' . $this->user_url . $bp ['groups']['slug']. '" title="' . sprintf( __( "%s's group list", 'buddypress' ), $this->fullname ) . '">' . $this->total_groups . '</a>';117 $this->total_groups = '<a href="' . $this->user_url . $bp->groups->slug . '" title="' . sprintf( __( "%s's group list", 'buddypress' ), $this->fullname ) . '">' . $this->total_groups . '</a>'; 118 118 } 119 119 } … … 167 167 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); 168 168 169 $total_users = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(um.user_id) FROM {$wpdb->base_prefix}usermeta um LEFT JOIN {$wpdb->base_prefix}users u ON u.ID = um.user_id WHERE u.spam = 0 AND u.deleted = 0 AND u.user_status = 0 AND u.ID != %d ORDER BY RAND() DESC", $bp ['loggedin_userid']) );170 $paged_users = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT um.user_id FROM {$wpdb->base_prefix}usermeta um LEFT JOIN {$wpdb->base_prefix}users u ON u.ID = um.user_id WHERE u.spam = 0 AND u.deleted = 0 AND u.user_status = 0 AND u.ID != %d ORDER BY RAND(){$pag_sql}", $bp ['loggedin_userid']) );169 $total_users = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(um.user_id) FROM {$wpdb->base_prefix}usermeta um LEFT JOIN {$wpdb->base_prefix}users u ON u.ID = um.user_id WHERE u.spam = 0 AND u.deleted = 0 AND u.user_status = 0 AND u.ID != %d ORDER BY RAND() DESC", $bp->loggedin_user->id ) ); 170 $paged_users = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT um.user_id FROM {$wpdb->base_prefix}usermeta um LEFT JOIN {$wpdb->base_prefix}users u ON u.ID = um.user_id WHERE u.spam = 0 AND u.deleted = 0 AND u.user_status = 0 AND u.ID != %d ORDER BY RAND(){$pag_sql}", $bp->loggedin_user->id ) ); 171 171 172 172 return array( 'users' => $paged_users, 'total' => $total_users ); … … 181 181 $total_users = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(um.user_id) FROM {$wpdb->base_prefix}usermeta um LEFT JOIN {$wpdb->base_prefix}users u ON u.ID = um.user_id WHERE um.meta_key = 'last_activity' AND u.spam = 0 AND u.deleted = 0 AND u.user_status = 0 AND DATE_ADD( FROM_UNIXTIME(um.meta_value), INTERVAL 5 MINUTE ) >= NOW() ORDER BY FROM_UNIXTIME(um.meta_value) DESC" ) ); 182 182 $paged_users = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT um.user_id FROM {$wpdb->base_prefix}usermeta um LEFT JOIN {$wpdb->base_prefix}users u ON u.ID = um.user_id WHERE um.meta_key = 'last_activity' AND u.spam = 0 AND u.deleted = 0 AND u.user_status = 0 AND DATE_ADD( FROM_UNIXTIME(um.meta_value), INTERVAL 5 MINUTE ) >= NOW() ORDER BY FROM_UNIXTIME(um.meta_value) DESC{$pag_sql}" ) ); 183 183 184 184 return array( 'users' => $paged_users, 'total' => $total_users ); 185 185 } … … 199 199 like_escape($letter); 200 200 201 $total_users = count( $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT u.ID user_id FROM {$wpdb->base_prefix}users u LEFT JOIN {$bp['profile']['table_name_data']} pd ON u.ID = pd.user_id LEFT JOIN {$bp['profile']['table_name_fields']}pf ON pd.field_id = pf.id WHERE u.spam = 0 AND u.deleted = 0 AND u.user_status = 0 AND pf.name = %s AND pd.value LIKE '$letter%%' ORDER BY pd.value ASC", BP_XPROFILE_FULLNAME_FIELD_NAME ) ) );202 $paged_users = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT u.ID as user_id FROM {$wpdb->base_prefix}users u LEFT JOIN {$bp['profile']['table_name_data']} pd ON u.ID = pd.user_id LEFT JOIN {$bp['profile']['table_name_fields']}pf ON pd.field_id = pf.id WHERE u.spam = 0 AND u.deleted = 0 AND u.user_status = 0 AND pf.name = %s AND pd.value LIKE '$letter%%' ORDER BY pd.value ASC{$pag_sql}", BP_XPROFILE_FULLNAME_FIELD_NAME ) );201 $total_users = count( $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT u.ID user_id FROM {$wpdb->base_prefix}users u LEFT JOIN $bp->profile->table_name_data pd ON u.ID = pd.user_id LEFT JOIN $bp->profile->table_name_fields pf ON pd.field_id = pf.id WHERE u.spam = 0 AND u.deleted = 0 AND u.user_status = 0 AND pf.name = %s AND pd.value LIKE '$letter%%' ORDER BY pd.value ASC", BP_XPROFILE_FULLNAME_FIELD_NAME ) ) ); 202 $paged_users = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT u.ID as user_id FROM {$wpdb->base_prefix}users u LEFT JOIN $bp->profile->table_name_data pd ON u.ID = pd.user_id LEFT JOIN $bp->profile->table_name_fields pf ON pd.field_id = pf.id WHERE u.spam = 0 AND u.deleted = 0 AND u.user_status = 0 AND pf.name = %s AND pd.value LIKE '$letter%%' ORDER BY pd.value ASC{$pag_sql}", BP_XPROFILE_FULLNAME_FIELD_NAME ) ); 203 203 204 204 return array( 'users' => $paged_users, 'total' => $total_users ); … … 216 216 like_escape($search_terms); 217 217 218 $total_users = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(u.ID) as user_id FROM {$wpdb->base_prefix}users u LEFT JOIN {$bp['profile']['table_name_data']}pd ON u.ID = pd.user_id WHERE pd.value LIKE '%%$search_terms%%' ORDER BY pd.value ASC" ) );219 $paged_users = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT u.ID as user_id FROM {$wpdb->base_prefix}users u LEFT JOIN {$bp['profile']['table_name_data']}pd ON u.ID = pd.user_id WHERE pd.value LIKE '%%$search_terms%%' ORDER BY pd.value ASC{$pag_sql}" ) );218 $total_users = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(u.ID) as user_id FROM {$wpdb->base_prefix}users u LEFT JOIN $bp->profile->table_name_data pd ON u.ID = pd.user_id WHERE pd.value LIKE '%%$search_terms%%' ORDER BY pd.value ASC" ) ); 219 $paged_users = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT u.ID as user_id FROM {$wpdb->base_prefix}users u LEFT JOIN $bp->profile->table_name_data pd ON u.ID = pd.user_id WHERE pd.value LIKE '%%$search_terms%%' ORDER BY pd.value ASC{$pag_sql}" ) ); 220 220 221 221 return array( 'users' => $paged_users, 'total' => $total_users ); … … 251 251 global $wpdb, $bp; 252 252 253 if ( $notification = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM " . $bp['core']['table_name_notifications'] . "WHERE id = %d", $this->id ) ) ) {253 if ( $notification = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->core->table_name_notifications} WHERE id = %d", $this->id ) ) ) { 254 254 $this->item_id = $notification->item_id; 255 255 $this->secondary_item_id = $notification->secondary_item_id; … … 267 267 if ( $this->id ) { 268 268 // Update 269 $sql = $wpdb->prepare( "UPDATE " . $bp['core']['table_name_notifications'] . "SET item_id = %d, secondary_item_id = %d, user_id = %d, component_name = %s, component_action = %d, date_notified = FROM_UNIXTIME(%d), is_new = %d ) WHERE id = %d", $this->item_id, $this->secondary_item_id, $this->user_id, $this->component_name, $this->component_action, $this->date_notified, $this->is_new, $this->id );269 $sql = $wpdb->prepare( "UPDATE {$bp->core->table_name_notifications} SET item_id = %d, secondary_item_id = %d, user_id = %d, component_name = %s, component_action = %d, date_notified = FROM_UNIXTIME(%d), is_new = %d ) WHERE id = %d", $this->item_id, $this->secondary_item_id, $this->user_id, $this->component_name, $this->component_action, $this->date_notified, $this->is_new, $this->id ); 270 270 } else { 271 271 // Save 272 $sql = $wpdb->prepare( "INSERT INTO " . $bp['core']['table_name_notifications'] . "( item_id, secondary_item_id, user_id, component_name, component_action, date_notified, is_new ) VALUES ( %d, %d, %d, %s, %s, FROM_UNIXTIME(%d), %d )", $this->item_id, $this->secondary_item_id, $this->user_id, $this->component_name, $this->component_action, $this->date_notified, $this->is_new );272 $sql = $wpdb->prepare( "INSERT INTO {$bp->core->table_name_notifications} ( item_id, secondary_item_id, user_id, component_name, component_action, date_notified, is_new ) VALUES ( %d, %d, %d, %s, %s, FROM_UNIXTIME(%d), %d )", $this->item_id, $this->secondary_item_id, $this->user_id, $this->component_name, $this->component_action, $this->date_notified, $this->is_new ); 273 273 } 274 274 … … 285 285 global $wpdb, $bp; 286 286 287 return $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM " . $bp['core']['table_name_notifications'] . "WHERE id = %d AND user_id = %d", $notification_id, $user_id ) );287 return $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->core->table_name_notifications} WHERE id = %d AND user_id = %d", $notification_id, $user_id ) ); 288 288 } 289 289 290 290 function get_all_for_user( $user_id ) { 291 291 global $wpdb, $bp; 292 293 return $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . $bp['core']['table_name_notifications'] . "WHERE user_id = %d AND is_new = 1", $user_id ) );292 293 return $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->core->table_name_notifications} WHERE user_id = %d AND is_new = 1", $user_id ) ); 294 294 } 295 295 … … 297 297 global $wpdb, $bp; 298 298 299 return $wpdb->query( $wpdb->prepare( "DELETE FROM " . $bp['core']['table_name_notifications'] . "WHERE user_id = %d AND component_name = %s AND component_action = %s", $user_id, $component_name, $component_action ) );299 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->core->table_name_notifications} WHERE user_id = %d AND component_name = %s AND component_action = %s", $user_id, $component_name, $component_action ) ); 300 300 } 301 301 … … 306 306 $secondary_item_sql = $wpdb->prepare( " AND secondary_item_id = %d", $secondary_item_id ); 307 307 308 return $wpdb->query( $wpdb->prepare( "DELETE FROM " . $bp['core']['table_name_notifications'] . "WHERE user_id = %d AND item_id = %d AND component_name = %s AND component_action = %s{$secondary_item_sql}", $user_id, $item_id, $component_name, $component_action ) );308 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->core->table_name_notifications} WHERE user_id = %d AND item_id = %d AND component_name = %s AND component_action = %s{$secondary_item_sql}", $user_id, $item_id, $component_name, $component_action ) ); 309 309 } 310 310
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)