Skip to:
Content

bbPress.org


Ignore:
Timestamp:
03/20/2017 10:44:00 AM (5 years ago)
Author:
johnjamesjacoby
Message:

Moderation: Allow per-forum moderators to edit topics & replies inside of forums they have moderation control over.

This feature require the following changes:

  • Prefer read_forum capability check over read_private_forums or read_hidden_forums, and include a $forum_id parameter to assist map_meta_cap filters
  • Prefer edit_others_topics|replies over moderate where appropriate, to ensure capability mappings work as intended
  • Introduce bbp_get_public_topic_statuses() to replace several duplicate occurrences of the same array usage (also allow these to be filtered)
  • Introduce bbp_is_topic_public() (not to be confused with bbp_is_topic_published()) to provide parity with bbp_is_forum_public() and also utilize bbp_get_public_topic_statuses() from above
  • Add local caching to bbp_exclude_forum_ids() as a performance optimization to reduce the depth of current_user_can() calls when private & hidden forums are in use
  • Add user_can( 'moderate' ) capability checks to various mappings, to ensure forum moderators can read/edit/delete content inside of the individual forums they are moderators of
  • Use bbp_get_user_id() where appropriate, rather than casting as int
  • Various surrounding code clean-ups

See #2593.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/common/functions.php

    r6298 r6384  
    564564        $last_posted = get_transient( '_bbp_' . bbp_current_author_ip() . '_last_posted' );
    565565
    566         if ( ! empty( $last_posted ) && time() < $last_posted + $throttle_time ) {
     566        if ( ! empty( $last_posted ) && ( time() < ( $last_posted + $throttle_time ) ) ) {
    567567            return false;
    568568        }
     
    573573        $last_posted = bbp_get_user_last_posted( $author_id );
    574574
    575         if ( isset( $last_posted ) && time() < $last_posted + $throttle_time && !current_user_can( 'throttle' ) ) {
     575        if ( isset( $last_posted ) && ( time() < ( $last_posted + $throttle_time ) ) && ! user_can( $author_id, 'throttle' ) ) {
    576576            return false;
    577577        }
     
    17751775                                'post_type'      => bbp_get_reply_post_type(),
    17761776                                'post_parent'    => 'any',
    1777                                 'post_status'    => array( bbp_get_public_status_id(), bbp_get_closed_status_id() ),
     1777                                'post_status'    => bbp_get_public_topic_statuses(),
    17781778                                'posts_per_page' => bbp_get_replies_per_rss_page(),
    17791779                                'order'          => 'DESC',
     
    17931793                                'post_type'      => bbp_get_topic_post_type(),
    17941794                                'post_parent'    => bbp_get_forum_id(),
    1795                                 'post_status'    => array( bbp_get_public_status_id(), bbp_get_closed_status_id() ),
     1795                                'post_status'    => bbp_get_public_topic_statuses(),
    17961796                                'posts_per_page' => bbp_get_topics_per_rss_page(),
    17971797                                'order'          => 'DESC'
     
    18151815                                'post_type'      => array( bbp_get_reply_post_type(), bbp_get_topic_post_type() ),
    18161816                                'post_parent'    => 'any',
    1817                                 'post_status'    => array( bbp_get_public_status_id(), bbp_get_closed_status_id() ),
     1817                                'post_status'    => bbp_get_public_topic_statuses(),
    18181818                                'posts_per_page' => bbp_get_replies_per_rss_page(),
    18191819                                'order'          => 'DESC',
Note: See TracChangeset for help on using the changeset viewer.