Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/06/2009 03:07:48 AM (17 years ago)
Author:
apeatling
Message:

Converted $bp as an array to $bp as an object. See this post for more info: http://buddypress.org/forums/topic.php?id=1125

File:
1 edited

Legend:

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

    r973 r1021  
    9191                                        $this->total_friends .= ' ' . __( 'friends', 'buddypress' );
    9292                       
    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>';
    9494                        }
    9595                }
     
    102102                                        $this->total_blogs .= ' ' . __( 'blogs', 'buddypress' );                       
    103103                               
    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>';
    105105                        }
    106106                }
     
    115115                                        $this->total_groups .= ' ' . __( 'groups', 'buddypress' );
    116116
    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>';
    118118                        }
    119119                }
     
    167167                        $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
    168168
    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 ) );
    171171               
    172172                return array( 'users' => $paged_users, 'total' => $total_users );
     
    181181                $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" ) );
    182182                $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
    184184                return array( 'users' => $paged_users, 'total' => $total_users );
    185185        }
     
    199199                like_escape($letter);
    200200
    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 ) );
    203203               
    204204                return array( 'users' => $paged_users, 'total' => $total_users );
     
    216216                like_escape($search_terms);     
    217217
    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}" ) );
    220220               
    221221                return array( 'users' => $paged_users, 'total' => $total_users );
     
    251251                global $wpdb, $bp;
    252252               
    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 ) ) ) {
    254254                        $this->item_id = $notification->item_id;
    255255                        $this->secondary_item_id = $notification->secondary_item_id;
     
    267267                if ( $this->id ) {
    268268                        // 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 );
    270270                } else {
    271271                        // 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 );
    273273                }
    274274
     
    285285                global $wpdb, $bp;
    286286               
    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 ) );
    288288        }
    289289       
    290290        function get_all_for_user( $user_id ) {
    291291                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 ) );
    294294        }
    295295       
     
    297297                global $wpdb, $bp;
    298298               
    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 ) );
    300300        }
    301301       
     
    306306                        $secondary_item_sql = $wpdb->prepare( " AND secondary_item_id = %d", $secondary_item_id );
    307307               
    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 ) );
    309309        }
    310310       
Note: See TracChangeset for help on using the changeset viewer.