Changeset 8249
- Timestamp:
- 04/07/2014 05:33:26 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity/bp-activity-classes.php
r8226 r8249 1106 1106 1107 1107 /** 1108 * Get a list of components that have recorded activity associated with them 1109 * 1108 * Get a list of components that have recorded activity associated with them. 1109 * 1110 * @param bool $skip_last_activity If true, components will not be 1111 * included if the only activity type associated with them is 1112 * 'last_activity'. (Since 2.0.0, 'last_activity' is stored in 1113 * the activity table, but these items are not full-fledged 1114 * activity items.) Default: true. 1110 1115 * @return array List of component names. 1111 1116 */ 1112 public static function get_recorded_components( ) {1117 public static function get_recorded_components( $skip_last_activity = true ) { 1113 1118 global $wpdb, $bp; 1114 return $wpdb->get_col( "SELECT DISTINCT component FROM {$bp->activity->table_name} ORDER BY component ASC" ); 1119 1120 if ( $skip_last_activity ) { 1121 $components = $wpdb->get_col( "SELECT DISTINCT component FROM {$bp->activity->table_name} WHERE action != '' AND action != 'last_activity' ORDER BY component ASC" ); 1122 } else { 1123 $components = $wpdb->get_col( "SELECT DISTINCT component FROM {$bp->activity->table_name} ORDER BY component ASC" ); 1124 } 1125 1126 return $components; 1115 1127 } 1116 1128 -
trunk/tests/testcases/activity/class.BP_Activity_Activity.php
r8201 r8249 444 444 445 445 /** 446 * @group get_recorded_components 447 */ 448 public function test_get_recorded_components_skip_last_activity_false() { 449 $a1 = $this->factory->activity->create( array( 450 'component' => 'members', 451 'action' => 'last_activity', 452 ) ); 453 $a2 = $this->factory->activity->create( array( 454 'component' => 'groups', 455 'action' => 'created_group', 456 ) ); 457 $a3 = $this->factory->activity->create( array( 458 'component' => 'friends', 459 'action' => 'friendship_accepted', 460 ) ); 461 462 $found = BP_Activity_Activity::get_recorded_components( false ); 463 sort( $found ); 464 465 $this->assertSame( array( 'friends', 'groups', 'members' ), BP_Activity_Activity::get_recorded_components( false ) ); 466 } 467 468 /** 469 * @group get_recorded_components 470 */ 471 public function test_get_recorded_components_skip_last_activity_true_filter_empty_component() { 472 $a1 = $this->factory->activity->create( array( 473 'component' => 'members', 474 'action' => 'last_activity', 475 ) ); 476 $a2 = $this->factory->activity->create( array( 477 'component' => 'groups', 478 'action' => 'created_group', 479 ) ); 480 $a3 = $this->factory->activity->create( array( 481 'component' => 'friends', 482 'action' => 'friendship_accepted', 483 ) ); 484 485 $found = BP_Activity_Activity::get_recorded_components( true ); 486 sort( $found ); 487 488 $this->assertSame( array( 'friends', 'groups' ), BP_Activity_Activity::get_recorded_components() ); 489 } 490 491 /** 492 * @group get_recorded_components 493 */ 494 public function test_get_recorded_components_skip_last_activity_true_members_component_not_empty() { 495 $a1 = $this->factory->activity->create( array( 496 'component' => 'members', 497 'action' => 'last_activity', 498 ) ); 499 $a2 = $this->factory->activity->create( array( 500 'component' => 'groups', 501 'action' => 'created_group', 502 ) ); 503 $a3 = $this->factory->activity->create( array( 504 'component' => 'friends', 505 'action' => 'friendship_accepted', 506 ) ); 507 $a4 = $this->factory->activity->create( array( 508 'component' => 'members', 509 'action' => 'foo', 510 ) ); 511 512 $found = BP_Activity_Activity::get_recorded_components( true ); 513 sort( $found ); 514 515 $this->assertSame( array( 'friends', 'groups', 'members' ), BP_Activity_Activity::get_recorded_components() ); 516 } 517 518 /** 519 * @group get_recorded_components 520 */ 521 public function test_get_recorded_components_skip_last_activity_true_la_in_multiple_components() { 522 $a1 = $this->factory->activity->create( array( 523 'component' => 'members', 524 'action' => 'last_activity', 525 ) ); 526 $a2 = $this->factory->activity->create( array( 527 'component' => 'groups', 528 'action' => 'created_group', 529 ) ); 530 $a3 = $this->factory->activity->create( array( 531 'component' => 'friends', 532 'action' => 'friendship_accepted', 533 ) ); 534 $a4 = $this->factory->activity->create( array( 535 'component' => 'groups', 536 'action' => 'last_activity', 537 ) ); 538 539 $found = BP_Activity_Activity::get_recorded_components( true ); 540 sort( $found ); 541 542 $this->assertSame( array( 'friends', 'groups', ), BP_Activity_Activity::get_recorded_components() ); 543 } 544 /** 446 545 * @group activity_action 447 546 */
Note: See TracChangeset
for help on using the changeset viewer.