Ticket #2985: 2985.001.diff
File 2985.001.diff, 26.6 KB (added by , 14 years ago) |
---|
-
bp-friends.php
556 556 if ( !$user_ids ) 557 557 return false; 558 558 559 for ( $i = 0 ; $i < count($user_ids); $i++ ) {559 for ( $i = 0, $j = count( $user_ids ); $i < $j; $i++ ) { 560 560 $users[] = new BP_Core_User($user_ids[$i]); 561 561 } 562 562 -
bp-themes/bp-default/_inc/ajax.php
514 514 } else { 515 515 $thread_ids = explode( ',', $_POST['thread_ids'] ); 516 516 517 for ( $i = 0 ; $i < count($thread_ids); $i++ ) {517 for ( $i = 0, $j = count( $thread_ids ); $i < $j; $i++ ) { 518 518 BP_Messages_Thread::mark_as_unread($thread_ids[$i]); 519 519 } 520 520 } … … 530 530 } else { 531 531 $thread_ids = explode( ',', $_POST['thread_ids'] ); 532 532 533 for ( $i = 0 ; $i < count($thread_ids); $i++ ) {533 for ( $i = 0, $j = count( $thread_ids ); $i < $j; $i++ ) { 534 534 BP_Messages_Thread::mark_as_read($thread_ids[$i]); 535 535 } 536 536 } … … 546 546 } else { 547 547 $thread_ids = explode( ',', $_POST['thread_ids'] ); 548 548 549 for ( $i = 0 ; $i < count($thread_ids); $i++ )549 for ( $i = 0, $j = count( $thread_ids ); $i < $j; $i++ ) 550 550 BP_Messages_Thread::delete($thread_ids[$i]); 551 551 552 552 _e('Messages deleted.', 'buddypress'); -
bp-core/bp-core-notifications.php
39 39 40 40 $notifications = BP_Core_Notification::get_all_for_user( $user_id ); 41 41 42 / * Group notifications by component and component_action and provide totals */43 for ( $i = 0 ; $i < count($notifications); $i++ ) {42 // Group notifications by component and component_action and provide totals 43 for ( $i = 0, $j = count( $notifications ); $i < $j; $i++ ) { 44 44 $notification = $notifications[$i]; 45 45 $grouped_notifications[$notification->component_name][$notification->component_action][] = $notification; 46 46 } … … 48 48 if ( empty( $grouped_notifications ) ) 49 49 return false; 50 50 51 / * Calculated a renderable outcome for each notification type */51 // Calculated a renderable outcome for each notification type 52 52 foreach ( (array)$grouped_notifications as $component_name => $action_arrays ) { 53 53 if ( !$action_arrays ) 54 54 continue; -
bp-core/bp-core-adminbar.php
198 198 199 199 if ( $notifications ) { 200 200 $counter = 0; 201 for ( $i = 0 ; $i < count($notifications); $i++ ) {201 for ( $i = 0, $j = count( $notifications ); $i < $j; $i++ ) { 202 202 $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : ''; ?> 203 203 204 204 <li<?php echo $alt ?>><?php echo $notifications[$i] ?></li> -
bp-core/bp-core-classes.php
346 346 if ( empty( $user_ids ) ) 347 347 return $paged_users; 348 348 349 / * Fetch the user's full name */349 // Fetch the user's full name 350 350 if ( bp_is_active( 'xprofile' ) && 'alphabetical' != $type ) { 351 / * Ensure xprofile globals are set */351 // Ensure xprofile globals are set 352 352 if ( !defined( 'BP_XPROFILE_FULLNAME_FIELD_NAME' ) ) 353 353 xprofile_setup_globals(); 354 354 355 355 $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 ) ); 356 for ( $i = 0 ; $i < count( $paged_users ); $i++ ) {356 for ( $i = 0, $j = count( $paged_users ); $i < $j; $i++ ) { 357 357 foreach ( (array)$names as $name ) { 358 358 if ( $name->id == $paged_users[$i]->id ) 359 359 $paged_users[$i]->fullname = $name->fullname; … … 361 361 } 362 362 } 363 363 364 / * Fetch the user's total friend count */364 // Fetch the user's total friend count/ 365 365 if ( 'popular' != $type ) { 366 366 $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} )" ); 367 for ( $i = 0 ; $i < count( $paged_users ); $i++ ) {367 for ( $i = 0, $j = count( $paged_users ); $i < $j; $i++ ) { 368 368 foreach ( (array)$friend_count as $count ) { 369 369 if ( $count->id == $paged_users[$i]->id ) 370 370 $paged_users[$i]->total_friend_count = (int)$count->total_friend_count; … … 372 372 } 373 373 } 374 374 375 / * Fetch whether or not the user is a friend */375 // Fetch whether or not the user is a friend 376 376 if ( bp_is_active( 'friends' ) ) { 377 377 $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 ) ); 378 for ( $i = 0 ; $i < count( $paged_users ); $i++ ) {378 for ( $i = 0, $j = count( $paged_users ); $i < $j; $i++ ) { 379 379 foreach ( (array)$friend_status as $status ) { 380 380 if ( $status->initiator_user_id == $paged_users[$i]->id || $status->friend_user_id == $paged_users[$i]->id ) 381 381 $paged_users[$i]->is_friend = $status->is_confirmed; … … 385 385 386 386 if ( 'active' != $type ) { 387 387 $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} )" ); 388 for ( $i = 0 ; $i < count( $paged_users ); $i++ ) {388 for ( $i = 0, $j = count( $paged_users ); $i < $j; $i++ ) { 389 389 foreach ( (array)$user_activity as $activity ) { 390 390 if ( $activity->id == $paged_users[$i]->id ) 391 391 $paged_users[$i]->last_activity = $activity->last_activity; … … 393 393 } 394 394 } 395 395 396 / * Fetch the user's last_activity */396 // Fetch the user's last_activity 397 397 if ( 'active' != $type ) { 398 398 $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} )" ); 399 for ( $i = 0 ; $i < count( $paged_users ); $i++ ) {399 for ( $i = 0, $j = count( $paged_users ); $i < $j; $i++ ) { 400 400 foreach ( (array)$user_activity as $activity ) { 401 401 if ( $activity->id == $paged_users[$i]->id ) 402 402 $paged_users[$i]->last_activity = $activity->last_activity; … … 404 404 } 405 405 } 406 406 407 / * Fetch the user's latest update */407 // Fetch the user's latest update 408 408 $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} )" ); 409 for ( $i = 0 ; $i < count( $paged_users ); $i++ ) {409 for ( $i = 0, $j = count( $paged_users ); $i < $j; $i++ ) { 410 410 foreach ( (array)$user_update as $update ) { 411 411 if ( $update->id == $paged_users[$i]->id ) 412 412 $paged_users[$i]->latest_update = $update->latest_update; -
bp-xprofile/bp-xprofile-templatetags.php
98 98 function has_fields() { 99 99 $has_data = false; 100 100 101 for ( $i = 0 ; $i < count( $this->group->fields ); $i++ ) {101 for ( $i = 0, $j = count( $this->group->fields ); $i < $j; $i++ ) { 102 102 $field = &$this->group->fields[$i]; 103 103 104 104 if ( !empty( $field->data ) && $field->data->value != null ) { … … 415 415 if ( 'multiselectbox' != $field->type ) 416 416 $html .= '<option value="">--------</option>'; 417 417 418 for ( $k = 0 ; $k < count($options); $k++ ) {418 for ( $k = 0, $l = count( $options ); $k < $l; $k++ ) { 419 419 $original_option_values = maybe_unserialize( BP_XProfile_ProfileData::get_value_byid( $options[$k]->parent_id ) ); 420 420 $option_values = (array) $original_option_values; 421 421 … … 446 446 case 'radio': 447 447 $html .= '<div id="field_' . $field->id . '">'; 448 448 449 for ( $k = 0 ; $k < count($options); $k++ ) {449 for ( $k = 0, $l = count( $options ); $k < $l; $k++ ) { 450 450 $option_value = BP_XProfile_ProfileData::get_value_byid($options[$k]->parent_id); 451 451 452 452 // Check for updated posted values, but errors preventing them from being saved first time … … 476 476 477 477 $option_values = maybe_unserialize($option_values); 478 478 479 for ( $k = 0 ; $k < count($options); $k++ ) {479 for ( $k = 0, $l = count( $options ); $k < $l; $k++ ) { 480 480 $selected = ''; 481 481 482 482 // First, check to see whether the user's saved values 483 483 // match the option 484 for ( $j = 0 ; $j < count($option_values); $j++ ) {484 for ( $j = 0, $m = count( $option_values ); $j < $m; $j++ ) { 485 485 if ( $option_values[$j] == $options[$k]->name || @in_array( $options[$k]->name, $value ) ) { 486 486 $selected = ' checked="checked"'; 487 487 break; … … 618 618 $group_name = bp_profile_group_name(false); 619 619 620 620 $tabs = array(); 621 for ( $i = 0 ; $i < count($groups); $i++ ) {621 for ( $i = 0, $j = count( $groups ); $i < $j; $i++ ) { 622 622 if ( $group_name == $groups[$i]->name ) 623 623 $selected = ' class="current"'; 624 624 else -
bp-xprofile/bp-xprofile-classes.php
61 61 if ( !$this->can_delete ) 62 62 return false; 63 63 64 / * Delete field group */64 // Delete field group 65 65 if ( !$wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->profile->table_name_groups} WHERE id = %d", $this->id ) ) ) { 66 66 return false; 67 67 } else { 68 / * Remove the group's fields. */68 // Remove the group's fields. 69 69 if ( BP_XProfile_Field::delete_for_group( $this->id ) ) { 70 / * Remove profile data for the groups fields */71 for ( $i = 0 ; $i < count( $this->fields ); $i++ ) {70 // Remove profile data for the groups fields 71 for ( $i = 0, $j = count( $this->fields ); $i < $j; $i++ ) { 72 72 BP_XProfile_ProfileData::delete_for_field( $this->fields[$i]->id ); 73 73 } 74 74 } … … 569 569 } 570 570 571 571 if ( !empty( $options ) ) { 572 for ( $i = 0 ; $i < count( $options ); $i++ ) {572 for ( $i = 0, $k = count( $options ); $i < $k; $i++ ) { 573 573 $j = $i + 1; 574 574 575 575 if ( 'multiselectbox' == $type || 'checkbox' == $type ) … … 889 889 $field_sql = ''; 890 890 891 891 if ( is_array( $fields ) ) { 892 for ( $i = 0 ; $i < count( $fields ); $i++ ) {892 for ( $i = 0, $j = count( $fields ); $i < $j; $i++ ) { 893 893 if ( $i == 0 ) 894 894 $field_sql .= $wpdb->prepare( "AND ( f.name = %s ", $fields[$i] ); 895 895 else … … 909 909 $new_values = array(); 910 910 911 911 if ( is_array( $fields ) ) { 912 for ( $i = 0 ; $i < count( $values ); $i++ ) {913 for ( $j = 0 ; $j < count( $fields ); $j++ ) {912 for ( $i = 0, $k = count( $values ); $i < $k; $i++ ) { 913 for ( $j = 0, $l = count( $fields ); $j < $l; $j++ ) { 914 914 if ( $values[$i]->name == $fields[$j] ) 915 915 $new_values[$fields[$j]] = $values[$i]->value; 916 916 else if ( !array_key_exists( $fields[$j], $new_values ) ) -
bp-friends/bp-friends-templatetags.php
41 41 42 42 <?php if ( $friend_ids ) { ?> 43 43 <ul class="horiz-gallery"> 44 <?php for ( $i = 0 ; $i < count( $friend_ids ); $i++ ) { ?>44 <?php for ( $i = 0, $j = count( $friend_ids ); $i < $j; $i++ ) { ?> 45 45 <li> 46 46 <a href="<?php echo bp_core_get_user_domain( $friend_ids[$i] ) ?>"><?php echo bp_core_fetch_avatar( array( 'item_id' => $friend_ids[$i], 'type' => 'thumb' ) ) ?></a> 47 47 <h5><?php echo bp_core_get_userlink($friend_ids[$i]) ?></h5> … … 68 68 ?> 69 69 <?php if ( $user_ids['users'] ) { ?> 70 70 <ul class="item-list" id="random-members-list"> 71 <?php for ( $i = 0 ; $i < count( $user_ids['users'] ); $i++ ) { ?>71 <?php for ( $i = 0, $j = count( $user_ids['users'] ); $i < $j; $i++ ) { ?> 72 72 <li> 73 73 <a href="<?php echo bp_core_get_user_domain( $user_ids['users'][$i]->user_id ) ?>"><?php echo bp_core_fetch_avatar( array( 'item_id' => $user_ids['users'][$i]->user_id, 'type' => 'thumb' ) ) ?></a> 74 74 <h5><?php echo bp_core_get_userlink( $user_ids['users'][$i]->user_id ) ?></h5> -
bp-friends/bp-friends-classes.php
94 94 $friends = $wpdb->get_results( $wpdb->prepare( "SELECT friend_user_id, initiator_user_id FROM {$bp->friends->table_name} $friend_sql $oc_sql ORDER BY date_created DESC" ) ); 95 95 $fids = array(); 96 96 97 for ( $i = 0 ; $i < count($friends); $i++ ) {97 for ( $i = 0, $j = count( $friends ); $i < $j; $i++ ) { 98 98 if ( $assoc_arr ) 99 99 $fids[] = array( 'user_id' => ( $friends[$i]->friend_user_id == $user_id ) ? $friends[$i]->initiator_user_id : $friends[$i]->friend_user_id ); 100 100 else … … 276 276 $sql = $wpdb->prepare( "SELECT friend_user_id, initiator_user_id FROM {$bp->friends->table_name} WHERE (friend_user_id = %d || initiator_user_id = %d) && is_confirmed = 1 ORDER BY rand() LIMIT %d", $user_id, $user_id, $total_friends ); 277 277 $results = $wpdb->get_results($sql); 278 278 279 for ( $i = 0 ; $i < count($results); $i++ ) {279 for ( $i = 0, $j = count( $results ); $i < $j; $i++ ) { 280 280 $fids[] = ( $results[$i]->friend_user_id == $user_id ) ? $results[$i]->initiator_user_id : $results[$i]->friend_user_id; 281 281 } 282 282 … … 293 293 $friend_ids = BP_Friends_Friendship::get_friend_user_ids( $user_id ); 294 294 295 295 $invitable_count = 0; 296 for ( $i = 0 ; $i < count($friend_ids); $i++ ) {296 for ( $i = 0, $j = count( $friend_ids ); $i < $j; $i++ ) { 297 297 298 298 if ( BP_Groups_Member::check_is_member( (int)$friend_ids[$i], $group_id ) ) 299 299 continue; -
bp-activity/bp-activity-classes.php
430 430 431 431 $activities = bp_activity_get_sitewide( array( 'max' => $limit ) ); 432 432 433 for ( $i = 0 ; $i < count($activities); $i++ ) {433 for ( $i = 0, $j = count( $activities ); $i < $j; $i++ ) { 434 434 $title = explode( '<span', $activities[$i]['content'] ); 435 435 436 436 $activity_feed[$i]['title'] = trim( strip_tags( $title[0] ) ); -
bp-messages.php
448 448 449 449 if ( is_array($thread_ids) ) { 450 450 $error = 0; 451 for ( $i = 0 ; $i < count($thread_ids); $i++ ) {451 for ( $i = 0, $j = count( $thread_ids ); $i < $j; $i++ ) { 452 452 if ( !$status = BP_Messages_Thread::delete($thread_ids[$i]) ) 453 453 $error = 1; 454 454 } -
bp-forums.php
397 397 if ( empty( $topics ) ) 398 398 return $topics; 399 399 400 /* Get the topic ids */ 401 foreach ( (array)$topics as $topic ) $topic_ids[] = $topic->topic_id; 400 // Get the topic ids 401 foreach ( (array)$topics as $topic ) 402 $topic_ids[] = $topic->topic_id; 402 403 $topic_ids = $wpdb->escape( join( ',', (array)$topic_ids ) ); 403 404 404 / * Fetch the topic's last poster details */405 // Fetch the topic's last poster details 405 406 $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} )" ) ); 406 for ( $i = 0 ; $i < count( $topics ); $i++ ) {407 for ( $i = 0, $j = count( $topics ); $i < $j; $i++ ) { 407 408 foreach ( (array)$poster_details as $poster ) { 408 409 if ( $poster->topic_id == $topics[$i]->topic_id ) { 409 410 $topics[$i]->topic_last_poster_email = $poster->user_email; … … 414 415 } 415 416 } 416 417 417 / * Fetch fullname for the topic's last poster */418 // Fetch fullname for the topic's last poster 418 419 if ( bp_is_active( 'xprofile' ) ) { 419 420 $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} )" ) ); 420 for ( $i = 0; $i < count( $topics ); $i++ ) {421 for ( $i = 0; $i < $j; $i++ ) { 421 422 foreach ( (array)$poster_names as $name ) { 422 423 if ( $name->topic_id == $topics[$i]->topic_id ) 423 424 $topics[$i]->topic_last_poster_displayname = $name->value; … … 514 515 if ( empty( $posts ) ) 515 516 return $posts; 516 517 517 /* Get the user ids */ 518 foreach ( (array)$posts as $post ) $user_ids[] = $post->poster_id; 518 // Get the user ids 519 foreach ( (array)$posts as $post ) 520 $user_ids[] = $post->poster_id; 519 521 $user_ids = $wpdb->escape( join( ',', (array)$user_ids ) ); 520 522 521 / * Fetch the poster's user_email, user_nicename and user_login */523 // Fetch the poster's user_email, user_nicename and user_login 522 524 $poster_details = $wpdb->get_results( $wpdb->prepare( "SELECT u.ID as user_id, u.user_login, u.user_nicename, u.user_email, u.display_name FROM {$wpdb->users} u WHERE u.ID IN ( {$user_ids} )" ) ); 523 525 524 for ( $i = 0 ; $i < count( $posts ); $i++ ) {526 for ( $i = 0, $j = count( $posts ); $i < $j; $i++ ) { 525 527 foreach ( (array)$poster_details as $poster ) { 526 528 if ( $poster->user_id == $posts[$i]->poster_id ) { 527 529 $posts[$i]->poster_email = $poster->user_email; … … 532 534 } 533 535 } 534 536 535 / * Fetch fullname for each poster. */537 // Fetch fullname for each poster. 536 538 if ( bp_is_active( 'xprofile' ) ) { 537 539 $poster_names = $wpdb->get_results( $wpdb->prepare( "SELECT pd.user_id, pd.value FROM {$bp->profile->table_name_data} pd WHERE pd.user_id IN ( {$user_ids} )" ) ); 538 for ( $i = 0; $i < count( $posts ); $i++ ) {540 for ( $i = 0; $i < $j; $i++ ) { 539 541 foreach ( (array)$poster_names as $name ) { 540 542 if ( isset( $topics[$i] ) && $name->user_id == $topics[$i]->user_id ) 541 $posts[$i]->poster_name = $poster->value;543 $posts[$i]->poster_name = $poster->value; 542 544 } 543 545 } 544 546 } -
bp-groups.php
2306 2306 $invited_users = groups_get_invites_for_group( $user_id, $group_id ); 2307 2307 $group = new BP_Groups_Group( $group_id ); 2308 2308 2309 for ( $i = 0 ; $i < count( $invited_users ); $i++ ) {2309 for ( $i = 0, $j = count( $invited_users ); $i < $j; $i++ ) { 2310 2310 $member = new BP_Groups_Member( $invited_users[$i], $group_id ); 2311 2311 2312 2312 // Send the actual invite … … 2425 2425 2426 2426 require_once ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-notifications.php' ); 2427 2427 2428 for ( $i = 0 ; $i < count( $admins ); $i++ ) {2428 for ( $i = 0, $j = count( $admins ); $i < $j; $i++ ) { 2429 2429 // Saved okay, now send the email notification 2430 2430 groups_notification_new_membership_request( $requesting_user_id, $admins[$i]->user_id, $group_id, $requesting_user->id ); 2431 2431 } -
bp-blogs/bp-blogs-classes.php
281 281 if ( empty( $blog_ids ) ) 282 282 return $paged_blogs; 283 283 284 for ( $i = 0 ; $i < count( $paged_blogs ); $i++ ) {284 for ( $i = 0, $j = count( $paged_blogs ); $i < $j; $i++ ) { 285 285 $blog_prefix = $wpdb->get_blog_prefix( $paged_blogs[$i]->blog_id ); 286 286 $paged_blogs[$i]->latest_post = $wpdb->get_row( "SELECT post_title, guid FROM {$blog_prefix}posts WHERE post_status = 'publish' AND post_type = 'post' AND id != 1 ORDER BY id DESC LIMIT 1" ); 287 287 } 288 288 289 / * Fetch the blog description for each blog (as it may be empty we can't fetch it in the main query). */289 // Fetch the blog description for each blog (as it may be empty we can't fetch it in the main query). 290 290 $blog_descs = $wpdb->get_results( $wpdb->prepare( "SELECT blog_id, meta_value as description FROM {$bp->blogs->table_name_blogmeta} WHERE meta_key = 'description' AND blog_id IN ( {$blog_ids} )" ) ); 291 291 292 for ( $i = 0; $i < count( $paged_blogs ); $i++ ) {292 for ( $i = 0; $i < $j; $i++ ) { 293 293 foreach ( (array)$blog_descs as $desc ) { 294 294 if ( $desc->blog_id == $paged_blogs[$i]->blog_id ) 295 295 $paged_blogs[$i]->description = $desc->description; -
bp-messages/bp-messages-classes.php
172 172 return false; 173 173 174 174 $count = 0; 175 for ( $i = 0 ; $i < count($unread_counts); $i++ ) {175 for ( $i = 0, $j = count( $unread_counts ); $i < $j; $i++ ) { 176 176 $count += $unread_counts[$i]->unread_count; 177 177 } 178 178 … … 331 331 return false; 332 332 333 333 if ( is_array( $recipient_usernames ) ) { 334 for ( $i = 0 ; $i < count($recipient_usernames); $i++ ) {334 for ( $i = 0, $j = count( $recipient_usernames ); $i < $j; $i++ ) { 335 335 if ( $rid = bp_core_get_userid( trim($recipient_usernames[$i]) ) ) 336 336 $recipient_ids[] = $rid; 337 337 } -
bp-core.php
1422 1422 $older_date = gmmktime( (int)$time_chunks[1], (int)$time_chunks[2], (int)$time_chunks[3], (int)$date_chunks[1], (int)$date_chunks[2], (int)$date_chunks[0] ); 1423 1423 } 1424 1424 1425 / * $newer_date will equal false if we want to know the time elapsed between a date and the current time */1426 / * $newer_date will have a value if we want to work out time elapsed between two known dates */1425 // $newer_date will equal false if we want to know the time elapsed between a date and the current time 1426 // $newer_date will have a value if we want to work out time elapsed between two known dates 1427 1427 $newer_date = ( !$newer_date ) ? strtotime( bp_core_current_time() ) : $newer_date; 1428 1428 1429 / * Difference in seconds */1429 // Difference in seconds 1430 1430 $since = $newer_date - $older_date; 1431 1431 1432 / * Something went wrong with date calculation and we ended up with a negative date. */1432 // Something went wrong with date calculation and we ended up with a negative date. 1433 1433 if ( 0 > $since ) 1434 1434 return __( 'sometime', 'buddypress' ); 1435 1435 … … 1440 1440 * so there's only two bits of calculation below: 1441 1441 */ 1442 1442 1443 / * Step one: the first chunk */1444 for ( $i = 0, $j = count( $chunks); $i < $j; $i++) {1443 // Step one: the first chunk 1444 for ( $i = 0, $j = count( $chunks ); $i < $j; $i++) { 1445 1445 $seconds = $chunks[$i][0]; 1446 1446 1447 / * Finding the biggest chunk (if the chunk fits, break) */1447 // Finding the biggest chunk (if the chunk fits, break) 1448 1448 if ( ( $count = floor($since / $seconds) ) != 0 ) 1449 1449 break; 1450 1450 } … … 1453 1453 if ( !isset( $chunks[$i] ) ) 1454 1454 return '0 ' . __( 'seconds', 'buddypress' ); 1455 1455 1456 / * Set output var */1456 // Set output var 1457 1457 $output = ( 1 == $count ) ? '1 '. $chunks[$i][1] : $count . ' ' . $chunks[$i][2]; 1458 1458 1459 / * Step two: the second chunk */1459 // Step two: the second chunk 1460 1460 if ( $i + 2 < $j ) { 1461 1461 $seconds2 = $chunks[$i + 1][0]; 1462 1462 $name2 = $chunks[$i + 1][1]; 1463 1463 1464 1464 if ( ( $count2 = floor( ( $since - ( $seconds * $count ) ) / $seconds2 ) ) != 0 ) { 1465 / * Add to output var */1465 // Add to output var 1466 1466 $output .= ( 1 == $count2 ) ? _x( ',', 'Separator in time since', 'buddypress' ) . ' 1 '. $chunks[$i + 1][1] : _x( ',', 'Separator in time since', 'buddypress' ) . ' ' . $count2 . ' ' . $chunks[$i + 1][2]; 1467 1467 } 1468 1468 } -
bp-groups/bp-groups-classes.php
525 525 if ( empty( $group_ids ) ) 526 526 return $paged_groups; 527 527 528 / * Fetch the logged in users status within each group */528 // Fetch the logged in users status within each group 529 529 $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 ) ); 530 for ( $i = 0 ; $i < count( $paged_groups ); $i++ ) {530 for ( $i = 0, $j = count( $paged_groups ); $i < $j; $i++ ) { 531 531 $paged_groups[$i]->is_member = false; 532 532 533 533 foreach ( (array)$user_status as $group_id ) { … … 537 537 } 538 538 539 539 $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 ) ); 540 for ( $i = 0; $i < count( $paged_groups ); $i++ ) {540 for ( $i = 0; $i < $j; $i++ ) { 541 541 $paged_groups[$i]->is_banned = false; 542 542 543 543 foreach ( (array)$user_banned as $group_id ) { … … 1034 1034 else 1035 1035 $total_member_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(user_id) FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 1 {$banned_sql} {$exclude_admins_sql} {$exclude_sql}", $group_id ) ); 1036 1036 1037 /* Fetch whether or not the user is a friend */ 1038 foreach ( (array)$members as $user ) $user_ids[] = $user->user_id; 1037 // Fetch whether or not the user is a friend 1038 foreach ( (array)$members as $user ) 1039 $user_ids[] = $user->user_id; 1039 1040 $user_ids = $wpdb->escape( join( ',', (array)$user_ids ) ); 1040 1041 1041 1042 if ( bp_is_active( 'friends' ) ) { 1042 1043 $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 ) ); 1043 for ( $i = 0 ; $i < count( $members ); $i++ ) {1044 for ( $i = 0, $j = count( $members ); $i < $j; $i++ ) { 1044 1045 foreach ( (array)$friend_status as $status ) { 1045 1046 if ( $status->initiator_user_id == $members[$i]->user_id || $status->friend_user_id == $members[$i]->user_id ) 1046 1047 $members[$i]->is_friend = $status->is_confirmed; -
bp-groups/bp-groups-templatetags.php
1856 1856 if ( $friends ) { 1857 1857 $invites = groups_get_invites_for_group( $bp->loggedin_user->id, $group_id ); 1858 1858 1859 for ( $i = 0 ; $i < count( $friends ); $i++ ) {1859 for ( $i = 0, $j = count( $friends ); $i < $j; $i++ ) { 1860 1860 $checked = ''; 1861 1861 1862 1862 if ( !empty( $invites ) ) {