Skip to:
Content

BuddyPress.org

Ticket #2768: 2768.patch

File 2768.patch, 3.2 KB (added by DJPaul, 14 years ago)
  • bp-activity/bp-activity-templatetags.php

     
    691691                return apply_filters( 'bp_activity_get_comments', $comments_html );
    692692        }
    693693                /* TODO: The HTML in this function is temporary and will be moved to the template in a future version. */
    694                 function bp_activity_recurse_comments( $comment ) {
     694                function bp_activity_recurse_comments( $comment, &$depth=0 ) {
    695695                        global $activities_template, $bp;
    696696
    697697                        if ( !$comment->children )
     
    702702                                if ( !$comment->user_fullname )
    703703                                        $comment->user_fullname = $comment->display_name;
    704704
     705                                $depth++;
    705706                                $content .= '<li id="acomment-' . $comment->id . '">';
    706707                                $content .= '<div class="acomment-avatar"><a href="' . bp_core_get_user_domain( $comment->user_id, $comment->user_nicename, $comment->user_login ) . '">' . bp_core_fetch_avatar( array( 'item_id' => $comment->user_id, 'width' => 20, 'height' => 20, 'email' => $comment->user_email ) ) . '</a></div>';
    707708                                $content .= '<div class="acomment-meta"><a href="' . bp_core_get_user_domain( $comment->user_id, $comment->user_nicename, $comment->user_login ) . '">' . apply_filters( 'bp_acomment_name', $comment->user_fullname, $comment ) . '</a> &middot; ' . sprintf( __( '%s ago', 'buddypress' ), bp_core_time_since( $comment->date_recorded ) );
    708709
    709710                                /* Reply link - the span is so that threaded reply links can be hidden when JS is off. */
    710                                 if ( is_user_logged_in() && bp_activity_can_comment_reply( $comment ) )
     711                                if ( is_user_logged_in() && bp_activity_can_comment_reply( $comment, $depth ) )
    711712                                        $content .= apply_filters( 'bp_activity_comment_reply_link', '<span class="acomment-replylink"> &middot; <a href="#acomment-' . $comment->id . '" class="acomment-reply" id="acomment-reply-' . $activities_template->activity->id . '">' . __( 'Reply', 'buddypress' ) . '</a></span>', $comment );
    712713
    713714                                /* Delete link */
     
    719720                                $content .= '</div>';
    720721                                $content .= '<div class="acomment-content">' . apply_filters( 'bp_get_activity_content', $comment->content ) . '</div>';
    721722
    722                                 $content .= bp_activity_recurse_comments( $comment );
     723                                $content .= bp_activity_recurse_comments( $comment, $depth );
    723724                                $content .= '</li>';
     725
     726                                // If we're at the start of an activity loop, we'll be at the start of a new level of items, so reset the depth.
     727                                if ( 0 === $activities_template->current_activity )
     728                                        $depth = 0;
    724729                        }
     730
     731                        $depth = 0;
    725732                        $content .= '</ul>';
    726733
    727734                        return apply_filters( 'bp_activity_recurse_comments', $content );
     
    952959        return apply_filters( 'bp_activity_can_comment', $can_comment );
    953960}
    954961
    955 function bp_activity_can_comment_reply( $comment ) {
     962function bp_activity_can_comment_reply( $comment, $depth ) {
    956963        $can_comment = true;
    957964
    958         return apply_filters( 'bp_activity_can_comment_reply', $can_comment, $comment );
     965        if ( get_option( 'thread_comments' ) && $depth >= get_option( 'thread_comments_depth' ) )
     966                $can_comment = false;
     967
     968        return apply_filters( 'bp_activity_can_comment_reply', $can_comment, $comment, $depth );
    959969}
    960970
    961971function bp_activity_can_favorite() {