Skip to:
Content

BuddyPress.org

Changeset 2576


Ignore:
Timestamp:
02/03/2010 09:06:27 PM (14 years ago)
Author:
apeatling
Message:

Fixes #1551 - also safeguarded all foreach loops with an array typecast.

Location:
trunk
Files:
30 edited

Legend:

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

    r2541 r2576  
    319319
    320320        /* Now fetch the activity comments and parse them into the correct position in the activities array. */
    321         foreach( $activities as $activity ) {
     321        foreach( (array)$activities as $activity ) {
    322322            if ( 'activity_comment' != $activity->type && $activity->mptt_left && $activity->mptt_right )
    323323                $activity_comments[$activity->id] = BP_Activity_Activity::get_activity_comments( $activity->id, $activity->mptt_left, $activity->mptt_right );
     
    325325
    326326        /* Merge the comments with the activity items */
    327         foreach( $activities as $key => $activity )
     327        foreach( (array)$activities as $key => $activity )
    328328            $activities[$key]->children = $activity_comments[$activity->id];
    329329
     
    345345
    346346        /* Loop descendants and build an assoc array */
    347         foreach ( $descendants as $d ) {
     347        foreach ( (array)$descendants as $d ) {
    348348            $d->children = array();
    349349
     
    373373
    374374        /* Loop the descendants and recalculate the left and right values */
    375         foreach ( $descendants as $descendant )
     375        foreach ( (array)$descendants as $descendant )
    376376            $right = BP_Activity_Activity::rebuild_activity_comment_tree( $descendant->id, $right );
    377377
  • trunk/bp-activity/bp-activity-templatetags.php

    r2559 r2576  
    502502        $parent_activity = false;
    503503
    504         foreach( $activities_template->activities as $activity ) {
     504        foreach( (array)$activities_template->activities as $activity ) {
    505505            if ( $parent_id == $activity->id ) {
    506506                /* Need a copy not a reference, this was the only PHP4 compat way I could find. */
     
    563563
    564564            $content .= '<ul>';
    565             foreach ( $comment->children as $comment ) {
     565            foreach ( (array)$comment->children as $comment ) {
    566566                if ( !$comment->user_fullname )
    567567                    $comment->user_fullname = $comment->display_name;
     
    609609                return $count;
    610610
    611             foreach ( $comment->children as $comment ) {
     611            foreach ( (array)$comment->children as $comment ) {
    612612                $count++;
    613613                $count = bp_activity_recurse_comment_count( $comment, $count );
  • trunk/bp-blogs.php

    r2460 r2576  
    322322
    323323    if ( $blog_ids ) {
    324         foreach( $blog_ids as $blog_id ) {
     324        foreach( (array)$blog_ids as $blog_id ) {
    325325            $users = get_users_of_blog( $blog_id );
    326326
    327327            if ( $users ) {
    328                 foreach ( $users as $user ) {
     328                foreach ( (array)$users as $user ) {
    329329                    $role = unserialize( $user->meta_value );
    330330
  • trunk/bp-blogs/bp-blogs-classes.php

    r2553 r2576  
    102102        if ( !empty( $search_terms ) ) {
    103103            $filter = like_escape( $wpdb->escape( $search_terms ) );
    104             $paged_blogs = $wpdb->get_results( $wpdb->prepare( "SELECT b.blog_id, b.user_id as admin_user_id, u.user_email as admin_user_email, wb.domain, wb.path, bm.meta_value as last_activity, bm2.meta_value as name, bm3.meta_value as description FROM {$bp->blogs->table_name} b, {$bp->blogs->table_name_blogmeta} bm, {$bp->blogs->table_name_blogmeta} bm2, {$bp->blogs->table_name_blogmeta} bm3, {$wpdb->base_prefix}blogs wb, {$wpdb->users} u WHERE b.blog_id = wb.blog_id AND b.user_id = u.ID AND b.blog_id = bm.blog_id AND b.blog_id = bm2.blog_id AND b.blog_id = bm3.blog_id AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 {$hidden_sql} AND bm.meta_key = 'last_activity' AND bm2.meta_key = 'name' AND bm3.meta_key = 'description' AND ( bm2.meta_value LIKE '%%$filter%%' || bm3.meta_value LIKE '%%$filter%%' ) {$user_sql} {$order_sql} {$pag_sql}" ) );
    105             $total_blogs = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT b.blog_id) FROM {$bp->blogs->table_name} b, {$wpdb->base_prefix}blogs wb, {$bp->blogs->table_name_blogmeta} bm, {$bp->blogs->table_name_blogmeta} bm2 WHERE b.blog_id = wb.blog_id AND bm.blog_id = b.blog_id AND bm2.blog_id = b.blog_id AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 {$hidden_sql} AND bm.meta_key = 'name' AND bm2.meta_key = 'description' AND ( bm.meta_value LIKE '%%$filter%%' || bm2.meta_value LIKE '%%$filter%%' ) {$user_sql}" ) );
     104            $paged_blogs = $wpdb->get_results( "SELECT b.blog_id, b.user_id as admin_user_id, u.user_email as admin_user_email, wb.domain, wb.path, bm.meta_value as last_activity, bm2.meta_value as name, bm3.meta_value as description FROM {$bp->blogs->table_name} b, {$bp->blogs->table_name_blogmeta} bm, {$bp->blogs->table_name_blogmeta} bm2, {$bp->blogs->table_name_blogmeta} bm3, {$wpdb->base_prefix}blogs wb, {$wpdb->users} u WHERE b.blog_id = wb.blog_id AND b.user_id = u.ID AND b.blog_id = bm.blog_id AND b.blog_id = bm2.blog_id AND b.blog_id = bm3.blog_id AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 {$hidden_sql} AND bm.meta_key = 'last_activity' AND bm2.meta_key = 'name' AND bm3.meta_key = 'description' AND ( bm2.meta_value LIKE '%%$filter%%' || bm3.meta_value LIKE '%%$filter%%' ) {$user_sql} {$order_sql} {$pag_sql}" );
     105            $total_blogs = $wpdb->get_var( "SELECT COUNT(DISTINCT b.blog_id) FROM {$bp->blogs->table_name} b, {$wpdb->base_prefix}blogs wb, {$bp->blogs->table_name_blogmeta} bm, {$bp->blogs->table_name_blogmeta} bm2 WHERE b.blog_id = wb.blog_id AND bm.blog_id = b.blog_id AND bm2.blog_id = b.blog_id AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 {$hidden_sql} AND bm.meta_key = 'name' AND bm2.meta_key = 'description' AND ( bm.meta_value LIKE '%%$filter%%' || bm2.meta_value LIKE '%%$filter%%' ) {$user_sql}" );
    106106        } else {
    107107            $paged_blogs = $wpdb->get_results( $wpdb->prepare( "SELECT b.blog_id, b.user_id as admin_user_id, u.user_email as admin_user_email, wb.domain, wb.path, bm.meta_value as last_activity, bm2.meta_value as name, bm3.meta_value as description FROM {$bp->blogs->table_name} b, {$bp->blogs->table_name_blogmeta} bm, {$bp->blogs->table_name_blogmeta} bm2, {$bp->blogs->table_name_blogmeta} bm3, {$wpdb->base_prefix}blogs wb, {$wpdb->users} u WHERE b.blog_id = wb.blog_id AND b.user_id = u.ID AND b.blog_id = bm.blog_id AND b.blog_id = bm2.blog_id AND b.blog_id = bm3.blog_id {$user_sql} AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 {$hidden_sql} AND bm.meta_key = 'last_activity' AND bm2.meta_key = 'name' AND bm3.meta_key = 'description' {$order_sql} {$pag_sql}" ) );
     
    109109        }
    110110
    111         foreach ( $paged_blogs as $blog ) $blog_ids[] = $blog->blog_id;
     111        foreach ( (array)$paged_blogs as $blog ) $blog_ids[] = $blog->blog_id;
    112112        $blog_ids = $wpdb->escape( join( ',', (array)$blog_ids ) );
    113113        $paged_blogs = BP_Blogs_Blog::get_blog_extras( &$paged_blogs, $blog_ids, $type );
     
    284284
    285285        for ( $i = 0; $i < count( $paged_blogs ); $i++ ) {
    286             foreach ( $post_ids as $post ) {
     286            foreach ( (array)$post_ids as $post ) {
    287287                if ( $post->blog_id == $paged_blogs[$i]->blog_id ) {
    288288                    $paged_blogs[$i]->latest_post = $wpdb->get_row( "SELECT post_title, guid FROM {$wpdb->base_prefix}" . $post->blog_id . "_posts WHERE post_status = 'publish' AND post_type = 'post' ORDER BY id DESC LIMIT 1" );
  • trunk/bp-blogs/bp-blogs-templatetags.php

    r2536 r2576  
    746746        return false;
    747747
    748     foreach ( $terms as $term ) {
     748    foreach ( (array)$terms as $term ) {
    749749        $link = get_blog_option( BP_ROOT_BLOG, 'siteurl') . '/tag/' . $term->slug;
    750750        $link = apply_filters('term_link', $link);
  • trunk/bp-blogs/bp-blogs-widgets.php

    r2168 r2576  
    3434            </div>
    3535            <ul id="recent-posts" class="item-list">
    36                 <?php foreach ( $posts as $post ) : ?>
     36                <?php foreach ( (array)$posts as $post ) : ?>
    3737                    <li>
    3838                        <div class="item-avatar">
  • trunk/bp-core.php

    r2525 r2576  
    730730        return false;
    731731
    732     foreach ( $bp->bp_nav as $slug => $nav_item ) {
     732    foreach ( (array)$bp->bp_nav as $slug => $nav_item ) {
    733733        if ( empty( $temp[$nav_item['position']]) )
    734734            $temp[$nav_item['position']] = $nav_item;
     
    809809        return false;
    810810
    811     foreach ( $bp->bp_options_nav as $parent_slug => $subnav_items ) {
     811    foreach ( (array)$bp->bp_options_nav as $parent_slug => $subnav_items ) {
    812812        if ( !is_array( $subnav_items ) )
    813813            continue;
    814814
    815         foreach ( $subnav_items as $subnav_item ) {
     815        foreach ( (array)$subnav_items as $subnav_item ) {
    816816            if ( empty( $temp[$subnav_item['position']]) )
    817817                $temp[$subnav_item['position']] = $subnav_item;
     
    847847    /* Unset subnav items for this nav item */
    848848    if ( is_array( $bp->bp_options_nav[$parent_id] ) ) {
    849         foreach( $bp->bp_options_nav[$parent_id] as $subnav_item ) {
     849        foreach( (array)$bp->bp_options_nav[$parent_id] as $subnav_item ) {
    850850            bp_core_remove_subnav_item( $parent_id, $subnav_item['slug'] );
    851851        }
     
    15821582
    15831583    if ( is_array( $current ) ) {
    1584         foreach( $bp_illegal_names as $bp_illegal_name ) {
     1584        foreach( (array)$bp_illegal_names as $bp_illegal_name ) {
    15851585            if ( !in_array( $bp_illegal_name, $current ) )
    15861586                $current[] = $bp_illegal_name;
     
    20072007    global $wpdb;
    20082008
    2009     foreach( $comments as $comment ) {
     2009    foreach( (array)$comments as $comment ) {
    20102010        if ( $comment->user_id )
    20112011            $user_ids[] = $comment->user_id;
     
    20202020        return $comments;
    20212021
    2022     foreach( $userdata as $user )
     2022    foreach( (array)$userdata as $user )
    20232023        $users[$user->user_id] = bp_core_get_user_domain( $user->user_id, $user->user_nicename, $user->user_login );
    20242024
    2025     foreach( $comments as $i => $comment ) {
     2025    foreach( (array)$comments as $i => $comment ) {
    20262026        if ( !empty( $comment->user_id ) ) {
    20272027            if ( !empty( $users[$comment->user_id] ) )
  • trunk/bp-core/bp-core-activation.php

    r2381 r2576  
    3131                $profile_field_ids = explode( ',', $signup['meta']['profile_field_ids'] );
    3232
    33                 foreach( $profile_field_ids as $field_id ) {
     33                foreach( (array)$profile_field_ids as $field_id ) {
    3434                    $current_field = $signup['meta']["field_{$field_id}"];
    3535
  • trunk/bp-core/bp-core-admin.php

    r2480 r2576  
    1111
    1212        // Settings form submitted, now save the settings.
    13         foreach ( $_POST['bp-admin'] as $key => $value ) {
     13        foreach ( (array)$_POST['bp-admin'] as $key => $value ) {
    1414
    1515            if ( function_exists( 'xprofile_install' ) ) {
     
    144144
    145145        // Settings form submitted, now save the settings.
    146         foreach ( $_POST['bp_components'] as $key => $value ) {
     146        foreach ( (array)$_POST['bp_components'] as $key => $value ) {
    147147            if ( !(int) $value )
    148148                $disabled[$key] = 1;
  • trunk/bp-core/bp-core-adminbar.php

    r2479 r2576  
    6161    /* Loop through each navigation item */
    6262    $counter = 0;
    63     foreach( $bp->bp_nav as $nav_item ) {
     63    foreach( (array)$bp->bp_nav as $nav_item ) {
    6464        $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
    6565
     
    7171            $sub_counter = 0;
    7272
    73             foreach( $bp->bp_options_nav[$nav_item['slug']] as $subnav_item ) {
     73            foreach( (array)$bp->bp_options_nav[$nav_item['slug']] as $subnav_item ) {
    7474                $alt = ( 0 == $sub_counter % 2 ) ? ' class="alt"' : '';
    7575                echo '<li' . $alt . '><a id="bp-admin-' . $subnav_item['css_id'] . '" href="' . $subnav_item['link'] . '">' . $subnav_item['name'] . '</a></li>';
     
    112112    if ( is_array( $blogs['blogs'] ) && (int)$blogs['count'] ) {
    113113        $counter = 0;
    114         foreach ( $blogs['blogs'] as $blog ) {
     114        foreach ( (array)$blogs['blogs'] as $blog ) {
    115115            $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
    116116
     
    192192
    193193        echo '<ul class="author-list">';
    194         foreach( $authors as $author ) {
     194        foreach( (array)$authors as $author ) {
    195195            $author = new BP_Core_User( $author->user_id );
    196196            echo '<li>';
  • trunk/bp-core/bp-core-classes.php

    r2533 r2576  
    181181
    182182        /* Get paginated results */
    183         $paged_users = $wpdb->get_results( $wpdb->prepare( join( ' ', (array)$sql ) ) );
     183        $paged_users = $wpdb->get_results( join( ' ', (array)$sql ) );
    184184
    185185        /* Re-jig the SQL so we can get the total user count */
     
    201201
    202202        /* Get total user results */
    203         $total_users = $wpdb->get_var( $wpdb->prepare( join( ' ', (array)$sql ) ) );
     203        $total_users = $wpdb->get_var( join( ' ', (array)$sql ) );
    204204
    205205        /***
     
    207207         * We can't add these to the main query above since only users who have this information will be returned (since the much of the data is in usermeta and won't support any type of directional join)
    208208         */
    209         foreach ( $paged_users as $user )
     209        foreach ( (array)$paged_users as $user )
    210210            $user_ids[] = $user->id;
    211211
     
    241241         * We can't add these to the main query above since only users who have this information will be returned (since the much of the data is in usermeta and won't support any type of directional join)
    242242         */
    243         foreach ( $paged_users as $user )
     243        foreach ( (array)$paged_users as $user )
    244244            $user_ids[] = $user->id;
    245245
     
    300300         * We can't add these to the main query above since only users who have this information will be returned (since the much of the data is in usermeta and won't support any type of directional join)
    301301         */
    302         foreach ( $paged_users as $user )
     302        foreach ( (array)$paged_users as $user )
    303303            $user_ids[] = $user->id;
    304304
     
    322322            $names = $wpdb->get_results( $wpdb->prepare( "SELECT pd.user_id as id, pd.value as fullname FROM {$bp->profile->table_name_fields} pf, {$bp->profile->table_name_data} pd WHERE pf.id = pd.field_id AND pf.name = %s AND pd.user_id IN ( {$user_ids} )", BP_XPROFILE_FULLNAME_FIELD_NAME ) );
    323323            for ( $i = 0; $i < count( $paged_users ); $i++ ) {
    324                 foreach ( $names as $name ) {
     324                foreach ( (array)$names as $name ) {
    325325                    if ( $name->id == $paged_users[$i]->id )
    326326                        $paged_users[$i]->fullname = $name->fullname;
     
    333333            $friend_count = $wpdb->get_results( "SELECT user_id as id, meta_value as total_friend_count FROM " . CUSTOM_USER_META_TABLE . " WHERE meta_key = 'total_friend_count' AND user_id IN ( {$user_ids} )" );
    334334            for ( $i = 0; $i < count( $paged_users ); $i++ ) {
    335                 foreach ( $friend_count as $count ) {
     335                foreach ( (array)$friend_count as $count ) {
    336336                    if ( $count->id == $paged_users[$i]->id )
    337337                        $paged_users[$i]->total_friend_count = (int)$count->total_friend_count;
     
    344344            $friend_status = $wpdb->get_results( $wpdb->prepare( "SELECT initiator_user_id, friend_user_id, is_confirmed FROM {$bp->friends->table_name} WHERE (initiator_user_id = %d AND friend_user_id IN ( {$user_ids} ) ) OR (initiator_user_id IN ( {$user_ids} ) AND friend_user_id = %d )", $bp->loggedin_user->id, $bp->loggedin_user->id ) );
    345345            for ( $i = 0; $i < count( $paged_users ); $i++ ) {
    346                 foreach ( $friend_status as $status ) {
     346                foreach ( (array)$friend_status as $status ) {
    347347                    if ( $status->initiator_user_id == $paged_users[$i]->id || $status->friend_user_id == $paged_users[$i]->id )
    348348                        $paged_users[$i]->is_friend = $status->is_confirmed;
     
    354354            $user_activity = $wpdb->get_results( "SELECT user_id as id, meta_value as last_activity FROM " . CUSTOM_USER_META_TABLE . " WHERE meta_key = 'last_activity' AND user_id IN ( {$user_ids} )" );
    355355            for ( $i = 0; $i < count( $paged_users ); $i++ ) {
    356                 foreach ( $user_activity as $activity ) {
     356                foreach ( (array)$user_activity as $activity ) {
    357357                    if ( $activity->id == $paged_users[$i]->id )
    358358                        $paged_users[$i]->last_activity = $activity->last_activity;
     
    365365            $user_activity = $wpdb->get_results( "SELECT user_id as id, meta_value as last_activity FROM " . CUSTOM_USER_META_TABLE . " WHERE meta_key = 'last_activity' AND user_id IN ( {$user_ids} )" );
    366366            for ( $i = 0; $i < count( $paged_users ); $i++ ) {
    367                 foreach ( $user_activity as $activity ) {
     367                foreach ( (array)$user_activity as $activity ) {
    368368                    if ( $activity->id == $paged_users[$i]->id )
    369369                        $paged_users[$i]->last_activity = $activity->last_activity;
     
    375375        $user_update = $wpdb->get_results( "SELECT user_id as id, meta_value as latest_update FROM " . CUSTOM_USER_META_TABLE . " WHERE meta_key = 'bp_latest_update' AND user_id IN ( {$user_ids} )" );
    376376        for ( $i = 0; $i < count( $paged_users ); $i++ ) {
    377             foreach ( $user_update as $update ) {
     377            foreach ( (array)$user_update as $update ) {
    378378                if ( $update->id == $paged_users[$i]->id )
    379379                    $paged_users[$i]->latest_update = $update->latest_update;
  • trunk/bp-core/bp-core-notifications.php

    r2077 r2576  
    5151
    5252    /* Calculated a renderable outcome for each notification type */
    53     foreach ( $grouped_notifications as $component_name => $action_arrays ) {
     53    foreach ( (array)$grouped_notifications as $component_name => $action_arrays ) {
    5454        if ( !$action_arrays )
    5555            continue;
    5656
    57         foreach ( $action_arrays as $component_action_name => $component_action_items ) {
     57        foreach ( (array)$action_arrays as $component_action_name => $component_action_items ) {
    5858            $action_item_count = count($component_action_items);
    5959
  • trunk/bp-core/bp-core-settings.php

    r2389 r2576  
    114114
    115115        if ( $_POST['notifications'] ) {
    116             foreach ( $_POST['notifications'] as $key => $value ) {
     116            foreach ( (array)$_POST['notifications'] as $key => $value ) {
    117117                update_usermeta( (int)$current_user->id, $key, $value );
    118118            }
  • trunk/bp-core/bp-core-signup.php

    r2493 r2576  
    8787        /* Add any errors to the action for the field in the template for display. */
    8888        if ( !empty( $bp->signup->errors ) ) {
    89             foreach ( $bp->signup->errors as $fieldname => $error_message )
     89            foreach ( (array)$bp->signup->errors as $fieldname => $error_message )
    9090                add_action( 'bp_' . $fieldname . '_errors', create_function( '', 'echo "<div class=\"error\">' . $error_message . '</div>";' ) );
    9191        } else {
     
    208208            $profile_field_ids = explode( ',', $usermeta['profile_field_ids'] );
    209209
    210             foreach( $profile_field_ids as $field_id ) {
     210            foreach( (array)$profile_field_ids as $field_id ) {
    211211                $current_field = $usermeta["field_{$field_id}"];
    212212
  • trunk/bp-core/bp-core-templatetags.php

    r2539 r2576  
    501501    global $bp;
    502502
    503     foreach ( $bp->bp_nav as $user_nav_item ) {
     503    foreach ( (array)$bp->bp_nav as $user_nav_item ) {
    504504        if ( !$user_nav_item['show_for_displayed_user'] && !bp_is_my_profile() )
    505505            continue;
     
    545545
    546546    /* Loop through each navigation item */
    547     foreach ( $bp->bp_options_nav[$bp->current_component] as $subnav_item ) {
     547    foreach ( (array)$bp->bp_options_nav[$bp->current_component] as $subnav_item ) {
    548548        if ( !$subnav_item['user_has_access'] )
    549549            continue;
  • trunk/bp-forums.php

    r2547 r2576  
    341341
    342342    /* Get the topic ids */
    343     foreach ( $topics as $topic ) $topic_ids[] = $topic->topic_id;
     343    foreach ( (array)$topics as $topic ) $topic_ids[] = $topic->topic_id;
    344344    $topic_ids = $wpdb->escape( join( ',', (array)$topic_ids ) );
    345345
     
    347347    $poster_details = $wpdb->get_results( $wpdb->prepare( "SELECT t.topic_id, t.topic_last_poster, u.user_login, u.user_nicename, u.user_email, u.display_name FROM {$wpdb->users} u, {$bbdb->topics} t WHERE u.ID = t.topic_last_poster AND t.topic_id IN ( {$topic_ids} )" ) );
    348348    for ( $i = 0; $i < count( $topics ); $i++ ) {
    349         foreach ( $poster_details as $poster ) {
     349        foreach ( (array)$poster_details as $poster ) {
    350350            if ( $poster->topic_id == $topics[$i]->topic_id ) {
    351351                $topics[$i]->topic_last_poster_email = $poster->user_email;
     
    361361        $poster_names = $wpdb->get_results( $wpdb->prepare( "SELECT t.topic_id, pd.value FROM {$bp->profile->table_name_data} pd, {$bbdb->topics} t WHERE pd.user_id = t.topic_last_poster AND pd.field_id = 1 AND t.topic_id IN ( {$topic_ids} )" ) );
    362362        for ( $i = 0; $i < count( $topics ); $i++ ) {
    363             foreach ( $poster_names as $name ) {
     363            foreach ( (array)$poster_names as $name ) {
    364364                if ( $name->topic_id == $topics[$i]->topic_id )
    365365                    $topics[$i]->topic_last_poster_displayname = $name->value;
  • trunk/bp-forums/bp-forums-admin.php

    r2274 r2576  
    206206
    207207    // Loop through the lines and modify them
    208     foreach ( $lines as $line ) {
     208    foreach ( (array)$lines as $line ) {
    209209        if ( isset( $alterations[substr( $line, 0, 20 )] ) ) {
    210210            $alteration = $alterations[substr( $line, 0, 20 )];
     
    239239
    240240    // Write lines one by one to avoid OS specific newline hassles
    241     foreach ( $modified_lines as $modified_line ) {
     241    foreach ( (array)$modified_lines as $modified_line ) {
    242242        if ( false !== strpos( $modified_line, '?>' ) ) {
    243243            $modified_line = '?>';
  • trunk/bp-groups.php

    r2557 r2576  
    11291129             * we need to loop the step array and fetch the next step that way.
    11301130             */
    1131             foreach ( $bp->groups->group_creation_steps as $key => $value ) {
     1131            foreach ( (array)$bp->groups->group_creation_steps as $key => $value ) {
    11321132                if ( $key == $bp->groups->current_create_step ) {
    11331133                    $next = 1;
     
    12031203        return false;
    12041204
    1205     foreach ( $bp->groups->group_creation_steps as $slug => $step ) {
     1205    foreach ( (array)$bp->groups->group_creation_steps as $slug => $step ) {
    12061206        while ( !empty( $temp[$step['position']] ) )
    12071207            $step['position']++;
     
    12141214    unset($bp->groups->group_creation_steps);
    12151215
    1216     foreach( $temp as $position => $step )
     1216    foreach( (array)$temp as $position => $step )
    12171217        $bp->groups->group_creation_steps[$step['slug']] = array( 'name' => $step['name'], 'position' => $position );
    12181218}
  • trunk/bp-groups/bp-groups-classes.php

    r2556 r2576  
    273273
    274274        if ( $user_id ) {
    275             $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 ORDER BY g.date_created DESC {$pag_sql}", $user_id ) );
    276             $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql} {$search_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0", $user_id ) );
    277         } else {
    278             $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} ORDER BY g.date_created DESC {$pag_sql}" ) );
    279             $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm INNER JOIN {$bp->groups->table_name} g ON gm.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql} {$search_sql}" ) );
    280         }
    281 
    282         foreach ( $paged_groups as $group ) $group_ids[] = $group->id;
     275            $user_id = $wpdb->escape( $user_id );
     276            $paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.inviter_id = 0 AND m.is_banned = 0 ORDER BY g.date_created DESC {$pag_sql}" );
     277            $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.inviter_id = 0 AND m.is_banned = 0" );
     278        } else {
     279            $paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} ORDER BY g.date_created DESC {$pag_sql}" );
     280            $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm INNER JOIN {$bp->groups->table_name} g ON gm.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql} {$search_sql}" );
     281        }
     282
     283        foreach ( (array)$paged_groups as $group ) $group_ids[] = $group->id;
    283284        $group_ids = $wpdb->escape( join( ',', (array)$group_ids ) );
    284285        $paged_groups = BP_Groups_Group::get_group_extras( &$paged_groups, $group_ids, 'newest' );
     
    302303
    303304        if ( $user_id ) {
    304             $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 ORDER BY last_activity DESC {$pag_sql}", $user_id ) );
    305             $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql} {$search_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0", $user_id ) );
    306         } else {
    307             $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} ORDER BY last_activity DESC {$pag_sql}" ) );
    308             $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm INNER JOIN {$bp->groups->table_name} g ON gm.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql} {$search_sql}" ) );
    309         }
    310 
    311         foreach ( $paged_groups as $group ) $group_ids[] = $group->id;
     305            $user_id = $wpdb->escape( $user_id );
     306            $paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.inviter_id = 0 AND m.is_banned = 0 ORDER BY last_activity DESC {$pag_sql}" );
     307            $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.inviter_id = 0 AND m.is_banned = 0" );
     308        } else {
     309            $paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} ORDER BY last_activity DESC {$pag_sql}" );
     310            $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm INNER JOIN {$bp->groups->table_name} g ON gm.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql} {$search_sql}" );
     311        }
     312
     313        foreach ( (array)$paged_groups as $group ) $group_ids[] = $group->id;
    312314        $group_ids = $wpdb->escape( join( ',', (array)$group_ids ) );
    313315        $paged_groups = BP_Groups_Group::get_group_extras( &$paged_groups, $group_ids, 'active' );
     
    332334
    333335        if ( $user_id ) {
    334             $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 ORDER BY CONVERT(gm1.meta_value, SIGNED) DESC {$pag_sql}", $user_id ) );
    335             $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql} {$search_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0", $user_id ) );
    336         } else {
    337             $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} ORDER BY CONVERT(gm1.meta_value, SIGNED) DESC {$pag_sql}" ) );
    338             $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql}" ) );
    339         }
    340 
    341         foreach ( $paged_groups as $group ) $group_ids[] = $group->id;
     336            $user_id = $wpdb->escape( $user_id );
     337            $paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.inviter_id = 0 AND m.is_banned = 0 ORDER BY CONVERT(gm1.meta_value, SIGNED) DESC {$pag_sql}" );
     338            $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.inviter_id = 0 AND m.is_banned = 0" );
     339        } else {
     340            $paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} ORDER BY CONVERT(gm1.meta_value, SIGNED) DESC {$pag_sql}" );
     341            $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql}" );
     342        }
     343
     344        foreach ( (array)$paged_groups as $group ) $group_ids[] = $group->id;
    342345        $group_ids = $wpdb->escape( join( ',', (array)$group_ids ) );
    343346        $paged_groups = BP_Groups_Group::get_group_extras( &$paged_groups, $group_ids, 'popular' );
     
    361364
    362365        if ( $user_id ) {
    363             $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 ORDER BY g.name ASC {$pag_sql}", $user_id ) );
    364             $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id WHERE gm.meta_key = 'last_activity' {$hidden_sql} {$search_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0", $user_id ) );
    365         } else {
    366             $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} ORDER BY g.name ASC {$pag_sql}" ) );
    367             $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql}" ) );
    368         }
    369 
    370         foreach ( $paged_groups as $group ) $group_ids[] = $group->id;
     366            $user_id = $wpdb->escape( $user_id );
     367            $paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.inviter_id = 0 AND m.is_banned = 0 ORDER BY g.name ASC {$pag_sql}" );
     368            $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id WHERE gm.meta_key = 'last_activity' {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.inviter_id = 0 AND m.is_banned = 0" );
     369        } else {
     370            $paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} ORDER BY g.name ASC {$pag_sql}" );
     371            $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql}" );
     372        }
     373
     374        foreach ( (array)$paged_groups as $group ) $group_ids[] = $group->id;
    371375        $group_ids = $wpdb->escape( join( ',', (array)$group_ids ) );
    372376        $paged_groups = BP_Groups_Group::get_group_extras( &$paged_groups, $group_ids, 'alphabetical' );
     
    394398
    395399        if ( $user_id ) {
    396             $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_groupmeta} gm3, {$bp->groups->table_name_members} m, {$bbdb->forums} f, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND g.id = gm3.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND (gm3.meta_key = 'forum_id' AND gm3.meta_value = f.forum_id) AND f.topics > 0 {$hidden_sql} {$search_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 ORDER BY f.topics DESC {$pag_sql}", $user_id ) );
    397             $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_groupmeta} gm3, {$bbdb->forums} f, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND g.id = gm3.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND (gm3.meta_key = 'forum_id' AND gm3.meta_value = f.forum_id) AND f.topics > 0 {$hidden_sql} {$search_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0", $user_id ) );
    398         } else {
    399             $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_groupmeta} gm3, {$bbdb->forums} f, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND g.id = gm3.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND (gm3.meta_key = 'forum_id' AND gm3.meta_value = f.forum_id) AND f.topics > 0 {$hidden_sql} {$search_sql} ORDER BY f.topics DESC {$pag_sql}" ) );
    400             $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_groupmeta} gm3, {$bbdb->forums} f, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND g.id = gm3.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND (gm3.meta_key = 'forum_id' AND gm3.meta_value = f.forum_id) AND f.topics > 0 {$hidden_sql} {$search_sql}" ) );
    401         }
    402 
    403         foreach ( $paged_groups as $group ) $group_ids[] = $group->id;
     400            $user_id = $wpdb->escape( $user_id );
     401            $paged_groups = $wpdb->get_results( "SELECT DISTINCT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_groupmeta} gm3, {$bp->groups->table_name_members} m, {$bbdb->forums} f, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND g.id = gm3.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND (gm3.meta_key = 'forum_id' AND gm3.meta_value = f.forum_id) AND f.topics > 0 {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.inviter_id = 0 AND m.is_banned = 0 ORDER BY f.topics DESC {$pag_sql}" );
     402            $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_groupmeta} gm3, {$bbdb->forums} f, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND g.id = gm3.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND (gm3.meta_key = 'forum_id' AND gm3.meta_value = f.forum_id) AND f.topics > 0 {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.inviter_id = 0 AND m.is_banned = 0" );
     403        } else {
     404            $paged_groups = $wpdb->get_results( "SELECT DISTINCT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_groupmeta} gm3, {$bbdb->forums} f, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND g.id = gm3.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND (gm3.meta_key = 'forum_id' AND gm3.meta_value = f.forum_id) AND f.topics > 0 {$hidden_sql} {$search_sql} ORDER BY f.topics DESC {$pag_sql}" );
     405            $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_groupmeta} gm3, {$bbdb->forums} f, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND g.id = gm3.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND (gm3.meta_key = 'forum_id' AND gm3.meta_value = f.forum_id) AND f.topics > 0 {$hidden_sql} {$search_sql}" );
     406        }
     407
     408        foreach ( (array)$paged_groups as $group ) $group_ids[] = $group->id;
    404409        $group_ids = $wpdb->escape( join( ',', (array)$group_ids ) );
    405410        $paged_groups = BP_Groups_Group::get_group_extras( &$paged_groups, $group_ids, 'most_forum_topics' );
     
    427432
    428433        if ( $user_id ) {
    429             $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_groupmeta} gm3, {$bp->groups->table_name_members} m, {$bbdb->forums} f, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND g.id = gm3.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND (gm3.meta_key = 'forum_id' AND gm3.meta_value = f.forum_id) {$hidden_sql} {$search_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 ORDER BY f.posts ASC {$pag_sql}", $user_id ) );
    430             $total_groups = $wpdb->get_results( $wpdb->prepare( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_groupmeta} gm3, {$bp->groups->table_name_members} m, {$bbdb->forums} f, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND g.id = gm3.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND (gm3.meta_key = 'forum_id' AND gm3.meta_value = f.forum_id) AND f.posts > 0 {$hidden_sql} {$search_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0", $user_id ) );
    431         } else {
    432             $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_groupmeta} gm3, {$bbdb->forums} f, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND g.id = gm3.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND (gm3.meta_key = 'forum_id' AND gm3.meta_value = f.forum_id) AND f.posts > 0 {$hidden_sql} {$search_sql} ORDER BY f.posts ASC {$pag_sql}"  ) );
    433             $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_groupmeta} gm3, {$bbdb->forums} f, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND g.id = gm3.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND (gm3.meta_key = 'forum_id' AND gm3.meta_value = f.forum_id) {$hidden_sql} {$search_sql}" ) );
    434         }
    435 
    436         foreach ( $paged_groups as $group ) $group_ids[] = $group->id;
     434            $user_id = $wpdb->escape( $user_id );
     435            $paged_groups = $wpdb->get_results( "SELECT DISTINCT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_groupmeta} gm3, {$bp->groups->table_name_members} m, {$bbdb->forums} f, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND g.id = gm3.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND (gm3.meta_key = 'forum_id' AND gm3.meta_value = f.forum_id) {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.inviter_id = 0 AND m.is_banned = 0 ORDER BY f.posts ASC {$pag_sql}" );
     436            $total_groups = $wpdb->get_results( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_groupmeta} gm3, {$bp->groups->table_name_members} m, {$bbdb->forums} f, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND g.id = gm3.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND (gm3.meta_key = 'forum_id' AND gm3.meta_value = f.forum_id) AND f.posts > 0 {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.inviter_id = 0 AND m.is_banned = 0" );
     437        } else {
     438            $paged_groups = $wpdb->get_results( "SELECT DISTINCT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_groupmeta} gm3, {$bbdb->forums} f, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND g.id = gm3.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND (gm3.meta_key = 'forum_id' AND gm3.meta_value = f.forum_id) AND f.posts > 0 {$hidden_sql} {$search_sql} ORDER BY f.posts ASC {$pag_sql}" );
     439            $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_groupmeta} gm3, {$bbdb->forums} f, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND g.id = gm3.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND (gm3.meta_key = 'forum_id' AND gm3.meta_value = f.forum_id) {$hidden_sql} {$search_sql}" );
     440        }
     441
     442        foreach ( (array)$paged_groups as $group ) $group_ids[] = $group->id;
    437443        $group_ids = $wpdb->escape( join( ',', (array)$group_ids ) );
    438444        $paged_groups = BP_Groups_Group::get_group_extras( &$paged_groups, $group_ids, 'most_forum_posts' );
     
    503509        $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND g.name LIKE '$letter%%' {$hidden_sql} {$search_sql} ORDER BY g.name ASC {$pag_sql}"  ) );
    504510
    505         foreach ( $paged_groups as $group ) $group_ids[] = $group->id;
     511        foreach ( (array)$paged_groups as $group ) $group_ids[] = $group->id;
    506512        $group_ids = $wpdb->escape( join( ',', (array)$group_ids ) );
    507513        $paged_groups = BP_Groups_Group::get_group_extras( &$paged_groups, $group_ids, 'letter' );
     
    525531
    526532        if ( $user_id ) {
    527             $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 ORDER BY rand() {$pag_sql}", $user_id ) );
    528             $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql} {$search_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0", $user_id ) );
    529         } else {
    530             $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} ORDER BY rand() {$pag_sql}" ) );
    531             $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm INNER JOIN {$bp->groups->table_name} g ON gm.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql} {$search_sql}" ) );
    532         }
    533 
    534         foreach ( $paged_groups as $group ) $group_ids[] = $group->id;
     533            $user_id = $wpdb->escape( $user_id );
     534            $paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.inviter_id = 0 AND m.is_banned = 0 ORDER BY rand() {$pag_sql}" );
     535            $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.inviter_id = 0 AND m.is_banned = 0" );
     536        } else {
     537            $paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} ORDER BY rand() {$pag_sql}" );
     538            $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm INNER JOIN {$bp->groups->table_name} g ON gm.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql} {$search_sql}" );
     539        }
     540
     541        foreach ( (array)$paged_groups as $group ) $group_ids[] = $group->id;
    535542        $group_ids = $wpdb->escape( join( ',', (array)$group_ids ) );
    536543        $paged_groups = BP_Groups_Group::get_group_extras( &$paged_groups, $group_ids, 'random' );
     
    548555        $user_status = $wpdb->get_col( $wpdb->prepare( "SELECT group_id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id IN ( {$group_ids} ) AND is_confirmed = 1 AND is_banned = 0", $bp->loggedin_user->id ) );
    549556        for ( $i = 0; $i < count( $paged_groups ); $i++ ) {
    550             foreach ( $user_status as $group_id ) {
     557            foreach ( (array)$user_status as $group_id ) {
    551558                if ( $group_id == $paged_groups[$i]->id )
    552559                    $paged_groups[$i]->is_member = true;
     
    556563        $user_banned = $wpdb->get_col( $wpdb->prepare( "SELECT group_id FROM {$bp->groups->table_name_members} WHERE is_banned = 1 AND user_id = %d AND group_id IN ( {$group_ids} )", $bp->loggedin_user->id ) );
    557564        for ( $i = 0; $i < count( $paged_groups ); $i++ ) {
    558             foreach ( $user_banned as $group_id ) {
     565            foreach ( (array)$user_banned as $group_id ) {
    559566                if ( $group_id == $paged_groups[$i]->id )
    560567                    $paged_groups[$i]->is_banned = true;
     
    989996
    990997        /* Fetch whether or not the user is a friend */
    991         foreach ( $members as $user ) $user_ids[] = $user->user_id;
     998        foreach ( (array)$members as $user ) $user_ids[] = $user->user_id;
    992999        $user_ids = $wpdb->escape( join( ',', (array)$user_ids ) );
    9931000
     
    9951002            $friend_status = $wpdb->get_results( $wpdb->prepare( "SELECT initiator_user_id, friend_user_id, is_confirmed FROM {$bp->friends->table_name} WHERE (initiator_user_id = %d AND friend_user_id IN ( {$user_ids} ) ) OR (initiator_user_id IN ( {$user_ids} ) AND friend_user_id = %d )", $bp->loggedin_user->id, $bp->loggedin_user->id ) );
    9961003            for ( $i = 0; $i < count( $members ); $i++ ) {
    997                 foreach ( $friend_status as $status ) {
     1004                foreach ( (array)$friend_status as $status ) {
    9981005                    if ( $status->initiator_user_id == $members[$i]->user_id || $status->friend_user_id == $members[$i]->user_id )
    9991006                        $members[$i]->is_friend = $status->is_confirmed;
  • trunk/bp-groups/bp-groups-notifications.php

    r2575 r2576  
    88
    99    $user_ids = BP_Groups_Member::get_group_member_ids( $group->id );
    10     foreach ( $user_ids as $user_id ) {
     10    foreach ( (array)$user_ids as $user_id ) {
    1111        if ( 'no' == get_usermeta( $user_id, 'notification_groups_group_updated' ) ) continue;
    1212
  • trunk/bp-groups/bp-groups-templatetags.php

    r2550 r2576  
    804804    <?php if ( $admins ) { ?>
    805805        <ul id="admins-list" class="item-list<?php if ( $admin_list ) { ?> single-line<?php } ?>">
    806         <?php foreach ( $admins as $admin ) { ?>
     806        <?php foreach ( (array)$admins as $admin ) { ?>
    807807            <?php if ( $admin_list ) { ?>
    808808            <li>
     
    842842        <?php if ( $group_mods ) { ?>
    843843            <ul id="mods-list" class="item-list<?php if ( $admin_list ) { ?> single-line<?php } ?>">
    844             <?php foreach ( $group_mods as $mod ) { ?>
     844            <?php foreach ( (array)$group_mods as $mod ) { ?>
    845845                <?php if ( $admin_list ) { ?>
    846846                <li>
     
    15101510    $counter = 1;
    15111511
    1512     foreach ( $bp->groups->group_creation_steps as $slug => $step ) {
     1512    foreach ( (array)$bp->groups->group_creation_steps as $slug => $step ) {
    15131513        $is_enabled = bp_are_previous_group_creation_steps_complete( $slug ); ?>
    15141514
     
    15731573        $found = true;
    15741574
    1575         foreach ( $step_slugs as $step_slug ) {
     1575        foreach ( (array)$step_slugs as $step_slug ) {
    15761576            if ( !in_array( $step_slug, $bp->groups->completed_create_steps ) )
    15771577                $found = false;
     
    15971597
    15981598    /* Get previous steps */
    1599     foreach ( $bp->groups->group_creation_steps as $slug => $name ) {
     1599    foreach ( (array)$bp->groups->group_creation_steps as $slug => $name ) {
    16001600        if ( $slug == $step_slug )
    16011601            break;
     
    16751675        global $bp;
    16761676
    1677         foreach ( $bp->groups->group_creation_steps as $slug => $name ) {
     1677        foreach ( (array)$bp->groups->group_creation_steps as $slug => $name ) {
    16781678            if ( $slug == $bp->action_variables[1] )
    16791679                break;
  • trunk/bp-messages.php

    r2558 r2576  
    453453
    454454        /* Format this to match existing recipients */
    455         foreach( $recipient_ids as $i => $recipient_id ) {
     455        foreach( (array)$recipient_ids as $i => $recipient_id ) {
    456456            $message->recipients[$i] = new stdClass;
    457457            $message->recipients[$i]->user_id = $recipient_id;
  • trunk/bp-messages/bp-messages-classes.php

    r2558 r2576  
    4646        $results = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->messages->table_name_recipients} WHERE thread_id = %d", $this->thread_id ) );
    4747
    48         foreach ( $results as $recipient )
     48        foreach ( (array)$results as $recipient )
    4949            $recipients[$recipient->user_id] = $recipient;
    5050
     
    9797
    9898        /* Sort threads by date_sent */
    99         foreach( $thread_ids as $thread ) {
     99        foreach( (array)$thread_ids as $thread ) {
    100100            $sorted_threads[$thread->thread_id] = strtotime($thread->date_sent);
    101101        }
     
    103103
    104104        $threads = false;
    105         foreach ( $sorted_threads as $thread_id => $date_sent )
     105        foreach ( (array)$sorted_threads as $thread_id => $date_sent )
    106106            $threads[] = new BP_Messages_Thread( $thread_id );
    107107
     
    193193            return count( $recipients ) . __(' Recipients', 'buddypress');
    194194
    195         foreach ( $recipients as $recipient ) {
     195        foreach ( (array)$recipients as $recipient ) {
    196196            $recipient_links[] = bp_core_get_userlink( $recipient->user_id );
    197197        }
  • trunk/bp-themes/bp-default/_inc/ajax.php

    r2573 r2576  
    246246    /* Add the new page param */
    247247    $args = explode( '&', trim( $query_string ) );
    248     foreach( $args as $arg ) {
     248    foreach( (array)$args as $arg ) {
    249249        if ( false === strpos( $arg, 'page' ) )
    250250            $new_args[] = $arg;
     
    544544
    545545    if ( $friends['friends'] ) {
    546         foreach ( $friends['friends'] as $user_id ) {
     546        foreach ( (array)$friends['friends'] as $user_id ) {
    547547            $ud = get_userdata($user_id);
    548548            $username = $ud->user_login;
  • trunk/bp-themes/bp-default/_inc/global.js

    r2574 r2576  
    104104    /* List tabs event delegation */
    105105    j('div.activity-type-tabs').click( function(event) {
    106         var target = j(event.target).parent();
     106        var target = j(event.target).parent().parent();
    107107
    108108        if ( event.target.nodeName != 'A' )
  • trunk/bp-themes/bp-default/comments.php

    r2277 r2576  
    1616            <?php
    1717            $numTrackBacks = 0; $numComments = 0;
    18             foreach ( $comments as $comment ) if ( get_comment_type() != "comment") $numTrackBacks++; else $numComments++;
     18            foreach ( (array)$comments as $comment ) if ( get_comment_type() != "comment") $numTrackBacks++; else $numComments++;
    1919            ?>
    2020
     
    164164
    165165                <ul id="trackbacklist">
    166                     <?php foreach ( $comments as $comment ) : ?>
     166                    <?php foreach ( (array)$comments as $comment ) : ?>
    167167
    168168                        <?php if ( get_comment_type() != 'comment' ) : ?>
  • trunk/bp-themes/bp-sn-parent/_inc/ajax.php

    r2424 r2576  
    293293
    294294    if ( $friends['friends'] ) {
    295         foreach ( $friends['friends'] as $user_id ) {
     295        foreach ( (array)$friends['friends'] as $user_id ) {
    296296            $ud = get_userdata($user_id);
    297297            $username = $ud->user_login;
  • trunk/bp-xprofile.php

    r2547 r2576  
    300300
    301301        /* Loop through the posted fields formatting any datebox values then validate the field */
    302         foreach ( $posted_field_ids as $field_id ) {
     302        foreach ( (array)$posted_field_ids as $field_id ) {
    303303            if ( !isset( $_POST['field_' . $field_id] ) ) {
    304304
     
    326326
    327327            /* Now we've checked for required fields, lets save the values. */
    328             foreach ( $posted_field_ids as $field_id ) {
     328            foreach ( (array)$posted_field_ids as $field_id ) {
    329329                if ( !xprofile_set_field_data( $field_id, $bp->displayed_user->id, $_POST['field_' . $field_id] ) )
    330330                    $errors = true;
  • trunk/bp-xprofile/bp-xprofile-classes.php

    r2547 r2576  
    355355                $counter = 1;
    356356                if ( $options ) {
    357                     foreach ( $options as $option_key => $option_value ) {
     357                    foreach ( (array)$options as $option_key => $option_value ) {
    358358                        $is_default = 0;
    359359
  • trunk/bp-xprofile/bp-xprofile-filters.php

    r2439 r2576  
    6565
    6666    if ( $values ) {
    67         foreach ( $values as $value ) {
     67        foreach ( (array)$values as $value ) {
    6868            $value = trim( $value );
    6969
     
    8686
    8787function xprofile_filter_comments( $comments, $post_id ) {
    88     foreach( $comments as $comment ) {
     88    foreach( (array)$comments as $comment ) {
    8989        if ( $comment->user_id )
    9090            $user_ids[] = $comment->user_id;
     
    9595
    9696    if ( $fullnames = BP_XProfile_ProfileData::get_value_byid( 1, $user_ids ) ) {
    97         foreach( $fullnames as $user ) {
     97        foreach( (array)$fullnames as $user ) {
    9898            $users[$user->user_id] = trim($user->value);
    9999        }
    100100    }
    101101
    102     foreach( $comments as $i => $comment ) {
     102    foreach( (array)$comments as $i => $comment ) {
    103103        if ( !empty( $comment->user_id ) ) {
    104104            if ( !empty( $users[$comment->user_id] ) )
Note: See TracChangeset for help on using the changeset viewer.