Skip to:
Content

bbPress.org

Changeset 6921


Ignore:
Timestamp:
11/07/2019 06:56:53 PM (2 weeks ago)
Author:
johnjamesjacoby
Message:

Moderation: make sure pending topics (for moderation reasons) are accessible to authors.

This commit updates the logic inside of the topic & reply map-meta-cap implementations, restricting edit-lock checks to actual "Edit" screens, and using the "edit_others_posts" capability in non-"Edit" screens, ensuring that both scenarios are covered.

It also adds an explicit condition for Pending Topics to both the Topic Description and Topic Notices, alerting users as to why they are seeing what they are seeing.

Fixes #3253 (again!) See also #3164 for other related discussion & details.

Location:
trunk/src/includes
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/replies/capabilities.php

    r6783 r6921  
    154154                } elseif ( ! is_admin() && ( (int) $user_id === (int) $_post->post_author ) ) {
    155155
    156                     // Only allow if not past the edit-lock period
    157                     $caps = ! bbp_past_edit_lock( $_post->post_date_gmt )
    158                         ? array( $post_type->cap->edit_posts )
    159                         : array( 'do_not_allow' );
     156                    // If editing...
     157                    if ( bbp_is_reply_edit() ) {
     158
     159                        // Only allow if not past the edit-lock period
     160                        $caps = ! bbp_past_edit_lock( $_post->post_date_gmt )
     161                            ? array( $post_type->cap->edit_posts )
     162                            : array( 'do_not_allow' );
     163
     164                    // Otherwise...
     165                    } else {
     166                        $caps = array( $post_type->cap->edit_posts );
     167                    }
    160168
    161169                // Fallback to edit_others_posts.
  • trunk/src/includes/topics/capabilities.php

    r6783 r6921  
    174174                } elseif ( ! is_admin() && ( (int) $user_id === (int) $_post->post_author ) ) {
    175175
    176                     // Only allow if not past the edit-lock period
    177                     $caps = ! bbp_past_edit_lock( $_post->post_date_gmt )
    178                         ? array( $post_type->cap->edit_posts )
    179                         : array( 'do_not_allow' );
     176                    // If editing...
     177                    if ( bbp_is_topic_edit() ) {
     178
     179                        // Only allow if not past the edit-lock period
     180                        $caps = ! bbp_past_edit_lock( $_post->post_date_gmt )
     181                            ? array( $post_type->cap->edit_posts )
     182                            : array( 'do_not_allow' );
     183
     184                    // Otherwise...
     185                    } else {
     186                        $caps = array( $post_type->cap->edit_posts );
     187                    }
    180188
    181189                // Unknown, so map to edit_others_posts
  • trunk/src/includes/topics/template.php

    r6903 r6921  
    30823082        // Trashed notice
    30833083        case bbp_get_trash_status_id() :
    3084             $notice_text = esc_html__( 'This topic is in the trash.',   'bbpress' );
     3084            $notice_text = esc_html__( 'This topic is in the trash.', 'bbpress' );
     3085            break;
     3086
     3087        // Pending notice
     3088        case bbp_get_pending_status_id() :
     3089            $notice_text = esc_html__( 'This topic is pending moderation.', 'bbpress' );
    30853090            break;
    30863091
     
    33363341        // Topic has activity (could be from reply or topic author)
    33373342        $last_active = bbp_get_topic_last_active_id( $topic_id );
    3338         if ( ! empty( $last_active ) ) {
     3343        if ( ! empty( $vc_int ) && ! empty( $last_active ) ) {
    33393344            $last_updated_by = bbp_get_author_link( array( 'post_id' => $last_active, 'size' => $r['size'] ) );
    33403345            $retstr          = sprintf( esc_html__( 'This topic has %1$s, %2$s, and was last updated %3$s by %4$s.', 'bbpress' ), $reply_count, $voice_count, $time_since, $last_updated_by );
    33413346
    33423347        // Topic has no replies
    3343         } elseif ( ! empty( $voice_count ) && ! empty( $reply_count ) ) {
     3348        } elseif ( ! empty( $vc_int ) && ! empty( $reply_count ) ) {
    33443349            $retstr = sprintf( esc_html__( 'This topic has %1$s and %2$s.', 'bbpress' ), $voice_count, $reply_count );
    33453350
    33463351        // Topic has no replies and no voices
    3347         } elseif ( empty( $voice_count ) && empty( $reply_count ) ) {
    3348             $retstr = sprintf( esc_html__( 'This topic has no replies.', 'bbpress' ), $voice_count, $reply_count );
     3352        } elseif ( empty( $vc_int ) && empty( $reply_count ) ) {
     3353            $retstr = esc_html__( 'This topic has no replies.', 'bbpress' );
     3354
     3355        // Topic is pending
     3356        } elseif ( bbp_get_topic_status( $topic_id ) === bbp_get_pending_status_id() ) {
     3357            $retstr = esc_html__( 'This topic is pending moderation.', 'bbpress' );
     3358
     3359        // Fallback
     3360        } else {
     3361            $retstr = esc_html__( 'This topic is empty.', 'bbpress' );
    33493362        }
    33503363
  • trunk/src/includes/users/template.php

    r6868 r6921  
    22902290
    22912291    // Looking at a single topic, topic is open, and forum is open
    2292     } elseif ( ( bbp_is_single_topic() || is_page() || is_single() ) && bbp_is_topic_open() && bbp_is_forum_open() ) {
     2292    } elseif ( ( bbp_is_single_topic() || is_page() || is_single() ) && bbp_is_topic_open() && bbp_is_forum_open() && bbp_is_topic_published() ) {
    22932293        $retval = bbp_current_user_can_publish_replies();
    22942294
Note: See TracChangeset for help on using the changeset viewer.