Skip to:
Content

BuddyPress.org

Changeset 8201


Ignore:
Timestamp:
03/29/2014 12:40:28 AM (11 years ago)
Author:
boonebgorges
Message:

Use WP's comment depth setting to limit activity comment depth

Fixes #2768

Location:
trunk
Files:
4 edited

Legend:

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

    r8187 r8201  
    10081008            }
    10091009
     1010            // Calculate depth for each item
     1011            foreach ( $ref as &$r ) {
     1012                $depth = 1;
     1013                $parent_id = $r->secondary_item_id;
     1014                while ( $parent_id !== $r->item_id ) {
     1015                    $depth++;
     1016                    $parent_id = $ref[ $parent_id ]->secondary_item_id;
     1017                }
     1018                $r->depth = $depth;
     1019            }
     1020
    10101021            // If we cache a value of false, it'll count as a cache
    10111022            // miss the next time the activity comments are fetched.
  • trunk/bp-activity/bp-activity-template.php

    r8190 r8201  
    17981798         * @since BuddyPress (1.2)
    17991799         *
    1800          * @todo remove $counter global
    1801          *
    18021800         * @param object $comment The activity object currently being recursed
    18031801         *
     
    21522150
    21532151/**
     2152 * Output the depth of the current activity comment.
     2153 *
     2154 * @since BuddyPress (2.0.0)
     2155 */
     2156function bp_activity_comment_depth() {
     2157    echo bp_activity_get_comment_depth();
     2158}
     2159    /**
     2160     * Return the current activity comment depth.
     2161     *
     2162     * @since BuddyPress (2.0.0)
     2163     *
     2164     * @return int
     2165     */
     2166    function bp_activity_get_comment_depth() {
     2167        global $activities_template;
     2168        return apply_filters( 'bp_activity_get_comment_depth', $activities_template->activity->current_comment->depth );
     2169    }
     2170
     2171/**
    21542172 * Output the activity comment link.
    21552173 *
     
    26522670    $can_comment = true;
    26532671
     2672    if ( get_option( 'thread_comments' ) && bp_activity_get_comment_depth() >= get_option( 'thread_comments_depth' ) ) {
     2673        $can_comment = false;
     2674    }
     2675
    26542676    return apply_filters( 'bp_activity_can_comment_reply', $can_comment, $comment );
    26552677}
  • trunk/bp-templates/bp-legacy/buddypress-functions.php

    r8150 r8201  
    773773        $activities_template->activity->id              = $activities_template->activities[0]->item_id;
    774774        $activities_template->activity->current_comment = $activities_template->activities[0];
     775
     776        // Because the whole tree has not been loaded, we manually
     777        // determine depth
     778        $depth = 1;
     779        $parent_id = $activities_template->activities[0]->secondary_item_id;
     780        while ( $parent_id !== $activities_template->activities[0]->item_id ) {
     781            $depth++;
     782            $p_obj = new BP_Activity_Activity( $parent_id );
     783            $parent_id = $p_obj->secondary_item_id;
     784        }
     785        $activities_template->activity->current_comment->depth = $depth;
    775786    }
    776787
  • trunk/tests/testcases/activity/class.BP_Activity_Activity.php

    r8131 r8201  
    394394        $e2->user_fullname = bp_core_get_user_displayname( $e2->user_id );
    395395        $e2->children = array();
     396        $e2->depth = 1;
    396397
    397398        $a3_obj = new BP_Activity_Activity( $a3 );
     
    411412        $e3->user_fullname = bp_core_get_user_displayname( $e3->user_id );
    412413        $e3->children = array();
     414        $e3->depth = 1;
    413415
    414416        $expected = array(
Note: See TracChangeset for help on using the changeset viewer.