Skip to:
Content

BuddyPress.org

Changeset 7574


Ignore:
Timestamp:
11/15/2013 08:57:09 PM (13 years ago)
Author:
boonebgorges
Message:

Support more liberal params for disabling comments in bp_has_activities()

The 'display_comments' argument of bp_has_activities() takes either a string
value (such as 'threaded') or a bool false to disable comments altogether.
However, the false check in the query method is strict, meaning that various
analogous null values for display_comments were not recognized. In particular,
the strict check made it impossible to disable activity comments via a
querystring, as is often done in templates: ?display_comments=0.

This changeset adds 0, '0', 'false', and 'none' to the possible values for
the null display_comments value, to support the longtime codex suggestions.
Changes are made at the level of bp_has_activities(), which means that the
query method still requires a string false for $display_comments.

Fixes #5029

Location:
trunk
Files:
2 edited

Legend:

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

    r7570 r7574  
    530530        extract( $r );
    531531
     532        // Translate various values for 'display_comments'
     533        // This allows disabling comments via ?display_comments=0
     534        // or =none or =false. Final true is a strict type check. See #5029
     535        if ( in_array( $display_comments, array( 0, '0', 'none', 'false' ), true ) ) {
     536                $display_comments = false;
     537        }
     538
    532539        if ( empty( $search_terms ) && ! empty( $_REQUEST['s'] ) )
    533540                $search_terms = $_REQUEST['s'];
  • trunk/tests/testcases/activity/template.php

    r7127 r7574  
    254254
    255255        }
    256         /**
    257          * @ticket BP5029
    258          */
    259         public function test_get_with_display_comments_false_querystring() {
    260                 $now = time();
    261                 $a1 = $this->factory->activity->create( array(
    262                         'content' => 'Life Rules',
    263                         'recorded_time' => date( 'Y-m-d H:i:s', $now ),
    264                 ) );
    265                 $a2 = $this->factory->activity->create( array(
    266                         'content' => 'Life Drools',
    267                         'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ),
    268                 ) );
    269                 $a3 = bp_activity_new_comment( array(
    270                         'activity_id' => $a1,
    271                         'content' => 'Candy is good',
    272                         'recorded_time' => date( 'Y-m-d H:i:s', $now - 50 ),
    273                 ) );
    274 
    275                 $expected = BP_Activity_Activity::get( array(
    276                         'display_comments' => false,
    277                 ) );
    278 
    279                 $found = BP_Activity_Activity::get( 'display_comments=false' );
    280                 $this->assertEquals( $expected, $found );
    281 
    282         }
    283 
    284 
    285256}
Note: See TracChangeset for help on using the changeset viewer.