Skip to:
Content

bbPress.org

Changeset 7255


Ignore:
Timestamp:
06/23/2024 08:27:45 PM (9 months ago)
Author:
johnjamesjacoby
Message:

Topic/Reply: improvements to status updates.

This change includes 2 fixes:

  • Prefer $topic_id over $topic->ID, and use it (instead of $forum_id) when checking for moderation capability
  • Add missing logic in bbp_edit_reply_handler() that was preventing statuses from saving as intended

See #2644.

In branches/2.6, for 2.6.10.

Location:
branches/2.6/src/includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/2.6/src/includes/replies/functions.php

    r7242 r7255  
    641641    /** Reply Status **********************************************************/
    642642
     643    // Get available reply statuses
     644    $reply_statuses = bbp_get_reply_statuses( $reply_id );
     645
    643646    // Use existing post_status
    644647    $reply_status = $reply->post_status;
     
    647650    if ( bbp_is_reply_public( $reply_id ) && ! bbp_check_for_moderation( $anonymous_data, $reply_author, $reply_title, $reply_content ) ) {
    648651        $reply_status = bbp_get_pending_status_id();
     652
     653    // Check for possible posted reply status
     654    } elseif ( ! empty( $_POST['bbp_reply_status'] ) && in_array( $_POST['bbp_reply_status'], array_keys( $reply_statuses ), true ) ) {
     655
     656        // Allow capable users to explicitly override the status
     657        if ( current_user_can( 'moderate', $reply_id ) ) {
     658            $reply_status = sanitize_key( $_POST['bbp_reply_status'] );
     659
     660        // Not capable
     661        } else {
     662            bbp_add_error( 'bbp_edit_reply_status', __( '<strong>Error</strong>: You do not have permission to do that.', 'bbpress' ) );
     663        }
    649664    }
    650665
     
    20572072 *
    20582073 * @param string $where
     2074 * @param WP_Query $query
    20592075 * @return string
    20602076 */
  • branches/2.6/src/includes/topics/functions.php

    r7208 r7255  
    580580
    581581    // Maybe force into pending
    582     if ( bbp_is_topic_public( $topic->ID ) && ! bbp_check_for_moderation( $anonymous_data, $topic_author, $topic_title, $topic_content ) ) {
     582    if ( bbp_is_topic_public( $topic_id ) && ! bbp_check_for_moderation( $anonymous_data, $topic_author, $topic_title, $topic_content ) ) {
    583583        $topic_status = bbp_get_pending_status_id();
    584584
     
    587587
    588588        // Allow capable users to explicitly override the status
    589         if ( current_user_can( 'moderate', $forum_id ) ) {
     589        if ( current_user_can( 'moderate', $topic_id ) ) {
    590590            $topic_status = sanitize_key( $_POST['bbp_topic_status'] );
    591591
Note: See TracChangeset for help on using the changeset viewer.