Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
01/02/2018 10:28:52 PM (7 years ago)
Author:
r-a-y
Message:

Blogs: Disable activity commenting for blog items requiring manual approval.

For sites that have the "Comment must be manually approved" option enabled,
we are disabling activity commenting for these activity entries since there
is currently no way for us to replicate the WordPress pending comment
experience within the BuddyPress activity stream.

Users will still be able to comment on the original blog post, but will no
longer be able to comment within the BuddyPress activity stream.

Hat-tip aleon4 for reporting this issue.

Fixes #7592.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-blogs/bp-blogs-activity.php

    r11447 r11788  
    11491149    $allow_comments = bp_blogs_comments_open( $activity );
    11501150    $thread_depth   = bp_blogs_get_blogmeta( $activity->item_id, 'thread_comments_depth' );
     1151    $moderation     = bp_blogs_get_blogmeta( $activity->item_id, 'comment_moderation' );
    11511152
    11521153    // Initialize a local object so we won't have to query this again in the
     
    11581159        buddypress()->blogs->thread_depth   = array();
    11591160    }
    1160 
    1161     // Cache comment settings in the buddypress() singleton to reference later in
    1162     // the activity comment loop
    1163     // @see bp_blogs_disable_activity_replies()
    1164     //
    1165     // thread_depth is keyed by activity ID instead of blog ID because when we're
    1166     // in a comment loop, we don't have access to the blog ID...
    1167     // should probably object cache these values instead...
    1168     buddypress()->blogs->allow_comments[ $activity->id ] = $allow_comments;
    1169     buddypress()->blogs->thread_depth[ $activity->id ]   = $thread_depth;
     1161    if ( empty( buddypress()->blogs->comment_moderation ) ) {
     1162        buddypress()->blogs->comment_moderation = array();
     1163    }
     1164
     1165    /*
     1166     * Cache comment settings in the buddypress() singleton for later reference.
     1167     *
     1168     * See bp_blogs_disable_activity_commenting() / bp_blogs_can_comment_reply().
     1169     *
     1170     * thread_depth is keyed by activity ID instead of blog ID because when we're
     1171     * in an actvity comment loop, we don't have access to the blog ID...
     1172     *
     1173     * Should probably object cache these values instead...
     1174     */
     1175    buddypress()->blogs->allow_comments[ $activity->id ]     = $allow_comments;
     1176    buddypress()->blogs->thread_depth[ $activity->id ]       = $thread_depth;
     1177    buddypress()->blogs->comment_moderation[ $activity->id ] = $moderation;
    11701178}
    11711179
     
    12321240                $retval = false;
    12331241            }
     1242
     1243            // If comments need moderation, disable activity commenting.
     1244            if ( ! empty( buddypress()->blogs->comment_moderation[ bp_get_activity_id() ] ) ) {
     1245                $retval = false;
     1246            }
    12341247        // The activity type does not support comments or replies
    12351248        } else {
     
    13151328    }
    13161329
     1330    // If comments need moderation, disable activity commenting.
     1331    if ( ! empty( buddypress()->blogs->comment_moderation[$comment->item_id] ) ) {
     1332        $retval = false;
     1333    }
     1334
    13171335    return $retval;
    13181336}
Note: See TracChangeset for help on using the changeset viewer.