Skip to:
Content

BuddyPress.org

Ticket #2768: 2768.02.patch

File 2768.02.patch, 3.2 KB (added by boonebgorges, 10 years ago)
  • bp-activity/bp-activity-classes.php

    diff --git bp-activity/bp-activity-classes.php bp-activity/bp-activity-classes.php
    index 0155ed8..818c990 100644
    class BP_Activity_Activity { 
    950950                                }
    951951                        }
    952952
     953                        // Calculate depth for each item
     954                        foreach ( $ref as &$r ) {
     955                                $depth = 1;
     956                                $parent_id = $r->secondary_item_id;
     957                                while ( $parent_id !== $r->item_id ) {
     958                                        $depth++;
     959                                        $parent_id = $ref[ $parent_id ]->secondary_item_id;
     960                                }
     961                                $r->depth = $depth;
     962                        }
     963
    953964                        // If we cache a value of false, it'll count as a cache
    954965                        // miss the next time the activity comments are fetched.
    955966                        // Storing the string 'none' is a hack workaround to
  • bp-activity/bp-activity-template.php

    diff --git bp-activity/bp-activity-template.php bp-activity/bp-activity-template.php
    index c574302..d41a742 100644
    function bp_activity_comments( $args = '' ) { 
    17491749                 *
    17501750                 * @since BuddyPress (1.2)
    17511751                 *
    1752                  * @todo remove $counter global
    1753                  *
    17541752                 * @param object $comment The activity object currently being recursed
    17551753                 *
    17561754                 * @global object $activities_template {@link BP_Activity_Template}
    function bp_activity_comment_count() { 
    21032101                }
    21042102
    21052103/**
     2104 * Output the depth of the current activity comment.
     2105 *
     2106 * @since BuddyPress (2.0.0)
     2107 */
     2108function bp_activity_comment_depth() {
     2109        echo bp_activity_get_comment_depth();
     2110}
     2111        /**
     2112         * Return the current activity comment depth.
     2113         *
     2114         * @since BuddyPress (2.0.0)
     2115         *
     2116         * @return int
     2117         */
     2118        function bp_activity_get_comment_depth() {
     2119                global $activities_template;
     2120                return apply_filters( 'bp_activity_get_comment_depth', $activities_template->activity->current_comment->depth );
     2121        }
     2122
     2123/**
    21062124 * Output the activity comment link.
    21072125 *
    21082126 * @since BuddyPress (1.2)
    function bp_activity_can_comment() { 
    26032621function bp_activity_can_comment_reply( $comment ) {
    26042622        $can_comment = true;
    26052623
     2624        if ( get_option( 'thread_comments' ) && bp_activity_get_comment_depth() >= get_option( 'thread_comments_depth' ) ) {
     2625                $can_comment = false;
     2626        }
     2627
    26062628        return apply_filters( 'bp_activity_can_comment_reply', $can_comment, $comment );
    26072629}
    26082630
  • bp-templates/bp-legacy/buddypress-functions.php

    diff --git bp-templates/bp-legacy/buddypress-functions.php bp-templates/bp-legacy/buddypress-functions.php
    index 0cb3153..ea7b13b 100644
    function bp_legacy_theme_new_activity_comment() { 
    692692                $activities_template->activity = new stdClass();
    693693                $activities_template->activity->id              = $activities_template->activities[0]->item_id;
    694694                $activities_template->activity->current_comment = $activities_template->activities[0];
     695
     696                // Because the whole tree has not been loaded, we manually
     697                // determine depth
     698                $depth = 1;
     699                $parent_id = $activities_template->activities[0]->secondary_item_id;
     700                while ( $parent_id !== $activities_template->activities[0]->item_id ) {
     701                        $depth++;
     702                        $p_obj = new BP_Activity_Activity( $parent_id );
     703                        $parent_id = $p_obj->secondary_item_id;
     704                }
     705                $activities_template->activity->current_comment->depth = $depth;
    695706        }
    696707
    697708        // get activity comment template part